From: Anthony Towns <aj@azure.humbug.org.au>
Date: Fri, 25 Nov 2005 05:58:18 +0000 (+0000)
Subject: cron.unchecked lockfile udpates
X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=f544f13b91fa2ebc2a5c91eb81098d93af639bfe;p=dak.git

cron.unchecked lockfile udpates
---

diff --git a/ChangeLog b/ChangeLog
index 56f50b4f..d8e85425 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,14 @@
 2005-11-25  Anthony Towns  <aj@erisian.com.au>
 
+	* Finishing merge of changes from spohr, by various people still
+
 	* jennifer: If changed-by parsing fails, set variables to "" so REJECT
 	works
 	* jennifer: Re-enable .deb ar format checking
 	* katie.py: Convert to +bX binNMU special casing
 	* rhona: Add some debug output when deleting binaries
 	* cron.daily: Add emilie
+	* cron.unchecked: Add lock files
 
 2005-11-15  Anthony Towns  <aj@erisian.com.au>
 
diff --git a/cron.unchecked b/cron.unchecked
index 6129c549..a96ec091 100644
--- a/cron.unchecked
+++ b/cron.unchecked
@@ -4,29 +4,48 @@ set -e
 export SCRIPTVARS=/org/ftp.debian.org/katie/vars
 . $SCRIPTVARS
 
-cd $unchecked
-
-changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
-report=$queuedir/REPORT
-timestamp=$(date "+%Y-%m-%d %H:%M")
-
-if [ ! -z "$changes" ]; then
-  echo "$timestamp": "$changes"  >> $report
-  jennifer -a $changes >> $report
-  echo "--" >> $report
-else
-  echo "$timestamp": Nothing to do >> $report
-fi
+LOCKFILE="$lockdir/unchecked.lock"
+NOTICE="$lockdir/daily.lock"
 
-psql projectb -A -t -q -c "SELECT filename FROM accepted_autobuild WHERE suite = 5 AND filename ~ 'd(sc|eb)$'" > $dbdir/dists/unstable_accepted.list
-cd $overridedir
-denise &>/dev/null
-rm -f override.sid.all3 override.sid.all3.src
-for i in main contrib non-free main.debian-installer; do
-  cat override.sid.$i >> override.sid.all3
-  if [ "$i" != "main.debian-installer" ]; then
-    cat override.sid.$i.src >> override.sid.all3.src
+cleanup() {
+  rm -f "$LOCKFILE"
+  if [ ! -z "$LOCKDAILY" ]; then
+	  rm -f "$NOTICE"
   fi
-done
-cd $masterdir
-apt-ftparchive -qq generate apt.conf.buildd &>/dev/null
+}
+
+# only run one cron.unchecked
+if lockfile -r3 $LOCKFILE; then
+	trap cleanup 0
+	cd $unchecked
+
+	changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
+	report=$queuedir/REPORT
+	timestamp=$(date "+%Y-%m-%d %H:%M")
+
+	if [ ! -z "$changes" ]; then
+		echo "$timestamp": "$changes"  >> $report
+		jennifer -a $changes >> $report
+		echo "--" >> $report
+
+		if lockfile -r3 $NOTICE; then
+			LOCKDAILY="YES"
+			psql projectb -A -t -q -c "SELECT filename FROM accepted_autobuild WHERE suite = 5 AND in_accepted = true AND filename ~ 'd(sc|eb)$'" > $dbdir/dists/unstable_accepted.list
+			cd $overridedir
+			denise &>/dev/null
+			rm -f override.sid.all3 override.sid.all3.src
+			for i in main contrib non-free main.debian-installer; do
+				cat override.sid.$i >> override.sid.all3
+				if [ "$i" != "main.debian-installer" ]; then
+					cat override.sid.$i.src >> override.sid.all3.src
+				fi
+			done
+			cd $masterdir
+			apt-ftparchive -qq generate apt.conf.buildd
+			. $masterdir/cron.buildd
+		fi
+	else
+		echo "$timestamp": Nothing to do >> $report
+	fi
+fi
+