]> git.decadent.org.uk Git - dak.git/blobdiff - scripts/debian/buildd-add-keys
only run when there is something to do. also only update the keyrings for dsa if...
[dak.git] / scripts / debian / buildd-add-keys
index ddb56a42d6c446b97c4bde3192123e5d787e3621..d96fa758308672e10916d392306b9f79ac8ab53f 100755 (executable)
@@ -51,12 +51,12 @@ function cleanup() {
     done
     exit $ERRVAL
 }
-trap cleanup ERR EXIT TERM HUP INT QUIT
 
 base="${base}/scripts/builddkeyrings"
 INCOMING="${base}/incoming"
 ERRORS="${base}/errors"
 ADMINS="${base}/adminkeys.gpg"
+STAMPFILE="${base}/updatedkeyring"
 
 # Default options for our gpg calls
 DEFGPGOPT="--no-default-keyring --batch --no-tty --no-options --exit-on-status-write-error --no-greeting"
@@ -66,16 +66,24 @@ if ! [ -d "${INCOMING}" ]; then
     exit 1
 fi
 
+cd "${INCOMING}"
+KEYS=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.key | sed -e "s,./,," | xargs)
+if [ -z "${KEYS}" ]; then
+    exit 0
+fi
+
+trap cleanup ERR EXIT TERM HUP INT QUIT
+
 # Whenever something goes wrong, its put in there.
 mkdir -p "${ERRORS}"
 
 # We process all new files in our incoming directory
-for file in $(ls -1 ${INCOMING}/*.key); do
+for file in ${KEYS}; do
     file=${file##*/}
     # First we want to see if we recognize the filename. The buildd people have
     # to follow a certain schema:
-    # architecture_builddname.YEAR-MONTH-DAY_HOUR:MINUTE.key
-    if [[ $file =~ (.*)_(.*).([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}:[0-9]{2}).key ]]; then
+    # architecture_builddname.YEAR-MONTH-DAY_HOURMINUTE.key
+    if [[ $file =~ (.*)_(.*).([0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}[0-9]{2}).key ]]; then
         ARCH=${BASH_REMATCH[1]}
         BUILDD=${BASH_REMATCH[2]}
         # Right now timestamp is unused
@@ -222,7 +230,7 @@ for file in $(ls -1 ${INCOMING}/*.key); do
     # We need to check for the amount of keys
     ARCHKEYRING="${base}/${ARCH}/keyring.gpg"
 
-    KEYNO=$(gpg ${DEFGPGOPT} --keyring "${ARCHKEYRING}" --with-colons --list-keys "buildd_${ARCH}-${BUILDD}@buildd.debian.org" | grep -c '^pub:')
+    KEYNO=$(gpg ${DEFGPGOPT} --keyring "${ARCHKEYRING}" --with-colons --list-keys "buildd_${ARCH}-${BUILDD}@buildd.debian.org" | grep -c '^pub:' || /bin/true )
     if [ ${KEYNO} -gt 2 ]; then
         DATE=$(date -Is)
         mv "${INCOMING}/${file}" "${ERRORS}/toomany.${file}.${DATE}"