Move the .uuid file to /boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid
To prevent the file from being accidentally missed when someone copies the ISO's contents, let's not place it in a directory that starts with a dot. Since all GRUB related files are in /boot/grub/, put it there too. Instead of using a more unique UUID for the file name, use `YYYY-mm-dd-HH-MM-SS-00.uuid` which matches the ISO's modification date in UTC,i.e. its "UUID". If multiple ISOs would be generated in the exact same second, the ISO 9660 modification date (i.e. its "UUID") would be the same, so there would be not way to distinguish between the volumes anyway. This also makes the file look less suspicious to the casual glance.
This commit is contained in:
parent
d96a356995
commit
c8474f8dbe
@ -10,7 +10,7 @@ Added
|
||||
|
||||
- Support *file system transposition* to simplify boot medium preparation for UEFI boot via extracting the ISO image
|
||||
contents to a drive. ``grub.cfg`` does not hardcode the ISO volume label anymore, instead GRUB will search for volume
|
||||
with a ``/.disk/%UUID_SEARCH_FILENAME%.uuid`` file on it.
|
||||
with a ``/boot/grub/YYYY-mm-dd-HH-MM-SS-00.uuid`` file on it.
|
||||
- Preload GRUB's NTFS modules for UEFI that allegedly have native NTFS support. GRUB's exFAT and UDF modules are also
|
||||
preloaded in case someone finds them useful.
|
||||
|
||||
|
@ -558,22 +558,24 @@ _make_common_bootmode_grub_copy_to_isofs() {
|
||||
|
||||
# Prepare GRUB configuration files
|
||||
_make_common_bootmode_grub_cfg(){
|
||||
local _cfg uuid_search_filename
|
||||
|
||||
# Create a .uuid file and place it in /.disk/ on ISO 9660 to provide a way for GRUB to search for the volume
|
||||
uuid_search_filename="$(uuidgen --sha1 --namespace 93a870ff-8565-4cf3-a67b-f47299271a96 \
|
||||
--name "${SOURCE_DATE_EPOCH} disk search UUID")"
|
||||
install -d -m 0755 -- "${isofs_dir}/.disk"
|
||||
: > "${isofs_dir}/.disk/${uuid_search_filename}.uuid"
|
||||
local _cfg archiso_uuid 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"
|
||||
|
||||
# Fill GRUB configuration files
|
||||
for _cfg in "${profile}/grub/"*'.cfg'; do
|
||||
sed "s|%ARCHISO_LABEL%|${iso_label}|g;
|
||||
s|%INSTALL_DIR%|${install_dir}|g;
|
||||
s|%ARCH%|${arch}|g;
|
||||
s|%UUID_SEARCH_FILENAME%|${uuid_search_filename}|g" \
|
||||
s|%ARCHISO_SEARCH_FILENAME%|${search_filename}|g" \
|
||||
"${_cfg}" > "${work_dir}/grub/${_cfg##*/}"
|
||||
done
|
||||
|
||||
@ -596,13 +598,13 @@ if [ -z "${ARCHISO_HINT}" ]; then
|
||||
fi
|
||||
|
||||
# Search for the ISO volume
|
||||
if search --no-floppy --set=archiso_device --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"; then
|
||||
if search --no-floppy --set=archiso_device --file '%ARCHISO_SEARCH_FILENAME%' --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!"
|
||||
echo "Could not find a volume with a '%ARCHISO_SEARCH_FILENAME%' file on it!"
|
||||
fi
|
||||
|
||||
# Load grub.cfg
|
||||
@ -616,18 +618,18 @@ else
|
||||
echo "File '(${ARCHISO_HINT})/boot/grub/grub.cfg' not found!"
|
||||
fi
|
||||
EOF
|
||||
grubembedcfg="${grubembedcfg//'%UUID_SEARCH_FILENAME%'/"${uuid_search_filename}"}"
|
||||
grubembedcfg="${grubembedcfg//'%ARCHISO_SEARCH_FILENAME%'/"${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' \
|
||||
"$(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}" \
|
||||
"${uuid_search_filename}" \
|
||||
"${search_filename}" \
|
||||
"$(printf '%0.1s' "#"{1..1024})")" \
|
||||
> "${work_dir}/grub/grubenv"
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ if [ -z "${ARCHISO_UUID}" ]; then
|
||||
if [ -z "${ARCHISO_HINT}" ]; then
|
||||
regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}"
|
||||
fi
|
||||
search --no-floppy --set=root --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"
|
||||
search --no-floppy --set=root --file '%ARCHISO_SEARCH_FILENAME%' --hint "${ARCHISO_HINT}"
|
||||
probe --set ARCHISO_UUID --fs-uuid "${root}"
|
||||
fi
|
||||
|
||||
|
@ -29,7 +29,7 @@ if [ -z "${ARCHISO_UUID}" ]; then
|
||||
if [ -z "${ARCHISO_HINT}" ]; then
|
||||
regexp --set=1:ARCHISO_HINT '^\(([^)]+)\)' "${cmdpath}"
|
||||
fi
|
||||
search --no-floppy --set=root --file '/.disk/%UUID_SEARCH_FILENAME%.uuid' --hint "${ARCHISO_HINT}"
|
||||
search --no-floppy --set=root --file '%ARCHISO_SEARCH_FILENAME%' --hint "${ARCHISO_HINT}"
|
||||
probe --set ARCHISO_UUID --fs-uuid "${root}"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user