User Tools

Site Tools


linux:source_rpm

Installing Source RPM

Some useful links regarding RPM:

Basics

Heres an example on how to install Source RPMs on CentOS (or any other RPM driven distribution).

  • You need the package rpm-build
  • It is recommended to setup your normal user so that you can perform rpm operations with an unpreviledged user.
  • For more information about Building this environment see here for more details. Or just read on.
  • The easiest way is to use –rebuild: rpmbuild –rebuild /data/downloads/ctags-5.8-1.src.rpm
  • But since this can be pretty risky we do the steps on their own and see what happens:

Building the environment

# Creating the Building Environment for the unprivileged user.
(~/downloads) skull@dc:$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
(~/downloads) skull@dc:$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros

Or as an alternative just run this shellscript

(~) skull@dc:$ wget http://www.oldrpm.org/hintskinks/buildtree/RPM-build-tree.txt
(~) skull@dc:$ chmod 755 RPM-build-tree.txt
(~) skull@dc:$ ./RPM-build-tree.txt

Building the RPM

The Easy Way

# Preparation
(~) skull@dc:$ cd ~/build/
(~) skull@dc:$ mkdir foo
(~) skull@dc:$ cd foo

# Download and build
(~) skull@dc:$ wget http://www.google.com/foo-1.1.5-3.src.rpm
(~) skull@dc:$ rpmbuild --rebuild foo-1.1.5-3.src.rpm
(~) skull@dc:$ sudo rpm -Uvh ~/rpmbuild/RPMS/x86_64/foo-5.8-1.x86_64.rpm
(~) skull@dc:$ sudo yum upgrade

The Hard Way

Building

#
# The following commands all take place as a normal user.
#
(~/downloads) skull@dc:$ wget http://prdownloads.sourceforge.net/ctags/ctags-5.8-1.src.rpm

# Let's check the file first:
(~/downloads) skull@dc:$ file ctags-5.8-1.src.rpm
ctags-5.8-1.src.rpm: RPM v3.0 src

# Create tmp
(~/downloads) skull@dc:$ mkdir ~/tmp
(~/downloads) skull@dc:$ mv ctags-5.8-1.src.rpm ~/tmp/

# Check content
(~/tmp) skull@dc:$ rpm -qpl ctags-5.8-1.src.rpm
ctags-5.8.spec
ctags-5.8.tar.gz

# Install the Source
(~/tmp) skull@dc:$ rpm -i ctags-5.8-1.src.rpm

# RPM now then extracts the SPECFILE and the ~/rpmbuild/SPECS
# Other files (usually a tarball) gets placed in ~/rpmbuild/SOURCES

To build the actual .rpm file we have to use rpmbuild:

(~/tmp) skull@dc:$ cd ~/rpmbuild/SPECS
(~/rpmbuild/SPECS) skull@dc:$ rpmbuild -ba mypackage.spec

Installing

Finally our RPM is ready for install.

(~) root@dc:$ cd /data/skull/rpmbuild/RPMS/x86_64/
(/data/skull/rpmbuild/RPMS/x86_64) root@dc:$ rpm -i ctags-5.8-1.x86_64.rpm
(/data/skull/rpmbuild/RPMS/x86_64) root@dc:$ rpm -qa | grep ctags
ctags-5.8-1.x86_64
linux/source_rpm.txt · Last modified: 2012/05/20 21:06 by skull@darktemple.ch