aboutsummaryrefslogtreecommitdiff
path: root/di-maker
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2010-12-12 22:35:20 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2010-12-12 22:35:20 -0500
commitb67e05ec7e1d8c176f75037947630b4170e7bd83 (patch)
tree41a9945ea2c4e86d2e8331123a0db2c2c8f75a0e /di-maker
parentc4f207e85a33bc6cee2d4cefb42a62ed77b08961 (diff)
downloadkvm-manager-b67e05ec7e1d8c176f75037947630b4170e7bd83.tar.gz
kvm-manager-b67e05ec7e1d8c176f75037947630b4170e7bd83.tar.bz2
work from Nat and Joseph to make it so you can rebuild the ISO without re-fetching if it already exists, and can include arbitrary files in the initramfs.
Diffstat (limited to 'di-maker')
-rwxr-xr-xdi-maker37
1 files changed, 17 insertions, 20 deletions
diff --git a/di-maker b/di-maker
index b99b62d..bcf6c63 100755
--- 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"