Skip to content

Supplemental packages#988

Open
cpuguy83 wants to merge 7 commits into
project-dalec:mainfrom
cpuguy83:supplemental_packages
Open

Supplemental packages#988
cpuguy83 wants to merge 7 commits into
project-dalec:mainfrom
cpuguy83:supplemental_packages

Conversation

@cpuguy83

@cpuguy83 cpuguy83 commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator

Adds subpackages (supplemental packages): a single build can produce multiple installable packages, defined per target under a packages field. Each subpackage shares the primary's build (steps, sources, version, license, …) and selects its own artifacts.

  • RPM: emits per-subpackage %package/%files sections.
  • Debian: emits extra Package: stanzas with per-package install/maintainer scripts and dh_installsystemd overrides.
  • windowscross: one zip per package; the container target installs binaries from all packages.

Artifacts are self-contained — anything placed in a subpackage isn't also shipped by the primary. Install-time scriptlet requirements (systemd, users/groups) are derived per subpackage.

Closes #607

@cpuguy83 cpuguy83 self-assigned this Mar 9, 2026
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from d8c9938 to ef53ce1 Compare June 7, 2026 18:32
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from ef53ce1 to 0408abc Compare June 7, 2026 19:32
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 0408abc to 4f193d7 Compare June 7, 2026 23:07
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 4f193d7 to e5e4200 Compare June 8, 2026 00:12
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from e5e4200 to 4ff35c2 Compare June 8, 2026 01:02
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from b18783d to 5413d66 Compare June 12, 2026 01:13
@cpuguy83 cpuguy83 marked this pull request as ready for review June 12, 2026 01:13
Copilot AI review requested due to automatic review settings June 12, 2026 01:13

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

This PR implements supplemental packages (subpackages) for Dalec, addressing issue #607. It enables a single build to produce multiple installable packages — a primary package plus one or more supplemental packages that share the build output but have their own artifact selection, runtime dependencies, and metadata. This follows the native subpackage model of RPM and Debian packaging systems.

Changes:

  • Adds a new SubPackage type and packages map field on Target, with validation (description required, unique names, no collision with primary), build arg expansion, and public APIs (GetSubPackages, GetAllPackageNames).
  • Implements subpackage support in RPM (subpackage sections with %package, %files, scriptlets), DEB (multi-stanza debian/control, per-package install scripts, postinst, systemd handling, permissions fixing), and Windows (per-package zips, per-package directories in container images).
  • Adds comprehensive unit and integration tests across all three targets, plus documentation and JSON schema updates.

Reviewed changes

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

Show a summary per file
File Description
subpackage.go New SubPackage/SubPackageDependencies types, validation, name resolution, GetSubPackages/GetAllPackageNames APIs
subpackage_test.go Comprehensive unit tests for core subpackage model
target.go Adds Packages field to Target, wires validate/processBuildArgs/fillDefaults
load.go Integrates validateSubPackageNames into Spec.Validate()
packaging/linux/rpm/template.go RPM subpackage sections, refactored scriptlet body generators, shared writeFilesBody/installArtifacts
packaging/linux/rpm/template_test.go Extensive RPM subpackage template tests
packaging/linux/rpm/buildroot_test.go LLB-level RPM buildroot tests for subpackages
packaging/linux/deb/template_control.go Debian control subpackage stanzas with deps/conflicts/provides
packaging/linux/deb/template_control_test.go Control file subpackage tests
packaging/linux/deb/template_rules.go Per-package systemd overrides, subpackage-aware perm fixing
packaging/linux/deb/template_rules_test.go Replaced primary mixed-enable test with subpackage test
packaging/linux/deb/template_custom_dh_installsystemd_postinst.go Per-package custom systemd postinst partials
packaging/linux/deb/debroot.go Multi-package install scripts, postinst, links, permissions
packaging/linux/deb/debroot_subpackage_test.go Comprehensive debroot subpackage tests
packaging/linux/deb/templates/debian_control.tmpl Adds {{ .SubPackages }} to control template
targets/windows/handle_zip.go Per-package zips, per-package artifact staging
targets/windows/handle_container.go Installs all package binaries into container image
targets/windows/validation.go Validates no empty packages for zip target
targets/windows/handle_zip_test.go Unit tests for windows subpackage functions
test/subpackage_test.go Shared cross-distro integration test for subpackages
test/linux_target_test.go Wires subpackage integration test into linux test suite
test/windows_test.go Wires subpackage integration test into windows test suite
test/target_rockylinux_test.go Adds missing Key field to rockylinux8 config
test/target_almalinux_test.go Adds missing Key field to almalinux8 config
website/docs/targets.md Documents subpackage feature with examples
docs/spec.schema.json Adds SubPackage/SubPackageDependencies to JSON schema

Comment thread packaging/linux/deb/template_rules_test.go
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 5413d66 to 08704e7 Compare June 15, 2026 20:46
@cpuguy83 cpuguy83 added this to the v0.22 milestone Jun 19, 2026
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 08704e7 to 00b43ce Compare June 25, 2026 20:52
cpuguy83 added 3 commits June 29, 2026 11:16
Introduce SubPackage and SubPackageDependencies types for supplemental
package support (subpackages from shared builds). Add Packages field to
Target, validation in Spec.Validate(), and full unit test coverage.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Add SubPackages() method and supporting types to produce %package,
%description, %files, and scriptlet sections for each supplemental
package. Refactor Install() to include subpackage artifacts in the
shared %install section. Includes comprehensive template-level tests.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Test RPMSpec() at the LLB layer by marshaling the returned state,
extracting protobuf ops, and asserting on Mkdir/Mkfile actions. Covers
default and custom directory paths, subpackage sections with default
and custom names, dependencies, sorted ordering, install artifacts,
wrong-target exclusion, and invalid spec error handling.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 00b43ce to 02c6335 Compare June 29, 2026 18:16
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for dalec ready!

Name Link
🔨 Latest commit 4231aa6
🔍 Latest deploy log https://app.netlify.com/projects/dalec/deploys/6a42cd36a2789f000813431e
😎 Deploy Preview https://deploy-preview-988--dalec.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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>
cpuguy83 added 3 commits June 29, 2026 12:43
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
The windowscross/zip target previously emitted only the primary package
and silently dropped any supplemental packages defined under a target's
`packages` block. Now a single build produces one zip per package
(primary + each supplemental), named
`<name>_<version>-<revision>_<arch>.zip`.

Build artifacts are staged into per-package directories so the zip and
container targets can address each package individually. Artifact `name:`
overrides are now honored for windows binaries, and chmod targets the
staged file rather than the source path (fixing a latent bug for keys
containing a slash).

Because a zip with no contents is meaningless, the zip target now errors
if any package (primary or supplemental) resolves to no artifacts. This
mirrors the "empty artifacts on Windows" requirement and differs from rpm
and deb, where an artifact-less metapackage is valid.

The windowscross container target installs the binaries from every
package, matching the linux container target which installs all packages
produced for the target.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the supplemental_packages branch from 02c6335 to 4231aa6 Compare June 29, 2026 19:53
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.

[REQ] Supplemental packages

2 participants