Skip to content

Add package definitions, build script, and test suite#232

Open
peterjan wants to merge 3 commits into
masterfrom
pj/deb-packages
Open

Add package definitions, build script, and test suite#232
peterjan wants to merge 3 commits into
masterfrom
pj/deb-packages

Conversation

@peterjan

@peterjan peterjan commented Jun 15, 2026

Copy link
Copy Markdown
Member

Groundwork for #129 and #179. It changes how we define our .deb packages, but doesn't touch the release flow yet. A later PR flips the build workflow over and closes both, if this gets approved. It's long because it also migrates existing installs to the new layout.

Two things are wrong with our packages today:

  • upgrading stops and disables your service, and overwrites any edits to the unit file
  • they ignore Debian's conventions

The main fix is about config. Every daemon already writes its own config to /etc/<name>/<name>.yml when you run <name> config. The tempting way to help with #179 would be to ship a default config in the package, but then the package and the daemon would fight over that file: the package claims it, the daemon overwrites it the first time you run <name> config, and every upgrade stops to ask "keep yours or take mine?". So we deliberately ship no config. The daemon owns it, the package never touches it, upgrades can't clobber it. That's #179.

A test suite installs, upgrades, migrates and removes the packages in real containers across debian bullseye, bookworm, trixie and ubuntu jammy, questing. all green, runs on every PR. nothing here changes what we publish until the follow up PR.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new, Debian-policy-aligned packaging layout for Sia daemons by defining per-daemon package metadata/config under packages/<name>/, generating .deb artifacts via a shared scripts/build-deb.sh, and validating install/upgrade/migration/remove behavior with an end-to-end containerized test suite.

Changes:

  • Add scripts/build-deb.sh and packaging templates (systemd unit, maintainer scripts, control, logrotate, copyright).
  • Add per-daemon package definitions and default configs for hostd, renterd, walletd, and s3d.
  • Add a Docker-based packaging test suite + CI workflow to lint, build, and run package scenarios across Debian/Ubuntu variants.

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.gitignore Ignore generated dist/ artifacts and .deb outputs.
.github/workflows/test.yml Add CI workflow for shellcheck, Go checks, package build, and package scenario tests.
scripts/build-deb.sh New build script that assembles .deb packages from templates + per-daemon definitions.
scripts/templates/control.tmpl Package control file template.
scripts/templates/copyright.tmpl Debian copyright file template.
scripts/templates/logrotate.tmpl Logrotate config template for daemon logs.
scripts/templates/postinst.tmpl Post-install maintainer script handling migration and restart policy.
scripts/templates/postrm.tmpl Post-removal maintainer script handling purge and failure unwind.
scripts/templates/preinst.tmpl Pre-install maintainer script handling legacy unit detection/stash.
scripts/templates/prerm.tmpl Pre-removal maintainer script handling disable/stop policy.
scripts/templates/service.tmpl Systemd unit template using Debian-expected locations and defaults.
packages/hostd/package.env hostd package metadata.
packages/hostd/hostd.yml Default hostd config shipped as a conffile under /etc.
packages/renterd/package.env renterd package metadata.
packages/renterd/renterd.yml Default renterd config shipped as a conffile under /etc.
packages/s3d/package.env s3d package metadata.
packages/s3d/s3d.yml Default s3d config shipped as a conffile under /etc.
packages/walletd/package.env walletd package metadata.
packages/walletd/walletd.yml Default walletd config shipped as a conffile under /etc.
tests/README.md Documentation for running the packaging test suite locally.
tests/Dockerfile.systemd Builds a systemd-enabled test image for running package scenarios.
tests/lib.sh Container lifecycle helpers for the packaging tests.
tests/run-tests.sh Orchestrates building the stub, building images, running scenario scripts.
tests/container-prep.sh Container-side prep: copy sources, build debs, build legacy debs.
tests/build-legacy-deb.sh Builds legacy-style .deb packages for migration testing.
tests/lintian-suppressions.txt Lintian suppressions used by the lintian scenario.
tests/stub/main.go Minimal stub daemon used by packaging tests.
tests/scenarios/helpers.sh Scenario assertion helpers and systemd state helpers.
tests/scenarios/01-fresh-install.sh Fresh install layout + conffile registration assertions.
tests/scenarios/02-upgrade.sh Upgrade behavior assertions (restart-if-running, preserve enablement).
tests/scenarios/03-config-preservation.sh Conffile + systemd drop-in preservation assertions.
tests/scenarios/04-legacy-migration.sh Legacy migration assertions (stock vs modified unit behavior).
tests/scenarios/05-remove-purge.sh Remove vs purge behavior assertions (keep config/data vs cleanup logs/config).
tests/scenarios/06-lintian.sh Lintian check scenario (runs on Debian trixie only).
tests/scenarios/07-failed-upgrade.sh Failed-upgrade unwind behavior assertions.
tests/scenarios/nosystemd-install.sh Install/upgrade/remove/purge + legacy migration in no-systemd containers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/test.yml Outdated
Comment thread scripts/templates/postrm.tmpl
Copilot AI review requested due to automatic review settings June 15, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.

