Total Pageviews

Sunday, 20 May 2012

Building an RPM in Fedora 16 example grive

Hi there,

We are going to create an rpm from an existing Open Source project called grive which is a client for Google Drive.
The project only provides a tar.gz which we are to use to build our RPM.


First of all create a user, or you can use your own user, but never use root to build an rpm.

I assume you are using Fedora, then you need to install the development tools.

yum install @development-tools
yum install fedora-packager

* Also make sure you have the following libraries installed

cppunit
libstdc++
libstdc++-devel
json-c
json-c-devel
openssl
openssl-devel
expat
expat-devel
cppunit
libcurl
libcurl-devel
gdbm-devel
gdbm
cmake
cmake-fedora

* yum install cppunit libstdc++ libstdc++-devel json-c json-c-devel openssl openssl-devel expat expat-devel cppunit libcurl libcurl-devel gdbm-devel gdbm cmake cmake-fedora

**this libraries are necessary to compile and build the rpm.

1. Create the required directory structure in your home directory by executing rpmdev-setuptree, that command will create the following tree of directories which you will use to build your rpm.


$HOME/rpmbuild/
├── BUILD
├── BUILDROOT
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS

2. Put the match065-grive-50f1d81.tar.gz that you can download from https://github.com/manuken/grive/downloads
in the SOURCES directory.

$HOME/rpmbuild/SOURCES/
└── match065-grive-50f1d81.tar.gz

3. Download the grive.spec file from
https://github.com/manuken/grive/tree/master/Fedora%2016%20RPM and put it in SPECS. The spec files contain all the information needed to build the RPM. Have a look at it it's important to understand it.

/home/jbustos/rpmbuild/SPECS/
└── grive.spec

4. And now you can build the rpm by using the following command

rpmbuild -ba ~/SPECS/grive.spec

5. You will find the RPM built in the RPMS directory

/rpmbuild/RPMS/
└── x86_64
├── match065-grive-50f1d81-5.fc16.x86_64.rpm
└── match065-grive-debuginfo-50f1d81-5.fc16.x86_64.rpm

6. Now you can install your RPM.
yum localinstall match065-grive-50f1d81-5.fc16.x86_64.rpm

** By running yum localinstall all the depencencies will be automatically resolved for you.
To understand better the spec file and to know more about building an rpm you can check the documentation here

No comments: