separate, specialised config files for the different boot equipments.
[rrq/tiniest.git] / packiso.sh
1 #!/bin/bash
2 #
3 # Run xorriso to make a bootable ISO of bootimage.raw; a hybrid, multi
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 unless it's already set up"
13 if [ ! -d $ISOTREE ] ; then
14     mkdir $ISOTREE
15
16     # Determine start and size of first parition
17     X=( $(sfdisk -l -ostart,sectors bootimage.raw | tail -n 2) )
18     dd if=bootimage.raw of=$P1 skip=${X[0]} count=${X[1]}
19
20     echo "# Set up the isolinux boot loader in $ISOTREE"
21     mkdir -p $ISOTREE/boot/isolinux/bios
22     cp kernel/usr/lib/syslinux/modules/bios/* $ISOTREE/boot/isolinux/bios
23     cp kernel/usr/lib/ISOLINUX/isolinux.bin $ISOTREE/boot/isolinux
24
25     ## ldlinux.c32 must be sibling to isolinux.bin
26     mv $ISOTREE/boot/isolinux/bios/ldlinux.c32 $ISOTREE/boot/isolinux
27
28     ## use isolinux.cfg for isolinux boot
29     cp syslinux-iso.cfg $ISOTREE/boot/isolinux/isolinux.cfg
30
31     ## put splash, vmlinux and initrd as siblings
32     mcopy -i $P1 ::/splash.png ::/vmlinuz ::/initrd.gz $ISOTREE/boot/isolinux
33     
34 fi
35
36 [ -r $ISO ] && rm $ISO
37
38 PREPID="'$(id -un), $(getent passwd $(id -un)|awk -F: '{print $5}')'"
39
40 XORRISO=(
41     -report_about ALL
42     -outdev $ISO
43     -map $ISOTREE /
44     -rockridge on -joliet on
45     -volid "TINIEST"
46     -volset_id "$(date +"Tiniest %Y-%m-%d %H:%M:%S")"
47     -publisher "Ralph (rrq) Ronnquist"
48     -application_id "Hybrid Multi Mode Disk Image"
49     -system_id "Tiniest Linux"
50     #-copyright_file copyright.txt
51     #-abstract_file abstract.txt
52     #-biblio_file biblio.txt
53     -preparer_id "$PREPID"
54     #-application_use path
55     #-out_charset "UTF8" ??
56     -uid 0 -gid 0
57
58     # Mastering a cdrom legacy boot that uses the ISO tree only
59     -boot_image isolinux system_area=kernel/usr/lib/ISOLINUX/isohdpfx.bin
60
61     # Mastering a disk legacy boot reusing the cdrom legacy boot
62     -boot_image isolinux dir=/boot/isolinux
63     #-boot_image  any iso_mbr_part_type=0x00
64     -boot_image isolinux  partition_entry=gpt_basdat
65     
66     # Mastering a disk UEFI boot using the separate boot partition $P1
67     # Bootloader = /EFI/BOOT/bootx64.efi
68     -boot_image any next
69     -append_partition 2 0xef ${P1}
70     -boot_image any 
71     efi_path=--interval:appended_partition_2:all::/EFI/BOOT/bootx64.efi
72
73     # make part#2 bootable
74 )
75
76 xorriso "${XORRISO[@]}"
77 #sfdisk -f --part-attrs tiniest.iso 2 LegacyBIOSBootable
78 #sfdisk -A tiniest.iso 2