Skip to content

Commit 3f2174c

Browse files
fix(iot): detect ubuntu-server-minimal.squashfs and fallback scan
- Add support for casper/ubuntu-server-minimal.squashfs - Keep existing checks for minimal.squashfs and filesystem.squashfs - Fallback: scan ISO tree (depth-limited) for *.squashfs and prefer *minimal* - Log selection and warn when multiple candidates are found Rationale: Recent Ubuntu ISOs package rootfs as ubuntu-server-minimal.squashfs, which broke the previous hard-coded paths. This makes detection robust across ISO variants. Signed-off-by: Bjordis Collaku <[email protected]>
1 parent 5044543 commit 3f2174c

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

rootfs/scripts/build-ubuntu-rootfs.sh

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,44 @@ image_preproccessing_iot() {
210210
exit 1
211211
fi
212212

213-
# Prefer minimal.squashfs; fallback to filesystem.squashfs
214-
SQUASHFS_PATH=""
215-
if [[ -f "$ISO_EXTRACT_DIR/casper/minimal.squashfs" ]]; then
216-
SQUASHFS_PATH="$ISO_EXTRACT_DIR/casper/minimal.squashfs"
217-
elif [[ -f "$ISO_EXTRACT_DIR/casper/filesystem.squashfs" ]]; then
218-
SQUASHFS_PATH="$ISO_EXTRACT_DIR/casper/filesystem.squashfs"
219-
echo "[WARN][iot][ubuntu] 'minimal.squashfs' not found, using 'filesystem.squashfs'."
220-
else
221-
echo "[ERROR] Neither 'casper/minimal.squashfs' nor 'casper/filesystem.squashfs' found in ISO."
222-
echo " Looked under: $ISO_EXTRACT_DIR/casper/"
213+
# --- Robust squashfs selection ---
214+
local SQUASHFS_PATH=""
215+
for candidate in \
216+
"$ISO_EXTRACT_DIR/casper/ubuntu-server-minimal.squashfs" \
217+
"$ISO_EXTRACT_DIR/casper/minimal.squashfs" \
218+
"$ISO_EXTRACT_DIR/casper/filesystem.squashfs" \
219+
"$ISO_EXTRACT_DIR/ubuntu-server-minimal.squashfs" \
220+
"$ISO_EXTRACT_DIR/minimal.squashfs" \
221+
"$ISO_EXTRACT_DIR/filesystem.squashfs"
222+
do
223+
if [[ -f "$candidate" ]]; then
224+
SQUASHFS_PATH="$candidate"
225+
break
226+
fi
227+
done
228+
if [[ -z "$SQUASHFS_PATH" ]]; then
229+
mapfile -t found_squashfs < <(find "$ISO_EXTRACT_DIR" -maxdepth 3 -type f -name '*.squashfs' 2>/dev/null | sort)
230+
if (( ${#found_squashfs[@]} == 1 )); then
231+
SQUASHFS_PATH="${found_squashfs[0]}"
232+
elif (( ${#found_squashfs[@]} > 1 )); then
233+
for f in "${found_squashfs[@]}"; do
234+
if [[ "$f" =~ minimal\.squashfs$ ]]; then
235+
SQUASHFS_PATH="$f"
236+
break
237+
fi
238+
done
239+
[[ -z "$SQUASHFS_PATH" ]] && SQUASHFS_PATH="${found_squashfs[0]}"
240+
echo "[WARN][iot][ubuntu] Multiple squashfs files found:"
241+
printf ' - %s\n' "${found_squashfs[@]}"
242+
echo " Selected: $SQUASHFS_PATH"
243+
fi
244+
fi
245+
if [[ -z "$SQUASHFS_PATH" ]]; then
246+
echo "[ERROR] No squashfs image found in ISO after scanning."
247+
echo " Looked under: $ISO_EXTRACT_DIR (depth 3)"
223248
exit 1
224249
fi
250+
echo "[INFO][iot][ubuntu] Using squashfs: $SQUASHFS_PATH"
225251

226252
echo "[INFO][iot][ubuntu] Unsquashing rootfs from: $SQUASHFS_PATH"
227253
if ! unsquashfs -d "$SQUASHFS_WORK_DIR" "$SQUASHFS_PATH" >/dev/null; then

0 commit comments

Comments
 (0)