Tuesday, January 18, 2011

Creating an RPM Package



Hello Again Readers,

WARNING: All tasks performed in this post must NOT be done as the root user.

This post will discuss my experiences on creating an RPM Package based on the tarballs (packages) from my previous post -- gnupg-1.4.11 & wdiff-0.6.5, also including a step by step procedure on how I was successful.

Before beginning an RPM build you need to ensure you have the following installed; Fedora Packager (yum groupinstall "Fedora Packager"), this will automatically install rpmlint.

Note: yum-utils came pre-installed for me on Fedora 14 after performing a system update using the "yum update" command.

After the necessary packages were installed we then need to build the required RPM tree structure where RPM packaging will take place this can be done by using the "rpmdev-setuptree" command. This command will create the following directory structure;

[root@gcasella-fc14 ~]$ tree rpmbuild/
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS

Next I will provide the necessary commands and expected output to successfully build an RPM Package.


Step 1: I placed the source (.tar.gz) files into the ~/rpmbuild/SOURCES/ directory.

Step 2: Changed my current working directory to the ~/rpmbuild/SPECS/ directory and create a new spec file using the rpmdev-newspec <filename>.

Step 3: For the purpose of this post I will show a sample spec file that I had used for my gnupg-1.4.11.tar.gz RPM build. (The spec file can be found here http://fpaste.org/w9kr/)

Step 4: When the spec file was configured properly I ran the rpmbuild -ba <spec-filename> and waited for the build to complete. (Note: Some builds may take longer than others)

Step 5: If the build returned with no errors you should be able navigate to the ~/rpmbuild/RPMS/ and ~/rpmbuild/SRPMS/ directories and find your two newly created RPM Packages.

Step 6: I then tested my newly created RPM Packages by using the rpmlint  command on each of the following;
rpmlint ~/rpmbuild/SPECS/<spec-filename>
rpmlint ~/rpmbuild/RPMS/<new-RPM-package.rpm>
rpmlint ~/rpmbuild/SRPMS/<new-SRPM-package.src.rpm>
Note: The rpmlint command will show any errors/warnings that may be needed to fix before releasing.


Problems While Building

The only real problem I ran into while Building an RPM Package was during the actual build I would be told that a specific directory would not exist. I then noticed the "Name" and "Version" values MUST be the same as the name and version of the package. For example, if you use the gnupg-1.4.11.tar.gz package your spec file must contain the two pieces of data within the meta-data.
Name: gnupg
Version: 1.4.11
This was the only error that I've encountered throughout my attempts to build an RPM Package.


Where To Find My Files! 
gnupg-1.4.11 Files
RPM
SRPM
wdiff-0.6.5 Files
SRPM

Gian-Luca Casella -- Last Updated on Wednesday January 26th, 2011

Saturday, January 15, 2011

Building from Source Code

For this post I have chosen to build the following two packages from the GNU Software Collection;

       GnuPG -- Version 1.4.11
       wdiff -- Version 0.6.5

These two packages can be obtained by using the following two commands;
       wget ftp://ftp.gnu.org/gnu/wdiff/wdiff-0.6.5.tar.gz
       wget ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.11.tar.gz

After I downloaded the two packages I extracted the contents using the tar -zxf command. I then issued the ./configure command in both directories that were created after extracting the two packages.

While using the ./configure command I ran into no problems, all the required dependencies were already installed on my Fedora 14 System. Once the ./configure command returned successful I used the time make command for both packages, the results of this command are listed below;

          gnupg-1.4.11
          real    0m38.872s
          user    0m32.281s
          sys    0m4.720s

The binary created during the make process is located in ./g10/gpg. Basic instructions on how to use this package you can type the ./g10/gpg --help command.

          wdiff-0.6.5
          real    0m1.545s
          user    0m0.932s
          sys    0m0.394s

The binary created during the make process is located in ./src/wdiff. Basic instructions on how to use this package you can type the ./src/wdiff --help command.

Glossary
./configure ---> Configures the package for the specific system.
time make ---> Determines how long it took for the make command to execute.

--------------------------------------------------------
Gian-Luca Casella

Root Introduction

Hello Everyone,

My name is Gian-Luca Casella and I'm in my final semester in the CTYC program at Seneca@York.

After working at my last co-op placement I had the opportunity to work with different flavours of Open-Source Operating Systems. This includes but is not limited to -- Debian Based Systems, SLES (SuSe Linux Enterprise Server), and a great number of Red-Hat systems.

Software Build and Release is something new to me so I am really looking forward to participate in projects within the Fedora Community.

IRC Nickname: gcasella (Learn ID as well)
Seneca Wiki Profile
Fedora Wiki Profile


IRC Chat Log:

<gcasella> Hello Everyone! :-)

<mustafaj> hi gcasella!

<gcasella> How's it going? I'm in ctrylers SBR class this semester.

<mustafaj> oh cool stuff! I think you'll like it a lot

<gcasella> I hope so, haha, it's something completely new to me, so i'm hoping a lot will come out of it. I'm more of a Networking/Sys Admin type of guy.

<mustafaj> It's a networking/sys admin kind of course

<mustafaj> what you make of it really.  so should be just right

<gcasella> Well i figured it would be a sys admin/networking type of course since it's part of the CTY professional programs :-P.

<mustafaj> cool beans gcasella

<gcasella> Interesting, while I was on my co-op work term I've done a lot of source code installations, but I definitely failed using the rpmbuild command.

<mustafaj> yea its tricky stuff

<gcasella> Just out of curiosity, what kind of things have you done in this course? (Assuming you've already taken it :-))

<mustafaj> mustafaredha.wordpress.com

<gcasella> Cool cool, hah, I've also done the whole Windows USB bootable while I was on my work term as well.

<gcasella> I made a USB key with a grub menu to choose between different Operating Systems, even including live versions of Windows 2k3, XP, etc.

<mustafaj> thats pretty neat

<gcasella> if you're interested http://www.nu2.nu/pebuilder/

<mustafaj> you should blog it ;)

<gcasella> Definitely will eventually :)

<mustafaj> i am, thanks i'll bookmark it

<mustafaj> what's your blogs url?

<gcasella> I have two at the moment, one of them specific to SBR gcasella.blogspot.com and one personal one at gcasella.wordpress.com 

<mustafaj> cool i'll check em out.  time for food ;) cheers

<gcasella> Take care!

<mustafaj> you too

--------------------------------------------------------
Gian-Luca Casella