forked from metal3-io/ironic-image
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprepare-efi.sh
More file actions
executable file
·57 lines (47 loc) · 1.92 KB
/
prepare-efi.sh
File metadata and controls
executable file
·57 lines (47 loc) · 1.92 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
#!/bin/bash
set -euxo pipefail
OS=${1:-centos}
build_efi() {
DEST=/tmp/uefi_esp_${ARCH}.img
if [[ "$ARCH" == "x86_64" ]]; then
GRUB_PKG=grub2-efi-x64
BOOTEFI=BOOTX64.EFI
GRUBEFI=grubx64.efi
SHIM_PKG=shim-x64
elif [[ "$ARCH" == "aarch64" ]]; then
GRUB_PKG=grub2-efi-aa64
BOOTEFI=BOOTAA64.EFI
GRUBEFI=grubaa64.efi
SHIM_PKG=shim-aa64
else
echo "WARNING: don't know how to build an EFI image on $ARCH"
touch "$DEST"
exit 0
fi
# NOTE(elfosardo): glibc-gconv-extra was included by default in the past and
# we need it otherwise mkfs.msdos will fail with:
# ``Cannot initialize conversion from codepage 850 to ANSI_X3.4-1968: Invalid argument``
# ``Cannot initialize conversion from ANSI_X3.4-1968 to codepage 850: Invalid argument``
# subsequently making mmd fail with:
# ``Error converting to codepage 850 Invalid argument``
# ``Cannot initialize '::'``
# This is due to the conversion table missing codepage 850, included in glibc-gconv-extra
dnf install -y --allowerasing grub2 dosfstools mtools glibc-gconv-extra
# grub2-efi-XXX and shim-XXX are architecture specific packages, so force the architecture here
dnf install -y --allowerasing --forcearch="$ARCH" "$GRUB_PKG" "$SHIM_PKG"
## TODO(TheJulia): At some point we may want to try and make the size
## of the ESP image file to be sized smaller for the files that need to
## be copied in, however that requires more advanced scripting beyond
## an MVP.
dd bs=1024 count=6400 if=/dev/zero of="$DEST"
mkfs.msdos -F 12 -n 'ESP_IMAGE' "$DEST"
mmd -i "$DEST" EFI
mmd -i "$DEST" EFI/BOOT
mcopy -i "$DEST" -v "/boot/efi/EFI/BOOT/$BOOTEFI" ::EFI/BOOT
mcopy -i "$DEST" -v "/boot/efi/EFI/$OS/$GRUBEFI" ::EFI/BOOT
mdir -i "$DEST" ::EFI/BOOT
rpm -e --nodeps "$SHIM_PKG"
}
for ARCH in x86_64 aarch64; do
build_efi
done