Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archiso/mkarchiso
diff options
context:
space:
mode:
authornl6720 <nl6720@gmail.com>2023-01-28 13:08:49 +0200
committernl6720 <nl6720@gmail.com>2023-02-22 18:28:24 +0200
commitf5ade898f9cb0de1f6fb01fcef088d8a6b56de7d (patch)
tree68a6aa53a2fb830ccce5feceec20d6680e25c345 /archiso/mkarchiso
parent40e09767f0cea7c4a94af98504e9c936f1dd7720 (diff)
Do not duplicate grub.cfg in efiboot.img
Instruct the embeded grub.cfg to search for a volume with a `/.disk/%UUID_SEARCH_FILENAME%.uuid` file and load `/EFI/BOOT/grub.cfg` from it. This avoid duplicating GRUB configuration files in two places (ISO 9660 and FAT) and ensures there is no confusion about which is the _correct_ configuration file. Since nothing besides EFI binaries is copied to `efibootimg`, the `_make_common_bootmode_grub_copy_to_efibootimg` function is removed. Fixes #208
Diffstat (limited to 'archiso/mkarchiso')
-rwxr-xr-xarchiso/mkarchiso54
1 files changed, 34 insertions, 20 deletions
diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index c116a27..00c974e 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -544,18 +544,7 @@ _make_efibootimg() {
mmd -i "${efibootimg}" ::/EFI ::/EFI/BOOT
}
-# Copy GRUB files to efiboot.img which is used by both IA32 UEFI and x64 UEFI.
-_make_common_bootmode_grub_copy_to_efibootimg() {
- local files_to_copy=()
-
- files_to_copy+=("${work_dir}/grub/"*)
- if compgen -G "${profile}/grub/!(*.cfg)" &> /dev/null; then
- files_to_copy+=("${profile}/grub/"!(*.cfg))
- fi
- mcopy -i "${efibootimg}" "${files_to_copy[@]}" ::/EFI/BOOT/
-}
-
-# Copy GRUB files to efiboot.img which is used by both IA32 UEFI and x64 UEFI.
+# Copy GRUB files to ISO 9660 which is used by both IA32 UEFI and x64 UEFI
_make_common_bootmode_grub_copy_to_isofs() {
local files_to_copy=()
@@ -563,6 +552,7 @@ _make_common_bootmode_grub_copy_to_isofs() {
if compgen -G "${profile}/grub/!(*.cfg)" &> /dev/null; then
files_to_copy+=("${profile}/grub/"!(*.cfg))
fi
+ install -d -m 0755 -- "${isofs_dir}/EFI/BOOT"
install -m 0644 -- "${files_to_copy[@]}" "${isofs_dir}/EFI/BOOT/"
}
@@ -586,9 +576,6 @@ _make_common_bootmode_grub_cfg(){
s|%UUID_SEARCH_FILENAME%|${uuid_search_filename}|g" \
"${_cfg}" > "${work_dir}/grub/${_cfg##*/}"
done
- # Add all GRUB files to the list of files used to calculate the required FAT image size.
- efiboot_files+=("${work_dir}/grub/"
- "${profile}/grub/"!(*.cfg))
# Prepare grub.cfg that will be embedded inside the GRUB binaries
IFS='' read -r -d '' grubembedcfg <<'EOF' || true
@@ -597,12 +584,39 @@ if ! [ -d "$cmdpath" ]; then
# launched from a case-insensitive FAT-formatted EFI system partition, but it seemingly cannot access that partition
# and sets cmdpath to the whole cd# device which has case-sensitive ISO 9660 + Rock Ridge + Joliet file systems.
# See https://gitlab.archlinux.org/archlinux/archiso/-/issues/183 and https://savannah.gnu.org/bugs/?62886
- if regexp --set=1:isodevice '^(\([^)]+\))\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "$cmdpath"; then
- cmdpath="${isodevice}/EFI/BOOT"
+ if regexp --set=1:archiso_bootdevice '^\(([^)]+)\)\/?[Ee][Ff][Ii]\/[Bb][Oo][Oo][Tt]\/?$' "${cmdpath}"; then
+ set cmdpath="(${archiso_bootdevice})/EFI/BOOT"
+ set ARCHISO_HINT="${archiso_bootdevice}"
fi
fi
-configfile "${cmdpath}/grub.cfg"
+
+# Prepare a hint for the search command using the device in cmdpath
+if [ -z "${ARCHISO_HINT}" ]; then
+ regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}"
+fi
+
+# Search for the ISO volume
+if search --no-floppy --set=archiso_device --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"; then
+ set ARCHISO_HINT="${archiso_device}"
+ if probe --set ARCHISO_UUID --fs-uuid "${ARCHISO_HINT}"; then
+ export ARCHISO_UUID
+ fi
+else
+ echo "Could not find a volume with a '/.disk/%UUID_SEARCH_FILENAME%.uuid' file on it!"
+fi
+
+# Load grub.cfg
+if [ "${ARCHISO_HINT}" == 'memdisk' -o -z "${ARCHISO_HINT}" ]; then
+ echo 'Could not find the ISO volume!'
+elif [ -e "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg" ]; then
+ export ARCHISO_HINT
+ set root="${ARCHISO_HINT}"
+ configfile "(${ARCHISO_HINT})/EFI/BOOT/grub.cfg"
+else
+ echo "File '(${ARCHISO_HINT})/EFI/BOOT/grub.cfg' not found!"
+fi
EOF
+ grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}"
printf '%s\n' "$grubembedcfg" > "${work_dir}/grub-embed.cfg"
}
@@ -645,7 +659,7 @@ _make_bootmode_uefi-ia32.grub.esp() {
mcopy -i "${efibootimg}" "${work_dir}/BOOTIA32.EFI" ::/EFI/BOOT/BOOTIA32.EFI
# Copy GRUB files
- _run_once _make_common_bootmode_grub_copy_to_efibootimg
+ _run_once _make_common_bootmode_grub_copy_to_isofs
if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi" ]]; then
mcopy -i "${efibootimg}" "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi" ::/shellia32.efi
@@ -716,7 +730,7 @@ _make_bootmode_uefi-x64.grub.esp() {
mcopy -i "${efibootimg}" "${work_dir}/BOOTx64.EFI" ::/EFI/BOOT/BOOTx64.EFI
# Copy GRUB files
- _run_once _make_common_bootmode_grub_copy_to_efibootimg
+ _run_once _make_common_bootmode_grub_copy_to_isofs
if [[ -e "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ]]; then
mcopy -i "${efibootimg}" "${pacstrap_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" ::/shellx64.efi