initramfs to also use merge-rootfs

This commit is contained in:
2026-03-24 23:58:33 +08:00
parent aad4edd194
commit ec8ceb1690
9 changed files with 167 additions and 26 deletions

View File

@@ -0,0 +1,67 @@
#!/bin/sh
set -eu
MNT=/mnt
USB_DEV=/dev/sda
EMMC_DEV=/dev/mmcblk0
DEFAULT_GLOB="${MNT}/$${BUILD_TAG}_RELEASE_IMAGE"
mkdir -p "$MNT"
echo "[*] Mounting USB..."
mount "$USB_DEV" "$MNT"
# Find a default image (first match)
DEFAULT_IMG="$(ls $DEFAULT_GLOB 2>/dev/null | head -n1 || true)"
echo
if [ -n "$DEFAULT_IMG" ]; then
echo "Default image found:"
echo " $DEFAULT_IMG"
else
echo "No default image found under $DEFAULT_GLOB"
fi
echo
# Prompt user
printf "Image Location (%s): " "${DEFAULT_IMG:-/mnt/...}"
read -r IMG
# Use default if empty
if [ -z "$IMG" ]; then
IMG="$DEFAULT_IMG"
fi
# Validate
if [ -z "$IMG" ] || [ ! -f "$IMG" ]; then
echo "Invalid image: $IMG"
umount "$MNT" || true
exit 1
fi
echo
echo "About to write:"
echo " Image: $IMG"
echo " Target: $EMMC_DEV"
echo
printf "Type 'YES' to continue: "
read -r CONFIRM
if [ "$CONFIRM" != "YES" ]; then
echo "Aborted."
umount "$MNT" || true
exit 1
fi
echo "[*] Flashing..."
gunzip -c "$IMG" > "$EMMC_DEV"
echo "[*] Syncing..."
sync
echo "[*] Done."
umount "$MNT" || true
echo "[*] Rebooting..."
reboot -f