From dc7a7f8e2c77aee8e1404e05a30cbfd6e18d5a94 Mon Sep 17 00:00:00 2001 From: David P Date: Sat, 3 Oct 2020 18:22:23 -0300 Subject: [archiso] Replace bash arithmetic with awk functions Copied from archiso commit 55cfb8ba0 archiso/mkarchiso: The bash arithmethics in _make_boot_uefi-x64.systemd-boot.esp() introduced rounding issues, that can lead to insufficient FAT image size for the files. Conversion functions for awk now replace the bash arithmetics and additionally size up to the next full MiB. Add an info message about the size of the created FAT image. Fixes #70 Signed-off-by: David P --- parabolaiso/mkparabolaiso | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'parabolaiso/mkparabolaiso') diff --git a/parabolaiso/mkparabolaiso b/parabolaiso/mkparabolaiso index 0eb1831..719d703 100755 --- a/parabolaiso/mkparabolaiso +++ b/parabolaiso/mkparabolaiso @@ -555,7 +555,8 @@ _make_boot_uefi-x64.systemd-boot.esp() { _msg_info "Setting up systemd-boot for UEFI booting..." install -d -m 0755 -- "${isofs_dir}/EFI/parabolaiso" - efiboot_imgsize="$(( (( (( $(du --apparent-size -bc \ + # the required image size in KiB (rounded up to the next full MiB with an additional MiB for reserved sectors) + efiboot_imgsize="$(du -bc \ "${airootfs_dir}/usr/lib/systemd/boot/efi/systemd-bootx64.efi" \ "${airootfs_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" \ "${profile}/efiboot/" \ @@ -564,6 +565,7 @@ _make_boot_uefi-x64.systemd-boot.esp() { 2>/dev/null | awk 'END {print $1}') / 1048576 )) +1 )) * 1024 ))" # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html + _msg_info "Creating FAT image of size: ${efiboot_imgsize} KiB..." mkfs.fat -C -n PARABOLAISO_EFI "${isofs_dir}/EFI/parabolaiso/efiboot.img" "$efiboot_imgsize" mmd -i "${isofs_dir}/EFI/parabolaiso/efiboot.img" ::/EFI ::/EFI/BOOT @@ -596,7 +598,8 @@ _make_boot_uefi-x64.refind.esp() { _msg_info "Setting up rEFInd for UEFI booting..." install -d -m 0755 -- "${isofs_dir}/EFI/parabolaiso" - efiboot_imgsize="$(( (( (( $(du --apparent-size -bc \ + # the required image size in KiB (rounded up to the next full MiB with an additional MiB for reserved sectors) + efiboot_imgsize="$(du -bc \ "${airootfs_dir}/usr/share/refind/refind_x64.efi" \ "${airootfs_dir}/usr/share/edk2-shell/x64/Shell_Full.efi" \ "${profile}/efiboot/" \ @@ -605,6 +608,7 @@ _make_boot_uefi-x64.refind.esp() { 2>/dev/null | awk 'END {print $1}') / 1048576 )) +1 )) * 1024 ))" # The FAT image must be created with mkfs.fat not mformat, as some systems have issues with mformat made images: # https://lists.gnu.org/archive/html/grub-devel/2019-04/msg00099.html + _msg_info "Creating FAT image of size: ${efiboot_imgsize} KiB..." mkfs.fat -C -n PARABOLAISO_EFI "${isofs_dir}/EFI/parabolaiso/efiboot.img" "$efiboot_imgsize" mmd -i "${isofs_dir}/EFI/parabolaiso/efiboot.img" ::/EFI ::/EFI/BOOT -- cgit v1.2.2