Skip to content

Commit 94fa7ea

Browse files
committed
.github: drop rootfs.squashfs from release tarballs
Release tarballs waste ~131MB per architecture by including both rootfs.itb and rootfs.squashfs, even though rootfs.itb already contains the squashfs (itb = 4096-byte header + squashfs). This change removes rootfs.squashfs from releases and provides two solutions for users who need it: 1. utils/extract-squashfs.sh - Full-featured utility for extracting squashfs from release tarballs or .itb files. Includes validation and helpful error messages. 2. board/common/qemu/qemu.sh - Auto-extraction support. When running in initrd mode, automatically extracts rootfs.squashfs from rootfs.itb if missing. Zero user impact - ./qemu.sh just works! Space savings: ~262MB per release (2 architectures × 131MB) Fixes #858 Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 7a6b1ea commit 94fa7ea

File tree

3 files changed

+134
-0
lines changed

3 files changed

+134
-0
lines changed

.github/workflows/build-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ jobs:
100100
mv cpe.json images/sbom/
101101
mv legal-info/*.csv images/sbom/
102102
103+
# Remove rootfs.squashfs from release (can be extracted from rootfs.itb)
104+
# Saves ~131MB per architecture. See issue #858
105+
rm -f images/rootfs.squashfs
106+
103107
mv images ${{ steps.vars.outputs.dir }}
104108
ln -s ${{ steps.vars.outputs.dir }} images
105109
tar cfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}

board/common/qemu/qemu.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,35 @@ gdb_args()
313313
echo -n "-gdb chardev:gdbqemu"
314314
}
315315

316+
extract_squashfs()
317+
{
318+
# Extract rootfs.squashfs from rootfs.itb if missing
319+
# The .itb file is rootfs.itbh (4096 bytes) + rootfs.squashfs
320+
input="${1:-rootfs.itb}"
321+
output="${2:-rootfs.squashfs}"
322+
323+
[ -f "$input" ] || die "Cannot extract $output: $input not found"
324+
325+
echo "Extracting $output from $input (skipping 4096-byte FIT header)..."
326+
dd if="$input" of="$output" bs=4096 skip=1 2>/dev/null \
327+
|| die "Failed to extract $output from $input"
328+
329+
echo "Successfully created $output"
330+
}
331+
316332
run_qemu()
317333
{
334+
# Auto-extract rootfs.squashfs from rootfs.itb if needed for initrd mode
335+
if [ "$CONFIG_QEMU_ROOTFS_INITRD" = "y" ]; then
336+
if [ "$CONFIG_QEMU_ROOTFS" = "rootfs.squashfs" ] && [ ! -f "rootfs.squashfs" ]; then
337+
if [ -f "rootfs.itb" ]; then
338+
extract_squashfs "rootfs.itb" "rootfs.squashfs"
339+
else
340+
die "Missing rootfs.squashfs and cannot find rootfs.itb to extract it from"
341+
fi
342+
fi
343+
fi
344+
318345
if [ "$CONFIG_QEMU_ROOTFS_VSCSI" = "y" ]; then
319346
if ! qemu-img check "qemu.qcow2"; then
320347
rm -f "qemu.qcow2"

utils/extract-squashfs.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/sh
2+
#
3+
# Extract rootfs.squashfs from a release tarball's rootfs.itb file
4+
#
5+
# Usage: extract-squashfs.sh <tarball-or-itb-file> [output-file]
6+
#
7+
8+
set -e
9+
10+
usage() {
11+
cat <<EOF
12+
Usage: $(basename "$0") <tarball-or-itb-file> [output-file]
13+
14+
Extract rootfs.squashfs from a release tarball or .itb file.
15+
16+
Arguments:
17+
<tarball-or-itb-file> Release tarball (*.tar.gz) or rootfs.itb file
18+
[output-file] Output squashfs file (default: rootfs.squashfs)
19+
20+
Examples:
21+
# From release tarball
22+
$(basename "$0") infix-x86_64-25.09.0.tar.gz
23+
24+
# From .itb file directly
25+
$(basename "$0") output/images/rootfs.itb
26+
27+
# Custom output location
28+
$(basename "$0") infix-x86_64-25.09.0.tar.gz /tmp/my-rootfs.squashfs
29+
30+
The script skips the 4096-byte FIT header to extract the SquashFS image.
31+
EOF
32+
}
33+
34+
die() {
35+
echo "ERROR: $*" >&2
36+
exit 1
37+
}
38+
39+
# Parse arguments
40+
case "$1" in
41+
-h|--help)
42+
usage
43+
exit 0
44+
;;
45+
"")
46+
usage
47+
exit 1
48+
;;
49+
esac
50+
51+
input="$1"
52+
output="${2:-rootfs.squashfs}"
53+
54+
[ -f "$input" ] || die "File not found: $input"
55+
56+
# Detect if input is a tarball or .itb file
57+
case "$input" in
58+
*.tar.gz)
59+
echo "Extracting rootfs.itb from tarball..."
60+
itb_file=$(tar -tzf "$input" | grep -m1 'rootfs\.itb$') \
61+
|| die "No rootfs.itb found in tarball"
62+
63+
echo "Found: $itb_file"
64+
echo "Extracting SquashFS (skipping 4096-byte FIT header)..."
65+
66+
tar -xzOf "$input" "$itb_file" | dd bs=4096 skip=1 of="$output" 2>/dev/null \
67+
|| die "Failed to extract SquashFS"
68+
;;
69+
*.itb)
70+
echo "Extracting SquashFS from .itb file (skipping 4096-byte FIT header)..."
71+
dd if="$input" of="$output" bs=4096 skip=1 2>/dev/null \
72+
|| die "Failed to extract SquashFS"
73+
;;
74+
*)
75+
die "Unsupported file type. Expected *.tar.gz or *.itb"
76+
;;
77+
esac
78+
79+
# Verify output
80+
if [ -f "$output" ]; then
81+
size=$(stat --format=%s "$output" 2>/dev/null || stat -f%z "$output")
82+
file_type=$(file "$output")
83+
84+
# Try to format size nicely, fall back to bytes if numfmt not available
85+
if command -v numfmt >/dev/null 2>&1; then
86+
size_str=$(numfmt --to=iec-i --suffix=B "$size")
87+
else
88+
size_str="$size bytes"
89+
fi
90+
91+
echo "Success! Created: $output ($size_str)"
92+
echo "Type: $file_type"
93+
94+
# Quick sanity check for squashfs magic
95+
if echo "$file_type" | grep -qi squashfs; then
96+
echo "✓ Verified: Valid SquashFS filesystem"
97+
else
98+
echo "⚠ Warning: Output may not be a valid SquashFS image"
99+
exit 1
100+
fi
101+
else
102+
die "Failed to create output file"
103+
fi

0 commit comments

Comments
 (0)