]> git.decadent.org.uk Git - dak.git/commitdiff
Merge branch 'master' of ssh://ftp-master.debian.org/srv/ftp.debian.org/git/dak
authorTorsten Werner <twerner@debian.org>
Tue, 4 Jan 2011 19:07:56 +0000 (20:07 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 4 Jan 2011 19:07:56 +0000 (20:07 +0100)
config/debian/common
config/debian/cron.daily
config/debian/cron.dinstall
config/debian/dinstall.functions
dak/import_keyring.py
dak/override.py
daklib/threadpool.py

index a42c18ff9481be77fa36ec25a6904b416bc06450..f611c19e55b22dffe4ee5f60cdeee3805819d889 100644 (file)
@@ -3,11 +3,8 @@
 #
 # Set $PROGRAM to a string to have it added to the output.
 function log () {
-        if [ -z "${PROGRAM}" ]; then
-                echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@"
-        else
-                echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@"
-        fi
+        local prefix=${PROGRAM:-}
+        echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@"
 }
 
 # log the message using log() but then also send a mail
index 1ededd036545b2e7b7e89bfeb2f93a677976ec06..5b4335684f6c97eaca0cd6e5a4f3b98dffec378f 100755 (executable)
@@ -21,6 +21,11 @@ function cleanup {
 }
 trap cleanup SIGHUP SIGINT SIGPIPE SIGTERM EXIT ERR
 
+# log to dinstall's logfile instead of sending email
+PROGRAM="cron.daily"
+LOGFILE="$logdir/dinstall.log"
+exec >> "$LOGFILE" 2>&1
+
 # get the latest list of wnpp bugs and their source packages
 wget -q -O${TMPFILE} http://qa.debian.org/data/bts/wnpp_rm
 chmod go+r ${TMPFILE}
index 2b219cdaa113ad9fd0501bd37d65db7946783d8f..d275354cc2daf6f7505906a9d628bb2a1b5c8140 100755 (executable)
@@ -381,9 +381,7 @@ GO=(
 )
 stage $GO
 
-rm -f "$LOCK_ACCEPTED"
-rm -f "$LOCK_NEW"
-rm -f "${LOCK_DAILY}"
+remove_locks
 
 ts "locked part finished"
 state "postlock"
@@ -510,6 +508,9 @@ GO=(
 )
 stage $GO
 
+# we need to wait for the background processes before the end of dinstall
+wait
+
 log "Daily cron scripts successful, all done"
 
 exec > "$logdir/afterdinstall.log" 2>&1
index 0ad674ea1d39a5cbe2a8a8a8fbbcc888ebebb154..605dd2b907cd6b8376d58fd2effea2ddf36b1b00 100644 (file)
@@ -4,10 +4,14 @@ function ts() {
         echo "Archive maintenance timestamp ($1): $(date +%H:%M:%S)"
 }
 
-# Cleanup actions
+# Remove all locks
+function remove_locks() {
+    rm -f $LOCK_DAILY $LOCK_ACCEPTED $LOCK_NEW
+}
+
+# trap handler for cleaning up on signal / error
 function cleanup() {
-       rm -f ${LOCK_DAILY}
-       rm -f ${LOCK_ACCEPTED}
+    remove_locks
 }
 
 # If we error out this one is called, *FOLLOWED* by cleanup above
@@ -22,7 +26,11 @@ function onerror() {
     fi
     subject="${subject} dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)"
 
-    cat "${STAGEFILE}.log" | mail -s "${subject}" -a "X-Debian: DAK" cron@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
+    if [ -r "${STAGEFILE}.log" ]; then
+        cat "${STAGEFILE}.log"
+    else
+        echo "file ${STAGEFILE}.log does not exist, sorry"
+    fi | mail -s "${subject}" -a "X-Debian: DAK" cron@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
 }
 
 ########################################################################
index e26eb7e54d390d46641a506fba310427262267ee..6f366d859548e357da70716169c11d6e10080c52 100755 (executable)
@@ -48,13 +48,30 @@ def get_fingerprint_info(session):
         fins[fingerprint] = (uid, fingerprint_id, keyring)
     return fins
 
+def list_uids(session, pattern):
+    sql_pattern = "%%%s%%" % pattern
+    message = "List UIDs matching pattern %s" % sql_pattern
+    message += "\n" + ("=" * len(message))
+    print message
+    uid_query = session.query(Uid).filter(Uid.uid.ilike(sql_pattern))
+    for uid in uid_query.all():
+       print "\nuid %s" % uid.uid
+       for fp in uid.fingerprint:
+           print "    fingerprint %s" % fp.fingerprint
+           keyring = "unknown"
+           if fp.keyring:
+               keyring = fp.keyring.keyring_name
+           print "        keyring %s" % keyring
+
 ################################################################################
 
 def usage (exit_code=0):
     print """Usage: dak import-keyring [OPTION]... [KEYRING]
   -h, --help                  show this help and exit.
   -L, --import-ldap-users     generate uid entries for keyring from LDAP
-  -U, --generate-users FMT    generate uid entries from keyring as FMT"""
+  -U, --generate-users FMT    generate uid entries from keyring as FMT
+  -l, --list-uids STRING      list all uids matching *STRING*
+  -n, --no-action             don't change database"""
     sys.exit(exit_code)
 
 
@@ -67,9 +84,12 @@ def main():
     Arguments = [('h',"help","Import-Keyring::Options::Help"),
                  ('L',"import-ldap-users","Import-Keyring::Options::Import-Ldap-Users"),
                  ('U',"generate-users","Import-Keyring::Options::Generate-Users", "HasArg"),
+                 ('l',"list-uids","Import-Keyring::Options::List-UIDs", "HasArg"),
+                 ('n',"no-action","Import-Keyring::Options::No-Action"),
                 ]
 
-    for i in [ "help", "report-changes", "generate-users", "import-ldap-users" ]:
+    for i in [ "help", "report-changes", "generate-users",
+           "import-ldap-users", "list-uids", "no-action" ]:
         if not cnf.has_key("Import-Keyring::Options::%s" % (i)):
             cnf["Import-Keyring::Options::%s" % (i)] = ""
 
@@ -82,15 +102,19 @@ def main():
     if Options["Help"]:
         usage()
 
+    ### Initialise
+    session = DBConn().session()
+
+    if Options["List-UIDs"]:
+       list_uids(session, Options["List-UIDs"])
+       sys.exit(0)
+
     if len(keyring_names) != 1:
         usage(1)
 
     ### Keep track of changes made
     changes = []   # (uid, changes strings)
 
-    ### Initialise
-    session = DBConn().session()
-
     ### Cache all the existing fingerprint entries
     db_fin_info = get_fingerprint_info(session)
 
@@ -198,14 +222,9 @@ def main():
                 session.flush()
 
         else:
-            if newuid and olduid != newuid:
-                if olduid != -1:
-                    changes.append((newuiduid, "Linked key: %s" % f))
-                    changes.append((newuiduid, "  (formerly belonging to %s)" % (db_uid_byid[olduid][0])))
-                else:
-                    changes.append((newuiduid, "Linked key: %s" % f))
-                    changes.append((newuiduid, "  (formerly unowned)"))
-
+            if newuid and olduid != newuid and olduid == -1:
+                changes.append((newuiduid, "Linked key: %s" % f))
+                changes.append((newuiduid, "  (formerly unowned)"))
                 session.execute("UPDATE fingerprint SET uid = :uid WHERE id = :fpr",
                                 {'uid': newuid, 'fpr': oldfid})
 
@@ -250,11 +269,15 @@ def main():
                         session.flush()
 
                 else:
-                    print "Key %s exists in both %s and %s keyrings. Not demoting." % (oldkeyring.keyring_name,
+                    print "Key %s exists in both %s and %s keyrings. Not demoting." % (f,
+                                                                                       oldkeyring.keyring_name,
                                                                                        keyring.keyring_name)
 
     # All done!
-    session.commit()
+    if Options["No-Action"]:
+       session.rollback()
+    else:
+       session.commit()
 
     # Print a summary
     changesd = {}
index 3e8a9b4149ea7e9f7328534e171ea30283038c59..d280aa8b4427205f39ff61736182f3e527502e15 100755 (executable)
@@ -121,7 +121,7 @@ def main ():
         if q.rowcount == 0:
             continue
         if q.rowcount > 1:
-            utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()))
+            utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.rowcount))
 
         r = q.fetchone()
         if packagetype == 'binary':
index 5b17e3c496c5e99959badedc2c97402a5572eb5d..f075f5c380c8907959103b2d33ebe9d174270f30 100644 (file)
@@ -131,14 +131,15 @@ class ThreadPool:
         # Tell all the threads to quit
         self.__resizeLock.acquire()
         try:
-            self.__setThreadCountNolock(0)
-            self.__isJoining = True
-
             # Wait until all threads have exited
             if waitForThreads:
+                for t in self.__threads:
+                    t.goAway()
                 for t in self.__threads:
                     t.join()
                     del t
+            self.__setThreadCountNolock(0)
+            self.__isJoining = True
 
             # Reset the pool for potential reuse
             self.__isJoining = False