Google Site SearchFN Site Search FN Blog Login FN Blog Login
Site Navigation:
 
 

HOWTO: How to create rpmbuild directory

by Thomas Chung on Jan 10, 2004 (updated 2005-11-17)

To build RPMS as a local user, you need to create rpmbuild directory in your home directory.
Thanks to Rui Miguel Seabra's suggestion.

[tchung@localhost tchung]$ cd ~
[tchung@localhost tchung]$ cp -a /usr/src/redhat/ rpmbuild
[tchung@localhost tchung]$ echo '%_topdir %(echo $HOME)/rpmbuild' >> .rpmmacros

Another method to create rpmbuild directory in your home directory is using fedora-rpmdevtools
Thanks to Mr. Warren Togami's suggestion.

1) Install fedora-rpmdevtools binary RPM from Fedora Extras for your Fedora release.
   $ sudo yum install fedora-rpmdevtools

2) As a non-root user, run fedora-buildrpmtree to create rpmbuild directory.
   $ fedora-buildrpmtree
Thanks to Jef Spaleta's suggestion, here is another way of building RPM as non-root:
ftp://people.redhat.com/mharris/hacks/rpmbuild-nonroot-1.0.tar.gz

Also it's good idea to add yourself in the /etc/sudoers file

# User privilege specification
root    ALL=(ALL) ALL
tchung  ALL=(ALL) ALL

So you can install binary RPMS with sudo command as a local user
Notice in below that you can't install RPMS as a local user but you CAN if you use sudo command.

[tchung@localhost i386]$ ls
acroread-5.0.8-fc1.i386.rpm
[tchung@localhost i386]$ rpm -Uvh acroread-5.0.8-fc1.i386.rpm
error: cannot get exclusive lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
error: cannot open Packages database in /var/lib/rpm
[tchung@localhost i386]$ sudo rpm -Uvh acroread-5.0.8-fc1.i386.rpm
Password: (enter your password NOT root password)
Preparing...                ########################################### [100%]
   1:acroread               ########################################### [100%]
[tchung@localhost i386]$

Once a user has been authenticated, a timestamp is updated and the user may then use sudo 
without a password for a short period of time (5 minutes by default).

TIP by Forrest Taylor

You might also add '%debug_package %{nil}' to .rpmmacros to avoid building the debug packages. echo '%debug_package %{nil}' >> .rpmmacros