Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archiso
diff options
context:
space:
mode:
authorDavid Runge <dvzrv@archlinux.org>2020-10-03 19:58:41 +0200
committerDavid Runge <dvzrv@archlinux.org>2020-10-03 22:55:31 +0200
commit55cfb8ba021266d754eb21fb22c666f9f7a49442 (patch)
tree87004e00e1a4c6ea9115cd8e47bd85c322719ce0 /archiso
parent2e1ddec0a796188097bae05117973c60da81ab51 (diff)
Replace bash arithmetic with awk functions
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 a ceil() function rounds the calculated size up to the next full MiB. Add an info message about the size of the created FAT image. Fixes #70
Diffstat (limited to 'archiso')
-rwxr-xr-xarchiso/mkarchiso10
1 files changed, 8 insertions, 2 deletions
diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index 01eb536..ed932d9 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -544,16 +544,22 @@ _make_boot_uefi-x64.systemd-boot.esp() {
_msg_info "Setting up systemd-boot for UEFI booting..."
install -d -m 0755 -- "${isofs_dir}/EFI/archiso"
- 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/" \
"${airootfs_dir}/boot/vmlinuz-"* \
"${airootfs_dir}/boot/initramfs-"*".img" \
"${airootfs_dir}/boot/"{intel-uc.img,intel-ucode.img,amd-uc.img,amd-ucode.img,early_ucode.cpio,microcode.cpio} \
- 2>/dev/null | awk 'END {print $1}') / 1048576 )) +1 )) * 1024 ))"
+ 2>/dev/null | awk 'function ceil(x){return int(x)+(x>int(x))}
+ function byte_to_kib(x){return x/1024}
+ function mib_to_kib(x){return x*1024}
+ END {print mib_to_kib(ceil((byte_to_kib($1)+1024)/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 ARCHISO_EFI "${isofs_dir}/EFI/archiso/efiboot.img" "$efiboot_imgsize"
mmd -i "${isofs_dir}/EFI/archiso/efiboot.img" ::/EFI ::/EFI/BOOT