Swathantra Malayalam Computing




Building a RPM (hands on using smc-malayalam installation)


Introduction

Building a rpm package is quite easy. All you need to do is to create a spec file and execute the spec file and the rpm builder will create a rpm package for you! The spec file consists of various things like what all files go into the rpm, pre-requisite packages for rpm, etc. For this project, I built the rpm from a source tarball. This rpm is going to contain only the files present in tarball and nothing else. So, its quite easy to build !

Pre-requisites

1.To build a rpm, you need rpm-build package. Make sure that you have installed it.
2.You need to create a directory structure (if it doesnt exist). Please make sure that you have the following (or create it if you dont)

/usr/src/redhat/SPECS
/usr/src/redhat/SOURCES
/usr/src/redhat/BUILD
/usr/src/redhat/RPMS
/usr/src/redhat/SRPMS

This is the default directory structure for building any rpm package. The spec file must be placed in the SPECS directory and the source (or tarball) file must be placed in the SOURCES folder. I placed malayalam-gnome-1.0.tar.gz in SOURCES folder and the malayalam-gnome-1.0.spec in the SPECS folder.

Building a RPM

Firstly, we have to create a rpm spec file. The spec file file that I have created for this project is quite simple.

The first part of the spec file is the header and it contains all the description for the rpm. Please note that the version and name of spec file and the source file must match (in our case it is malayalam-gnome-1.0).

Summary, Name, version, Release, Copyright, Group, Source, Packager are all self explanatory. The "Requires" field contains the dependencies of the final rpm package. The dependency package used here is pango. This means that the final rpm package (malayalam-gnome-1.0.rpm) depends on pango and pango must be installed before attempting to install the final build rpm. I have specified the version number of pango also. The minimum requirement is pango-1.2.

After the header, there is the body of the spec and this contains of various macros. %description macro is self explanatory. %prep macro takes the tarball (as mentioned in name field in header) from source directory, explodes it and places all the files in the BUILD directory. We are going to create a rpm from this. We dont need the other macros but I have just added it for namesake. We dont need other macros as we are not going to build the tarball but rather place all the files as it is from tarball to a rpm. So, we can skip %setup,%build,%install,%clean. I have added what each macro does in comments. Note that we dont need %prep macro also for building a rpm for our project. As, %prep places the files in the BUILD directory. But, our tarball (malayalam-gnome-1.0) does not need to be built but rather executed. So, what I do is place all the files in the directory mentioned in %files macro. So, what %files does is it adds the list of files into the rpm and then rpm is executed, it puts these files in that folder.

For example, we need /usr/share/fonts/malayalam folder. So, I create this folder and mention it in %files and when a person X installs the final rpm, the /usr/share/fonts/malayalam is created in his m/c. So, we list out the files that need to be in the rpm. %changelog is self explanatory.

Save the spec file and open a xterm and goto /usr/src/redhat/SPEC folder.

Note : Make sure you have to src tarball in SOURCES folder.

$> rpmbuild -ba malayalam-gnome-1.0.spec

This should take care of it. If you need the rpm for a specific platform (i386,....), specify

$> rpmbuild -ba -target i386 malayalam-gnome-1.0.spec

If you check in RPMS folder, you will see a folder called i386 and it will contain the rpm. You can check SRPMS for sourcs rpm package.


(C) Swathantra Malayalam Computing

Trademarks are owned by their owners.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software Foundation;
A copy of the license is located at www.gnu.org/copyleft/fdl.html, in the section entitled "GNU Free Documentation License".
The information given in this document is believed to be correct, the author will accept no liability for the content of this document.
Use this document at your own risk.

Questions, Comments, Corrections? Email webmaster