Repository navigation
package: Share the package build plumbing of rpm.package() - #378
Merged
Merged
Conversation
martinpitt
reviewed
Nov 2, 2026
martinpitt
left a comment
Member
There was a problem hiding this comment.
Thanks! Looks mostly good, but one blocker.
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>
daandemeyer
force-pushed
the
package-build-prep
branch
from
November 2, 2026 09:43
a38b728 to
0ed817b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.