]> err.no Git - dak/commitdiff
debian-security: place locks around dak commands that affect packages
authorAnsgar Burchardt <ansgar@debian.org>
Mon, 27 Feb 2012 23:13:29 +0000 (00:13 +0100)
committerAnsgar Burchardt <ansgar@debian.org>
Mon, 27 Feb 2012 23:13:29 +0000 (00:13 +0100)
We don't want process-upload and generate-packages-sources2 or similar
combinations running at the same time. So just create a lock around such
sections.

config/debian-security/cron.daily
config/debian-security/cron.unchecked
config/debian-security/cron.weekly
dak/new_security_install.py

index abe3c08a946e3460d1fe3382b573526153ea5b08..ba1d11ee8aced36ac17ab4a5b71e6b8953a015d8 100755 (executable)
@@ -6,6 +6,8 @@ set -e
 export SCRIPTVARS=/srv/security-master.debian.org/dak/config/debian-security/vars
 . $SCRIPTVARS
 
+LOCKFILE="$lockdir/unchecked.lock"
+
 ################################################################################
 
 # Fix overrides
@@ -66,10 +68,24 @@ done
 
 cd $configdir
 dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
+
+cleanup() {
+    rm -f "$LOCKFILE"
+}
+
+if ! lockfile -r100 "$LOCKFILE"; then
+    echo "Could not lock $LOCKFILE." >&2
+    exit 1
+fi
+trap cleanup EXIT
+
 dak clean-queues
 dak clean-queues -i $disembargo
 dak clean-suites
 
+cleanup
+trap - EXIT
+
 symlinks -d -r $ftpdir
 
 pg_dump obscurity > /org/security-master.debian.org/dak-backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
index e6ccf82446492e7d7b85f404ce81ef92878f1e62..eea530b445cb1c36342927bd91bf512eb5c5ff5f 100755 (executable)
@@ -15,6 +15,7 @@ reportdis=$queuedir/REPORT.disembargo
 timestamp=$(date "+%Y-%m-%d %H:%M")
 doanything=false
 dopolicy=false
+LOCKFILE="$lockdir/unchecked.lock"
 
 # So first we should go and see if any process-policy action is done
 dak process-policy embargoed | mail -a "X-Debian: DAK" -e -s "Automatically accepted from embargoed" team@security.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
@@ -24,6 +25,16 @@ dak process-policy unembargoed | mail -a "X-Debian: DAK" -e -s "Automatically ac
 # in newstage mean they are (late) accepts of security stuff, need
 # to sync to ftp-master
 
+cleanup() {
+    rm -f "$LOCKFILE"
+}
+
+if ! lockfile -r8 "$LOCKFILE"; then
+    echo "aborting cron.unchecked because $LOCKFILE has already been locked"
+    exit 0
+fi
+trap cleanup EXIT
+
 cd $newstage
 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
 if [ -n "$changes" ]; then
@@ -70,4 +81,7 @@ if [ "x${dopolicy}x" = "xtruex" ]; then
     sudo -u archvsync -H /home/archvsync/signal_security
 fi
 
+cleanup
+trap - EXIT
+
 $configdir/cron.buildd
index 80a835381620f525cddb75ed74cf2e52f1f9208a..15c9d16fe2fa6db2c2265aae7b97570381d13f1d 100755 (executable)
@@ -6,13 +6,30 @@ set -e
 export SCRIPTVARS=/srv/security-master.debian.org/dak/config/debian-security/vars
 . $SCRIPTVARS
 
+LOCKFILE="$lockdir/unchecked.lock"
+
 ################################################################################
 
 # Weekly generation of release files, then pushing mirrors.
 # Used as we have a "Valid-until" field in our release files of 10 days. In case
 # we dont have a security update in that time...
 cd $configdir
+
+cleanup() {
+    rm -f "$LOCKFILE"
+}
+
+if ! lockfile -r100 "$LOCKFILE"; then
+    echo "Could not lock $LOCKFILE. Assuming resigning is not needed."
+    exit 0
+fi
+trap cleanup EXIT
+
 dak generate-releases
+
+cleanup
+trap - EXIT
+
 /srv/security-master.debian.org/dak/config/debian-security/make-mirror.sh
 sudo -u archvsync -H /home/archvsync/signal_security
 
index 65df7b08fc2691df1b4b59e5031ff197ae06e719..fb2d5ccff58e40b90486301e29868722569011a0 100755 (executable)
@@ -95,26 +95,34 @@ def _do_Approve():
     print "Sync stuff for upload to ftpmaster"
     spawn("rsync -a -q %s/. /srv/queued/ftpmaster/." % (newstage.path))
 
-    # 3. Now run process-upload in the newstage dir
-    print "Now put it into the security archive"
-    spawn("dak process-upload -a -d %s" % (newstage.path))
-
-    # 4. Run all the steps that are needed to publish the changed archive
-    print "Domination"
-    spawn("dak dominate")
-#    print "Generating filelist for apt-ftparchive"
-#    spawn("dak generate-filelist")
-    print "Updating Packages and Sources files... This may take a while, be patient"
-    spawn("/srv/security-master.debian.org/dak/config/debian-security/map.sh")
-#    spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file()))
-    spawn("dak generate-packages-sources2")
-    print "Updating Release files..."
-    spawn("dak generate-releases")
-    print "Triggering security mirrors... (this may take a while)"
-    spawn("/srv/security-master.debian.org/dak/config/debian-security/make-mirror.sh")
-    spawn("sudo -u archvsync -H /home/archvsync/signal_security")
-    print "Triggering metadata export for packages.d.o and other consumers"
-    spawn("/srv/security-master.debian.org/dak/config/debian-security/export.sh")
+    print "Locking unchecked"
+    lockfile='/srv/security-master.debian.org/lock/unchecked.lock'
+    spawn("lockfile -r8 {0}".format(lockfile))
+
+    try:
+        # 3. Now run process-upload in the newstage dir
+        print "Now put it into the security archive"
+        spawn("dak process-upload -a -d %s" % (newstage.path))
+
+        # 4. Run all the steps that are needed to publish the changed archive
+        print "Domination"
+        spawn("dak dominate")
+        #    print "Generating filelist for apt-ftparchive"
+        #    spawn("dak generate-filelist")
+        print "Updating Packages and Sources files... This may take a while, be patient"
+        spawn("/srv/security-master.debian.org/dak/config/debian-security/map.sh")
+        #    spawn("apt-ftparchive generate %s" % (utils.which_apt_conf_file()))
+        spawn("dak generate-packages-sources2")
+        print "Updating Release files..."
+        spawn("dak generate-releases")
+        print "Triggering security mirrors... (this may take a while)"
+        spawn("/srv/security-master.debian.org/dak/config/debian-security/make-mirror.sh")
+        spawn("sudo -u archvsync -H /home/archvsync/signal_security")
+        print "Triggering metadata export for packages.d.o and other consumers"
+        spawn("/srv/security-master.debian.org/dak/config/debian-security/export.sh")
+    finally:
+        os.unlink(lockfile)
+        print "Lock released."
 
 ########################################################################
 ########################################################################