Skip to content

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

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

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

Conversation

@peterjan

@peterjan peterjan commented Jun 15, 2026

Copy link
Copy Markdown
Member

This PR lays the groundwork for closing out #129 and #179. I'll F/U with a PR that switches the build workflow over and closes both, if this gets approved of course. This PR restructures how our .deb packages are defined, without touching the release flow yet. It's quite lengthy because we migrate existing installs...

The main problem with our packages now as I understand it are:

  • upgrading overrides user defined settings and actually stops the service on upgrade
  • current package essentially ignores Debians conventions for the most part

I think the solution that tackles both of these problems is to ship a conffile.

A conffile is just a config file that the package manager treats as yours. It never overwrites it on upgrade. If we ever change the default and you changed yours too, apt shows you the diff and asks what to do instead of clobbering it. That is basically the exact thing #179 asked for, and shipping config under /etc the proper way is also what Debian wants, so it helps #129 at the same time.

So this PR adds a packages// folder per daemon with its metadata and a default config, and a build script that turns that into a .deb. Same script is used by CI and the tests, so what we test is what we ship. hostd, renterd, walletd and s3d are all in here. Adding a new one later is just one more folder.

What else the new packages do

  • the service file moves to where Debian expects it instead of /etc
  • we ship a config with sane defaults, logs go to /var/log/ and get rotated so they cannot grow forever
  • upgrades no longer stop or disable your service, they just restart it if it was already running
  • apt remove keeps your config and data, apt purge cleans up but never deletes /var/lib/ because your wallet lives there
  • the service starts off disabled, because the daemons need a seed or password before they can run. So the flow is: fill in the config, then systemctl enable --now

Upgrading from the old packages

The first upgrade moves everything to the new layout for you. If you never touched the service file, we swap it for the new one. If you did edit it, we leave yours exactly as is. If it was set up and running, we turn it back on once after the upgrade. Old installs that already had a config keep using it, nothing changes for them.

There is a test suite that installs, upgrades, migrates and removes the packages inside real containers, across debian bullseye, bookworm, trixie and ubuntu jammy, questing. It is all green. CI runs it on every PR. Nothing here changes the actual release flow yet. The packages we publish stay the same until the follow up PR flips the switch.

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
@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
# builds a .deb package for a Sia daemon from a prebuilt linux binary and the
# package definition under packages/<project>. used by the build workflow and
# by the test suite so the tested artifact matches the shipped artifact.
set -euo pipefail
Comment thread scripts/build-deb.sh
Comment on lines +86 to +88
# bash replacement keeps every substitution literal. the replacements must be
# quoted because bash 5.2 enables patsub_replacement by default, which gives
# unquoted & and backslash special meaning
Comment thread tests/scenarios/05-remove-purge.sh Outdated
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# remove keeps configuration and data, purge removes configuration and logs
# but never wallet data

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why leave wallet data? Seems a bit annoying to not be able to rely on purge to actually remove everything.

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