From e596091daf51443248a0cb427832be62552eaf27 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 28 Oct 2013 19:50:41 +0100 Subject: Reorganization. Move preseed-related stuff in ./preseed/, and vm-related stuff in ./virtualenv/. --- preseed.sh | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100755 preseed.sh (limited to 'preseed.sh') diff --git a/preseed.sh b/preseed.sh new file mode 100755 index 0000000..b3d8362 --- /dev/null +++ b/preseed.sh @@ -0,0 +1,93 @@ +#!/bin/sh +# +# Usage: preseed.sh preseeded.iso source.iso [udebs] +# +# Credits: https://wiki.debian.org/DebianInstaller/Preseed/EditIso +# https://wiki.debian.org/DebianInstaller/Modify/CD +# +# Install with 'Advanced options > Automated install' + +set -ue + +newiso=$(readlink -f "$1") +[ -e "$newiso" ] && rm -f "$newiso" + +iso="$2" +test -r "$iso" || exit 1 +shift; shift +pwd=$(pwd) + +for prog in fuseiso fusermount rsync md5sum genisoimage find; do + if ! which "$prog" >/dev/null; then + echo "Error: Missing $prog" >&2 + exit 1 + fi +done + +mountdir=$(mktemp -d) +fuseiso "$iso" "$mountdir" + +isoeditdir=$(mktemp -d) +rsync -aH --exclude=TRANS.TBL --chmod=u+w "$mountdir"/ "$isoeditdir"/ + +fusermount -u "$mountdir" +rmdir "$mountdir" + +cp preseed.cfg "$isoeditdir/" +md5sum ./preseed.cfg >> "$isoeditdir/md5sum.txt" + +isolinux=isolinux/adtxt.cfg +sed -ri "s@^\s+append\s(.*\s)?auto=true\b@& file=/cdrom/preseed.cfg @" \ + "$isoeditdir/$isolinux" +# ^ no need to update the checksum, $isolinux is not in './md5sum.txt'. + +mkdir "$isoeditdir/include" +rsync -aL ./include/ "$isoeditdir/include"/ +find ./include \( \! -name '.*' -a -type f \) -print0 | \ + xargs -r0 md5sum >> "$isoeditdir/md5sum.txt" + +# TODO: that's ugly +dist=$(for x in "$isoeditdir"/dists/*; do [ -h "$x" ] && continue; [ -d "$x" ] && echo ${x##*/} && break; done) +arch=$(for x in "$isoeditdir/dists/$dist/main"/binary-*; do test -d "$x" && echo ${x##*/binary-} && break; done) +packages="dists/$dist/main/debian-installer/binary-$arch/Packages" +while [ $# -gt 0 ]; do + cd "${1%%_*}-udeb"; shift + name="$(sed -n 's/Package:\s\s*//p' ./debian/control)" + udeb=$(cut -d' ' -f1,1 ./debian/files) + dir="pool/main/$(expr substr "$name" 1 1)/$name" + mkdir -p "$isoeditdir/$dir/" + cp ../"$udeb" "$isoeditdir/$dir/" + + cat "./debian/$name/DEBIAN/control" >> "$isoeditdir/$packages" + echo "Filename: $dir/$udeb" >> "$isoeditdir/$packages" + echo "MD5sum: $(md5sum ../"$udeb" | cut -d' ' -f1,1)" >> "$isoeditdir/$packages" + echo "SHA1: $(sha1sum ../"$udeb" | cut -d' ' -f1,1)" >> "$isoeditdir/$packages" + echo "SHA256: $(sha256sum ../"$udeb" | cut -d' ' -f1,1)" >> "$isoeditdir/$packages" + echo >> "$isoeditdir/$packages" + + cd "$isoeditdir" + md5sum "./$dir/$udeb" >> "$isoeditdir/md5sum.txt" + cd "$pwd" +done + +cd "$isoeditdir" +gzip -fk ./"$packages" + +md5sums=$(mktemp) +while read sum file; do + if [ "$file" = "./${packages}" -o \ + "$file" = "./${packages}.gz" ]; then + md5sum "$file" + else + echo "$sum $file" + fi +done < ./md5sum.txt > "$md5sums" +mv "$md5sums" "$isoeditdir/md5sum.txt" + +genisoimage -o "$newiso" -quiet -r -J \ + -no-emul-boot -boot-load-size 4 \ + -boot-info-table \ + -b isolinux/isolinux.bin \ + -c isolinux/boot.cat \ + ./ +rm -rf "$isoeditdir" -- cgit v1.2.3