mkarchiso: place prepared systemd-boot configuration in work directory

Keep the prepared `.conf` files in `work_dir` to avoid having to run
them through `sed` twice.

This makes sure the FAT image size calculation is more correct and also
simplifies copying the files m to both ISO 9660 and the FAT image since
the the whole `loader` directory can copied instead of copying
individual files.
This commit is contained in:
nl6720 2023-12-21 09:33:06 +02:00
parent ebceecbd84
commit 56417cead4
No known key found for this signature in database
GPG key ID: 5CE88535E188D369

View file

@ -851,7 +851,7 @@ _make_common_bootmode_systemd-boot() {
efiboot_files+=("${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi" efiboot_files+=("${pacstrap_dir}/usr/lib/systemd/boot/efi/systemd-bootia32.efi"
"${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi") "${pacstrap_dir}/usr/share/edk2-shell/ia32/Shell_Full.efi")
fi fi
efiboot_files+=("${profile}/efiboot/" efiboot_files+=("${work_dir}/loader/"
"${pacstrap_dir}/boot/vmlinuz-"* "${pacstrap_dir}/boot/vmlinuz-"*
"${pacstrap_dir}/boot/initramfs-"*".img" "${pacstrap_dir}/boot/initramfs-"*".img"
"${_available_ucodes[@]}") "${_available_ucodes[@]}")
@ -860,40 +860,39 @@ _make_common_bootmode_systemd-boot() {
_make_efibootimg "$efiboot_imgsize" _make_efibootimg "$efiboot_imgsize"
} }
_make_common_bootmode_systemd-boot_conf.isofs() { _make_common_bootmode_systemd-boot_conf() {
local _conf local _conf
# Copy systemd-boot configuration files install -d -m 0755 -- "${work_dir}/loader" "${work_dir}/loader/entries"
install -d -m 0755 -- "${isofs_dir}/loader/entries"
install -m 0644 -- "${profile}/efiboot/loader/loader.conf" "${isofs_dir}/loader/" install -m 0644 -- "${profile}/efiboot/loader/loader.conf" "${work_dir}/loader"
for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do for _conf in "${profile}/efiboot/loader/entries/"*".conf"; do
sed "s|%ARCHISO_LABEL%|${iso_label}|g; sed "s|%ARCHISO_LABEL%|${iso_label}|g;
s|%ARCHISO_UUID%|${iso_uuid}|g; s|%ARCHISO_UUID%|${iso_uuid}|g;
s|%INSTALL_DIR%|${install_dir}|g; s|%INSTALL_DIR%|${install_dir}|g;
s|%ARCH%|${arch}|g" \ s|%ARCH%|${arch}|g" \
"${_conf}" >"${isofs_dir}/loader/entries/${_conf##*/}" "${_conf}" >"${work_dir}/loader/entries/${_conf##*/}"
done done
} }
_make_common_bootmode_systemd-boot_conf.esp() { # Copy systemd-boot configuration files to ISO 9660
local _conf _make_common_bootmode_systemd-boot_conf.isofs() {
cp -r --remove-destination -- "${work_dir}/loader" "${isofs_dir}/"
}
# Copy systemd-boot configuration files # Copy systemd-boot configuration files to FAT image
mmd -i "${efibootimg}" ::/loader ::/loader/entries _make_common_bootmode_systemd-boot_conf.esp() {
mcopy -i "${efibootimg}" "${profile}/efiboot/loader/loader.conf" ::/loader/ mcopy -i "${efibootimg}" -s "${work_dir}/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##*/}"
done
} }
# Prepare systemd-boot for booting when written to a disk (isohybrid) # Prepare systemd-boot for booting when written to a disk (isohybrid)
_make_bootmode_uefi-x64.systemd-boot.esp() { _make_bootmode_uefi-x64.systemd-boot.esp() {
_msg_info "Setting up systemd-boot for x64 UEFI booting..." _msg_info "Setting up systemd-boot for x64 UEFI booting..."
# Prepare configuration files
_run_once _make_common_bootmode_systemd-boot_conf
# Prepare a FAT image for the EFI system partition
_run_once _make_common_bootmode_systemd-boot _run_once _make_common_bootmode_systemd-boot
# Copy systemd-boot EFI binary to the default/fallback boot path # Copy systemd-boot EFI binary to the default/fallback boot path
@ -918,6 +917,9 @@ _make_bootmode_uefi-x64.systemd-boot.esp() {
# Prepare systemd-boot for El Torito booting # Prepare systemd-boot for El Torito booting
_make_bootmode_uefi-x64.systemd-boot.eltorito() { _make_bootmode_uefi-x64.systemd-boot.eltorito() {
# Prepare configuration files
_run_once _make_common_bootmode_systemd-boot_conf
# El Torito UEFI boot requires an image containing the EFI system partition. # El Torito UEFI boot requires an image containing the EFI system partition.
# uefi-x64.systemd-boot.eltorito has the same requirements as uefi-x64.systemd-boot.esp # uefi-x64.systemd-boot.eltorito has the same requirements as uefi-x64.systemd-boot.esp
_run_once _make_bootmode_uefi-x64.systemd-boot.esp _run_once _make_bootmode_uefi-x64.systemd-boot.esp
@ -947,6 +949,10 @@ _make_bootmode_uefi-x64.systemd-boot.eltorito() {
_make_bootmode_uefi-ia32.systemd-boot.esp() { _make_bootmode_uefi-ia32.systemd-boot.esp() {
_msg_info "Setting up systemd-boot for IA32 UEFI booting..." _msg_info "Setting up systemd-boot for IA32 UEFI booting..."
# Prepare configuration files
_run_once _make_common_bootmode_systemd-boot_conf
# Prepare a FAT image for the EFI system partition
_run_once _make_common_bootmode_systemd-boot _run_once _make_common_bootmode_systemd-boot
# Copy systemd-boot EFI binary to the default/fallback boot path # Copy systemd-boot EFI binary to the default/fallback boot path
@ -970,6 +976,9 @@ _make_bootmode_uefi-ia32.systemd-boot.esp() {
} }
_make_bootmode_uefi-ia32.systemd-boot.eltorito() { _make_bootmode_uefi-ia32.systemd-boot.eltorito() {
# Prepare configuration files
_run_once _make_common_bootmode_systemd-boot_conf
# El Torito UEFI boot requires an image containing the EFI system partition. # El Torito UEFI boot requires an image containing the EFI system partition.
# uefi-ia32.systemd-boot.eltorito has the same requirements as uefi-ia32.systemd-boot.esp # uefi-ia32.systemd-boot.eltorito has the same requirements as uefi-ia32.systemd-boot.esp
_run_once _make_bootmode_uefi-ia32.systemd-boot.esp _run_once _make_bootmode_uefi-ia32.systemd-boot.esp