Enhance Raspberry Pi OS image handling and dashboard UI
Update the API to support streaming and decompressing of golden images in .img.xz and .img.gz formats on the fly. Modify the cloud-init build process to compress images to .img.xz for size reduction. Revise the dashboard templates to set 'desktop' as the default variant for Raspberry Pi OS builds, improving user experience and clarity in options. Update related scripts to ensure compatibility with the new image handling features.
This commit is contained in:
@@ -165,6 +165,21 @@ write_status "finalizing" "Copying image to cloud-init images…" "" ""
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
cp "$IMG_FILE" "$OUT_PATH"
|
||||
|
||||
# Compress to .img.xz to reduce size (deploy supports decompress on the fly)
|
||||
write_status "finalizing" "Compressing image (xz)…" "" ""
|
||||
OUT_XZ="${OUT_PATH}.xz"
|
||||
# -T 0 = use all cores; fallback to -T 1 if old xz
|
||||
if ! xz -T 0 -z -k -f "$OUT_PATH" 2>/dev/null; then
|
||||
xz -T 1 -z -k -f "$OUT_PATH" 2>/dev/null || true
|
||||
fi
|
||||
if [[ -f "$OUT_XZ" ]]; then
|
||||
rm -f "$OUT_PATH"
|
||||
OUT_NAME="${OUT_NAME}.xz"
|
||||
OUT_PATH="$OUT_XZ"
|
||||
else
|
||||
write_status "finalizing" "Compression skipped (xz failed), keeping raw image." "" ""
|
||||
fi
|
||||
|
||||
if [[ "$SET_AS_GOLDEN" == "1" ]]; then
|
||||
rm -f "$GOLDEN_IMAGE"
|
||||
ln -sf "$OUT_PATH" "$GOLDEN_IMAGE"
|
||||
|
||||
@@ -217,7 +217,15 @@ for (( i = 0; i < WAIT_TIMEOUT; i += 2 )); do
|
||||
fi
|
||||
write_status "flashing" "Writing golden image…" "null"
|
||||
log "Flashing $GOLDEN_IMAGE to $target_dev..."
|
||||
if dd if="$GOLDEN_IMAGE" of="$target_dev" bs=4M status=progress conv=fsync; then
|
||||
GOLDEN_RESOLVED="$(readlink -f "$GOLDEN_IMAGE" 2>/dev/null || echo "$GOLDEN_IMAGE")"
|
||||
if [[ "$GOLDEN_RESOLVED" == *.img.xz ]]; then
|
||||
decompress_cmd="xz -d -c"
|
||||
elif [[ "$GOLDEN_RESOLVED" == *.img.gz ]]; then
|
||||
decompress_cmd="gzip -c -d"
|
||||
else
|
||||
decompress_cmd="cat"
|
||||
fi
|
||||
if $decompress_cmd "$GOLDEN_IMAGE" 2>/dev/null | dd of="$target_dev" bs=4M status=progress conv=fsync; then
|
||||
log "Flash complete. Remove eMMC disable jumper and power cycle the reTerminal."
|
||||
write_status "done" "Flash complete. Remove eMMC disable jumper and power cycle the reTerminal." "100"
|
||||
# Auto-reset status to idle after 90s so dashboard does not stay on this message (dashboard also auto-clears after 60s when open)
|
||||
|
||||
Reference in New Issue
Block a user