fix: disk image build, piCore64 URL, license
Some checks failed
CI / Go Tests (push) Has been cancelled
CI / Build Go Binaries (amd64, linux, linux-amd64) (push) Has been cancelled
CI / Build Go Binaries (arm64, linux, linux-arm64) (push) Has been cancelled
CI / Shellcheck (push) Has been cancelled
Release / Test (push) Has been cancelled
Release / Build Binaries (amd64, linux, linux-amd64) (push) Has been cancelled
Release / Build Binaries (arm64, linux, linux-arm64) (push) Has been cancelled
Release / Build ISO (amd64) (push) Has been cancelled
Release / Create Release (push) Has been cancelled
Some checks failed
CI / Go Tests (push) Has been cancelled
CI / Build Go Binaries (amd64, linux, linux-amd64) (push) Has been cancelled
CI / Build Go Binaries (arm64, linux, linux-arm64) (push) Has been cancelled
CI / Shellcheck (push) Has been cancelled
Release / Test (push) Has been cancelled
Release / Build Binaries (amd64, linux, linux-amd64) (push) Has been cancelled
Release / Build Binaries (arm64, linux, linux-arm64) (push) Has been cancelled
Release / Build ISO (amd64) (push) Has been cancelled
Release / Create Release (push) Has been cancelled
- Add kpartx for reliable loop partition mapping in Docker containers - Fix piCore64 download URL (changed from .img.gz to .zip format) - Fix piCore64 boot partition mount (initramfs on p1, not p2) - Fix tar --wildcards for RPi firmware extraction - Add MIT license (same as KubeSolo) - Add kpartx and unzip to Docker builder image Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,23 +29,40 @@ if [ "$EXTRACT_ARCH" = "arm64" ]; then
|
||||
|
||||
echo "==> Extracting piCore64 image: $PICORE_IMG"
|
||||
|
||||
# Decompress .img.gz to raw image
|
||||
# Decompress to raw image (.img.gz or .zip)
|
||||
PICORE_RAW="$CACHE_DIR/piCore-${PICORE_VERSION}.img"
|
||||
if [ ! -f "$PICORE_RAW" ]; then
|
||||
echo " Decompressing..."
|
||||
gunzip -k "$PICORE_IMG" 2>/dev/null || \
|
||||
zcat "$PICORE_IMG" > "$PICORE_RAW"
|
||||
case "$PICORE_IMG" in
|
||||
*.zip)
|
||||
unzip -o -j "$PICORE_IMG" '*.img' -d "$CACHE_DIR" 2>/dev/null || \
|
||||
unzip -o "$PICORE_IMG" -d "$CACHE_DIR"
|
||||
# Find the extracted .img file
|
||||
EXTRACTED_IMG=$(find "$CACHE_DIR" -maxdepth 1 -name '*.img' -newer "$PICORE_IMG" | head -1)
|
||||
if [ -n "$EXTRACTED_IMG" ] && [ "$EXTRACTED_IMG" != "$PICORE_RAW" ]; then
|
||||
mv "$EXTRACTED_IMG" "$PICORE_RAW"
|
||||
fi
|
||||
;;
|
||||
*.img.gz)
|
||||
gunzip -k "$PICORE_IMG" 2>/dev/null || \
|
||||
zcat "$PICORE_IMG" > "$PICORE_RAW"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown piCore image format: $PICORE_IMG"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Mount the piCore rootfs partition (partition 2 in the SD image)
|
||||
# Use losetup to find the partition offset
|
||||
# Mount the piCore boot partition (partition 1) to find kernel/initramfs
|
||||
# piCore layout: p1=boot (FAT32, has kernel+initramfs), p2=rootfs (ext4, has tce/)
|
||||
IMG_MNT=$(mktemp -d)
|
||||
echo " Mounting piCore rootfs partition..."
|
||||
echo " Mounting piCore boot partition..."
|
||||
|
||||
# Get partition 2 offset (piCore layout: boot=p1, rootfs=p2)
|
||||
OFFSET=$(fdisk -l "$PICORE_RAW" 2>/dev/null | awk '/^.*img2/{print $2}')
|
||||
# Get partition 1 offset (boot/FAT partition with kernel+initramfs)
|
||||
OFFSET=$(fdisk -l "$PICORE_RAW" 2>/dev/null | awk '/^.*img1/{print $2}')
|
||||
if [ -z "$OFFSET" ]; then
|
||||
# Fallback: try sfdisk
|
||||
# Fallback: try sfdisk (first partition)
|
||||
OFFSET=$(sfdisk -d "$PICORE_RAW" 2>/dev/null | awk -F'[=,]' '/start=/{print $2; exit}' | tr -d ' ')
|
||||
fi
|
||||
if [ -z "$OFFSET" ]; then
|
||||
@@ -56,13 +73,13 @@ if [ "$EXTRACT_ARCH" = "arm64" ]; then
|
||||
|
||||
BYTE_OFFSET=$((OFFSET * 512))
|
||||
mount -o loop,ro,offset="$BYTE_OFFSET" "$PICORE_RAW" "$IMG_MNT" || {
|
||||
echo "ERROR: Failed to mount piCore rootfs (need root for losetup)"
|
||||
echo "ERROR: Failed to mount piCore boot partition (need root for losetup)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Find initramfs in the piCore rootfs
|
||||
# Find initramfs in the piCore boot partition
|
||||
COREGZ=""
|
||||
for f in "$IMG_MNT"/boot/corepure64.gz "$IMG_MNT"/boot/core.gz "$IMG_MNT"/*.gz; do
|
||||
for f in "$IMG_MNT"/rootfs-piCore64*.gz "$IMG_MNT"/boot/corepure64.gz "$IMG_MNT"/boot/core.gz "$IMG_MNT"/corepure64.gz "$IMG_MNT"/core.gz; do
|
||||
[ -f "$f" ] && COREGZ="$f" && break
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user