aboutsummaryrefslogtreecommitdiffstats
path: root/preseed.sh
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2014-01-24 02:17:56 +0100
committerGuilhem Moulin <guilhem@fripost.org>2015-06-07 04:27:59 +0200
commita6a742628b560f9d5097008940547391831762c0 (patch)
tree1911d5099c957bc32b9c02f09a2a8c36aef2b9cb /preseed.sh
parent5b655fc0a3bc5e035472326a5d8d827c62d3eb90 (diff)
Enable generation of HDD images.
This is only useful for older BIOSes, that don't support hybrid ISO which can otherwise be burnt onto USB key as well.
Diffstat (limited to 'preseed.sh')
-rwxr-xr-xpreseed.sh70
1 files changed, 58 insertions, 12 deletions
diff --git a/preseed.sh b/preseed.sh
index 729f97e..2bfdf3a 100755
--- a/preseed.sh
+++ b/preseed.sh
@@ -12,6 +12,17 @@ set -ue
newiso=$(readlink -f "$1")
[ -e "$newiso" ] && rm -f "$newiso"
+# Generate a (hybrid) ISO or an HDD image? The latter should only be
+# useful for older BIOSes that don't support hybrid ISOs.
+case "$newiso" in
+ *.iso) type=iso;;
+ *.tar) type=hdd; archive=;;
+ *.tar.gz|*.tgz) type=hdd; archive=z;;
+ *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) type=hdd; archive=j;;
+ *.tar.xz|*.txz) type=hdd; archive=J;;
+ *) echo "Error: $newiso: Unknown file type" >&2; exit 1;;
+esac
+
iso="$2"
test -r "$iso" || exit 1
shift; shift
@@ -85,18 +96,53 @@ while read sum file; do
done < ./md5sum.txt > "$md5sums"
mv "$md5sums" "$isoeditdir/md5sum.txt"
-if [ -f ./boot/grub/efi.img ]; then
- efi_opts="--efi-boot boot/grub/efi.img -append_partition 2 0x01 ./boot/grub/efi.img"
-else
- efi_opts=
+if [ $type = hdd ]; then
+ # Generate a HDD image
+ mv ./isolinux ./syslinux
+ mv ./syslinux/isolinux.cfg ./syslinux/syslinux.cfg
+ mv ./syslinux/isolinux.bin ./syslinux/syslinux.bin
+ sed -i 's/\bisolinux\b/syslinux/g' ./syslinux/*.cfg
+ # Dereference links, which are not compatible with FAT devices
+ tar --exclude='./debian' --hard-dereference --dereference \
+ -c ${archive:+-$archive} \
+ -f "$newiso" ./
+
+ ## To burn the archive onto a USB stick:
+ # device=/dev/disk/by-id/... # FIXME
+ # mountpoint=/mnt/usbkey # FIXME
+ #
+ # device=$(readlink -f "$device")
+ # parted $device mklabel msdos
+ # parted $device mkpart primary 1 1G
+ # parted $device set 1 boot on
+ # mkdosfs ${device}1
+ #
+ # install-mbr $device
+ # syslinux -i ${device}1
+ #
+ # mount ${device}1 $mountpoint
+ # tar -x -C "$mountpoint" -f "$image" --no-same-owner
+ # umount "$mountpoint"
+
+elif [ $type = iso ]; then
+ # Generate a hybrid ISO image
+ if [ -f ./boot/grub/efi.img ]; then
+ efi_opts="--efi-boot boot/grub/efi.img -append_partition 2 0x01 ./boot/grub/efi.img"
+ else
+ efi_opts=
+ fi
+
+ xorriso -as mkisofs -r \
+ -checksum_algorithm_iso all \
+ -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
+ -b isolinux/isolinux.bin -c isolinux/boot.cat \
+ -partition_offset 16 \
+ -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot $efi_opts \
+ -o "$newiso" \
+ ./
+
+ # To burn the ISO onto a USB stick, see
+ # http://www.debian.org/CD/faq/#write-usb
fi
-xorriso -as mkisofs -r \
- -checksum_algorithm_iso all \
- -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin \
- -b isolinux/isolinux.bin -c isolinux/boot.cat \
- -partition_offset 16 \
- -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot $efi_opts \
- -o "$newiso" \
- ./
rm -rf "$isoeditdir"