Reputation: 12522
I'm trying to build my own rpm package and have a couple of doubts.
First of all, in several places I've red that one shouldn't build rpms as root. Why is that? During the building process, rpmbuild has to go through the install stage where it installs files to the system.
As far as I understand I can't do that if I'm not root. rpmbuild process finishes with error. So, the question is if it is really possible to build an rpm without installing stuff into the system? Or eventually I do have to become root to complete the build process?
Upvotes: 3
Views: 2309
Reputation: 1529
Let your system know where u want to build your package - see $HOME/.rpmmacros file for the '_topdir' value:
rpm --eval %{_topdir} # get your current value
Second u want to change its your build root value:
rpmbuild --buildroot=[path] ..
(--buildroot key only get capability non-root user to build own rpm packages)
correct me, if something wrong that i say.
Upvotes: 0
Reputation: 3350
If you build RPMs on the live filesystem, you WILL overwrite what's already there. This is an unintended side effect of the build process and should be avoided at all costs.
The correct way of building RPMs is to have all files installed into a staging directory (usually in /var/tmp
). This avoids any conflicts with the live system and can help you ensure that:
None of this requires root privileges. If your RPM build script needs root to run, you're Doing It Wrong.
Since it does not require root privileges, you should not run it as root. Avoid running as root whenever possible.
Upvotes: 7