How to set the rpmbuild destination folder
Asked Answered
B

5

24

I noticed rpmbuild (-bb and --buildroot options) creates the .rpm in different locations depending of what OS are you using:

  • GNU/Linux Ubuntu <= 9.04: /usr/src/rpm/...
  • GNU/Linux Ubuntu >= 9.10: /home/rpmbuild/...
  • GNU/Linux Fedora: /usr/src/redhat/...

So how can I set manually the destination folder for all OS?

Byroad answered 6/5, 2010 at 0:52 Comment(1)
also related #6286292Jesuit
B
23

Replying myself, adding:

%define _rpmdir /outputdir

to .spec file.

Byroad answered 6/5, 2010 at 10:44 Comment(0)
P
13

You may want to use the command argument --define : For example, this will send the rpm files into the current directory.

rpmbuild anything.spec --bb --define "_rpmdir $(pwd)"

This will send the rpmsto output dir

rpmbuild anything.spec --bb --define "_rpmdir /outputdir"

Or perhaps something more complicated such as Custom gradle task for rpmbuild .

Photosphere answered 17/6, 2016 at 8:44 Comment(0)
T
3

For me the solution was to set _topdir to a subdirectory called rpmbuild inside my project. I also set a few macros, to control the .rpm path:

rpm:
rpmbuild -bb package.spec -D "_topdir $(shell pwd)/rpmbuild"  -D "SRC $(shell pwd)" -D "NAME $(NAME)" -D "ARCH $(ARCH)" -D "VERSION $(VERSION)" -D "RELEASE $(RELEASE)"
mv rpmbuild/RPMS/$(ARCH)/$(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm ./
rm -rf rpmbuild

Then I use make to generate the .rpm file and move it. I prefer rpmbuild to operate inside its directory.

make rpm

package.spec is using these macros, e.g.

Name:           %{NAME_PACKAGE}
Thusly answered 22/6, 2019 at 11:30 Comment(1)
I use the option --build-in-place, too.Shayna
F
2

Just a tiny comment.. adding "%define _rpmdir /outputdir" to spec file is also support by rpmbuild in AIX OS

Fertilizer answered 13/2, 2018 at 14:58 Comment(0)
B
1

Setting up the rpmbuild environment in /home/ http://www.linuxquestions.org/questions/linux-software-2/need-rpm-package-for-php-version-5-2-7-and-up-on-redhat-5-1-a-766486/#13

Actually it is not recommended to use /usr/src/**. I.e. by using /home/[name]/rpms/ you can work as unprivileged user. No su or sudo is required to build packages.


Besmirch answered 19/6, 2016 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.