mkarchiso: write grubenv in _make_common_bootmode_grub_cfg

Add all variables that we replace with values in configuration files.

Keep `${isofs_dir}/${install_dir}/grubenv` with fewer variables for
backwards compatibility. It will be removed in the future.
This commit is contained in:
nl6720 2023-01-28 13:57:36 +02:00
parent f7502001b0
commit d96a356995
No known key found for this signature in database
GPG Key ID: 5CE88535E188D369
3 changed files with 26 additions and 1 deletions

View File

@ -24,6 +24,9 @@ Changed
the ISO volume and load the ``grub.cfg`` from there.
- Moved GRUB files on ISO 9660 from ``/EFI/BOOT/`` to a boot-platform neutral place ``/boot/grub/``. This does not apply
to the EFI binaries that remain in the default/fallback boot path.
- Move ``grubenv`` to ``/boot/grub/grubenv`` on ISO 9660 so that it is together with the rest of GRUB-specific files.
Additionally write more variables in it. The previous ``/${install_dir}/grubenv`` (``/arch/grubenv`` for releng)
is deprecated and a future archiso release will not create this file anymore.
Removed
-------

View File

@ -129,7 +129,7 @@ boot the iso image from GRUB with a version specific cow directory to mitigate o
.. code:: sh
loopback loop archlinux.iso
load_env -f (loop)/arch/grubenv
load_env -f (loop)/boot/grub/grubenv
linux (loop)/arch/boot/x86_64/vmlinuz-linux ... \
cow_directory=${NAME}/${VERSION} ...
initrd (loop)/arch/boot/x86_64/initramfs-linux-lts.img

View File

@ -618,6 +618,18 @@ fi
EOF
grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}"
printf '%s\n' "$grubembedcfg" > "${work_dir}/grub-embed.cfg"
# Write grubenv
printf '%.1024s' \
"$(printf '# GRUB Environment Block\nNAME=%s\nVERSION=%s\nARCHISO_LABEL=%s\nINSTALL_DIR=%s\nARCH=%s\nUUID_SEARCH_FILENAME=%s\n%s' \
"${iso_name}" \
"${iso_version}" \
"${iso_label}" \
"${install_dir}" \
"${arch}" \
"${uuid_search_filename}" \
"$(printf '%0.1s' "#"{1..1024})")" \
> "${work_dir}/grub/grubenv"
}
_make_bootmode_uefi-ia32.grub.esp() {
@ -1067,6 +1079,10 @@ _export_netboot_artifacts() {
_msg_info "Exporting netboot artifacts..."
install -d -m 0755 "${out_dir}"
cp -a -- "${isofs_dir}/${install_dir}/" "${out_dir}/"
# Remove grubenv since it serves no purpose in netboot artifacts
rm -f -- "${out_dir}/${install_dir}/grubenv"
_msg_info "Done!"
du -hs -- "${out_dir}/${install_dir}"
}
@ -1663,7 +1679,13 @@ _make_version() {
install -d -m 0755 -- "${isofs_dir}/${install_dir}"
# Write version file to ISO 9660
printf '%s\n' "${iso_version}" > "${isofs_dir}/${install_dir}/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
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})")" \
> "${isofs_dir}/${install_dir}/grubenv"