Improve RPi image scripts

- flash-image.sh: Add optional device argument to bypass auto-detection
- flash-image.sh/pull-image.sh: Remove bc dependency, use bash integer math
- sanitize-for-image.sh: Add better debugging and verification for wizard setup

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-01-03 03:16:01 -05:00
parent 45b99d2c5e
commit 0d7b5a14cb
3 changed files with 119 additions and 86 deletions

View File

@@ -76,19 +76,12 @@ while IFS= read -r line; do
continue
fi
# Parse size to bytes for comparison
SIZE_NUM=$(echo "$SIZE" | sed 's/[^0-9.]//g')
SIZE_UNIT=$(echo "$SIZE" | sed 's/[0-9.]//g')
case $SIZE_UNIT in
G) SIZE_GB=$SIZE_NUM ;;
T) SIZE_GB=$(echo "$SIZE_NUM * 1024" | bc) ;;
M) SIZE_GB=$(echo "scale=2; $SIZE_NUM / 1024" | bc) ;;
*) SIZE_GB=0 ;;
esac
# Get size in bytes for reliable comparison
SIZE_BYTES=$(lsblk -b -d -o SIZE -n "/dev/$DEV" 2>/dev/null | tr -d ' ')
SIZE_GB_INT=$((SIZE_BYTES / 1073741824)) # 1024^3
# Check if size is in SD card range (8GB - 128GB)
if (( $(echo "$SIZE_GB >= 8" | bc -l) )) && (( $(echo "$SIZE_GB <= 128" | bc -l) )); then
if [ "$SIZE_GB_INT" -ge 8 ] && [ "$SIZE_GB_INT" -le 128 ]; then
CANDIDATES+=("/dev/$DEV")
CANDIDATE_INFO+=("$SIZE $TYPE ${TRAN:-???} $MODEL")
fi