This is somewhat similar to #545, except it doesn't require generated buildrequires or an attempted local build. In fact, quite the opposite.
If a package uses macros in its .spec that come from a BuildRequires: package that's not currently installed, that spec file can't be parsed by any rpmbuild commands except rpmbuild -bd. Attempting to use any other rpmbuild -bx mode will result in an immediate "error: Failed build dependencies" exit.
.spec
BuildRequires:
rpmbuild
rpmbuild -bd
rpmbuild -bx
But unlike rpmbuild -bp, or indeed fedpkg local, fedpkg prep will just attempt to barrel through without checking that the package dependencies are satisfied. That can lead to it tripping over the undefined macros, which causes it to fail with a significantly more confusing / less helpful error.
rpmbuild -bp
fedpkg local
fedpkg prep
For example, running In rpms/ignition/, on a system lacking the go-rpm-macros package that defines some of the macros used in ignition.spec:
rpms/ignition/
go-rpm-macros
ignition.spec
### RPMBUILD -BP $ rpmbuild -bp ignition.spec setting SOURCE_DATE_EPOCH=1737072000 error: Failed build dependencies: go-rpm-macros is needed by ignition-2.20.0-3.fc41.x86_64 ### FEDPKG LOCAL $ fedpkg --release f41 local Not downloading already downloaded ignition-2.20.0.tar.gz Not downloading already downloaded ignition-edge-b8d1b7a.tar.gz setting SOURCE_DATE_EPOCH=1737072000 error: Failed build dependencies: go-rpm-macros is needed by ignition-2.20.0-3.fc41.x86_64 ### FEDPKG PREP $ fedpkg --release f41 prep Not downloading already downloaded ignition-2.20.0.tar.gz Not downloading already downloaded ignition-edge-b8d1b7a.tar.gz setting SOURCE_DATE_EPOCH=1737072000 Executing(%mkbuilddir): /bin/sh -e /var/tmp/rpm-tmp.o8G7ZC + umask 022 + cd /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + test -d /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + /usr/bin/rm -rf /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + /usr/bin/mkdir -p /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + /usr/bin/mkdir -p /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build/SPECPARTS + RPM_EC=0 ++ jobs -p + exit 0 Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.fxLvCu + umask 022 + cd /home/ferd/rpmbuild/REPOS/fedora/ignition/ignition-2.20.0-build + %goprep -k /var/tmp/rpm-tmp.fxLvCu: line 34: fg: no job control error: Bad exit status from /var/tmp/rpm-tmp.fxLvCu (%prep) RPM build errors: Bad exit status from /var/tmp/rpm-tmp.fxLvCu (%prep) Could not execute prep: Failed to execute command.
It's a nice idea, to try and make a package prep-able without having to worry about satisfying its build dependencies, but specfile macro packages are where that breaks down. Satisfying the BuildRequires really is a prerequisite for even attempting to prep a package, in many cases.
prep
Checking rpmbuild -bd as a first step in fedpkg prep would put it on par with fedpkg local, in terms of failing with a useful message indicating the nature of the error when macro packages are missing. Rather than (as it does currently) exiting with a confusing error that gives no hint as to the actual nature of the problem.
Possible fix: https://pagure.io/rpkg/pull-request/731
Commit 6f0c200f fixes this issue
I left a comment in https://pagure.io/rpkg/pull-request/731, but I was thinking more... maybe I'm looking at this the wrong way.
The reason fedpkg prep fails on the ignition package, specifically, is because its spec uses the %goprep macro in %prep, and %goprep is defined in go-rpm-macros. It doesn't even actually have a BuildRequires on go-rpm-macros, that's inserted automatically by %gometa which is defined in go-srpm-macros which, unlike go-rpm-macros, is basically always available. (It's required by redhat-rpm-config.)
%goprep
%prep
BuildRequires
%gometa
go-srpm-macros
redhat-rpm-config
But if %goprep is required to prep the package, maybe it should ALSO be defined in go-srpm-macros so that it's always available. Even if prepping isn't technically part of the srpm-building process.
Metadata Update from @onosek: - Issue set to the milestone: 1.46