SRC RPM tips

Discuss Programming
Post Reply
User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

SRC RPM tips

Post by Void Main »

It's a good idea not to install and build SRC RPMs as root. I won't go into detail why but you can read more about it here:

I do suggest reading the above link for anyone who ever uses SRC RPM files or want to build their own. What I'm about to say I devised from reading the above.

The key to installing and compiling source RPMs as someone other than root is to either create your own RPM directory structure somewhere other than /usr/src/redhat (or /usr/src/rpm on other distros). You could alternately change the permissions on the /usr/src/redhat directory structure so your user has permissions to write to it but I suggest just localizing the structure to your userid. If you have a nice clean /usr/src/redhat/* structure you can copy it to your home directory by doing this:

$ cp -a /usr/src/redhat ~/redhat

(or "cp -a /usr/src/rpm ~/rpm")

Now you'll want to create a ~/.rpmmacros file so RPM knows where your build directory is when you are doing this from your own userID. Here's what my ~/.rpmmacros file looks like:

Code: Select all

%packager               Void Main
%distribution           Void Main RPMS (RH8)
%_signature             gpg
%_gpg_name              Void Main
%_topdir                /home/voidmain/redhat
%_tmppath               /var/tmp/rpm
%_rpmtopdir             %{_topdir}
%_builddir              %{_rpmtopdir}/BUILD
%_rpmdir                %{_rpmtopdir}/RPMS
%_sourcedir             %{_rpmtopdir}/SOURCES
%_srcrpmdir             %{_rpmtopdir}/SRPMS
%_specdir               %{_rpmtopdir}/SPECS
You only really need form "%_topdir" on down to the end. I just added some other useful variables for when I build my own RPMS. And of course you'll want to change "/home/voidmain/redhat" to whatever is the root of your new RPM build directory structure.

Now under your normal user account you can install "src.rpm" files and use all the "rpmbuild" commands on it and all the work will be done in the RPM directory structure under your home directory.

I believe it is most important not to actually build RPMs as root because it is easy to make a mistake in your SPEC file that could wipe out some of your key directory structures of you aren't careful. Aw heck, just read the doc I linked to and ignore all my drivel. It's not a long read and it's fun.

Posts: 689
Joined: Wed Jan 08, 2003 10:40 am

Post by Tux »

iiiinteresting, that was a nice little doc. Not revolutionary, but nice :)

Post Reply