Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornl6720 <nl6720@gmail.com>2023-09-28 10:45:43 +0300
committernl6720 <nl6720@gmail.com>2023-09-28 10:53:45 +0300
commita75d7e5f7e582b3bbbaf5f0d16e1f243c4c3a8bf (patch)
tree83e9e2c58269531b452865be87372a21eec0b70d
parent4280af747466c4a7d37eabc6502c1ed697210db9 (diff)
mkarchiso: always create /boot/grub/grubenv and /boot/grub/loopback.cfg
Even if GRUB is not used as a boot loader for the ISO, create a `/boot/grub/grubenv` file in the ISO 9660 file system. If a `loopback.cfg` file exists in the profile's `grub` directory, copy it to `/boot/grub/loopback.cfg` on the ISO. This ensures the funtionality will not be lost if the used boot loaders are changed.
-rwxr-xr-xarchiso/mkarchiso43
1 files changed, 41 insertions, 2 deletions
diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index a727a1a..7890615 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -420,6 +420,10 @@ _make_bootmodes() {
for bootmode in "${bootmodes[@]}"; do
_run_once "_make_bootmode_${bootmode}"
done
+
+ if [[ "${bootmodes[*]}" != *grub* ]]; then
+ _run_once _make_common_grubenv_and_loopbackcfg
+ fi
}
# Copy kernel and initramfs to ISO 9660
@@ -638,6 +642,40 @@ EOF
>"${work_dir}/grub/grubenv"
}
+# Create GRUB specific configuration files when GRUB is not used as a boot loader
+_make_common_grubenv_and_loopbackcfg() {
+ local search_filename
+
+ install -d -m 0755 -- "${isofs_dir}/boot/grub"
+ # Create a /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid file on ISO 9660. GRUB will search for it to find the ISO
+ # volume. This is similar to what grub-mkrescue does, except it places the file in /.disk/, but we opt to use a
+ # directory that does not start with a dot to avoid it being accidentally missed when copying the ISO's contents.
+ search_filename="/boot/grub/${iso_uuid}.uuid"
+ : >"${isofs_dir}/${search_filename}"
+
+ # Write grubenv
+ printf '%.1024s' \
+ "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nARCHISO_SEARCH_FILENAME=%s\n%s' \
+ "${iso_name}" \
+ "${iso_version}" \
+ "${iso_label}" \
+ "${install_dir}" \
+ "${arch}" \
+ "${search_filename}" \
+ "$(printf '%0.1s' "#"{1..1024})")" \
+ >"${isofs_dir}/boot/grub/grubenv"
+
+ # Copy loopback.cfg to /boot/grub/ on ISO 9660
+ if [[ -e "${profile}/grub/loopback.cfg" ]]; then
+ sed "s|%ARCHISO_LABEL%|${iso_label}|g;
+ s|%ARCHISO_UUID%|${iso_uuid}|g;
+ s|%INSTALL_DIR%|${install_dir}|g;
+ s|%ARCH%|${arch}|g;
+ s|%ARCHISO_SEARCH_FILENAME%|${search_filename}|g" \
+ "${profile}/grub/loopback.cfg" >"${isofs_dir}/boot/grub/loopback.cfg"
+ fi
+}
+
_make_bootmode_uefi-ia32.grub.esp() {
local grubmodules=()
@@ -1800,8 +1838,9 @@ _make_version() {
fi
if [[ "${buildmode}" == "iso" ]]; then
# Write grubenv with version information to ISO 9660
- # TODO: after sufficient time has passed, do not create this file anymore when GRUB boot modes are used.
- # _make_common_bootmode_grub_cfg already creates ${isofs_dir}/boot/grub/grubenv
+ # TODO: after sufficient time has passed, do not create this file anymore.
+ # _make_common_bootmode_grub_cfg and _make_common_grubenv_and_loopbackcfg already create a
+ # ${isofs_dir}/boot/grub/grubenv file
rm -f -- "${isofs_dir}/${install_dir}/grubenv"
printf '%.1024s' "$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\n%s' \
"${iso_name}" "${iso_version}" "$(printf '%0.1s' "#"{1..1024})")" \