Wednesday, 2 October 2013

The mighty RPM Build lab

In my first experience of building an RPM. I did not have any idea what I was up against. The process looked easy, however, when we actually began to configure the spec file, then it showed its real face. I am also writing this blog very late and I hope Chris would consider this, I had to take some time out for this to do my research and actually know what is going on.

To begin, I issued the commands to install Fedora Packager and  yum utils.
After that was done, I followed the steps outlined in the lab up until it told us to work on the SPEC file which I had no idea how to configure. I embarked on a journey of research and got to know a bit about SPEC how it functions, what are the common macros and what are the common issues in making a SPEC file.

The Packages that I had to build were "less" and "grep".

Building RPM for less:

In order to get information on less I issued the command

               rpm -qi less

and that gave me some information that I can use in my SPEC file
Name        : less
Version     : 444
Release     : 9.fc18
Architecture: i686
Install Date: Thu 26 Sep 2013 09:30:16 PM EDT
Group       : Applications/Text
Size        : 204397
License     : GPLv3+
Signature   : RSA/SHA256, Fri 26 Oct 2012 02:41:44 AM EDT, Key ID ff01125cde7f38bd
Source RPM  : less-444-9.fc18.src.rpm
Build Date  : Thu 25 Oct 2012 11:53:55 AM EDT
Build Host  : buildvm-02.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.greenwoodsoftware.com/less/
Summary     : A text file browser similar to more, but better
Description :
The less utility is a text file browser that resembles more, but has
more capabilities.  Less allows you to move backwards in the file as
well as forwards.  Since less doesn't have to read the entire input file
before it starts, less starts up more quickly than text editors (for
example, vi).

You should install less because it is a basic utility for viewing text
files, and you'll use it frequently.
I took a few things, like name, Description etc from this, however, for the version and release I had to get it from the source code I downloaded, otherwise it I would have built the RPM with a wrong version.

I filled the SPEC file with as much info as I can and then I started I issued the command to build the RPM
                               rpmbuild -ba less.spec

Little did I know what was ahead of me. When it was building the RPM the first warning i got was

configure: WARNING: unrecognized options: --disable-dependency-tracking

I did some research on this warning and found that if the config script of the source file had this option then this warning would not have showed up. To check if I had this option on the config script I issued this command in my source folder.

grep -qe --disable-dependency-tracking configure

The command did not return any result that meant that there was indeed no such option present, therefore, I ignored this warning. If i find anything that I can do in the SPEC file to ignore this warning then I would, but I think this requires some change in the config script and not the spec file.

I moved on, and the build command completed with a few errors.

   error: Installed (but unpackaged) file(s) found:
   /usr/bin/less
   /usr/bin/lessecho
   /usr/bin/lesskey
   /usr/share/man/man1/less.1.gz
   /usr/share/man/man1/lessecho.1.gz
   /usr/share/man/man1/lesskey.1.gz

the rpmbuild command failed to extract these files, therefore, I had to adjust my spec file so it would extract these files as well. I used %{_bindir} and %{_mandir} macros to fix these errors.

I added these lines to the spec File
%{_bindir}/less*
%{_mandir}/man1/less* 

Explanation:

%{_bindir}= /usr/bin
%{_mandir}/man1

Hence, by using these macros and specifying "less*" I was able to extract the files that were giving me error and the build completed successfully.

Here is a link to my Spec file less.spec
Here is a link to my RPM file  less-451-1.fc18.i686.rpm
Here is a link to my SRPM file less-451-1.fc18.src.rpm

Less took me about 1 hours and 30 minutes to build.

Building RPM for GREP:

This is where the fun began, I followed the steps that I did for less but I had much more errors then I had for less and I had to modify my SPEC FILE a lot more than I did for less.

I got information on GREP package by running the command
                    rpm -qi grep

I filled in the spec file with that and then I ran the rpmbuild command to see what awaits me.

First thing I noticed while it was building the package is that it gave me a warning:

configure: WARNING: libpcre development library was not found or not usable.

This was easy, I just had to install the pcre-devel, I did it by using the yum command.

