Rpm Building as a User

RPM Building as a User

Build rpms as normal user, without root priviledges. Make system
wide settings, so that all users can build rpms in their home directory.
Basic knowlegde about RPMs is expected, if you need that see links at
the bottom of the page.

Even though many guides teach how to build RPMS (the right way) as a
non-root user, this the first howto I have seen that has an example of system wide
rpmmacros for building rpms in home directory.

(c) Tero Karvinen

Marathi translation (pdf)
contributed by Dhanashree Nagre. Marathi is
a language spoken in Maharashtra, India. That’s where Mumbai is located.

Install rpm-build


yum -y install rpm-build

If you do not have root, you can rpm -q
rpm-build
to see if
rpm-build is installed and ask your administrator to install it. If you have
root but not yum, see my yum howto.

Install default settings

Copy this to /etc/rpm/macros


# /etc/rpm/macros
# (c) GPL 2003 Tero.Karvinen at-sign iki.fi
%packager %(echo "$USER")
%_topdir %(echo "$HOME")/rpmbuild
%_rpmtopdir %{_topdir}/%{name}
%_builddir %{_rpmtopdir}/BUILD
%_rpmdir %{_rpmtopdir}
%_sourcedir %{_rpmtopdir}
%_specdir %{_rpmtopdir}
%_srcrpmdir %{_rpmtopdir}
%_tmppath %{_rpmtopdir}/TMP
%_buildroot %{_tmppath}/%{name}-root

# Build rpms in your home directory, without root priviledges
# Users can copy this file to $HOME/.rpmmacros to override
# settings, such as packager to "Firstname Lastname email".
# Example of typical directory and file hierarchy for
# rpm building:
#  ~/rpmbuild/
#  ~/rpmbuild/nano/ # replace nano with rpm name
#  ~/rpmbuild/nano/TMP/
#  ~/rpmbuild/nano/BUILD/ # user must create this dir
# and files (can be extracted from a source rpm with
#  rpm2cpio *.src.rpm |cpio -dvi
#   ~/rpmbuild/nano/nano-1.2.tar.gz
#   ~/rpmbuild/nano/nano.spec
# Then you can build your rpm with
#  rm -rf TMP/* BUILD/* ; rpmbuild -ba *.spec 2>&1 |tee rpmbuild.log
# For more information, see www.iki.fi/karvinen

If you do not have root, you can copy the above file to $HOME/.rpmmacros

Troubleshooting

error: File /usr/src/redhat/SOURCES/nano-1.2.0.tar.gz: No such file or directory"
when trying to rpmbuild -ba *.spec.
Solution: rpmbuild can not see your /etc/rpm/macros or
$HOME/.rpmmacros.
See instructions above.

Can not write to /var/tmp/nano-1.2-1-root. Solution: change the buildroot in
spec file to Buildroot: %{_buildroot}

What “Group:” entry should I use? Solution: To see all valid groups less /usr/share/doc/rpm-*/GROUPS

Links

Saou 2003: The Fight This is where I first saw
instructions for building RPMs as a non-root user.

Red Hat 2000: Maximum RPM Considered the
most important reference manual about rpm. Badly outdated, talks about rpm where it should
be rpmbuild.

Fedora.us Wiki: Fedora Documents: Packaging Standards and
Fedora spec template.

Saou 2003: Freshrpms spec files online.

Local documentation provided with rpm in /usr/share/doc/rpm-*/, man rpm and man rpmbuild.

Harris 2003:
rpmbuild-nonroot-1.0.tar.gz
Commented .rpmmacros and .rpmrc, GPG signing.

Fox and Peddington (Redhat Inc) 2003: Fedora
Project Developer’s Guide: Chapter 4. Building RPM Packages
. Fedora Core packaging
guidelines and tips.

Copyright and meta

Tested with redhat 9.0 Shrike.

Copyright 2003-05-17, 2003-07-07, 2003-09-28, 2003-11-12 Tero Karvinen. GNU Free
Documentation License.
XHTML Basic 1.0

Posted in Old Site | Tagged , , , , | Comments Off on Rpm Building as a User

Comments are closed.