feat: replace Alpine mkinitfs with minimal ALARM-compatible initrd
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
48a9c9c956
commit
f0678f1e5b
|
|
@ -1,7 +1,51 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Create a minimal initramfs for the stock H700 kernel.
|
||||||
|
# The stock kernel has most drivers built-in, so we just need
|
||||||
|
# a minimal init that mounts rootfs and exec's /sbin/init.
|
||||||
|
set -e
|
||||||
|
|
||||||
podman run --arch=arm64 --security-opt=label=disable \
|
outdir="${1:-./artifacts}"
|
||||||
-v "${2:-./artifacts}:/artifacts" \
|
tmp="$(mktemp -d)"
|
||||||
-v ./mkinitfs.conf:/tmp/mkinitfs.conf:ro \
|
trap 'rm -rf "$tmp"' 0
|
||||||
--rm "docker.io/library/alpine:${1:-latest}" \
|
|
||||||
sh -c "apk update && apk add mkinitfs apk-tools && mkinitfs -c /tmp/mkinitfs.conf -n -o /artifacts/initramfs"
|
mkdir -p "$tmp"/{bin,dev,proc,sys,newroot}
|
||||||
|
|
||||||
|
# Use busybox from host or build a static one
|
||||||
|
# For now, create a minimal shell init script
|
||||||
|
cat > "$tmp/init" << 'INITEOF'
|
||||||
|
#!/bin/busybox sh
|
||||||
|
/bin/busybox mount -t proc none /proc
|
||||||
|
/bin/busybox mount -t sysfs none /sys
|
||||||
|
/bin/busybox mount -t devtmpfs none /dev
|
||||||
|
|
||||||
|
# Find the root partition (partition 5 = rootfs)
|
||||||
|
root=""
|
||||||
|
for dev in /dev/mmcblk0p5 /dev/mmcblk0p4; do
|
||||||
|
if [ -b "$dev" ]; then
|
||||||
|
root="$dev"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$root" ]; then
|
||||||
|
echo "Cannot find root partition!"
|
||||||
|
/bin/busybox sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
/bin/busybox mount -t ext4 "$root" /newroot
|
||||||
|
exec /bin/busybox switch_root /newroot /sbin/init
|
||||||
|
INITEOF
|
||||||
|
chmod +x "$tmp/init"
|
||||||
|
|
||||||
|
# Get a static busybox for aarch64
|
||||||
|
if [ ! -f "$outdir/busybox" ]; then
|
||||||
|
podman run --arch=aarch64 --security-opt=label=disable \
|
||||||
|
-v "$(realpath "$outdir"):/out" \
|
||||||
|
--rm "docker.io/library/alpine:latest" \
|
||||||
|
sh -c "apk add busybox-static && cp /bin/busybox.static /out/busybox"
|
||||||
|
fi
|
||||||
|
cp "$outdir/busybox" "$tmp/bin/busybox"
|
||||||
|
chmod +x "$tmp/bin/busybox"
|
||||||
|
|
||||||
|
# Create initramfs
|
||||||
|
(cd "$tmp" && find . | cpio -o -H newc 2>/dev/null | gzip > "$outdir/initramfs")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue