fix: make dev-vm.sh work on Linux with fallback ISO extraction methods
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
- Try bsdtar first (macOS + Linux with libarchive-tools) - Fall back to isoinfo (genisoimage/cdrtools) - Fall back to loop mount (Linux only, requires root) - Platform-aware error messages for e2fsprogs install Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -66,7 +66,12 @@ if [ -n "$MKFS_EXT4" ]; then
|
||||
echo " Data disk: 2 GB ext4 (persistent)"
|
||||
else
|
||||
echo "ERROR: mkfs.ext4 not found. Install e2fsprogs:"
|
||||
echo " brew install e2fsprogs"
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
echo " brew install e2fsprogs"
|
||||
else
|
||||
echo " apt install e2fsprogs # Debian/Ubuntu"
|
||||
echo " dnf install e2fsprogs # Fedora/RHEL"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -109,27 +114,65 @@ case "$IMAGE" in
|
||||
INITRAMFS="$ROOTFS_DIR/kubesolo-os.gz"
|
||||
echo " Using kernel/initramfs from build directory"
|
||||
else
|
||||
# Extract from ISO using bsdtar (works on macOS + Linux, no mount needed)
|
||||
# Extract kernel + initramfs from ISO.
|
||||
# Try multiple methods: bsdtar > isoinfo > loop mount
|
||||
EXTRACT_DIR="$(mktemp -d /tmp/kubesolo-extract-XXXXXX)"
|
||||
EXTRACTED=0
|
||||
|
||||
echo " Extracting kernel/initramfs from ISO..."
|
||||
bsdtar -xf "$IMAGE" -C "$EXTRACT_DIR" boot/vmlinuz boot/kubesolo-os.gz 2>/dev/null || {
|
||||
|
||||
# Method 1: bsdtar (ships with macOS, libarchive-tools on Linux)
|
||||
if [ $EXTRACTED -eq 0 ] && command -v bsdtar >/dev/null 2>&1; then
|
||||
if bsdtar -xf "$IMAGE" -C "$EXTRACT_DIR" boot/vmlinuz boot/kubesolo-os.gz 2>/dev/null; then
|
||||
echo " Extracted via bsdtar"
|
||||
EXTRACTED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 2: isoinfo (genisoimage/cdrtools on Linux)
|
||||
if [ $EXTRACTED -eq 0 ] && command -v isoinfo >/dev/null 2>&1; then
|
||||
mkdir -p "$EXTRACT_DIR/boot"
|
||||
isoinfo -i "$IMAGE" -x "/BOOT/VMLINUZ;1" > "$EXTRACT_DIR/boot/vmlinuz" 2>/dev/null || true
|
||||
isoinfo -i "$IMAGE" -x "/BOOT/KUBESOLO-OS.GZ;1" > "$EXTRACT_DIR/boot/kubesolo-os.gz" 2>/dev/null || true
|
||||
# isoinfo writes empty files on failure; check size
|
||||
if [ -s "$EXTRACT_DIR/boot/vmlinuz" ] && [ -s "$EXTRACT_DIR/boot/kubesolo-os.gz" ]; then
|
||||
echo " Extracted via isoinfo"
|
||||
EXTRACTED=1
|
||||
else
|
||||
rm -f "$EXTRACT_DIR/boot/vmlinuz" "$EXTRACT_DIR/boot/kubesolo-os.gz"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Method 3: loop mount (Linux only, requires root)
|
||||
if [ $EXTRACTED -eq 0 ] && [ "$(uname)" = "Linux" ]; then
|
||||
ISO_MOUNT="$EXTRACT_DIR/mnt"
|
||||
mkdir -p "$ISO_MOUNT"
|
||||
if mount -o loop,ro "$IMAGE" "$ISO_MOUNT" 2>/dev/null; then
|
||||
mkdir -p "$EXTRACT_DIR/boot"
|
||||
cp "$ISO_MOUNT/boot/vmlinuz" "$EXTRACT_DIR/boot/" 2>/dev/null || true
|
||||
cp "$ISO_MOUNT/boot/kubesolo-os.gz" "$EXTRACT_DIR/boot/" 2>/dev/null || true
|
||||
umount "$ISO_MOUNT" 2>/dev/null || true
|
||||
if [ -f "$EXTRACT_DIR/boot/vmlinuz" ] && [ -f "$EXTRACT_DIR/boot/kubesolo-os.gz" ]; then
|
||||
echo " Extracted via loop mount"
|
||||
EXTRACTED=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $EXTRACTED -eq 0 ]; then
|
||||
echo "ERROR: Failed to extract kernel/initramfs from ISO."
|
||||
echo " Ensure bsdtar is available (ships with macOS, install libarchive on Linux)."
|
||||
echo " Install one of: bsdtar (libarchive-tools), isoinfo (genisoimage), or run as root for loop mount."
|
||||
echo " Or run 'make rootfs initramfs' to produce build artifacts."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
VMLINUZ="$EXTRACT_DIR/boot/vmlinuz"
|
||||
INITRAMFS="$EXTRACT_DIR/boot/kubesolo-os.gz"
|
||||
|
||||
if [ ! -f "$VMLINUZ" ] || [ ! -f "$INITRAMFS" ]; then
|
||||
echo "ERROR: ISO does not contain expected boot/vmlinuz and boot/kubesolo-os.gz"
|
||||
echo " ISO contents:"
|
||||
bsdtar -tf "$IMAGE" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
echo " Extracted kernel/initramfs from ISO"
|
||||
fi
|
||||
|
||||
qemu-system-x86_64 \
|
||||
|
||||
Reference in New Issue
Block a user