Skip to content

build: honour DESTDIR in make install and ship LICENSE in every package - #710

Merged
vladimirrott merged 1 commit into
mainfrom
build/destdir-license
Oct 29, 2026
Merged

vladimirrott merged 1 commit into
mainfrom
build/destdir-license

Conversation

@vladimirrott

@vladimirrott vladimirrott commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Two packaging gaps from the OpenSSF Best Practices review.

make install DESTDIR=<stage>. Packagers stage an install into a scratch tree and ship that tree. The Makefile ignored DESTDIR, so every file went straight to the host. Each destination in install and uninstall now carries the $(DESTDIR) prefix, the preflight probes the staged paths, and the steps that act on the running system (systemd-sysusers, systemd-tmpfiles, systemctl daemon-reload, and systemctl disable --now on uninstall) run only when DESTDIR is empty. Each skipped step prints DESTDIR set; skipped: ... so the packager sees what their install scripts must run. A plain sudo make install does what it did before. docs/quickstart.md gets one paragraph for packagers.

LICENSE in every published package. crates.io and npm build each tarball from the package directory, and LICENSE lived only at the repository root, so sysknife-cli-0.28.0.crate and [email protected] carry license = "MIT" and no licence text. MIT asks for the notice in every copy. The six publishable crates and packages/setup now hold a copy; cargo package --list -p sysknife-cli and npm pack --dry-run both list it.

Related Issue

Closes #711, closes #712. Part of #731 (OpenSSF Best Practices: Silver installation_standard_variables, Baseline OSPS-LE-03.02).

Validation

  • Tests added or updated
  • Documentation updated if behavior changed
  • Security impact considered
  • Trust boundary preserved (daemon remains the only privileged executor)
  • CI passes

Two new tests, both wired into docs-and-hygiene:

  • tests/release/destdir-install.test.sh runs the real Makefile with every INSTALL_DIRS variable pointed into a scratch root, and stubs cargo, systemctl, systemd-sysusers, systemd-tmpfiles and visudo. A staged install must write all 22 destinations under DESTDIR, nothing outside it, and call no activation command; a staged uninstall must remove everything; a live install must still activate. It failed on main and passes here. I ran six mutants and each one failed the test: $(DESTDIR) dropped from the helpers, the sudoers line, the preflight probe or the uninstall rm, and on_host forced to always run or never run.
  • tests/release/package-license.test.sh reads cargo metadata for the publishable crates, plus packages/setup, and requires a LICENSE byte-identical to the root one with no include or exclude rule dropping it. Deleting crates/sysknife-core/LICENSE fails it, and so does one extra byte in packages/setup/LICENSE.

install-paths.test.sh now ignores $(DESTDIR) when it lists the variables the recipe writes into, and helper_install_coverage.rs expects the prefixed paths.

Locally the pre-commit gate (fmt, clippy --all-targets, doc, nextest 2091/2091 against the baseline) and scripts/ci-local.sh --fast both pass.

Notes for Reviewers

The staged sudoers fragment keeps mode 0440, and the test checks it. Nothing changes for a live install except the echoed paths.

🤖 Generated with Claude Code

`make install DESTDIR=<stage>` now writes every file under the stage and
skips systemd-sysusers, systemd-tmpfiles and systemctl, so a packager can
build a staged tree and leave activation to the package's install scripts.
`make uninstall DESTDIR=...` removes the staged files and leaves the running
service alone. Without DESTDIR both targets behave as before.

crates.io and npm build each tarball from the package's own directory, and
LICENSE sat only at the repository root, so sysknife-cli-0.28.0.crate and
[email protected] shipped a `license = "MIT"` field with no licence
file. Each publishable crate and packages/setup now hold a copy.

tests/release/destdir-install.test.sh runs the real Makefile with every
install directory redirected into scratch and the activation commands
stubbed. tests/release/package-license.test.sh compares every publishable
crate and the npm package against the root LICENSE. Both run in CI.

Signed-off-by: Vladimir Rotariu <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Published crates and the npm package ship without a LICENSE file make install ignores DESTDIR, so a packager cannot stage an install

1 participant