]> gitweb.fluxo.info Git - kvm-manager.git/commitdiff
work from Nat and Joseph to make it so you can rebuild the ISO without re-fetching...
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 13 Dec 2010 03:35:20 +0000 (22:35 -0500)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 13 Dec 2010 03:35:20 +0000 (22:35 -0500)
di-maker

index b99b62d8a06a39f770000abfbcb2c32a85c015cc..bcf6c63ee544f79bbd14118bc813b91389d6eb75 100755 (executable)
--- a/di-maker
+++ b/di-maker
@@ -4,6 +4,10 @@
 # Date: 2009-10-08
 # License: GPL v3+
 
+# usage:
+#  di-maker ISOFILE [FILE ...]
+#  make a new debian installer ISO, packing any additionally-supplied files into the initramfs directly
+
 set -e
 
 # depends on grub2
@@ -12,9 +16,9 @@ set -e
 
 output="$1"
 
-# optionally specify the second argument as a preseed file:
+# remaining arguments should be files to re-pack into the initrd
+shift
 
-preseed="$2"
 
 SUITE=${SUITE:-stable}
 ARCH=${ARCH:-amd64}
@@ -25,19 +29,6 @@ if [ -z "$output" ] ; then
     exit 1
 fi
 
-if [ -e "$output" ] ; then
-    printf "file '%s' already exists" "$output" >&2
-    exit 1
-fi
-
-preseed_args=''
-if [ "$preseed" ] ; then
-    if ! [ -r "$preseed" ] ; then
-        printf "could not read preseed file '%s'\n" "$preseed" >&2
-        exit 1
-    fi
-fi
-
 WORKDIR=$(mktemp -d)
 
 cleanup() {
@@ -83,13 +74,19 @@ case "$ARCH" in
 '
 esac
 
-( cd "$WORKDIR" && wget "$BASEPATH"/{$KERNEL,$INITRAMFS} )
+if ! [ -e "$output" ] ; then
+    ( cd "$WORKDIR" && wget "$BASEPATH"/{$KERNEL,$INITRAMFS} )
+else
+    isoinfo -R -i "$output" -x "/$KERNEL" > "$WORKDIR/$KERNEL"
+    isoinfo -R -i "$output" -x "/$INITRAMFS" > "$WORKDIR/$INITRAMFS"
+fi
 
-if [ "$preseed" ]; then
+if [ "$#" -gt 0 ]; then
     unpackdir=$(mktemp -d)
-    cp "$preseed" "$unpackdir/preseed.cfg"
-    ( cd "$unpackdir" && fakeroot bash -c "gzip -d < '$WORKDIR/$INITRAMFS' | cpio --extract ; find . | cpio --create -H newc | gzip" ) > "$WORKDIR/$INITRAMFS.new"
-    mv "$WORKDIR/$INITRAMFS.new" "$WORKDIR/$INITRAMFS"
+    fstate=$(mktemp)
+    gzip -d < "$WORKDIR/$INITRAMFS" | (cd "$unpackdir" && fakeroot -i "$fstate" -s "$fstate" cpio --extract)
+    cp "$@" "$unpackdir/"
+    (cd "$unpackdir" && find . | fakeroot -i "$fstate" -s "$fstate" cpio --create -H newc | gzip ) > "$WORKDIR/$INITRAMFS"
 fi
 
 mkdir -p "$WORKDIR/boot/grub"