mirror of
https://github.com/Klipper4FlashForge/firmware.git
synced 2026-10-21 12:52:16 -05:00
Both were deleted three commits ago and the sweep that followed missed these: the recipes, the s6-rc service scripts, printer.base.cfg's header and three qa modules all still pointed at them by name. Renamed to runFirmwareExe.sh, which is the file that actually does each thing described. Two needed more than a rename. anvil-link-prog.sh's ORDERING note explained itself in terms of stock run.sh's line numbers -- "distributes the software component at its lines 107-179, before the payload is extracted at line 180" -- and none of that is the shape of an install any more. What the note is really for is why the links cannot ship as files, which is unchanged, and it now says that instead. The paragraph about the component no longer carrying firmwareExe is replaced by the reason that matters: no component ships at all, so the version directory under /usr/prog/PROGRAM/software stays FlashForge's and app_startup.sh's watchdog has their binary to fall back on. test_moddir_paths.py's ALLOWED set excused two paths that no longer exist. anvil.conf went when the settings it held moved into the services, and .prev-root-hash is not written any more -- this installer only deletes the stale ones. Both were dead weight in a list whose whole job is to say "not shipped, and correctly so": an entry for a file nobody guards on excuses nothing and hides the next real one. Gates: 112 static tests, shellcheck clean over the edited payload scripts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CH7Yb4wuPhnppHAB25UX7e
88 lines
3.5 KiB
Python
88 lines
3.5 KiB
Python
"""A `[ -f $MODDIR/... ]` guard that can only ever be false.
|
|
|
|
THE BUG THIS EXISTS FOR. `installer/runFirmwareExe.sh` replaces FlashForge's
|
|
`klipperDaemon` -- whose `start` forks a second, unsupervised klippy beside the
|
|
s6-supervised one -- and it guarded that work with
|
|
|
|
if [ -f $MODDIR/bin/klipperDaemon ] && [ -d /usr/prog/klipper ]; then
|
|
|
|
The file ships at `$MODDIR/prog/klipperDaemon`. It moved there in 057a3a1 and
|
|
the guard did not, so the test was false on every printer and the whole block
|
|
was skipped IN SILENCE -- no error, no log line, just a stock `klipperDaemon`
|
|
left in place for release after release.
|
|
|
|
Nothing could have caught it. `sh -n` parses it, shellcheck likes it, and both
|
|
lanes stay green because the branch simply never runs. `test_no_undefined_names`
|
|
is the same idea for Python; this is the shell half.
|
|
|
|
WHY EXISTENCE GUARDS AND NOT EVERY $MODDIR PATH. Most `$MODDIR/...` references
|
|
are things a script CREATES or writes, and demanding those exist in a package
|
|
would be wrong. A `[ -f ]` / `[ -x ]` / `[ -d ]` is different: it is a claim
|
|
that something is already there, and the only two ways it can be true are that
|
|
a package ships it or that an earlier step wrote it. The second is the
|
|
allowlist below, and it is deliberately short so that adding to it is a
|
|
decision somebody makes rather than a way to silence this test.
|
|
"""
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from lib.paths import ROOT
|
|
|
|
pytestmark = pytest.mark.static
|
|
|
|
# Scripts that read $MODDIR expecting the payload to be installed.
|
|
SOURCES = sorted(
|
|
set(ROOT.glob("installer/*.sh"))
|
|
| set(ROOT.glob("pkgs/*/payload/prog/*"))
|
|
| set(ROOT.glob("pkgs/*/payload/bin/*.sh"))
|
|
| set(ROOT.glob("pkgs/*/payload/etc/s6-rc/source/*/run"))
|
|
)
|
|
|
|
# `[ -f $MODDIR/a/b ]`, `[ -x ${MODDIR}/a/b ]`. Only literal paths: anything
|
|
# with a variable or a glob in it cannot be resolved here and is skipped.
|
|
GUARD = re.compile(r"\[\s+-[fxdesr]\s+\$\{?MODDIR\}?/([A-Za-z0-9_.][A-Za-z0-9_./-]*)")
|
|
|
|
# Not shipped by any package, and correctly so.
|
|
ALLOWED = {
|
|
# Inside anvil-helixscreen's upstream tarball, which pkgs/helixscreen
|
|
# unpacks at build time -- so it is shipped, just not committed here.
|
|
"helixscreen/bin/helix-launcher.sh",
|
|
}
|
|
|
|
|
|
def _shipped():
|
|
"""Every path any recipe ships, relative to $MODDIR."""
|
|
out = set()
|
|
for payload in ROOT.glob("pkgs/*/payload"):
|
|
for p in payload.rglob("*"):
|
|
out.add(str(p.relative_to(payload)))
|
|
return out
|
|
|
|
|
|
def test_every_moddir_existence_guard_names_something_that_ships():
|
|
shipped = _shipped()
|
|
missing = []
|
|
for src in SOURCES:
|
|
try:
|
|
text = src.read_text(encoding="utf-8", errors="replace")
|
|
except OSError:
|
|
continue
|
|
for lineno, line in enumerate(text.splitlines(), 1):
|
|
for path in GUARD.findall(line):
|
|
path = path.rstrip("/")
|
|
if path in ALLOWED or path in shipped:
|
|
continue
|
|
missing.append(
|
|
"%s:%d $MODDIR/%s"
|
|
% (src.relative_to(ROOT), lineno, path))
|
|
|
|
assert not missing, (
|
|
"%d existence guard(s) name a $MODDIR path no recipe ships, so the "
|
|
"test is false on every printer and whatever it guards never runs -- "
|
|
"silently, which is how the klipperDaemon replacement was skipped for "
|
|
"several releases:\n %s\n"
|
|
"Either the path is wrong, or the file should be in a package, or it "
|
|
"is written at runtime and belongs in ALLOWED with a reason."
|
|
% (len(missing), "\n ".join(missing)))
|