Errors:
Installed (but unpackaged) file(s) found:
   /usr/bin/egrep
   /usr/bin/fgrep
   /usr/share/info/dir
   /usr/share/info/grep.info.gz
   /usr/share/locale/af/LC_MESSAGES/grep.mo
   /usr/share/locale/be/LC_MESSAGES/grep.mo
   /usr/share/locale/bg/LC_MESSAGES/grep.mo
   /usr/share/locale/ca/LC_MESSAGES/grep.mo
   /usr/share/locale/cs/LC_MESSAGES/grep.mo
   /usr/share/locale/da/LC_MESSAGES/grep.mo
   /usr/share/locale/de/LC_MESSAGES/grep.mo
   /usr/share/locale/el/LC_MESSAGES/grep.mo
   /usr/share/locale/eo/LC_MESSAGES/grep.mo
   /usr/share/locale/es/LC_MESSAGES/grep.mo
   /usr/share/locale/et/LC_MESSAGES/grep.mo
   /usr/share/locale/eu/LC_MESSAGES/grep.mo
   /usr/share/locale/fi/LC_MESSAGES/grep.mo
   /usr/share/locale/fr/LC_MESSAGES/grep.mo
   /usr/share/locale/ga/LC_MESSAGES/grep.mo
   /usr/share/locale/gl/LC_MESSAGES/grep.mo
   /usr/share/locale/he/LC_MESSAGES/grep.mo
   /usr/share/locale/hr/LC_MESSAGES/grep.mo
   /usr/share/locale/hu/LC_MESSAGES/grep.mo
   /usr/share/locale/id/LC_MESSAGES/grep.mo
   /usr/share/locale/it/LC_MESSAGES/grep.mo
   /usr/share/locale/ja/LC_MESSAGES/grep.mo
   /usr/share/locale/ko/LC_MESSAGES/grep.mo
   /usr/share/locale/ky/LC_MESSAGES/grep.mo
   /usr/share/locale/lt/LC_MESSAGES/grep.mo
   /usr/share/locale/nb/LC_MESSAGES/grep.mo
   /usr/share/locale/nl/LC_MESSAGES/grep.mo
   /usr/share/locale/pl/LC_MESSAGES/grep.mo
   /usr/share/locale/pt/LC_MESSAGES/grep.mo
   /usr/share/locale/pt_BR/LC_MESSAGES/grep.mo
   /usr/share/locale/ro/LC_MESSAGES/grep.mo
   /usr/share/locale/ru/LC_MESSAGES/grep.mo
   /usr/share/locale/sk/LC_MESSAGES/grep.mo
   /usr/share/locale/sl/LC_MESSAGES/grep.mo
   /usr/share/locale/sr/LC_MESSAGES/grep.mo
   /usr/share/locale/sv/LC_MESSAGES/grep.mo
   /usr/share/locale/th/LC_MESSAGES/grep.mo
   /usr/share/locale/tr/LC_MESSAGES/grep.mo
   /usr/share/locale/uk/LC_MESSAGES/grep.mo
   /usr/share/locale/vi/LC_MESSAGES/grep.mo
   /usr/share/locale/zh_CN/LC_MESSAGES/grep.mo
   /usr/share/locale/zh_TW/LC_MESSAGES/grep.mo
   /usr/share/man/man1/egrep.1.gz
   /usr/share/man/man1/fgrep.1.gz


FIXES:

   ERROR                                      Solution
/usr/bin/egrep                                     %{_bindir}/egrep
/usr/bin/fgrep                                     %{_bindir}/fgrep
/usr/share/info/grep.info.gz              %{_infodir}/%{name}*
/usr/share/info/dir                             %{_infodir}/dir
/usr/share/man/man1/egrep.1.gz      %{_mandir}/man1/fgrep*
/usr/share/man/man1/fgrep.1.gz       %{_mandir}/man1/egrep*

All the ".mo" files are language files, after doing my research I found a short way of addressing all the language files without compromising the security and accessing the files that do not need to be accessed.

%find_lang %{name}

%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi

%files -f %{name}.lang


After all of this my rpmbuild command executed without any errors or warnings.
The time command said:

real    2m33.418s
user    0m29.549s
sys    1m25.282s

Little did it know that it took me about 5 hours to build both of these RPMs.

Here is a link to my Spec file grep.spec
Here is a link to my RPM file grep-2.9-1.fc18.i686.rpm
Here is a link to my SRPM file grep-2.9-1.fc18.src.rpm


Rpmlint:
The rpmlint did not complain about a lot of things, for both spec file I gave a wrong URL, therefore, it just pointed out that it cannot access the provided URL. It also issued warnings when tab and space are used together in a line, I just edited the file to remove all the spaces and only have tab as a separator. It did not give me any error or warning after that. The output I got was:

0 packages and 1 specfiles checked; 0 errors, 0 warnings.

I got the same output for less as well as grep when i ran the rpmlint command.
Hope you enjoyed my blog, I certainly did enjoy figuring out all of this stuff.

No comments:

Post a Comment

How to add "Discord" in Steam's Big Picture Mode

 With the release of Steam deck a lot of people are turning into Steam Deck Big Picture Mode(BPM) to enjoy an exclusive gaming experience, t...