Fix ARM64 ISO: mkfs.fat PATH wrapper to guarantee EFI FAT headroom

Replace the fragile Python regex patch (which failed to match the actual
awk variable name in mkarchiso) with a mkfs.fat wrapper script placed
earlier in PATH. The wrapper intercepts every -C (create) invocation and
adds +128 MiB (131072 KiB) to the size argument, ensuring the ~50 MB
ARM64 kernel Image + FAT filesystem overhead fits regardless of which
exact size formula the installed mkarchiso version uses.

Also adds a grep of mkarchiso's size lines to stdout so the formula is
visible in build logs for future debugging.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-07-27 08:12:12 -04:00
1 parent bdfc6008fc
commit e56412ecdd
1 file changed
+26 -25
+26 -25
View File
@@ -657,9 +657,9 @@ echo "=== /usr/lib/modules/ ==="
ls /usr/lib/modules/ 2>&1 || echo "(empty)"
echo "=== end diagnostics ==="
# ALARM aarch64 sometimes installs the kernel as /boot/Image (uncompressed EFI
# stub) rather than /boot/vmlinuz-linux-aarch64. Archiso's vmlinuz glob and
# systemd-boot both expect the vmlinuz-* naming — create a symlink when needed.
# ALARM aarch64 may install the kernel as /boot/Image (uncompressed EFI
# stub) rather than /boot/vmlinuz-linux-aarch64. Archiso's vmlinuz-* glob
# and systemd-boot both expect the vmlinuz-* naming — create a symlink.
if [[ ! -f /boot/vmlinuz-linux-aarch64 ]]; then
if [[ -f /boot/Image ]]; then
ln -sf Image /boot/vmlinuz-linux-aarch64
@@ -729,28 +729,29 @@ echo "OrionOS ARM64 customization complete."
CUSTOMIZE
chmod 755 "$PROFILE/airootfs/root/customize_airootfs.sh"
# ── 13. Patch mkarchiso EFI FAT image size ───────────────────────────
# The ARM64 kernel (Image) is ~50 MB. mkarchiso's default size formula is
# int(total_bytes/1024/1024)+2 MiB, which leaves no room for FAT overhead
# and causes "Disk full". Bump the buffer to +128 MiB.
python3 - <<'PYEOF'
import re, sys
with open('/usr/bin/mkarchiso') as f:
txt = f.read()
orig = txt
# Match: int($1 / 1024 / 1024) + N (with any spacing or small N)
txt = re.sub(
r'int\(\$1\s*/\s*1024\s*/\s*1024\s*\)\s*\+\s*\d+',
r'int($1 / 1024 / 1024) + 128',
txt
)
if txt == orig:
print('mkarchiso: FAT size pattern not found — build may fail with Disk full', file=sys.stderr)
else:
with open('/usr/bin/mkarchiso', 'w') as f:
f.write(txt)
print('mkarchiso: patched EFI FAT size buffer to +128 MiB')
PYEOF
# ── 13. Fix EFI FAT image size for the large ARM64 kernel ────────────
# mkarchiso calculates EFI FAT image size as roughly (kernel+initramfs MiB)+N
# but the ARM64 kernel Image is ~50 MB and FAT filesystem overhead pushes
# the total over the calculated limit → "Disk full".
#
# Strategy: put a mkfs.fat wrapper earlier in PATH that transparently adds
# +128 MiB to every -C (create) call. This works regardless of which exact
# formula the installed mkarchiso version uses.
cat > /usr/local/bin/mkfs.fat <<'MKFAT'
#!/usr/bin/bash
args=("$@")
# When creating (-C) the EFI FAT image, add 128 MiB to the requested size
if [[ " ${args[*]} " == *" -C "* ]] && [[ "${args[-1]}" =~ ^[0-9]+$ ]]; then
args[-1]=$(( ${args[-1]} + 131072 )) # +128 MiB in KiB blocks
fi
exec /usr/bin/mkfs.fat "${args[@]}"
MKFAT
chmod +x /usr/local/bin/mkfs.fat
export PATH="/usr/local/bin:$PATH"
echo ">>> mkfs.fat wrapper active — EFI FAT creation gets +128 MiB headroom"
echo ">>> mkarchiso EFI size lines (for reference):"
grep -n "1024.*1024\|fat.*size\|efi.*size\|img_size" /usr/bin/mkarchiso 2>/dev/null \
| grep -iv "^[0-9]*:#\|comment" | head -8 || true
# ── 14. Build the ISO ─────────────────────────────────────────────────
echo ">>> Building ARM64 ISO (this takes 5-15 minutes)..."