Various refactoring
[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=part1.raw # $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
21     echo "# Set up the isolinux boot loader in $ISOTREE"
22     mkdir -p $ISOTREE/boot/isolinux/bios
23     cp kernel/usr/lib/syslinux/modules/bios/* $ISOTREE/boot/isolinux/bios
24     mv $ISOTREE/boot/isolinux/bios/ldlinux.c32 $ISOTREE/boot/isolinux
25     cp kernel/usr/lib/ISOLINUX/isolinux.bin $ISOTREE/boot/isolinux
26     cp syslinux-iso.cfg $ISOTREE/boot/isolinux/syslinux.cfg
27     mcopy -i $P1 ::/splash.png ::/vmlinuz $ISOTREE/
28
29     #mkdir -p $ISOTREE/EFI/BOOT
30     #cp kernel/usr/lib/SYSLINUX.EFI/efi64/syslinux.efi \
31     #   $ISOTREE/EFI/BOOT/bootia64.efi
32     #cp $ISOTREE/boot/isolinux/*.* $ISOTREE/EFI/boot/
33     
34     #mcopy -i $P1 ::/ldlinux.sys ::/ldlinux.c32 $ISOTREE/
35     #mcopy -i $P1 ::/initrd.gz $ISOTREE/
36     #cp devuan/initrd.gz $ISOTREE/
37 fi
38
39 [ ! -r $ISO ] || rm $ISO
40 PREPID="'$(id -un), $(getent passwd $(id -un)|awk -F: '{print $5}')'"
41
42 XORRISO=(
43     -report_about ALL
44     -outdev $ISO
45     -map $ISOTREE /
46     -rockridge on -joliet on
47     -volid "TINIEST"
48     -volset_id "$(date +"Tiniest %Y-%m-%d %H:%M:%S")"
49     -publisher "Ralph (rrq) Ronnquist"
50     -application_id "Hybrid Multi Mode Disk Image"
51     -system_id "Tiniest Linux"
52     #-copyright_file copyright.txt
53     #-abstract_file abstract.txt
54     #-biblio_file biblio.txt
55     -preparer_id "$PREPID"
56     #-application_use path
57     #-out_charset "UTF8" ??
58     -uid 0 -gid 0
59
60     # Mastering a cdrom legacy boot that uses the ISO tree only
61     -boot_image isolinux system_area=kernel/usr/lib/ISOLINUX/isohdpfx.bin
62
63     # Mastering a disk legacy boot reusing the cdrom legacy boot
64     -boot_image isolinux dir=/boot/isolinux
65     -boot_image any next
66
67     # Mastering a disk UEFI boot using the separate boot partition $P1
68     # Bootloader = /EFI/BOOT/bootx64.efi
69     -append_partition 2 0xef ${P1}
70     -boot_image any 
71     efi_path=--interval:appended_partition_2:all::/EFI/BOOT/bootx64.efi
72
73     # cdrom UEFI boot is missing
74 )
75
76 xorriso "${XORRISO[@]}"
77 #sfdisk -f --part-attrs tiniest.iso 2 LegacyBIOSBootable
78 sfdisk -A tiniest.iso 2