0f1ed4535e4db5d1e2cc267a35e232776255d39b
[rrq/tiniest.git] / packiso.sh
1 #!/bin/bash
2 #
3 # Run xorriso to make a bootable ISO of bootimage.raw; a hybrid, nulti
4 # mode bootable ISO.
5
6 set -e
7
8 ISOTREE=isotree
9 ISO=tiniest.iso
10 P1=$ISOTREE/part1.raw
11
12 echo "# Prepare ISO content tree"
13
14 if [ ! -d $ISOTREE ] ; then
15     mkdir $ISOTREE
16     touch $ISOTREE/catalog # Boot catalog
17     # Determine start and size of first parition
18     X=( $(sfdisk -l -ostart,sectors bootimage.raw | tail -n 2) )
19     dd if=bootimage.raw of=$P1 skip=${X[0]} count=${X[1]}
20     echo "# Set up the isolinux boot loader"
21     mkdir -p $ISOTREE/boot/syslinux/bios
22     cp kernel/usr/lib/syslinux/modules/bios/* $ISOTREE/boot/syslinux/bios
23     mv $ISOTREE/boot/syslinux/bios/ldlinux.c32 $ISOTREE/
24     cp kernel/usr/lib/ISOLINUX/isolinux.bin $ISOTREE/
25     mcopy -i $P1 ::/syslinux.cfg $ISOTREE/
26     mcopy -i $P1 ::/bootmenu.cfg $ISOTREE/
27     mcopy -i $P1 ::/splash.png $ISOTREE/
28     mcopy -i $P1 ::/vmlinuz $ISOTREE/
29     mcopy -i $P1 ::/initrd.gz $ISOTREE/
30 fi
31
32 [ ! -r $ISO ] || rm $ISO
33 PREPID="'$(id -un), $(getent passwd $(id -un)|awk -F: '{print $5}')'"
34
35 XORRISO=(
36     -report_about ALL
37     --outdev $ISO
38     -map $ISOTREE /
39     -rockridge on -joliet on
40     -volid "TINIEST"
41     -volset_id "$(date +"Tiniest %Y-%m-%d %H:%M:%S")"
42     -publisher "Ralph (rrq) Ronnquist"
43     -application_id "Hybrid Multi Mode Disk Image"
44     -system_id "Tiniest Linux"
45     #-copyright_file copyright.txt
46     #-abstract_file abstract.txt
47     #-biblio_file biblio.txt
48     -preparer_id "$PREPID"
49     #-application_use path
50     #-out_charset "UTF8" ??
51     -uid 0 -gid 0
52
53     -append_partition 2 0xef ${P1}
54     -boot_image next cat_path=/catalog
55     -boot_image any system_area=kernel/usr/lib/ISOLINUX/isohdppx.bin
56     -boot_image any bin_path=/isolinux.bin
57     -boot_image any boot_info_table=on
58     -boot_image any next
59     -boot_image any
60     efi_path=--interval:appended_partition_2:all::/EFI/BOOT/bootx64.efi
61     -boot_image any next
62 )
63
64 xorriso "${XORRISO[@]}"