Files
firmware/bin/unpack.sh
Oleksandr ShyshatskyiandClaude Opus 5 83a4600df8 Stop naming things that are not there any more
A sweep for comments and messages that describe machinery this tree no longer
has. Each one read as current and was not.

  * bin/verify.sh, retired two commits before this branch, was still named as
    the thing `make release` and docs/building.md were explaining the absence
    of. The absence needs no explaining -- `make qa-replica` is the gate.
  * `make test-recovery` does not exist. docs/hardware-testing.md told owners
    it "used to" prove the stock rollback; the useful half of that -- nothing
    tests the rollback today, treat it as unverified -- is kept and the dead
    target name is not. runFirmwareExe.sh pointed at it too.
  * run-append.sh in bin/build-payload.py, case-install.sh in
    docs/printer-replica.md: both files are gone.
  * `make test`/`make test-py` over test/, and the note that both suites run
    in CI "until a case-*.sh has a green replacement" -- test/ was deleted and
    there are no case scripts left to replace.
  * docs/building.md still said a package carries the software component.

CI's shellcheck globs are the one real defect this turned up. Two of the four
-- pkgs/*/payload/init.d/S* and pkgs/*/prog/*.sh -- match nothing: the recipes
stopped using both paths, and payload/prog/ is where those scripts live now.
shellcheck given a pattern that expands to nothing writes usage to stderr and
exits 1, so that step has been failing for its globs rather than for the code.
Fixed to the paths that exist, with a pointer to
qa/static/test_shell_syntax.py, which addresses the same files and refuses a
glob that matches nothing -- the guard this step did not have.

Verified: the corrected invocation runs clean over the 21 files it now
matches, and 112 static tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CH7Yb4wuPhnppHAB25UX7e
2026-08-30 15:38:25 +03:00

67 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# 1/3 -- decrypt the stock package and open what a release needs from it.
# ./bin/unpack.sh [<file>] default: $STOCK_TGZ from config.env
# -> work/outer/ the 8 top-level files. start.img, end.img and play ship;
# with FULL=1 so do kernel, control and library.
# -> work/software/ FlashForge's software component, opened but NOT shipped.
# bin/pack.sh reads two things out of it -- the printer.base.cfg
# to diff ours against, and the stock root hash the installer
# compares a live shadow to.
set -euo pipefail
. "$(dirname "$0")/common.sh"
SRC="${1:-$STOCK_TGZ}"
[ -f "$SRC" ] || { echo "no such package: $SRC" >&2; exit 1; }
rm -rf work/outer work/software
mkdir -p work/outer work/software
echo ">> decrypting $(basename "$SRC")"
# The printer's /usr/prog/bin/unTar runs exactly this, minus -md md5 (its
# OpenSSL 1.0.2 defaulted to MD5 key derivation; modern OpenSSL needs it said).
openssl des3 -d -k "$FF_KEY" -salt -md md5 -in "$SRC" 2>/dev/null \
| tar -xf - -C work/outer
echo ">> outer contents:"
ls -la work/outer | sed 's/^/ /'
SW_TARBALL=$(ls -1 work/outer/software-*.tar.xz 2>/dev/null | head -n1 || true)
[ -n "$SW_TARBALL" ] || { echo "no software-*.tar.xz in package" >&2; exit 1; }
STOCK_SW_VER=$(basename "$SW_TARBALL" | sed 's/^software-//; s/\.tar\.xz$//')
echo ">> extracting software component $STOCK_SW_VER"
tar -xf "$SW_TARBALL" -C work/software
# Recorded for bin/pack.sh, which bakes both into the installer's own gate.
PKG_MACHINE=$(sed -n 's/^MACHINE=//p' work/outer/runFirmwareExe.sh | head -n1)
PKG_PID=$(sed -n 's/^PID=//p' work/outer/runFirmwareExe.sh | head -n1)
echo "${PKG_MACHINE:-unknown}" > work/.pkg_machine
echo "${PKG_PID:-unknown}" > work/.pkg_pid
echo ">> package installs on: ${PKG_MACHINE:-unknown} (PID ${PKG_PID:-unknown})"
echo "$STOCK_SW_VER" > work/.stock_sw_ver
echo "$SRC" > work/.source_pkg
# Ours is FlashForge's file with the chamber block replaced by an include, so
# drift means a stale pin map or stepper current. Checked here because this is
# the only moment a pristine stock tree exists. A warning, not a gate.
STOCK_BASE=work/software/klipper/config/printer.base.cfg
OURS=pkgs/klipper-config/prog/config/printer.base.cfg
if [ -f "$STOCK_BASE" ] && [ -f "$OURS" ]; then
# Section/option lines only: comments differ by design, and the chamber
# and ff-*.cfg includes are ours.
strip() { grep -vE '^\s*(#|$)' "$1" | grep -vE '^\[(heater_generic|verify_heater) chamber_heater\]|^\[include printer\.chamber\.cfg\]|^\[include ff-[a-z-]+\.cfg\]'; }
if strip "$STOCK_BASE" | diff -q - <(strip "$OURS") >/dev/null 2>&1; then
echo ">> printer.base.cfg matches the stock file"
else
echo " !! printer.base.cfg DIFFERS from this package's stock file." >&2
echo " FlashForge may have changed pins/currents/limits. Review:" >&2
echo " diff $STOCK_BASE $OURS" >&2
fi
fi
echo
echo "Unpacked. Now run ./bin/payload.sh, then ./bin/pack.sh"
echo " stock software version: $STOCK_SW_VER"
echo " files: $(find work/software -type f | wc -l)"