Reputation: 5601
I have to build a rpm package for some drivers. I need to build the rpm from a .tar.gz archive. The tar ball also contains the .spec file. I have set up my rpmbuild environment as described here: http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
My directory structure is thus:
/home/rpmbuild
/home/rpmbuild/BUILD
/home/rpmbuild/RPMS
/home/rpmbuild/SOURCES
/home/rpmbuild/SPECS
/home/rpmbuild/SRPMS
The .tar.gz file contains the specfile and is placed in /home/rpmbuild/SOURCES
If I then navigate to that directory and run the following, the rpm package is built correctly, but is placed in /root/rpmbuild/RPMS instead of /home/rpmbuild/RPMS (where I expected it to be).
sudo rpmbuild -ta driver.tar.gz
I assume this is because I ran rpmbuild with sudo. Am I thinking of this correctly? Is there a way to direct it to build in /home/rpmbuild instead?
I know it is bad practice to use rpmbuild as root, but if I don't run it as root I run into many errors (not having permissions to access directories owned by root - like /tmp/orbit-root). It seems like it would be much more difficult to change the permissions of each of these directories then to change them back.
Is this the correct way to go about this? I greatly appreciate the help.
Upvotes: 13
Views: 19747
Reputation: 824
the non-privileged user should have access to BUILDROOT
. I would check .rpmmacros
file inside $HOME/rpmbuild
, it defines where is your top directory.
I have setup my .rpmmacros
like this:
%packager YourName
%_topdir /home/build/rpmbuild
%_tmppath /home/build/rpmbuild/tmp
Upvotes: 2
Reputation: 2390
If you are needing non-root write permission on system directories,
then your %install
scriptlet is not installing into %{buildroot}
.
You will need to patch your build to install into %{buildroot}
.
For autoconf generated Makefiles this is often done like
make DESTDIR=%{buildroot} ...
Upvotes: 0
Reputation: 325
Don't create setup-tree for rpm with command as:
rpmdev-setuptree
Make rpm tree where you want to build the rpm with the command as given below:
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
Now, copy the appropriate files in the folders as specs and tar.gz and run the following command in the rpmbuild directory:
rpmbuild --define "_topdir `pwd`" -v -ba SPECS/{*spec_file.specs*}
Upvotes: 20
Reputation: 8389
To keep build files out of the default location, I specify a different build root by using the --root
option to rpmbuild
:
rpmbuild --root /home/rpmbuild -ta driver.tar.gz
It'll treat that directory as the total root and attempt to use /home/rpmbuild/root/rpmbuild/{BUILDROOT,RPMS}
and /home/rpmbuild/root/rpmbuild/var/tmp
. The latter you may need to create before invoking the command. You can remove the /root/
part of the name by prefixing the rpmbuild
command with HOME=""
.
Upvotes: -1