Comment thread tests/scenarios/06-lintian.sh Outdated
@peterjan peterjan marked this pull request as ready for review June 15, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Comment thread scripts/build-deb.sh
Comment thread scripts/build-deb.sh Outdated
Comment thread tests/scenarios/05-remove-purge.sh Outdated
Copilot AI review requested due to automatic review settings June 18, 2026 08:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 4 comments.

Comment thread tests/scenarios/helpers.sh
Comment thread scripts/templates/postinst.tmpl Outdated
Comment thread scripts/templates/postrm.tmpl Outdated
Comment thread scripts/build-deb.sh Outdated
Copilot AI review requested due to automatic review settings June 18, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 1 comment.

Comment thread tests/Dockerfile.systemd
Copilot AI review requested due to automatic review settings June 18, 2026 12:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 3 comments.

Comment thread scripts/templates/service.tmpl
Comment thread tests/Dockerfile.systemd
Comment thread tests/run-tests.sh
Copilot AI review requested due to automatic review settings June 22, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.

Comment thread scripts/templates/service.tmpl
Comment thread tests/Dockerfile.systemd
@peterjan

peterjan commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@n8mgr @ChrisSchinnerl one thing I didn't really address with this PR is our logging strategy

Today all four daemons default File.Enabled to true, so a packaged install writes an unrotated log to /var/lib/<name>/<name>.log. They also log to stdout, which systemd already routes to the journal. So file lives under /var/lib instead of /var/log and nothing rotates it.

What if we would update our daemons though and default File.Enabled to false. Then anyone who wants a log file can still enable it, and make a deliberate choice and we don't have to ship a logrotate config file. Is that something we would consider? Or do we just want to ignore this all together?

edit: I'm trying to gauge whether we can effectively close #129 after these changes or if we need to keep that one open

@peterjan peterjan requested a review from ChrisSchinnerl June 22, 2026 06:57
@peterjan

Copy link
Copy Markdown
Member Author

@n8mgr @ChrisSchinnerl one thing I didn't really address with this PR is our logging strategy

Today all four daemons default File.Enabled to true, so a packaged install writes an unrotated log to /var/lib/<name>/<name>.log. They also log to stdout, which systemd already routes to the journal. So file lives under /var/lib instead of /var/log and nothing rotates it.

What if we would update our daemons though and default File.Enabled to false. Then anyone who wants a log file can still enable it, and make a deliberate choice and we don't have to ship a logrotate config file. Is that something we would consider? Or do we just want to ignore this all together?

edit: I'm trying to gauge whether we can effectively close #129 after these changes or if we need to keep that one open

as discussed I'll F/U with PRs that disable file logging by default so we can somewhat bypass the complaint we don't logrotate our log file

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.

3 participants