diff --git a/debian/changelog b/debian/changelog index ebc2f625..11b79973 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +debian-cd (3.1.19) UNRELEASED; urgency=medium + + [ Steve McIntyre ] + * Also fix size calculation for EFI image for arm64 + + -- Steve McIntyre <93sam@debian.org> Fri, 06 May 2016 22:59:32 +0100 + debian-cd (3.1.18) unstable; urgency=medium [ Steve McIntyre ] diff --git a/tools/boot/stretch/boot-arm64 b/tools/boot/stretch/boot-arm64 index fd736abf..ac36c8b0 100755 --- a/tools/boot/stretch/boot-arm64 +++ b/tools/boot/stretch/boot-arm64 @@ -93,12 +93,39 @@ if [ -d boot$N/grub ] ; then # This is the same as in efi-image, but we need to redo it here in # the case of a multi-arch image - size=0 - for file in $CDDIR/efi/boot/boot*.efi; do - size=$(($size + $(stat -c %s "$file"))) - done + # Stuff the EFI boot files into a FAT filesystem, making it as + # small as possible. - blocks=$((($size / 1024 + 55) / 32 * 32 )) + sector_bytes=512 # -S + cluster_sectors=4 # -s + cluster_bytes=$((sector_bytes * cluster_sectors)) + + clusters=2 # 1 cluster for each sub-directory + for file in $CDDIR/efi/boot/boot*.efi; do + [ -f "$file" ] || continue + clusters=$(($clusters + (($(stat -c %s "$file") + $cluster_bytes - 1) / $cluster_bytes))) + done + reserved_sectors=1 # boot-sector -R + reserved_bytes=$(($reserved_sectors * $sector_bytes)) + fat_copies=2 # -f + if [ "$clusters" -le $(((1 << 12) - 2)) ]; then + fat_entry_bytes=3/2 # -F + elif [ "$clusters" -le $(((1 << 16) - 2)) ]; then + fat_entry_bytes=2 # -F + else + fat_entry_bytes=4 # -F + fi + fat_bytes=$((($clusters * $fat_entry_bytes + $sector_bytes - 1) / $sector_bytes * $sector_bytes)) + root_entries=512 # -r + root_entry_bytes=32 + root_bytes=$(($root_entries * root_entry_bytes)) + size=$(($reserved_bytes + $fat_copies * $fat_bytes + $root_bytes + $clusters * $cluster_bytes)) + + track_sectors=32 + track_bytes=$((sector_bytes * $track_sectors)) + tracks=$((($size + $track_bytes - 1) / $track_bytes)) + block_bytes=1024 + blocks=$(($tracks * $track_bytes / $block_bytes)) rm -f $CDDIR/boot/grub/efi.img mkfs.msdos -C "$CDDIR/boot/grub/efi.img" $blocks >/dev/null