#!/bin/bash # Verify an RFS flist (.fl) by inspecting, listing tree, and optional mount test. # Usage: # ./scripts/rfs/verify-flist.sh /path/to/foo.fl # ./scripts/rfs/verify-flist.sh /path/to/foo.fl --mount # # Notes: # - Requires the rfs binary (PATH or components fallback). # - --mount performs a temporary mount (needs FUSE and privileges). set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=/dev/null source "${HERE}/common.sh" section() { echo -e "\n==== $* ====\n"; } if [[ $# -lt 1 ]]; then echo "Usage: $0 /path/to/foo.fl [--mount]" exit 1 fi FL_PATH="$1" DO_MOUNT="${2:-}" if [[ ! -f "$FL_PATH" ]]; then echo "[ERROR] flist not found: ${FL_PATH}" >&2 exit 1 fi section "Locating rfs binary" rfs_common_locate_rfs section "Inspect flist" safe_execute "${RFS_BIN}" flist inspect "${FL_PATH}" || true section "Tree (first 100 entries)" safe_execute "${RFS_BIN}" flist tree "${FL_PATH}" | head -n 100 || true if [[ "$DO_MOUNT" == "--mount" ]]; then section "Attempting temporary mount" MNT="$(mktemp -d /tmp/rfs-mnt-XXXXXX)" cleanup() { set +e if mountpoint -q "${MNT}" 2>/dev/null; then echo "[INFO] Unmounting ${MNT}" fusermount -u "${MNT}" 2>/dev/null || umount "${MNT}" 2>/dev/null || true fi rmdir "${MNT}" 2>/dev/null || true } trap cleanup EXIT INT TERM echo "[INFO] Mountpoint: ${MNT}" # Try mount; some environments require sudo or have limited FUSE. Best-effort. if "${RFS_BIN}" mount -m "${FL_PATH}" "${MNT}"; then echo "[INFO] Mounted. Listing top-level entries:" ls -la "${MNT}" | head -n 50 || true else echo "[WARN] rfs mount failed (FUSE/permissions?). Skipping mount verification." >&2 fi fi section "Done" echo "[INFO] Verified flist: ${FL_PATH}"