From: Torsten Werner Date: Tue, 4 Jan 2011 19:07:56 +0000 (+0100) Subject: Merge branch 'master' of ssh://ftp-master.debian.org/srv/ftp.debian.org/git/dak X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e8cd8223b1ba10c8b7231fb4f3e0f0c7049c30fe;hp=f694e88353ff776f325011ca962f1be8c2e718f1;p=dak.git Merge branch 'master' of ssh://ftp-master.debian.org/srv/ftp.debian.org/git/dak --- diff --git a/config/debian/common b/config/debian/common index a42c18ff..f611c19e 100644 --- a/config/debian/common +++ b/config/debian/common @@ -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 diff --git a/config/debian/cron.daily b/config/debian/cron.daily index 1ededd03..5b433568 100755 --- a/config/debian/cron.daily +++ b/config/debian/cron.daily @@ -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} diff --git a/config/debian/cron.dinstall b/config/debian/cron.dinstall index 2b219cda..d275354c 100755 --- a/config/debian/cron.dinstall +++ b/config/debian/cron.dinstall @@ -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 diff --git a/config/debian/dinstall.functions b/config/debian/dinstall.functions index 0ad674ea..605dd2b9 100644 --- a/config/debian/dinstall.functions +++ b/config/debian/dinstall.functions @@ -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 } ######################################################################## diff --git a/dak/import_keyring.py b/dak/import_keyring.py index e26eb7e5..6f366d85 100755 --- a/dak/import_keyring.py +++ b/dak/import_keyring.py @@ -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 = {} diff --git a/dak/override.py b/dak/override.py index 3e8a9b41..d280aa8b 100755 --- a/dak/override.py +++ b/dak/override.py @@ -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': diff --git a/daklib/threadpool.py b/daklib/threadpool.py index 5b17e3c4..f075f5c3 100644 --- a/daklib/threadpool.py +++ b/daklib/threadpool.py @@ -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