Skip to content

feat(packaging): deb/rpm packages, and the uninstall script they make reachable (#207, #137, #145) - #412

Merged
scttfrdmn merged 3 commits into
mainfrom
feat/packaging-and-modulefiles
Aug 9, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
feat/packaging-and-modulefiles

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #207, closes #137, closes #145.

What was wrong

scripts/preremove.sh has been in this repository unable to run. Only a package manager invokes a pre-removal hook, and there was no packaging — so grep -r preremove returned the script and nothing else. That is #207 exactly.

It also carried a defect that could not have been found any other way. Its unmount loop matched type fuse.objectfs in /proc/mounts, and an ObjectFS mount reports fuse.s3 (internal/fuse/mount.go sets Subtype: "s3"). The pattern had nothing to match against on any host, so the one thing the script existed to do could not happen. Same defect class as the JS SDK's isMounted, which checked a string that was never emitted.

What this adds

nfpm.yaml — one config, both formats, amd64 and arm64, via make package-linux. No version literal: ${OBJECTFS_VERSION} comes from cmd/objectfs/main.go through the Makefile using the same sed expression release.yml uses.

Both scriptlets are rewritten around guard-check-then-act, which is what #137 asks for. The previous postinstall.sh ran chmod 755 /etc/objectfs unconditionally, so every upgrade silently widened a directory an operator had tightened. A removal with a live mount now fails rather than proceeding — dpkg honours that as a refusal; rpm reports it and erases anyway, because %preun is not a veto, and the script's header says so instead of implying a guarantee it cannot make on both.

Two packaging decisions that are not the obvious ones, each argued at its site in nfpm.yaml:

  • fuse3 is a Recommends, not a Depends. fusermount3 is needed only for an unprivileged mount; a root mount goes through mount(2). Depends would make apt refuse the install on a build server or a container image being prepared for later use.
  • Nothing ships under /etc. A packaged file there is a dpkg conffile, and dpkg prompts on upgrade to merge it, which hangs an unattended apt upgrade. The cost is that /etc/objectfs/config.yaml survives apt purge — CI asserts that rather than wishing otherwise.

#145 rides along because the packages are what install it. configs/modules/ holds an Lmod and a TCL modulefile, shipped to /usr/share/modulefiles/objectfs/<version>, so module load objectfs works on a packaged host with no further steps. The version is in the filename — that is how both systems decide what objectfs/0.13.0 means — so the TCL file has no extension while the Lmod one keeps .lua, because Lmod needs it to parse the file as Lua at all. The two formats disagree here and the disagreement is correct.

Both refuse to load when no binary is found, listing the paths searched. Per CLAUDE.md's degradation rule that is the right kind of failure: locating the binary is a correctness capability, not a performance one. A modulefile that puts a directory on `PATH` with nothing in it reports success, appears in `module list`, and surfaces as "command not found" inside a batch job hours later — at which point the module system looks right and ObjectFS looks broken.

Verified, not reasoned about

  • Packages built and contents inspected: /usr/share/modulefiles/objectfs/0.13.0 and 0.13.0.lua, version expanded from the constant.
  • The extracted .deb tree loaded under real Lmod 9.3 and real TCL Modules 5.6.1. Both systems report exactly one objectfs/0.13.0 despite two files in one directory.
  • Both PATH branches exercised. A /usr install emits no PATH change, because /usr/bin is in the modulefile's systemBinDirs and prepending it would leave it hoisted after module unload; a versioned prefix does prepend. An earlier draft of the CI assertion had this backwards and would have failed the build on correct behaviour.
  • Four mutations on the modulefile destinations, each caught: expand omitted, version moved into a directory, TCL file given a .tcl suffix, both entries deleted.
  • The skip-is-an-error check was itself verified by pointing the interpreter candidates at /nonexistent: go test exited 0 with four skips, and the grep caught all four.

Testing

internal/config/packaging_test.go and modulefiles_test.go hold the static half — nfpm.yaml against the filesystem, the scripts, the Makefile and the version constant — and run both scripts against scratch roots through an OBJECTFS_ROOT seam.

Two CI jobs do it for real rather than by reading files:

  • packaging installs the .deb with dpkg, reinstalls over an edited config, loads the installed modulefile under Lmod, then removes and purges — asserting at each step, including that no modulefile survives removal (a leftover one would make module avail list a version whose binary is gone).
  • modulefiles installs Lmod and TCL Modules and fails if either test skips. Those tests t.Skipf when the interpreter is absent, which is the state of a bare runner, so without this they return a pass having checked nothing. The pattern is the labels job's.

shellcheck now runs on every shell script in pre-commit; three pre-existing findings in scripts/pjdfstest.sh and scripts/cleanup-aws-test.sh are fixed.

Reviewer notes

  • The ci.yml diff is large because the YAML pre-commit hook reindented the file. git diff -w is 292 insertions and no deletions — the change is purely additive.
  • Neither new job is a required status check yet, since a check that does not exist on main blocks every PR. Both get added to branch protection right after this merges.

… reachable (#207, #137, #145)

scripts/preremove.sh has been in this repository unable to run. Only a package manager invokes a
pre-removal hook and there was no packaging, so `grep -r preremove` returned the script and nothing
else — which is #207. nfpm.yaml builds both formats for amd64 and arm64 from one config and wires
both scriptlets, so the script now has a caller.

It also had a defect that could not have been found any other way. Its unmount loop matched
`type fuse.objectfs` in /proc/mounts, and an ObjectFS mount reports **fuse.s3** —
internal/fuse/mount.go sets Subtype: "s3". The pattern had nothing to match, so the one thing the
script existed to do could not happen on any host. Same defect class as the JS SDK's isMounted,
which checked a string that was never emitted.

Both scriptlets are rewritten around guard-check-then-act, which is what #137 asks for: the previous
postinstall.sh ran `chmod 755 /etc/objectfs` unconditionally, so every upgrade silently widened a
directory an operator had tightened. A removal with a live mount now fails rather than proceeding —
dpkg honours that as a refusal, rpm reports it and erases anyway because %preun is not a veto, and
the script's header says so rather than implying a guarantee it cannot make on both.

Two packaging decisions that are not the obvious ones, argued in nfpm.yaml at each site:

  * fuse3 is a Recommends, not a Depends. fusermount3 is needed only for an unprivileged mount; a
    root mount goes through mount(2). Depends would make apt refuse the install on a build server or
    a container image being prepared for later use. postinstall.sh warns with the per-distribution
    command instead.
  * Nothing ships under /etc. A packaged file there is a dpkg conffile, and dpkg prompts on upgrade
    to merge it, which hangs an unattended `apt upgrade`. The cost is that /etc/objectfs/config.yaml
    survives `apt purge`; CI asserts that rather than wishing otherwise.

#145 rides along because the packages are what install it. configs/modules/ holds an Lmod and a TCL
modulefile, shipped to /usr/share/modulefiles/objectfs/<version>, so `module load objectfs` works on
a packaged host with no further steps. The version is in the *filename* — that is how both systems
decide what `objectfs/0.13.0` means — and the TCL file therefore has no extension, while the Lmod
one keeps .lua because Lmod needs it to parse the file as Lua at all. The two formats disagree here
and the disagreement is correct. Both read their version back out of that path, so
cmd/objectfs/main.go stays the only place a version is written down.

They refuse to load when no binary is found, listing the paths searched. Per CLAUDE.md's degradation
rule that is the right kind: locating the binary is a correctness capability, not a performance one.
A modulefile that puts a directory on PATH with nothing in it reports success, appears in
`module list`, and surfaces as "command not found" inside a batch job hours later — at which point
the module system looks right and ObjectFS looks broken.

Verified rather than reasoned about. The packages were built and their contents inspected
(/usr/share/modulefiles/objectfs/0.13.0 and 0.13.0.lua, version expanded from the constant), the
extracted deb tree was loaded under real Lmod 9.3 and real TCL Modules 5.6.1, and both PATH branches
were exercised: a /usr install emits no PATH change, because /usr/bin is in the modulefile's
systemBinDirs and prepending it would leave it hoisted after `module unload`; a versioned prefix does
prepend. An earlier draft of the CI assertion here had it backwards and would have failed the build
on correct behaviour.

Testing. internal/config/packaging_test.go and modulefiles_test.go hold the static half — nfpm.yaml
against the filesystem, the scripts, the Makefile and the version constant — and run both scripts
against scratch roots through an OBJECTFS_ROOT seam. The four ways the modulefile destinations can
be wrong were each mutated and each caught: expand omitted, the version moved into a directory, the
TCL file given a .tcl suffix, and both entries deleted.

Two CI jobs do it for real rather than by reading files. `packaging` installs the .deb with dpkg,
reinstalls over an edited config, loads the installed modulefile under Lmod, then removes and purges,
asserting at each step — including that no modulefile survives removal, since a leftover one would
make `module avail` list a version whose binary is gone. `modulefiles` installs Lmod *and* TCL
Modules and **fails if either test skips**: those tests call t.Skipf when the interpreter is absent,
which is the state of a bare runner, so without this they return a pass having checked nothing. The
skip-is-an-error pattern is the labels job's, and it was verified by pointing the candidate paths at
/nonexistent — `go test` exited 0 with four skips, and the grep caught all four.

shellcheck now runs on every shell script in pre-commit; three pre-existing findings in
scripts/pjdfstest.sh and scripts/cleanup-aws-test.sh are fixed. The ci.yml diff is large because the
YAML pre-commit hook reindented the file; `git diff -w` is 292 insertions and no deletions.

Neither modulefile job is a required status check yet — a check that does not exist on main blocks
every PR — so both get added to branch protection after this merge.
…annot happen

Both fixes come from the first CI run of these jobs, and both were things reading the files could
not have told me.

**lmod and environment-modules Conflict on Ubuntu.** The job installed both in one step, on the
reasoning that a site running one is not evidence about a site running the other — and apt refused
with exit 100 before a single test ran:

    environment-modules : Conflicts: lmod but 8.6.19-1 is to be installed
    lmod : Conflicts: environment-modules but 5.4.0-1 is to be installed
    E: Unable to correct problems, you have held broken packages.

They conflict because both ship /usr/bin/modulecmd and both want the shell init snippets in
/etc/profile.d. So the job becomes a matrix, one interpreter per leg, fail-fast: false so a failure
under Lmod still reports the TCL answer. The skip-is-an-error check now names only its own leg's
system: the other one skips there correctly, because its interpreter genuinely is not installed, and
asserting on both would have failed every leg.

The reason for testing both survives intact — it is the same reason they conflict. A site runs one or
the other, and the two disagree on exactly the PATH semantics the modulefiles have to absorb.

**There is no purge phase.** `apt-get purge -y objectfs` failed with `Unable to locate package
objectfs`, and that is the packaging working rather than failing. dpkg keeps a removed package in the
`rc` state only when it has **conffiles**, and a conffile is precisely what nfpm.yaml declines to
create by shipping nothing under /etc. With none, `apt remove` takes the package out of dpkg's
database entirely, so purge has nothing left to act on and apt no longer knows the name.

The step now asserts that instead of performing it, and asserts the stronger property while it is
there: if dpkg ever reports objectfs in the `rc` state, the package has started shipping a conffile —
which brings an upgrade prompt that hangs unattended apt — and that should not arrive silently. The
config file surviving is still checked; it is created by the scriptlet rather than shipped, so nothing
in any removal path deletes it.

The CHANGELOG said the config "survives `apt purge`", which was wrong in the same way, and now states
what actually happens.

Everything else on that run passed, including the step that matters most here: the installed
modulefile loaded under real Lmod on a real dpkg install and reported the packaged version.
…t code

The tcl-modules leg of the new modulefiles job failed on CI while passing
locally, against a modulefile that was correct. The test asserted on
modulecmd.tcl's exit status, and that status is version-dependent: Modules
5.6.1 exits 1 on an aborted load, and the Modules 5.4.0 that Ubuntu 24.04
ships exits 0 — for byte-identical output.

What is version-independent is the shell code both emit. TCL writes
`test 0 = 1;` and Lmod writes `false`, and `module` is a shell function whose
entire body is an eval of that output. An operator's `module load objectfs ||
exit 1` branches on the eval and never on the interpreter's status, so the
eval is the contract and is now what the test runs. Mutation-verified by
removing the `break` from objectfs.tcl: the assertion fails as intended.

The comment in objectfs.tcl that claimed modulecmd.tcl exits 1 is what
misled the test, so it is corrected here rather than left to mislead again.

Also replaces TestModulefilesDoNotHardcodeAVersion's allowlist of exact
release strings ("Lmod 9.3", "Modules 5.6.1") with a check that a dotted
number is attributed to the tool it describes. The allowlist failed against
the corrected comment above simply because it measured a second Modules
release — an allowlist has to be edited every time a behavior is verified
somewhere new, and that edit is indistinguishable from suppressing a real
finding. Attributed versions are now stripped from the line rather than
skipping the line, so "under Modules 5.6.1, objectfs/0.13.0 resolves" still
fails on the ObjectFS literal. Both mutations verified.
@scttfrdmn
scttfrdmn merged commit d7369f1 into main Aug 9, 2026
38 checks passed
@scttfrdmn
scttfrdmn deleted the feat/packaging-and-modulefiles branch August 9, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant