Skip to content

package: Share the package build plumbing of rpm.package() - #378

Merged
martinpitt merged 10 commits into
amutable:mainfrom
daandemeyer:package-build-prep
Nov 2, 2026
Merged

martinpitt merged 10 commits into
amutable:mainfrom
daandemeyer:package-build-prep

Conversation

@daandemeyer

@daandemeyer daandemeyer commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

The buildroot delta, the packaging pin driver, the subpackage check, the rule plumbing and the driver setup
of package builds live in the rpm rule and driver, while the makepkg and Debian package builds need the
same steps. This moves them into package/ so every package system can use them, without changing what an
rpm build does. It also refuses a buildroot of another package system at analysis, gives rpm.package() an
optional distro, makes the shared source date epoch optional for Debian builds, and lets the pin driver
check out a single directory of the pinned commit.

The last commit fixes rpm source-tree builds of meson projects, whose debugsource package had no files and
failed the build. examples/package/rpm builds the checkout with meson to cover it.

@martinpitt martinpitt left a comment

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.

Thanks! Looks mostly good, but one blocker.

Comment thread package/subpackage.py Resolved
Comment thread package/packaging.py Resolved
Comment thread package/build.bzl Resolved
rpm.package() installs a package's BuildRequires as a delta over the shared
base buildroot, and the code to do so lives in the rpm rule. A makepkg rule
needs the same delta. Let's move it into package/buildroot.bzl so both rules
can use it.

Signed-off-by: Daan De Meyer <daan@amutable.com>
The driver that checks out a pinned packaging commit contains no rpm code. It
fetches a git branch and writes out a tree. A makepkg rule needs the same pin
to build a checkout with a pinned PKGBUILD. Let's move the driver and the
action that runs it to package/ so both package systems can use them.

Signed-off-by: Daan De Meyer <daan@amutable.com>
The rpm build driver matches the packages that rpmbuild wrote to the
subpackages that the target declares, and exposes each one as a sub-target.
The makepkg and Debian build drivers need the same check with other file
names. Let's move it into package/subpackage.py. The caller passes the pattern
of a file name after the package name, separator included, and the pattern of
the debug packages that the build tool adds on its own.

Signed-off-by: Daan De Meyer <daan@amutable.com>
rpm.package() installs the build's dependencies over the base buildroot, runs
its build driver and returns its outputs and providers, and its macro checks
the packaging pin arguments. Rules that build Arch and Debian packages need
the same steps and attributes. Let's move them into package/build.bzl.
package_build() declares the subpackage files with project.binaries_dir(), so
a duplicate or malformed subpackage name, or one named build or buildroot like
a built-in sub-target, now fails at analysis.

Signed-off-by: Daan De Meyer <daan@amutable.com>
rpm.package() takes no distribution, so a Fedora release that serves fewer
architectures than the catalog would break the analysis for the other
architectures. Let's give rpm.package() an optional distro, which makes the
target incompatible with an architecture that its release doesn't serve.
Imported packages name none and keep their current configuration.

Signed-off-by: Daan De Meyer <daan@amutable.com>
A package build rule runs the build driver of its buildroot's package system.
Once a second package system builds packages, a rule on a buildroot of that
system would run its driver on the rule's spec and fail late with a spec
error. Let's give each rule its own package system and refuse a buildroot
whose package manager installs packages of another one at analysis.

Signed-off-by: Daan De Meyer <daan@amutable.com>
The rpm build driver sets up a scratch tree and makes the project read-only.
It mounts the source tree in an overlay, mounts the kept build directory,
captures the tree after the build and removes it on success. The order of
those steps matters, and the makepkg and Debian build drivers need them too.
Let's move them into package/builder.py.

Signed-off-by: Daan De Meyer <daan@amutable.com>
A Debian source package dates its build with the top entry of
debian/changelog. dpkg-buildpackage uses that date when SOURCE_DATE_EPOCH is
unset, so a Debian build rule can't share an attribute that requires the
epoch. Let's make the shared source_date_epoch optional, and require it in
the rpm.package() macro instead.

Signed-off-by: Daan De Meyer <daan@amutable.com>
The packaging pin driver checks out the whole tree of the pinned commit. A
Debian packaging repository contains the upstream sources and their history
next to debian/, so a Debian build would fetch all of them to use one
directory. Let's take that directory from the caller, and fetch the commit
without the contents of the files outside it.

Signed-off-by: Daan De Meyer <daan@amutable.com>
An rpm build of a meson source tree fails because its debugsource package has
no files:

    error: Empty %files file /build/BUILD/hello-1-build/hello-1/debugsourcefiles.list

rpmbuild --build-in-place runs the build in a symlink to the checkout, and
find-debuginfo only collects the sources under the path of that symlink. ninja
starts the compiler in the meson build directory, and the compiler then
records the real path of the checkout. Let's map the real path of the checkout
to the path of the symlink through Fedora's hooks for extra C, C++ and Fortran
build flags. A spec that compiles with %{optflags} instead, or a Rust package,
doesn't get the map, since Fedora has no hook there.

Signed-off-by: Daan De Meyer <daan@amutable.com>

@martinpitt martinpitt left a comment

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.

Thanks!

@martinpitt
martinpitt merged commit 06a35d2 into amutable:main Nov 2, 2026
5 checks passed
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.

2 participants