From 094afd169a0ff871eb7a6b37d68a9b9bcb7195e4 Mon Sep 17 00:00:00 2001 From: nl6720 Date: Thu, 16 Mar 2023 09:22:57 +0200 Subject: mkarchiso: support %ARCHISO_UUID% variable in boot loader configuration It will be replaced with the ISO's modification date in UTC, i.e. its "UUID". This allows to replace `archisolabel=%ARCHISO_LABEL%` with `archisodevice=UUID=%ARCHISO_UUID%` in boot loader configurations. Related to #202 --- archiso/mkarchiso | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'archiso/mkarchiso') diff --git a/archiso/mkarchiso b/archiso/mkarchiso index e991b52..afaeb6e 100755 --- a/archiso/mkarchiso +++ b/archiso/mkarchiso @@ -29,6 +29,7 @@ gpg_key="" gpg_sender="" iso_name="" iso_label="" +iso_uuid="" iso_publisher="" iso_application="" iso_version="" @@ -446,6 +447,7 @@ _make_bootmode_bios.syslinux.mbr() { install -d -m 0755 -- "${isofs_dir}/boot/syslinux" for _cfg in "${profile}/syslinux/"*.cfg; do sed "s|%ARCHISO_LABEL%|${iso_label}|g; + s|%ARCHISO_UUID%|${iso_uuid}|g; s|%INSTALL_DIR%|${install_dir}|g; s|%ARCH%|${arch}|g" \ "${_cfg}" > "${isofs_dir}/boot/syslinux/${_cfg##*/}" @@ -558,21 +560,20 @@ _make_common_bootmode_grub_copy_to_isofs() { # Prepare GRUB configuration files _make_common_bootmode_grub_cfg(){ - local _cfg archiso_uuid search_filename + local _cfg search_filename install -d -- "${work_dir}/grub" - # Precalculate the ISO's modification date in UTC, i.e. its "UUID" - TZ=UTC printf -v archiso_uuid '%(%F-%H-%M-%S-00)T' "$SOURCE_DATE_EPOCH" # 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. - : > "${work_dir}/grub/${archiso_uuid}.uuid" - search_filename="/boot/grub/${archiso_uuid}.uuid" + : > "${work_dir}/grub/${iso_uuid}.uuid" + search_filename="/boot/grub/${iso_uuid}.uuid" # Fill GRUB configuration files for _cfg in "${profile}/grub/"*'.cfg'; do 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" \ @@ -821,6 +822,7 @@ _make_bootmode_uefi-x64.systemd-boot.esp() { mcopy -i "${efibootimg}" "${profile}/efiboot/loader/loader.conf" ::/loader/ for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do sed "s|%ARCHISO_LABEL%|${iso_label}|g; + s|%ARCHISO_UUID%|${iso_uuid}|g; s|%INSTALL_DIR%|${install_dir}|g; s|%ARCH%|${arch}|g" \ "${_conf}" | mcopy -i "${efibootimg}" - "::/loader/entries/${_conf##*/}" @@ -1660,6 +1662,8 @@ _set_overrides() { # Set variables that do not have overrides [[ -n "$airootfs_image_type" ]] || airootfs_image_type="squashfs" [[ -n "$iso_name" ]] || iso_name="${app_name}" + # Precalculate the ISO's modification date in UTC, i.e. its "UUID" + TZ=UTC printf -v iso_uuid '%(%F-%H-%M-%S-00)T' "$SOURCE_DATE_EPOCH" } _export_gpg_publickey() { -- cgit v1.2.3-54-g00ecf