Update bootc-image-builder script and add test script
Some checks failed
particle-os CI / Test particle-os (push) Failing after 1s
particle-os CI / Integration Test (push) Has been skipped
particle-os CI / Security & Quality (push) Failing after 1s
Tests / test (1.21.x) (push) Failing after 1s
Tests / test (1.22.x) (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
Some checks failed
particle-os CI / Test particle-os (push) Failing after 1s
particle-os CI / Integration Test (push) Has been skipped
particle-os CI / Security & Quality (push) Failing after 1s
Tests / test (1.21.x) (push) Failing after 1s
Tests / test (1.22.x) (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
This commit is contained in:
parent
2ecde247d3
commit
65302755dd
2 changed files with 138 additions and 18 deletions
|
|
@ -133,15 +133,12 @@ log_info "Container image: $CONTAINER_IMAGE"
|
|||
log_info "Output format: $OUTPUT_FORMAT"
|
||||
log_info "Output directory: $OUTPUT_DIR"
|
||||
|
||||
# Create temporary working directory
|
||||
# Use /var/tmp or /home instead of /tmp to avoid tmpfs space limitations
|
||||
WORK_DIR=$(mktemp -d /var/tmp/bootc-builder-XXXXXX 2>/dev/null || mktemp -d /home/joe/tmp/bootc-builder-XXXXXX 2>/dev/null || echo "/home/joe/tmp/bootc-builder-$$")
|
||||
if [[ ! -d "$WORK_DIR" ]]; then
|
||||
mkdir -p "$WORK_DIR" || {
|
||||
log_error "Failed to create working directory"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
# Create working directory in project directory
|
||||
WORK_DIR="$(pwd)/work/bootc-builder-$(date +%s)"
|
||||
mkdir -p "$WORK_DIR" || {
|
||||
log_error "Failed to create working directory"
|
||||
exit 1
|
||||
}
|
||||
log_info "Working directory: $WORK_DIR"
|
||||
|
||||
# Check available space
|
||||
|
|
@ -176,7 +173,7 @@ cleanup_on_exit() {
|
|||
for loop_dev in /dev/loop*; do
|
||||
if [[ -b "$loop_dev" ]]; then
|
||||
local mount_point
|
||||
mount_point=$(losetup -l "$loop_dev" 2>/dev/null | grep -o "/var/tmp/bootc-builder-[^[:space:]]*" || true)
|
||||
mount_point=$(losetup -l "$loop_dev" 2>/dev/null | grep -o ".*/work/bootc-builder-[^[:space:]]*" || true)
|
||||
if [[ -n "$mount_point" ]]; then
|
||||
log_info "Detaching orphaned loop device $loop_dev..."
|
||||
sudo losetup -d "$loop_dev" 2>/dev/null || true
|
||||
|
|
@ -215,7 +212,7 @@ cleanup_existing_loop_devices() {
|
|||
for loop_dev in /dev/loop*; do
|
||||
if [[ -b "$loop_dev" ]]; then
|
||||
local mount_point
|
||||
mount_point=$(losetup -l "$loop_dev" 2>/dev/null | grep -o "/var/tmp/bootc-builder-[^[:space:]]*" || true)
|
||||
mount_point=$(losetup -l "$loop_dev" 2>/dev/null | grep -o ".*/work/bootc-builder-[^[:space:]]*" || true)
|
||||
if [[ -n "$mount_point" ]]; then
|
||||
log_warn "Found existing loop device $loop_dev from previous run, cleaning up..."
|
||||
# Try to unmount if mounted
|
||||
|
|
@ -277,7 +274,7 @@ fi
|
|||
|
||||
# Create disk image using qemu-img (no sudo required)
|
||||
log_info "Creating disk image..."
|
||||
IMAGE_SIZE="2G" # Default size, could be made configurable
|
||||
IMAGE_SIZE="8G" # Increased size for enhanced simple-cli with Bazzite features
|
||||
|
||||
# Create a proper disk image with partitions for bootloader installation
|
||||
log_info "Creating partitioned disk image for bootloader installation..."
|
||||
|
|
@ -363,22 +360,40 @@ if [[ -x "$GRUB_INSTALL" ]]; then
|
|||
# Generate GRUB configuration manually since grub-mkconfig needs host environment
|
||||
log_info "Generating GRUB configuration manually..."
|
||||
|
||||
# Find the actual kernel and initrd files in the container
|
||||
KERNEL_FILE=$(find "$MOUNT_POINT/boot" -name "vmlinuz-*" | head -1)
|
||||
INITRD_FILE=$(find "$MOUNT_POINT/boot" -name "initrd.img-*" | head -1)
|
||||
|
||||
if [[ -z "$KERNEL_FILE" ]] || [[ -z "$INITRD_FILE" ]]; then
|
||||
log_error "Kernel or initrd not found in container"
|
||||
log_error "Available files in /boot:"
|
||||
ls -la "$MOUNT_POINT/boot/" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract just the filename without the full path
|
||||
KERNEL_NAME=$(basename "$KERNEL_FILE")
|
||||
INITRD_NAME=$(basename "$INITRD_FILE")
|
||||
|
||||
log_info "Found kernel: $KERNEL_NAME"
|
||||
log_info "Found initrd: $INITRD_NAME"
|
||||
|
||||
# Create a basic GRUB configuration for the container
|
||||
cat > "$MOUNT_POINT/boot/grub/grub.cfg" << 'EOF'
|
||||
cat > "$MOUNT_POINT/boot/grub/grub.cfg" << EOF
|
||||
# GRUB configuration for simple-cli container
|
||||
set timeout=5
|
||||
set timeout=1
|
||||
set default=0
|
||||
|
||||
menuentry "Simple CLI" {
|
||||
set root=(hd0,msdos1)
|
||||
linux /boot/vmlinuz-6.12.38+deb13-amd64 root=/dev/sda1 rw console=ttyS0
|
||||
initrd /boot/initrd.img-6.12.38+deb13-amd64
|
||||
linux /boot/$KERNEL_NAME root=/dev/sda1 rw console=ttyS0 quiet splash fastboot
|
||||
initrd /boot/$INITRD_NAME
|
||||
}
|
||||
|
||||
menuentry "Simple CLI (Recovery)" {
|
||||
set root=(hd0,msdos1)
|
||||
linux /boot/vmlinuz-6.12.38+deb13-amd64 root=/dev/sda1 rw single console=ttyS0
|
||||
initrd /boot/initrd.img-6.12.38+deb13-amd64
|
||||
linux /boot/$KERNEL_NAME root=/dev/sda1 rw single console=ttyS0
|
||||
initrd /boot/$INITRD_NAME
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue