diff --git a/export-image/04-set-partuuid/00-run.sh b/export-image/04-set-partuuid/00-run.sh index 99500f36fb..e528c3bfde 100755 --- a/export-image/04-set-partuuid/00-run.sh +++ b/export-image/04-set-partuuid/00-run.sh @@ -11,3 +11,22 @@ sed -i "s/BOOTDEV/PARTUUID=${BOOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/etc/fstab" sed -i "s/ROOTDEV/PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS_DIR}/boot/firmware/cmdline.txt" + +# Normalize CardputerZero cmdline for this image and keep console/splash/plymouth out. +if grep -q "dtoverlay=cardputerzero" "${ROOTFS_DIR}/boot/firmware/config.txt" 2>/dev/null; then + awk ' + { + out = "" + for (i = 1; i <= NF; i++) { + if ($i != "console=serial0,115200" && $i != "splash" && $i != "plymouth.ignore-serial-consoles") { + out = out (out == "" ? "" : " ") $i + } + } + print out + } + ' "${ROOTFS_DIR}/boot/firmware/cmdline.txt" > "${ROOTFS_DIR}/boot/firmware/cmdline.txt.tmp" + mv "${ROOTFS_DIR}/boot/firmware/cmdline.txt.tmp" "${ROOTFS_DIR}/boot/firmware/cmdline.txt" + + # Keep boot/cmdline.txt aligned with the file actually mounted in verify. + cp "${ROOTFS_DIR}/boot/firmware/cmdline.txt" "${ROOTFS_DIR}/boot/cmdline.txt" +fi diff --git a/stage2/05-cardputerzero/02-run.sh b/stage2/05-cardputerzero/02-run.sh index 87d2311b28..b7f03cc916 100755 --- a/stage2/05-cardputerzero/02-run.sh +++ b/stage2/05-cardputerzero/02-run.sh @@ -107,10 +107,27 @@ sed -i '1i kernel=u-boot.bin' ${ROOTFS_DIR}/boot/firmware/config.txt -# Append cmdline.txt parameters -sed -i 's/$/ quiet splash plymouth.ignore-serial-consoles fbcon=map:off cfg80211.ieee80211_regdom=AE/' \ +# Append custom cmdline parameters for CardputerZero. +sed -i 's/$/ quiet fbcon=map:off cfg80211.ieee80211_regdom=AE/' \ "${ROOTFS_DIR}/boot/firmware/cmdline.txt" +# Clean up CardputerZero cmdline tokens. +for cmd in "${ROOTFS_DIR}/boot/firmware/cmdline.txt" "${ROOTFS_DIR}/boot/cmdline.txt"; do + [ -f "$cmd" ] || continue + awk ' + { + out = "" + for (i = 1; i <= NF; i++) { + if ($i != "console=serial0,115200" && $i != "splash" && $i != "plymouth.ignore-serial-consoles") { + out = out (out == "" ? "" : " ") $i + } + } + print out + } + ' "$cmd" > "${cmd}.tmp" + mv "${cmd}.tmp" "$cmd" +done + # Module load config cat > "${ROOTFS_DIR}/etc/modules-load.d/cardputerzero.conf" << 'EOF' i2c-dev diff --git a/tools/verify-image.sh b/tools/verify-image.sh index bb3e2fab56..547f1c584c 100755 --- a/tools/verify-image.sh +++ b/tools/verify-image.sh @@ -92,10 +92,52 @@ else fi # Check cmdline.txt -if grep -q "quiet splash" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then - pass "cmdline.txt: quiet splash" +if awk ' +{ + for (i = 1; i <= NF; i++) { + if ($i == "quiet") { + ok = 1 + break + } + } +} +END { + exit (ok ? 0 : 1) +} +' "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + pass "cmdline.txt: quiet present" else - fail "cmdline.txt: missing quiet splash" + fail "cmdline.txt: quiet missing" +fi + +if awk ' +{ + for (i = 1; i <= NF; i++) { + if ($i == "splash") { + ok = 1 + break + } + } +} +END { + exit (ok ? 0 : 1) +} +' "$TMPDIR/boot/cmdline.txt" >/dev/null 2>&1; then + fail "cmdline.txt: splash should be removed for CardputerZero" +else + pass "cmdline.txt: splash removed" +fi + +if grep -q "plymouth.ignore-serial-consoles" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + fail "cmdline.txt: plymouth.ignore-serial-consoles should be removed for CardputerZero" +else + pass "cmdline.txt: plymouth.ignore-serial-consoles removed" +fi + +if grep -q "console=serial0,115200" "$TMPDIR/boot/cmdline.txt" 2>/dev/null; then + fail "cmdline.txt: console=serial0,115200 should be removed for CardputerZero" +else + pass "cmdline.txt: console=serial0,115200 removed" fi umount "$TMPDIR/boot" 2>/dev/null || true