1 |
commit: 880970ed280e2783bac46ca960faee8383669251 |
2 |
Author: Rick Farina (Zero_Chaos) <zerochaos <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 27 20:24:53 2018 +0000 |
4 |
Commit: Richard Farina <zerochaos <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 27 20:24:53 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=880970ed |
7 |
|
8 |
create the bootloader if cdtar not specified |
9 |
|
10 |
TODO | 2 +- |
11 |
doc/catalyst-spec.5.txt | 2 + |
12 |
targets/support/bootloader-setup.sh | 2 +- |
13 |
targets/support/functions.sh | 108 ++++++++++++++++++++++-------------- |
14 |
4 files changed, 70 insertions(+), 44 deletions(-) |
15 |
|
16 |
diff --git a/TODO b/TODO |
17 |
index a868508e..a2ee05dd 100644 |
18 |
--- a/TODO |
19 |
+++ b/TODO |
20 |
@@ -61,7 +61,7 @@ Targets: |
21 |
- change user creation to be more flexible |
22 |
- stage4 and netboot support |
23 |
- build boot software for targets on-demand |
24 |
- - removes cdtar requirement |
25 |
+ - removes cdtar requirement on remaining arches |
26 |
- allows one to specify multiple bootloaders |
27 |
- boot/loader: grub elilo |
28 |
- netboot/boot/loader: pxelinux elilo |
29 |
|
30 |
diff --git a/doc/catalyst-spec.5.txt b/doc/catalyst-spec.5.txt |
31 |
index 5e9cf87a..250acded 100644 |
32 |
--- a/doc/catalyst-spec.5.txt |
33 |
+++ b/doc/catalyst-spec.5.txt |
34 |
@@ -206,6 +206,8 @@ Bootloader |
35 |
~~~~~~~~~~ |
36 |
|
37 |
*livecd/cdtar*:: |
38 |
+This is required for livecd-stage2 on all arches except amd64 and x86 which can autogenerate one |
39 |
+if USE=system-bootloader is set. |
40 |
The cdtar is essentially the bootloader for the CD. It also holds the |
41 |
main configuration for the bootloader. On x86/amd64, it also can |
42 |
include a small memory testing application, called memtest86+ |
43 |
|
44 |
diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh |
45 |
index 9da6c969..0197b943 100755 |
46 |
--- a/targets/support/bootloader-setup.sh |
47 |
+++ b/targets/support/bootloader-setup.sh |
48 |
@@ -12,7 +12,7 @@ then |
49 |
extract_cdtar $1 |
50 |
elif [ "${clst_buildarch}" = "x86" ] || [ "${clst_buildarch}" = "amd64" ] |
51 |
then |
52 |
- #assume if there is no cdtar and we are on a support arch that the user just wants us to handle this |
53 |
+ #assume if there is no cdtar and we are on a supported arch that the user just wants us to handle this |
54 |
create_bootloader $1 |
55 |
else |
56 |
#While this seems a little crazy, it's entirely possible the bootloader is just shoved in isoroot overlay |
57 |
|
58 |
diff --git a/targets/support/functions.sh b/targets/support/functions.sh |
59 |
index 8eea1a07..e8f3e401 100755 |
60 |
--- a/targets/support/functions.sh |
61 |
+++ b/targets/support/functions.sh |
62 |
@@ -56,52 +56,76 @@ extract_cdtar() { |
63 |
tar -I lbzip2 -xpf ${clst_cdtar} -C $1 || die "Couldn't extract cdtar ${cdtar}" |
64 |
} |
65 |
|
66 |
-generate_bootloader() { |
67 |
+create_bootloader() { |
68 |
# For amd64 and x86 we attempt to copy boot loader files from the live system and configure it right |
69 |
# this prevents (among other issues) needing to keep a cdtar up to date. All files are thrown into $clst_target_path |
70 |
# Future improvement may make bootloaders optional, but for now there is only one option |
71 |
- if [ "${clst_buildarch}" = "amd64" ]; then |
72 |
- if [ -x "/usr/bin/grub2-mkstandalone" ]; then |
73 |
- grubmkstndaln="/usr/bin/grub2-mkstandalone" |
74 |
- elif [ -x "/usr/bin/grub-mkstandalone" ]; then |
75 |
- grubmkstndaln="/usr/bin/grub-mkstandalone" |
76 |
- else |
77 |
- die "Unable to find grub-mkstandalone\n" |
78 |
- fi |
79 |
- # while $1/grub is unused here, it triggers grub config building in bootloader-setup.sh |
80 |
- mkdir -p "$1/boot/EFI/BOOT" "$1/grub" |
81 |
- grub-stub="$(mktemp)" |
82 |
- echo "search --no-floppy --set=root --file /livecd" > "${grub-stub}" |
83 |
- echo "configfile /grub/grub.cfg" >> "${grub-stub}" |
84 |
- ${grubmkstndaln} /boot/grub/grub.cfg="${grub-stub}" --compress=xz -O x86_64-efi -o "$1/boot/EFI/BOOT/BOOTX64.EFI" --themes= || die "${grubmkstndaln} failed" |
85 |
- rm "${grub-stub}" |
86 |
- fi |
87 |
+ if [ -x "/usr/bin/grub2-mkstandalone" ]; then |
88 |
+ grubmkstndaln="/usr/bin/grub2-mkstandalone" |
89 |
+ elif [ -x "/usr/bin/grub-mkstandalone" ]; then |
90 |
+ grubmkstndaln="/usr/bin/grub-mkstandalone" |
91 |
+ else |
92 |
+ die "Unable to find grub-mkstandalone" |
93 |
+ fi |
94 |
|
95 |
- mkdir -p "$1/isolinux" |
96 |
- echo "Gentoo Linux Installation LiveCD http://www.gentoo.org/" > "$1/isolinux/boot.msg" |
97 |
- echo "Enter to boot; F1 for kernels F2 for options." >> "$1/isolinux/boot.msg" |
98 |
- echo "Press any key in the next 15 seconds or we'll try to boot from disk." >> "$1/isolinux/boot.msg" |
99 |
- if [ -f /usr/share/syslinux/isolinux.bin ]; then |
100 |
- cp /usr/share/syslinux/isolinux.bin "$1/isolinux/" |
101 |
- else |
102 |
- die "Unable to find isolinux.bin, which was requested" |
103 |
- fi |
104 |
- if [ -f /boot/memtest86plus/memtest ]; then |
105 |
- cp /boot/memtest86plus/memtest "$1/isolinux/" |
106 |
- else |
107 |
- die "Unable to find memtest, which was requested." |
108 |
- fi |
109 |
- if [ -f "/usr/share/syslinux/hdt.c32" ]; then |
110 |
- cp /usr/share/syslinux/hdt.c32 "$1/isolinux/" |
111 |
- if [ -f "/usr/share/misc/pci.ids" ]; then |
112 |
- cp /usr/share/misc/pci.ids "$1/isolinux/" |
113 |
- fi |
114 |
- fi |
115 |
- for i in libcom32.c32 libutil.c32 ldlinux.c32 reboot.c32 vesamenu.c32; do |
116 |
- if [ -f "/usr/share/syslinux/${i}" ]; then |
117 |
- cp "/usr/share/syslinux/${i}" "$1/isolinux/" |
118 |
- fi |
119 |
- done |
120 |
+ pushd "${1}" || die "Failed to enter livecd dir ${1}" |
121 |
+ |
122 |
+ # while $1/grub is unused here, it triggers grub config building in bootloader-setup.sh |
123 |
+ mkdir -p boot/EFI/BOOT grub/fonts isolinux |
124 |
+ #create boot.msg for isolinux |
125 |
+ echo "Gentoo Linux Installation LiveCD http://www.gentoo.org/" > isolinux/boot.msg |
126 |
+ echo "Enter to boot; F1 for kernels F2 for options." >> isolinux/boot.msg |
127 |
+ echo "Press any key in the next 15 seconds or we'll try to boot from disk." >> isolinux/boot.msg |
128 |
+ #install isolinux files |
129 |
+ if [ -f /usr/share/syslinux/isolinux.bin ]; then |
130 |
+ cp /usr/share/syslinux/isolinux.bin isolinux/ |
131 |
+ #isolinux support files |
132 |
+ for i in libcom32.c32 libutil.c32 ldlinux.c32 reboot.c32 vesamenu.c32; do |
133 |
+ if [ -f "/usr/share/syslinux/${i}" ]; then |
134 |
+ cp "/usr/share/syslinux/${i}" isolinux/ |
135 |
+ fi |
136 |
+ done |
137 |
+ #isolinux hardware detection toolkit, useful for system info and debugging |
138 |
+ if [ -f "/usr/share/syslinux/hdt.c32" ]; then |
139 |
+ cp /usr/share/syslinux/hdt.c32 isolinux/ |
140 |
+ if [ -f "/usr/share/misc/pci.ids" ]; then |
141 |
+ cp /usr/share/misc/pci.ids isolinux/ |
142 |
+ fi |
143 |
+ fi |
144 |
+ #memtest goes under isolinux since it doesn't work for uefi right now |
145 |
+ if [ -f /usr/share/memtest86+/memtest ]; then |
146 |
+ cp /usr/share/memtest86+/memtest isolinux/memtest86 |
147 |
+ else |
148 |
+ echo "Missing /usr/share/memtest86+/memtest, this livecd will not have memtest86+ support. Enable USE=system-bootloader on catalyst to pull in the correct deps" |
149 |
+ fi |
150 |
+ else |
151 |
+ echo "Missing /usr/share/syslinux/isolinux.bin, this livecd will not bios boot. Enable USE=system-bootloader on catalyst to pull in the correct deps" |
152 |
+ fi |
153 |
+ |
154 |
+ #create grub-stub.cfg for embedding in grub-mkstandalone |
155 |
+ echo "search --no-floppy --set=root --file /livecd" > grub-stub.cfg |
156 |
+ echo "configfile /grub/grub.cfg" >> grub-stub.cfg |
157 |
+ |
158 |
+ cp /usr/share/grub/unicode.pf2 grub/fonts/ |
159 |
+ if [ "${clst_buildarch}" = "x86" ] || [ "${clst_buildarch}" = "amd64" ]; then |
160 |
+ # some 64 bit machines have 32 bit UEFI, so we take the safest path |
161 |
+ mkdir -p grub/i386-efi |
162 |
+ cp /usr/lib/grub/i386-efi/*.lst /usr/lib/grub/i386-efi/*.img /usr/lib/grub/i386-efi/*.mod grub/i386-efi/ |
163 |
+ ${grubmkstndaln} /boot/grub/grub.cfg=./grub-stub.cfg --compress=xz -O i386-efi -o ./boot/EFI/BOOT/grubia32.efi --themes= -v || die "Failed to make grubia32.efi" |
164 |
+ #secure boot shim |
165 |
+ cp /usr/share/shim/BOOTIA32.EFI boot/EFI/BOOT/ |
166 |
+ cp /usr/share/shim/mmia32.efi boot/EFI/BOOT/ |
167 |
+ fi |
168 |
+ if [ "${clst_buildarch}" = "amd64" ]; then |
169 |
+ mkdir -p grub/x86_64-efi |
170 |
+ cp /usr/lib/grub/x86_64-efi/*.lst /usr/lib/grub/x86_64-efi/*.img /usr/lib/grub/x86_64-efi/*.mod grub/x86_64-efi/ |
171 |
+ ${grubmkstndaln} /boot/grub/grub.cfg=./grub-stub.cfg --compress=xz -O x86_64-efi -o ./boot/EFI/BOOT/grubx64.efi --themes= -v || die "Failed to make grubx64.efi" |
172 |
+ #secure boot shim |
173 |
+ cp /usr/share/shim/BOOTX64.EFI boot/EFI/BOOT/ |
174 |
+ cp /usr/share/shim/mmx64.efi boot/EFI/BOOT/ |
175 |
+ fi |
176 |
+ rm grub-stub.cfg || echo "Failed to remove grub-stub.cfg, but this hurts nothing" |
177 |
+ popd || die "Failed to leave livecd dir" |
178 |
} |
179 |
|
180 |
extract_kernels() { |