Reputation: 1771
I am making some config packages which are built by Jenkins, then checked out whenever they are needed. The package itself is built and runs fine. My problem right now is the directories that rpmbuild uses for actually building the project. When I call rpmbuild SPECS/package.spec from my working directory, rpmbuild makes a new directory at /home/user/rpmbuild
. This was fine when I was running tests but I would rather that I just be able to build from whatever file it is called from for the Jenkins process.
I see online people saying to make a ~/.rpmmacros
file to overwrite the $_topdir
variable. That approach isn't really working for the Jenkins build. Is there some way to simply call rpmbuild and build in the current directory? The structure is all there and it would work better for what I am trying to do. Thanks.
Upvotes: 2
Views: 950
Reputation: 485
Adding --define
to the rpmbuild
call may not be an option if rpmbuild
is e.g. in a Makefile of the sources which then need to be modified.
However, %{_topdir}
is based on $HOME
so you could try to run rpmbuild
in a modified environment where you could redefine $HOME
:
$ HOME=my/topdir rpmbuild -E %{_topdir}
my/topdir/rpmbuild
Also, ~/.rpmmacros
isn't the only location where you can define RPM macros, others are e.g. /etc/rpm/macros
which may be more appropriate to setup a Jenkins agent machine. In these macros files you can use environment variables including Jenkins-specific ones.
Upvotes: 0
Reputation: 81022
Yes, just override _topdir
directly.
rpmbuild -D '_topdir /new/value/for/_topdir'
or
rpmbuild --define='_topdir /new/value/for/_topdir'
those should be identical but I've learned that they aren't always for some reason (and in quick tests rpm -D '_topdir /opt/tnstmp' --showrc | grep _topdir
doesn't show the modified value but rpm --define '_topdir /opt/tnstmp' --showrc | grep _topdir
did).
Upvotes: 3