]> err.no Git - dak/commitdiff
implement public access to deferred
authorThomas Viehmann <tv@beamnet.de>
Mon, 6 Oct 2008 20:41:01 +0000 (20:41 +0000)
committerThomas Viehmann <tv@beamnet.de>
Mon, 6 Oct 2008 20:41:01 +0000 (20:41 +0000)
ChangeLog
daklib/database.py
tools/debianqueued-0.9/ChangeLog
tools/debianqueued-0.9/show-deferred

index 288c7708021ae37e1078f4e2ebb588d99794b526..3e1620de363e2a6cc4918dd8c44945a07ba83ac7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-05  Thomas Viehmann <tv@beamnet.de>
+
+        * daklib/database.py: added get_suites
+       
 2008-09-23  Joerg Jaspert  <joerg@debian.org>
 
        * config/debian/dak.conf: Add the validtime fields, set to 7
index 9185d0a3f54fd0c77e16df1e0dba623ebbc3bff6..1d9f3c0bc9bf052f638dff9be43a08a451ae6904 100755 (executable)
@@ -389,3 +389,12 @@ def get_maintainer (maintainer_id):
     return maintainer_cache[maintainer_id]
 
 ################################################################################
+
+def get_suites(pkgname, src=False):
+    if src:
+        sql = "select suite_name from source, src_associations,suite where source.id=src_associations.source and source.source='%s' and src_associations.suite = suite.id"%pkgname
+    else:
+        sql = "select suite_name from binaries, bin_associations,suite where binaries.id=bin_associations.bin and  package='%s' and bin_associations.suite = suite.id"%pkgname
+    q = projectB.query(sql)
+    return map(lambda x: x[0], q.getresult())
+
index cffd598fea1750f7044dc70f7588a4dd149182d8..42e62ea9e5d6b89d29b6a232fc9ac530cc3e397b 100644 (file)
@@ -1,4 +1,8 @@
-2008-09-20  Thomas Viehmann  <tv@beamnet.de>
+2008-10-05  Thomas Viehmann  <tv@beamnet.de>
+
+       * show-deferred: make non-new uploads in deferred accessible
+
+2008-09-22  Thomas Viehmann  <tv@beamnet.de>
 
        * show-deferred: minor fixes
 
index fb5af5299b28103b793bd7b1f034c12df26700c2..ab3fe5a3ef4a83189a0cb3cf6f07bc53079aeec1 100755 (executable)
 ################################################################################
 
 import sys, os, re, time
+import apt_pkg
 from debian_bundle import deb822
+from daklib import database
+from daklib import queue
+from daklib import utils
 
 ################################################################################
 
@@ -94,7 +98,7 @@ def table_header():
     return res
 
 def table_footer():
-    return '</table></center><br>\n'
+    return '</table><br/><p>non-NEW uploads are <a href="/deferred/">available</a>, use <tt>dcut reschedule foo.changes X-day</tt> to adjust delays.</p></center><br/>\n'
 
 def table_row(changesname, delay, changed_by, closes):
     global row_number
@@ -119,9 +123,28 @@ def get_upload_data(changesfn):
     else:
         remainingtime = 0
     #print dir(achanges)
-    #print achanges.keys()
+    print >> sys.stderr, achanges.keys(), achanges['binary']
     uploader = achanges.get('changed-by')
     uploader = re.sub(r'^\s*(\S.*)\s+<.*>',r'\1',uploader)
+    if Cnf.has_key("Show-Deferred::LinkPath"):
+        isnew = 0
+        suites = database.get_suites(achanges['source'],src=1)
+        if 'unstable' not in suites and 'experimental' not in suites:
+            isnew = 1
+        for b in achanges['binary'].split():
+            suites = database.get_suites(b)
+            if 'unstable' not in suites and 'experimental' not in suites:
+                isnew = 1
+        if not isnew:
+            # we don't link .changes because we don't want other people to
+            # upload it with the existing signature.
+            for afn in map(lambda x: x['name'],achanges['files']):
+                lfn = os.path.join(Cnf["Show-Deferred::LinkPath"],afn)
+                qfn = os.path.join(os.path.dirname(changesfn),afn)
+                if os.path.islink(lfn):
+                    os.unlink(lfn)
+                os.symlink(qfn,lfn)
+                os.chmod(qfn, 0644)
     return (delaydays*24*60*60+remainingtime, changesname, delay, uploader, achanges.get('closes').split())
 
 def list_uploads(filelist):
@@ -136,13 +159,50 @@ def list_uploads(filelist):
         print '<h1>Currently no deferred uploads to Debian</h1>'
     print footer()
 
-if len(sys.argv)!=2:
-    print >> sys.stderr, """Error! Invoke %s /path/to/DEFERRED"""%sys.argv[0]
-    sys.exit(1)
+def usage (exit_code=0):
+    if exit_code:
+        f = sys.stderr
+    else:
+        f = sys.stdout
+    print >> f, """Usage: dak show-deferred /path/to/DEFERRED
+  -h, --help                show this help and exit.
+  -p, --html-path [path]    override output directory.
+  """
+    sys.exit(exit_code)
+   
+def init():
+    global Cnf, Options, Upload, projectB
+    Cnf = utils.get_conf()
+    Arguments = [('h',"help","Show-Deferred::Options::Help"),
+                 ("p","link-path","Show-Deferred::LinkPath","HasArg")]
+    for i in ["help"]:
+        if not Cnf.has_key("Show-Deferred::Options::LinkPath"):
+            Cnf["Show-Deferred::Options::LinkPath"] = "/org/ftp.debian.org/web/deferred/"
+    if not Cnf.has_key("Show-Deferred::Options::%s" % (i)):
+          Cnf["Show-Deferred::Options::%s" % (i)] = ""
+    args = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
+    Options = Cnf.SubTree("Show-Deferred::Options")
+    if Options["help"]:
+        usage()
+    Upload = queue.Upload(Cnf)
+    projectB = Upload.projectB
+    return args
+
+args = init()
+if len(args)!=1:
+    usage(1)
     
 filelist = []
-for r,d,f  in os.walk(sys.argv[1]):
+for r,d,f  in os.walk(args[0]):
     filelist += map (lambda x: os.path.join(r,x),
                      filter(lambda x: x.endswith('.changes'), f))
-
 list_uploads(filelist)
+
+if Cnf.has_key("Show-Deferred::LinkPath"):
+    # remove dead links
+    for r,d,f in os.walk(Cnf["Show-Deferred::LinkPath"]):
+        for af in f:
+            af = os.path.join(r,af)
+            if not os.path.exists(af):
+                print >> sys.stderr, "obsolete",af
+                os.unlink(af)