chiark / gitweb /
ubuntu-daily: mount all the ISO images we can find as jigdo sources
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Mon, 10 Oct 2011 20:48:07 +0000 (21:48 +0100)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Mon, 10 Oct 2011 20:48:07 +0000 (21:48 +0100)
ubuntu-daily

index cadbc51..43d56e7 100755 (executable)
@@ -114,16 +114,49 @@ else
                sed -i "s/=$DIST-$1-$2/=$PROJECT-$DIST-$1-$2/g" "$LOCAL.jigdo"
        fi
        rsync -avP "$REMOTE.template" "$LOCAL.template"
+
+       mkdir -p old
+
        EXISTING=false
+       MOUNTS=
+
+       do_mount () {
+               mkdir -p "old/$1"
+               MOUNTS="${MOUNTS:+$MOUNTS }$1"
+               sudo mount -o loop,ro "$1" "old/$1"
+       }
+
+       cleanup () {
+               trap - EXIT HUP INT QUIT TERM
+
+               local mount
+
+               for mount in $MOUNTS; do
+                       sudo umount "old/$mount"
+                       rmdir -p --ignore-fail-on-non-empty "old/$mount"
+               done
+
+               if $EXISTING; then
+                       rm -f "$LOCAL.iso.old"
+               fi
+       }
+       trap cleanup EXIT HUP INT QUIT TERM
+
        if [ -e "$LOCAL.iso" ]; then
                EXISTING=:
                mv "$LOCAL.iso" "$LOCAL.iso.old"
-               mkdir -p "old-$2"
-               sudo mount -o loop,ro "$LOCAL.iso.old" "old-$2"
-       fi
-       ionice -c2 -n7 jigdo-lite "$LOCAL.jigdo"
-       if $EXISTING; then
-               sudo umount "old-$2" || true
-               rm -f "$LOCAL.iso.old"
+               do_mount "$LOCAL.iso.old"
        fi
+
+       for iso in *"$DIST"-*.iso; do
+               case $iso in
+                       *-install-*|*-alternate-*|*-server-*|*-addon-*|*-serveraddon-*) ;;
+                       *)
+                               continue
+                               ;;
+               esac
+               do_mount "$iso"
+       done
+
+       ionice -c2 -n7 jigdo-lite --scan "$PWD/old" "$LOCAL.jigdo"
 fi