Skip to main content.

Saturday, September 01, 2007

I've been searching for days for a way to create RPM packages without the need of being root (that is, system administrator).
Normally, RPM builds packages by searching source files and unpacking them in the /usr tree; to put source files there, you have to be administrator, and that was the problem.

I wanted to have all the RPM build system in another place, like i.e. /home/myself/rpm/..., but tutorials and directions on the net on how to do that was sloppy, or outdated, or not working, or the three of them. I understood that there was the need to change the _topdir variable that is defined in the RPM system. I tried to set it to my preferred directory in the spec, but it didn't work; also, using personalized rpmrc file (in /etc, in my home as .rpmrc, as a custom file using command line switches to load it) but I kept having errors (something about _topdir used as an invalid token).

Finally, I found the little code that does the magic in a RedHat mailing list archive:

$ export RPM_TOP_DIR=/your/preferred/directory
$ rpmbuild --define "_topdir $RPM_TOP_DIR" -ba <specfile>

This works great. As a side note, this small code can create the tree that rpmbuild will use:

mkdir -p \
$RPM_TOP_DIR/BUILD\
$RPM_TOP_DIR/RPMS\
$RPM_TOP_DIR/i386\
$RPM_TOP_DIR/SOURCES\
$RPM_TOP_DIR/SPECS\
$RPM_TOP_DIR/SRPMS

Comments

No comments yet

Add Comment

This item is closed, it's not possible to add new comments to it or to vote on it