Skip to content

Generate supplemental Debian packages - #1148

Open
cpuguy83 wants to merge 2 commits into
subpackage-rpmfrom
subpackage-deb
Open

cpuguy83 wants to merge 2 commits into
subpackage-rpmfrom
subpackage-deb

Conversation

@cpuguy83

Copy link
Copy Markdown
Collaborator

Adds Debian control stanzas and package-specific install, maintainer, systemd, and permissions behavior, with unit and LLB-level coverage.

This is layer 3 of the native supplemental-packages stack and depends on #1147.

Related to #607.

@cpuguy83
cpuguy83 marked this pull request as ready for review July 16, 2026 21:45
Copilot AI review requested due to automatic review settings July 16, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Debian-side support for “supplemental packages” (subpackage/binary package stanzas) so a single Dalec build can emit multiple Debian packages, aligning with the broader supplemental-packages stack (related to #607, depends on #1147).

Changes:

  • Extend Debian control generation to emit additional binary package stanzas for target subpackages.
  • Generate per-subpackage Debian install scripts and maintainer scripts (postinst) and handle systemd units per owning package.
  • Add unit-level and LLB-definition-level tests covering subpackage control stanzas, install file generation, postinst generation, perms/systemd behavior, and ordering.

Reviewed changes

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

Show a summary per file
File Description
packaging/linux/deb/templates/debian_control.tmpl Emits appended subpackage stanzas into the generated debian/control.
packaging/linux/deb/template_control.go Implements subpackage stanza rendering (Depends/Recommends/Provides/Conflicts/Replaces/Description).
packaging/linux/deb/template_control_test.go Unit tests for control output with subpackages (naming, sorting, deps, auto-requires behavior).
packaging/linux/deb/template_rules.go Routes systemd override behavior to the correct package (primary vs subpackage) and checks subpackage perms.
packaging/linux/deb/template_rules_test.go Adds coverage ensuring custom systemd enable snippets land in subpackage postinst when needed.
packaging/linux/deb/template_custom_dh_installsystemd_postinst.go Generates custom systemd enable/start snippets per owning package (primary + subpackages).
packaging/linux/deb/debroot.go Generates debroot artifacts for subpackages: .install files, .links, .docs, postinst, and per-package perms/systemd partials.
packaging/linux/deb/debroot_subpackage_test.go LLB-level tests validating that subpackage artifacts produce the expected debroot files and rules behavior.
Comments suppressed due to low confidence (1)

packaging/linux/deb/debroot.go:280

  • dir values passed into checkAndWritePerms are absolute paths (e.g. /usr/bin, /usr/share/doc/...). Using filepath.Join(basePath, dir, ...) drops basePath when dir is absolute, so fix_perms.sh will chmod host paths instead of files under debian/<pkgName>/....
			p := filepath.Join(basePath, dir, resolvedName)
			// TODO: do i need this?
			if cfg.SubPath != "" {
				p = filepath.Join(basePath, dir, cfg.SubPath, resolvedName)
			}

Comment thread packaging/linux/deb/debroot.go
Comment thread packaging/linux/deb/debroot.go
@cpuguy83
cpuguy83 force-pushed the subpackage-deb branch 2 times, most recently from f3739e9 to f2f0266 Compare July 17, 2026 23:42
@cpuguy83
cpuguy83 force-pushed the subpackage-deb branch 3 times, most recently from b6d626c to f1819dc Compare July 21, 2026 00:25

@invidian invidian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some review comments, although this is not thorough given the amount of code in this PR. I also don't know what testing level we cover here, but perhaps a lot is missing. Given that this could is large and complex, it would be nice to have a robust test suite for it so we can at least attempt to refactor it in the future.

Comment thread packaging/linux/deb/template_rules_test.go Outdated
Comment thread packaging/linux/deb/subpackage.go Outdated
Comment thread packaging/linux/deb/template_custom_dh_installsystemd_postinst.go Outdated
Comment thread packaging/linux/deb/debroot.go Outdated
Comment thread packaging/linux/deb/debroot.go Outdated
Comment thread packaging/linux/deb/debroot.go Outdated
Comment thread packaging/linux/deb/debroot.go
Comment thread packaging/linux/deb/template_rules.go
Comment thread packaging/linux/deb/template_control.go Outdated
Comment thread packaging/linux/deb/debroot.go
Add subpackage support to the Debian packaging pipeline:

- Control file: emit additional Package: stanzas for each subpackage
  with Architecture, Section, Depends, Recommends, Replaces, Conflicts,
  Provides, and Description fields.
- Install scripts: refactor createInstallScripts into per-package helper
  (packageInstallScripts) that generates .install, .manpages, .dirs,
  .docs, and .links files for both the primary package and subpackages.
- Postinst: refactor ownership/capabilities helpers to accept artifacts
  directly; add generateSubPackagePostinst for per-subpackage postinst.
- Fix perms: refactor fixupArtifactPerms to iterate primary + subpackages
  via writePackagePerms; update OverridePerms to check subpackage artifacts.
- Systemd: extend OverrideSystemd to emit dh_installsystemd -p<pkgName>
  for subpackage units; refactor customDHInstallSystemdPostinst to handle
  both primary and subpackage units via writeCustomEnableForUnits helper.
- Add comprehensive LLB-level and unit tests covering all generated files.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Normalize primary and supplemental packages so Debian files, control
metadata, and rules share the same generation paths. Add coverage for
package-local output and aggregated debhelper overrides.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 self-assigned this Aug 11, 2026
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