How to change rpmbuild default directory form /root/rpmbuild directory to other
centos, linux, rhel, rpm, rpmbuild
Solution
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*}
Problem
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.