-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_iso.sh
More file actions
executable file
·93 lines (77 loc) · 2.28 KB
/
build_iso.sh
File metadata and controls
executable file
·93 lines (77 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
PS4='[$LINENO]+ '
set -xeo pipefail
shopt -s nullglob
SQUASHFS_CTR_IMG_ROOTFS=/rootfs
GRUB_FILE_PATH=${GRUB_FILE_PATH:?}
OUTPUT_ISO_FILE=/out/titanoboa.iso
export DRACUT_NO_XATTR=1
die() {
echo >&2 "ERROR [${BASH_LINENO[1]}]: $*"
exit 1
}
breakpoint() {
echo >&2 "BREAKPOINT HIT"
exit 0
}
dnf install --setopt=install_weak_deps=False -yq \
dracut \
dracut-live \
kernel \
grub2-efi \
grub2-efi-x64-cdboot \
shim \
xorriso \
mtools \
dosfstools \
squashfs-tools \
jq \
/usr/lib/grub/i386-pc
# Prepare directories
mkdir -p /work/iso_files/{boot,LiveOS,images/pxeboot}
# Generate squashfs
mksquashfs "$SQUASHFS_CTR_IMG_ROOTFS" /work/iso_files/LiveOS/squashfs.img -all-root -noappend -e sysroot -e ostree
# Build initrd
kver=$(kernel-install list --json pretty | jq -r '.[] | select(.has_kernel == true) | .version')
DRACUT_NO_XATTR=1 dracut \
--kver="$kver" \
--zstd \
--reproducible \
--no-hostonly \
--no-hostonly-cmdline \
--add "dmsquash-live dmsquash-live-autooverlay" \
--force \
/work/iso_files/images/pxeboot/initrd.img
# Copy over the kernel
cp -av /usr/lib/modules/"$kver"/vmlinuz /work/iso_files/images/pxeboot/vmlinuz
# Copy GRUB modules
mkdir -p /work/iso_files/boot/grub2
cp -avT /usr/lib/grub/i386-pc /work/iso_files/boot/grub2/i386-pc
# Copy EFI dir to /work
cp -avT /boot/efi/EFI /work/EFI
# Remove fallback efi
cp -avT /work/EFI/fedora/grubx64.efi /work/EFI/BOOT/fbx64.efi
# Copy grub.cfg to each bootloader
for dir in /work/EFI/*/ /work/iso_files/boot/grub2/; do
cp "$GRUB_FILE_PATH" "$dir"
done
# Copy EFI to iso_files/EFI, because fedora requires it to be in the root of the ISO
cp -avT /work/EFI /work/iso_files/EFI
# Generate uefi.img
truncate -s 500M /work/uefi.img
mkfs.fat -F32 /work/uefi.img
mcopy -v -i /work/uefi.img -s /work/EFI ::
# Generate iso
mkdir -p "$(dirname "${OUTPUT_ISO_FILE}")"
xorriso -as mkisofs \
-R \
-V "titanoboa_boot" \
-partition_offset 16 \
-appended_part_as_gpt \
-append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B /work/uefi.img \
-iso_mbr_part_type EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
-e --interval:appended_partition_2:all:: \
-no-emul-boot \
-iso-level 3 \
-o "${OUTPUT_ISO_FILE}" \
/work/iso_files