Thursday, September 19, 2013

RPM Build Lab

RPM Writing Lab

To begin I do the required package installations

yum groupinstall “Fedora Packager”
yum install rpmlint  yum-utils rpmdevtools

Then If you are always running around as root like I do make sure to add your regular account to visudo and exit of root since it is recommended to run as a different user other than root.

Then I set up the folders inside the rpmbuild folder with:

rpmdev-setuptree

This will setup folders in /home/username/rpmbuild/
The folders are BUILD, BUILDROOT, RPMS, SOURCES, SPECS, SRPMS

If this folders were here before make sure to run this command:

rpmdev-wipetree

This will clean all the files in the folders.

now I download the tarball of which from GNU project and putting in ~/rpmbuild/SOURCES

I cd to ~/rpmbuild/SPECS and run the command.

rpmdev-newspec which

to create a new spec file for which.
The file is like a template and you fill up the missing data.

I did with the information that I had taken from the class, then I ran:

rpmbuild -ba which.spec

To which came up giving error. Knowing that I had not idea what I was doing and that the I failed to do the same with another package I decided to look at the original spec file.

I download the source file with yum then I rpm install the file:

yumdownloader --source which
rpm -i which-*.src.rpm

Which ended up populating the folders inside ~/rpmbuild/ from here I took the which.spec file to modify mine. I ended up taking only a few things and ignore many. To read through the spec file easier I decided to install vim and since I did that I also went ahead and installed gvim. It made things colorful and easy to identify inside the spec file.

With this new modification I managed to successfully build the package, then to test it I ran

rpmlint RPMS/ SRPMS/ SPECS/

This gave a whole set of problems around 14 errors and 3 warnings.
And I thought I was good to go !!!

I managed to get the errors down to 6 but I didn’t know what else to do so I made other changes from the original spec file to my spec file. which needed to also install 2 other local sources and a patch from version 2.19 before installing 2.20. So I copied the files to the SOURCES dir and modified the spec file correspondingly. After doing this I did another build and ran rpmlint which came with zero errors. Yay

The next package to build for RPM is less

I’ve noticed that many packages do not have clean spec files as was shown with wget, instead they are filled with other files and many patches. For that reason I have left this package mainly untouched.
There is a difference between BuildRequires and Requires
Requires is what the Built RPM requires
BuildRequires is what RPM needs in order to build

I have tried several packages before switching back to less but they all would give me error if I missed or modified a single line in the spec file.
But well with less I got no errors not even with rpmlint.

Files for which
https://drive.google.com/folderview?id=0B2G5T2vxJmLrbEtRbVNWQW5IVFk&usp=sharing

Files for less
https://drive.google.com/folderview?id=0B2G5T2vxJmLra1dKa2VpOWp4amM&usp=sharing

No comments:

Post a Comment