-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkarchiso.patch
231 lines (210 loc) · 10.5 KB
/
mkarchiso.patch
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
--- mkarchiso 2024-05-23 23:16:11.000000000 +0200
+++ mkarchiso 2024-05-29 23:06:09.870536100 +0200
@@ -373,6 +373,18 @@
fi
_msg_info "Done! Packages installed successfully."
+
+ # sign the kernel
+ for kernel in "${pacstrap_dir}/boot/vmlinuz-"*; do
+ sbsign --key DB.key --cert DB.crt --output "$kernel" "$kernel"
+ done
+ # signing grubx64.efi and shell once and for all
+ sbsign --key DB.key --cert DB.crt --output "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \
+ "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi"
+ sbsign --key DB.key --cert DB.crt --output "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" \
+ "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi"
+ sbsign --key DB.key --cert DB.crt --output "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi" \
+ "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi"
}
# Customize installation.
@@ -701,11 +713,18 @@
--locales="en@quot" \
--themes="" \
--sbat=/usr/share/grub/sbat.csv \
- --disable-shim-lock \
-o "${work_dir}/BOOTIA32.EFI" "boot/grub/grub.cfg=${work_dir}/grub-embed.cfg"
+
+ sbsign --key DB.key --cert DB.crt --output "${work_dir}/BOOTIA32.EFI" "${work_dir}/BOOTIA32.EFI"
+
# Add GRUB to the list of files used to calculate the required FAT image size.
efiboot_files+=("${work_dir}/BOOTIA32.EFI"
+ "${pacstrap_dir}/usr/share/shim-signed/shimia32.efi"
+ "${pacstrap_dir}/usr/share/shim-signed/mmia32.efi"
"${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi")
+ if [[ -f DB.cer ]] ;then
+ efiboot_files+=(DB.cer)
+ fi
if [[ " ${bootmodes[*]} " =~ uefi-x64.systemd-boot.esp ]]; then
# TODO: Remove this branch.
@@ -718,8 +737,17 @@
_make_efibootimg "$efiboot_imgsize"
fi
- # Copy GRUB EFI binary to the default/fallback boot path
- mcopy -i "${efibootimg}" "${work_dir}/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI
+ # Copy shim EFI binary to the default/fallback boot path
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/shimia32.efi" ::/EFI/BOOT/BOOTIA32.EFI
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/mmia32.efi" ::/EFI/BOOT/mmia32.efi
+ # Copy GRUB EFI binary as grubia32.efi chainloaded by shimia32.efi
+ mcopy -i "${efibootimg}" "${work_dir}/BOOTIA32.EFI" ::/EFI/BOOT/grubia32.efi
+
+ if [[ -f DB.cer ]] ;then
+ mcopy -o -i "${efibootimg}" DB.cer ::/EFI/BOOT/DB.cer
+ fi
# Copy GRUB files
_run_once _make_common_bootmode_grub_copy_to_isofs
@@ -746,8 +774,18 @@
_msg_info "Preparing an /EFI directory for the ISO 9660 file system..."
install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
+ # Copy shim EFI binary to the default/fallback boot path
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/shimia32.efi" \
+ "${isofs_dir}/EFI/BOOT/BOOTIA32.EFI"
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/mmia32.efi" \
+ "${isofs_dir}/EFI/BOOT/mmia32.efi"
+
# Copy GRUB EFI binary to the default/fallback boot path
- install -m 0644 -- "${work_dir}/BOOTIA32.EFI" "${isofs_dir}/EFI/BOOT/BOOTIA32.EFI"
+ install -m 0644 -- "${work_dir}/BOOTIA32.EFI" "${isofs_dir}/EFI/BOOT/grubia32.efi"
+
+ if [[ -f DB.cer ]] ;then
+ install -m 0644 DB.cer "${isofs_dir}/EFI/BOOT/DB.cer"
+ fi
# Copy GRUB configuration files
_run_once _make_common_bootmode_grub_copy_to_isofs
@@ -778,19 +816,35 @@
--locales="en@quot" \
--themes="" \
--sbat=/usr/share/grub/sbat.csv \
- --disable-shim-lock \
-o "${work_dir}/BOOTx64.EFI" "boot/grub/grub.cfg=${work_dir}/grub-embed.cfg"
+
+ sbsign --key DB.key --cert DB.crt --output "${work_dir}/BOOTx64.EFI" "${work_dir}/BOOTx64.EFI"
+
# Add GRUB to the list of files used to calculate the required FAT image size.
efiboot_files+=("${work_dir}/BOOTx64.EFI"
+ "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi"
+ "${pacstrap_dir}/usr/share/shim-signed/mmx64.efi"
"${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi")
+ if [[ -f DB.cer ]] ;then
+ efiboot_files+=(DB.cer)
+ fi
efiboot_imgsize="$(du -bcs -- "${efiboot_files[@]}" 2>/dev/null | awk 'END { print $1 }')"
# Create a FAT image for the EFI system partition
_make_efibootimg "$efiboot_imgsize"
- # Copy GRUB EFI binary to the default/fallback boot path
- mcopy -i "${efibootimg}" "${work_dir}/BOOTx64.EFI" ::/EFI/BOOT/BOOTx64.EFI
+ # Copy shim EFI binary to the default/fallback boot path
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi" ::/EFI/BOOT/BOOTx64.EFI
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/mmx64.efi" ::/EFI/BOOT/mmx64.efi
+ # Copy GRUB EFI binary as grubx64.efi chainloaded by shimx64.efi
+ mcopy -i "${efibootimg}" "${work_dir}/BOOTx64.EFI" ::/EFI/BOOT/grubx64.efi
+
+ if [[ -f DB.cer ]] ;then
+ mcopy -o -i "${efibootimg}" DB.cer ::/EFI/BOOT/DB.cer
+ fi
# Copy GRUB files
_run_once _make_common_bootmode_grub_copy_to_isofs
@@ -824,8 +878,18 @@
_msg_info "Preparing an /EFI directory for the ISO 9660 file system..."
install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
+ # Copy shim EFI binary to the default/fallback boot path
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi" \
+ "${isofs_dir}/EFI/BOOT/BOOTx64.EFI"
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/mmx64.efi" \
+ "${isofs_dir}/EFI/BOOT/mmx64.efi"
+
# Copy GRUB EFI binary to the default/fallback boot path
- install -m 0644 -- "${work_dir}/BOOTx64.EFI" "${isofs_dir}/EFI/BOOT/BOOTx64.EFI"
+ install -m 0644 -- "${work_dir}/BOOTx64.EFI" "${isofs_dir}/EFI/BOOT/grubx64.efi"
+
+ if [[ -f DB.cer ]] ;then
+ install -m 0644 DB.cer "${isofs_dir}/EFI/BOOT/DB.cer"
+ fi
# Copy GRUB files
_run_once _make_common_bootmode_grub_copy_to_isofs
@@ -867,6 +931,9 @@
"${pacstrap_dir}/boot/vmlinuz-"*
"${pacstrap_dir}/boot/initramfs-"*".img"
"${_available_ucodes[@]}")
+ if [[ -f DB.cer ]] ;then
+ efiboot_files+=(DB.cer)
+ fi
efiboot_imgsize="$(du -bcs -- "${efiboot_files[@]}" 2>/dev/null | awk 'END { print $1 }')"
# Create a FAT image for the EFI system partition
_make_efibootimg "$efiboot_imgsize"
@@ -907,9 +974,17 @@
# Prepare a FAT image for the EFI system partition
_run_once _make_common_bootmode_systemd-boot
- # Copy systemd-boot EFI binary to the default/fallback boot path
+ # Copy shim EFI binary to the default/fallback boot path
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi" ::/EFI/BOOT/BOOTx64.EFI
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/mmx64.efi" ::/EFI/BOOT/mmx64.efi
+ # Copy systemd-boot EFI binary as grubx64.efi chainloaded by shimx64.efi
mcopy -i "${efibootimg}" \
- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/BOOTx64.EFI
+ "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" ::/EFI/BOOT/grubx64.efi
+ if [[ -f DB.cer ]] ;then
+ mcopy -o -i "${efibootimg}" DB.cer ::/EFI/BOOT/DB.cer
+ fi
# Copy systemd-boot configuration files
_run_once _make_common_bootmode_systemd-boot_conf.esp
@@ -951,9 +1026,18 @@
_msg_info "Preparing an /EFI directory for the ISO 9660 file system..."
install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
- # Copy systemd-boot EFI binary to the default/fallback boot path
- install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \
+ # Copy shim EFI binary to the default/fallback boot path
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi" \
"${isofs_dir}/EFI/BOOT/BOOTx64.EFI"
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/mmx64.efi" \
+ "${isofs_dir}/EFI/BOOT/mmx64.efi"
+
+ # Copy systemd-boot EFI binary as grubx64.efi chainloaded by shimx64.efi
+ install -m 0644 "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \
+ "${isofs_dir}/EFI/BOOT/grubx64.efi"
+ if [[ -f DB.cer ]] ;then
+ install -m 0644 DB.cer "${isofs_dir}/EFI/BOOT/DB.cer"
+ fi
# Copy systemd-boot configuration files
_run_once _make_common_bootmode_systemd-boot_conf.isofs
@@ -983,9 +1067,17 @@
# Prepare a FAT image for the EFI system partition
_run_once _make_common_bootmode_systemd-boot
- # Copy systemd-boot EFI binary to the default/fallback boot path
+ # Copy shim EFI binary to the default/fallback boot path
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/shimia32.efi" ::/EFI/BOOT/BOOTIA32.EFI
+ mcopy -i "${efibootimg}" \
+ "${pacstrap_dir}/usr/share/shim-signed/mmia32.efi" ::/EFI/BOOT/mmia32.efi
+ # Copy systemd-boot EFI binary as grubia32.efi chainloaded by shimia32.efi
mcopy -i "${efibootimg}" \
- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi" ::/EFI/BOOT/BOOTIA32.EFI
+ "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi" ::/EFI/BOOT/grubia32.EFI
+ if [[ -f DB.cer ]] ;then
+ mcopy -o -i "${efibootimg}" DB.cer ::/EFI/BOOT/DB.cer
+ fi
# Copy systemd-boot configuration files
_run_once _make_common_bootmode_systemd-boot_conf.esp
@@ -1017,9 +1109,17 @@
_msg_info "Preparing an /EFI directory for the ISO 9660 file system..."
install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
- # Copy systemd-boot EFI binary to the default/fallback boot path
- install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi" \
+ # Copy shim EFI binary to the default/fallback boot path
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/shimx64.efi" \
"${isofs_dir}/EFI/BOOT/BOOTIA32.EFI"
+ install -m 0644 -- "${pacstrap_dir}/usr/share/shim-signed/mmia32.efi" \
+ "${isofs_dir}/EFI/BOOT/mmia32.efi"
+ # Copy systemd-boot EFI binary as grubia32.efi chainloaded by shimia32.efi
+ install -m 0644 -- "${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi" \
+ "${isofs_dir}/EFI/BOOT/grubia32.efi"
+ if [[ -f DB.cer ]] ;then
+ install -m 0644 -- DB.cer "${isofs_dir}/EFI/BOOT/DB.cer"
+ fi
# Copy systemd-boot configuration files
_run_once _make_common_bootmode_systemd-boot_conf.isofs