Sunday, January 16, 2011

SBR600 RPM-Writing Lab

Hello everyone,

Today, I was experimenting with RPM. I wanted to created a RPM package from source code that I downloaded from last lab (please look at my previous blog). I downloaded the nano source code(tarball) and started building RPM package with following commands:
  • yum groupinstall "Fedora Packager"
  • yum install rpmlint yum-utils
  • rpmdev-setuptree  
I used first and second command to install required packages for RPM's utilities and tools. The third one used to create necessary directories (trees) for working area with RPM commands and tools. I moved the tarball to ~/rpmbuil/SOURCES
directory and change my current directory to ~/rpmbuild/SPECS and ran this command: rpmdev-newspec nano 
This command creates a "nano.spec" file with the default format of configuration for this file and these configurations should change according to specification in nano. After a lot of searching in documentation of this software and internet (because it was the first time that I was working with RPM), I filled the blank fields like this(my first draft):

Name:           nano
Version:        2.2.6
Release:        1%{dist}
Summary:     Text editor

Group:          Applications
License:        GPL
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: autoconf, automake, gettext, groff, texinfo, gettext-devel, ncurses-devel
Requires: gcc, install-info

GNU nano is a small, useful, and friendly text editor.

%setup -q

%configure --enable-all
make %{?_smp_mflags}

%find_lang %{name}



%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample


Then I checked my "nano.spec" file with this command:    rpmlint nano.spec
The result was like this:

nano.spec:6: W: non-standard-group Applications
nano.spec:2: W: mixed-use-of-spaces-and-tabs (spaces: line 1, tab: line 2)
nano.spec: W: invalid-url Source0: HTTP Error 404: Not Found
0 packages and 1 specfiles checked; 0 errors, 3 warnings.

For the first try, it wasn't bad. I fixed these 3 warnings with following solutions:
  1. I looked at the /usr/share/doc/rpm-*/GROUPS and found that the right standard group for this software is : Application/Editors. So, I changed the Application to Application/Editors like this:"Group:       Applications/Editors"
  2. I found that the url was wrong(misspelling). So, I changed to this: "Source0:{name}-%{version}.tar.gz"  
  3. For first and second lines, I used tab for spacing and then I figured out that I should use space bar and not tab
After these steps, the problems solved for "nano.spec" file. The next step was building from spec file with this command:  rpmbuild -ba nano.spec
I got this error after running this command:

RPM build errors:
    Installed (but unpackaged) file(s) found:

After looking at nano's documentation, I figured out that I forgot to add some files to spec file. So, I added the following entries under %file macro in "nano.spec" file like this:


After adding these entries, the problem solved and I could create my first RPM package.
ls ../RPMS/x86_64/
nano-2.2.6-1.fc14.x86_64.rpm  nano-debuginfo-2.2.6-1.fc14.x86_64.rpm

The next step was testing my package with this command:
rpmlint ../RPMS/x86_64/nano-2.2.6-1.fc14.x86_64.rpm
and I got a long list of warning and errors like this:
nano.x86_64: E: no-changelogname-tag
nano.x86_64: W: invalid-license GPL
nano.x86_64: E: info-dir-file /usr/share/info/dir
nano.x86_64: E: info-files-without-install-info-postin /usr/share/info/dir
nano.x86_64: E: info-files-without-install-info-postun /usr/share/info/dir
nano.x86_64: W: file-not-utf8 /usr/share/man/fr/man5/nanorc.5.gz
nano.x86_64: W: file-not-utf8 /usr/share/man/fr/man1/nano.1.gz
nano.x86_64: W: file-not-utf8 /usr/share/man/fr/man1/rnano.1.gz
nano.x86_64: E: info-files-without-install-info-postin /usr/share/info/
nano.x86_64: E: info-files-without-install-info-postun /usr/share/info/
nano.x86_64: W: file-not-in-%lang /usr/share/locale/bg/LC_MESSAGES/
nano.x86_64: W: file-not-in-%lang /usr/share/locale/ca/LC_MESSAGES/
nano.x86_64: W: file-not-in-%lang /usr/share/locale/zh_CN/LC_MESSAGES/
nano.x86_64: W: file-not-in-%lang /usr/share/locale/zh_TW/LC_MESSAGES/
1 packages and 0 specfiles checked; 6 errors, 34 warnings. 

I started to fix the problems and I could fix all 34 warning and 1 error but I couldn't fix other 5 errors. Here was my solution:
  1. I found that the GPL is wrong and I changed to GPLv3 in spec file. I worked
  2. I found that I left the %changelog in spec file alone. In order to keep record of the package's change-history, I should enter the necessary information like this in spec file under %changelog: %changelog
    * Sun Jan 16 2011 - Khosro Taraghi <> 2.2.6-1
  3. According to, "Fedora includes an rpm macro called %find_lang. This macro will locate all of the locale files that belong to your package (by name), and put this list in a file. You can then use that file to include all of the locales. %find_lang should be run in the %install section of your spec file, after all of the files have been installed into the buildroot. The correct syntax for %find_lang is usually: %find_lang %{name} .In some cases, the application may use a different "name" for its locales. You may have to look at the locale files and see what they are named. If they are named, then you will need to pass myapp to %find_lang instead of %{name}. After %find_lang is run, it will generate a file in the active directory (by default, the top level of the source dir). This file will be named based on what you passed as the option to the %find_lang macro. Usually, it will be named %{name}.lang. You should then use this file in the %files list to include the locales detected by %find_lang. To do this, you should include it with the -f parameter to %files."  So, I added %find_lang %{name} under %install and %files -f %{name}.lang before %defattr(-,root,root,-) in spec file.
  4. finally, for UTF8 ,which indicates that the text encoding of the specified file, usually a documentation file, is not in UTF8, I ran this command for those files and added to the tarball before building RPM package:                     iconv -f iso8859-1 -t utf-8 name-of-file > name-of-file.conv && mv -f name-of-file.conv name-of-file
Unfortunately, I couldn't solve other 5 errors, but I am searching right now to find the problems and if I can not find the problem, i will ask my professor and update my blog to let you know about that.
Ooooooh, this lab was so long, but I hope that you enjoyed.


  1. Hey I am in the same class as you and I was wondering how did you do the UTF8 command?

    Do I do it in the folder or untar the tarball and tar it back?

  2. nice one.