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