165 | 165 |
# certain firmwares (eg: TianoCore) happy
|
166 | 166 |
# - use shim as the boot<arch>.efi that gets loaded first by the firmware
|
167 | 167 |
# - drop a grub.cfg (same reason as below) in the cfg directory as configured
|
168 | |
# by the signed grub efi binary creation. At the moment that is EFI/debian
|
169 | |
# as set by grub2/debian/build-efi-images and cannot be changed without
|
170 | |
# rebuilding grub2
|
|
168 |
# by the signed grub efi binary creation. This is set dynamically when grub2 is
|
|
169 |
# built with the ouput of dpkg-vendor, and can be overridden by the builder, so
|
|
170 |
# we do the same here in live-build.
|
171 | 171 |
# - the source paths are taken from shim-signed:
|
172 | 172 |
# https://packages.debian.org/sid/amd64/shim-signed/filelist
|
173 | 173 |
# and grub-efi-amd64-signed, currently in Ubuntu:
|
|
176 | 176 |
if [ -r ${_CHROOT_DIR}/usr/lib/grub/\$platform-signed/grub\$efi_name.efi.signed -a \
|
177 | 177 |
-r ${_CHROOT_DIR}/usr/lib/shim/shim\$efi_name.efi.signed -a \
|
178 | 178 |
"${LB_UEFI_SECURE_BOOT}" != "disable" ]; then
|
179 | |
mkdir -p ${_CHROOT_DIR}/grub-efi-temp/EFI/debian
|
|
179 |
mkdir -p "${_CHROOT_DIR}/grub-efi-temp/EFI/\$EFI_VENDOR"
|
180 | 180 |
cp ${_CHROOT_DIR}/usr/lib/grub/\$platform-signed/grub\$efi_name.efi.signed \
|
181 | 181 |
${_CHROOT_DIR}/grub-efi-temp/EFI/boot/grub\$efi_name.efi
|
182 | 182 |
cp ${_CHROOT_DIR}/usr/lib/shim/shim\$efi_name.efi.signed \
|
183 | 183 |
${_CHROOT_DIR}/grub-efi-temp/EFI/boot/boot\$efi_name.efi
|
184 | 184 |
fi
|
185 | 185 |
}
|
|
186 |
|
|
187 |
# The EFI vendor, used by Grub to set the directory in the monolithic image, depends
|
|
188 |
# on the distro vendor set at Grub's build time. It will be added to the package metadata.
|
|
189 |
EFI_VENDOR="\$(dpkg-query -f='\${Efi-Vendor}' -W grub-efi-${_SB_EFI_DEB}-bin)"
|
|
190 |
# If it's missing, fallback to the previous usage of just "debian".
|
|
191 |
if [ -z "$EFI_VENDOR" ]; then
|
|
192 |
EFI_VENDOR="debian"
|
|
193 |
fi
|
186 | 194 |
|
187 | 195 |
PRE_EFI_IMAGE_PATH="${PATH}"
|
188 | 196 |
if [ ! -e "${LIVE_BUILD}" ] ; then
|
|
239 | 247 |
# directories: EFI EFI/boot boot boot/grub
|
240 | 248 |
size=\$((\$size + 4096 * 4))
|
241 | 249 |
|
242 | |
# EFI/debian and additional grub.cfg
|
243 | |
if [ -d ${_CHROOT_DIR}/grub-efi-temp/EFI/debian ]; then
|
|
250 |
# EFI/\$EFI_VENDOR and additional grub.cfg
|
|
251 |
if [ -d "${_CHROOT_DIR}/grub-efi-temp/EFI/\$EFI_VENDOR" ]; then
|
244 | 252 |
size=\$((\$size + 4096))
|
245 | 253 |
size=\$((\$size + \$(stat -c %s "${_CHROOT_DIR}/grub-efi-temp-cfg/grub.cfg")))
|
246 | 254 |
cp ${_CHROOT_DIR}/grub-efi-temp-cfg/grub.cfg \
|
247 | |
${_CHROOT_DIR}/grub-efi-temp/EFI/debian
|
|
255 |
"${_CHROOT_DIR}/grub-efi-temp/EFI/\$EFI_VENDOR"
|
248 | 256 |
fi
|
249 | 257 |
|
250 | 258 |
blocks=\$(((\$size / 1024 + 55) / 32 * 32 ))
|
|
256 | 264 |
mcopy -o -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ${_CHROOT_DIR}/grub-efi-temp/EFI/boot/*.efi \
|
257 | 265 |
"::EFI/boot"
|
258 | 266 |
|
259 | |
if [ -d ${_CHROOT_DIR}/grub-efi-temp/EFI/debian ]; then
|
260 | |
mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::EFI/debian
|
|
267 |
if [ -d "${_CHROOT_DIR}/grub-efi-temp/EFI/\$EFI_VENDOR" ]; then
|
|
268 |
mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" "::EFI/\$EFI_VENDOR"
|
261 | 269 |
mcopy -o -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" \
|
262 | |
${_CHROOT_DIR}/grub-efi-temp-cfg/grub.cfg "::EFI/debian"
|
|
270 |
${_CHROOT_DIR}/grub-efi-temp-cfg/grub.cfg "::EFI/\$EFI_VENDOR"
|
263 | 271 |
fi
|
264 | 272 |
|
265 | 273 |
mmd -i "${_CHROOT_DIR}/grub-efi-temp/boot/grub/efi.img" ::boot
|