Tuesday, January 25, 2011

SBR600 Mock and Koji Lab

Hello everybody,

Today, I will discuss about Mock and koji. In previous lab (please look at my last post), I made my package and tested with rpmlint command successfully. Now, next step is Mock command. Mock is used to test that the BuildRequires for a package are complete and accurate. In order to use Mock command, I ran the following commands:
                       yum install mock  ------------------------->Install Mock
                       usermod -G mock ktaraghi ---------->Add myself to the mock group

Then, I ran this command:

                       mock -r fedora-14-x86_64 nano-2.2.6-1.fc14.src.rpm

which nano-2.2.6-1.fc14.src.rpm is my SRPM and fedora-14-x86_64 are distribution-release-arch values. I wanted to test in fedora 14 distribution with x86_64 architecture. Hopefully, I didn't have any errors in my SRPM but, it took a long time to test it. I thought that my bash shell has crashed, but when I look at my log file with this command:

tail -f /var/lib/mock/fedora-13-x86_64/result/build.log


I understood that it was downloading something with 300 MB size. Next step was koji. I installed koji with this command: yum install fedora-packager
and then ran this command:  /usr/bin/fedora-packager-setup 
If you want to use Koji to build Fedora packages you should use this command. It shows you the necessary information for getting certificate and is very easy process.
To queue the build request on the main koji server, I used this command:
koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm 
and it was successful. Also, it worked with other architecture such as arm,sparc, and S390. These are the commands that I used for other architecture.  
s390-koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm 
sparc-koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm 
arm-koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm  
The followings are the output of my first and second commands that I mentioned above:

$ koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm
Uploading srpm: nano-2.2.6-1.fc14.src.rpm
[====================================] 100% 00:00:32   1.51 MiB  47.19 KiB/sec
Created task: 2742773
Task info: http://koji.fedoraproject.org/koji/taskinfo?taskID=2742773
Watching tasks (this may be safely interrupted)...
2742773 build (dist-f14, nano-2.2.6-1.fc14.src.rpm): open (ppc12.phx2.fedoraproject.org)
  2742776 buildArch (nano-2.2.6-1.fc14.src.rpm, i686): free
  2742774 buildArch (nano-2.2.6-1.fc14.src.rpm, x86_64): open (x86-14.phx2.fedoraproject.org)
  2742776 buildArch (nano-2.2.6-1.fc14.src.rpm, i686): free -> open (x86-11.phx2.fedoraproject.org)
  2742776 buildArch (nano-2.2.6-1.fc14.src.rpm, i686): open (x86-11.phx2.fedoraproject.org) -> closed
  0 free  2 open  1 done  0 failed
2742773 build (dist-f14, nano-2.2.6-1.fc14.src.rpm): open (ppc12.phx2.fedoraproject.org) -> closed
  0 free  1 open  2 done  0 failed
  2742774 buildArch (nano-2.2.6-1.fc14.src.rpm, x86_64): open (x86-14.phx2.fedoraproject.org) -> closed
  0 free  0 open  3 done  0 failed

2742773 build (dist-f14, nano-2.2.6-1.fc14.src.rpm) completed successfully



and also this:


$ s390-koji build dist-f14 --scratch nano-2.2.6-1.fc14.src.rpm
Uploading srpm: nano-2.2.6-1.fc14.src.rpm
[====================================] 100% 00:00:29   1.51 MiB  52.04 KiB/sec
Created task: 293830
Task info: http://s390.koji.fedoraproject.org/koji/taskinfo?taskID=293830
Watching tasks (this may be safely interrupted)...
293830 build (dist-f14, nano-2.2.6-1.fc14.src.rpm): free
293830 build (dist-f14, nano-2.2.6-1.fc14.src.rpm): free -> open (fedora1.s390.bos.redhat.com)
  293831 buildArch (nano-2.2.6-1.fc14.src.rpm, s390): free
  293832 buildArch (nano-2.2.6-1.fc14.src.rpm, s390x): free
  293831 buildArch (nano-2.2.6-1.fc14.src.rpm, s390): free -> open (fedora2.s390.bos.redhat.com)
  293832 buildArch (nano-2.2.6-1.fc14.src.rpm, s390x): free -> open (fedora3.s390.bos.redhat.com)
  293832 buildArch (nano-2.2.6-1.fc14.src.rpm, s390x): open (fedora3.s390.bos.redhat.com) -> closed
  0 free  2 open  1 done  0 failed
293830 build (dist-f14, nano-2.2.6-1.fc14.src.rpm): open (fedora1.s390.bos.redhat.com) -> closed
  0 free  1 open  2 done  0 failed
  293831 buildArch (nano-2.2.6-1.fc14.src.rpm, s390): open (fedora2.s390.bos.redhat.com) -> closed
  0 free  0 open  3 done  0 failed

293830 build (dist-f14, nano-2.2.6-1.fc14.src.rpm) completed successfully



These are the screenshots of the above commands using web interface:




Finally, this is a link to my RPM and SRPM package. My RPM and SRPM
I will be glad if you send me your opinion about that.
Regards.

Saturday, January 22, 2011

Continuation of the RPM-Writing Lab

Hello,
I finished my "nano" RPM package successfully and without errors. I researched a lot on the Internet and Fedora Project website. Also, Special thanks to Chris Tyler and my friends in IRC for their advice that help me a lot to solve the errors. If you remember from my last blog, I ended up with these errors when I was running rpmlint command:

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: E: info-files-without-install-info-postin /usr/share/info/nano.info.gz
nano.x86_64: E: info-files-without-install-info-postun /usr/share/info/nano.info.gz


As you see here, these errors are related to info files. According to http://fedoraproject.org/wiki/Packaging/ScriptletSnippets under Texinfo section, "the GNU project and many other programs use the texinfo file format for much of its documentation. These info files are usually located in /usr/share/info/. When installing or removing a package, install-info from the info package takes care of adding the newly installed files to the main info index and removing them again on deinstallation." 

Also, it suggests a nice solution like this (I just added the below lines in my Specfile):
 
Requires(post): info
Requires(preun): info
...
%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :

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

These two scriptlets tell install-info to add entries for the info pages to the main index file on installation and remove them at erase time. The "|| :" in this case prevents failures that would typically affect systems that have been configured not to install any %doc files, or have read-only mounted, %_netsharedpath /usr/share.

I added these two scriptlets in my specfile and 4 errors were solved. The only error that left was "  nano.x86_64: E: info-dir-file /usr/share/info/dir". If you use rpmlint command with -i option, it gives you a description of error. According to that description, I included "dir" file to my package which means I included the info file for all packages to my package. In order to solve the problem, I added this line under %install section in specfile(last command):
                 rm %{buildroot}/%{_datadir}/info/dir
It removes dir file after installation. And the problem solved. Finally, I could solve the problem and get an output (RPM package) without any errors and warning.
Regards to all.

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
URL:             http://www.nano-editor.org/
Source0:       http://www.nano-editor.org/dist/v2.0/%{name}-%{version}.tar.gz
BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

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

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

%prep
%setup -q

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

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%find_lang %{name}

%clean
rm -rf $RPM_BUILD_ROOT


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
%{_bindir}/*
%{_mandir}/man*/*

%changelog

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://www.nano-editor.org/dist/v2.0/nano-2.2.6.tar.gz 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:       http://www.nano-editor.org/dist/v2.2/%{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:
   /usr/share/info/dir
   /usr/share/info/nano.info.gz
   /usr/share/locale/bg/LC_MESSAGES/nano.mo
   /usr/share/locale/ca/LC_MESSAGES/nano.mo
   /usr/share/locale/cs/LC_MESSAGES/nano.mo
   ...
   ...
   ...
   /usr/share/nano/ruby.nanorc
   /usr/share/nano/sh.nanorc
   /usr/share/nano/tcl.nanorc
   /usr/share/nano/tex.nanorc
   /usr/share/nano/xml.nanorc 

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:

%{_mandir}/fr/man*/*
%{_infodir}/nano.info*
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
%{_datadir}/nano/*
%{_datadir}/info/dir

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.info.gz
nano.x86_64: E: info-files-without-install-info-postun /usr/share/info/nano.info.gz
nano.x86_64: W: file-not-in-%lang /usr/share/locale/bg/LC_MESSAGES/nano.mo
nano.x86_64: W: file-not-in-%lang /usr/share/locale/ca/LC_MESSAGES/nano.mo
...
...
...
nano.x86_64: W: file-not-in-%lang /usr/share/locale/zh_CN/LC_MESSAGES/nano.mo
nano.x86_64: W: file-not-in-%lang /usr/share/locale/zh_TW/LC_MESSAGES/nano.mo
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 <ktaraghi@learn.senecac.on.ca> 2.2.6-1
  3. According to  https://fedoraproject.org/wiki/Packaging/Guidelines#Handling_Locale_Files, "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 myapp.mo, 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.

Saturday, January 15, 2011

Build from Source

Hello Everyone,
Today, I am going to run, test, and demonstrate building from source. First, I picked up to completely free packages from GNU software collection.By the way, these software collections were amazing and I found a lot of useful software for absolutely free.
The first package that I downloaded was "nano" that is a text editor almost similar to "vi". After unpack the tar ball with tar xvzf ... command, I went to "nano-2.2.6" directory and ran the following commands:

./configure  ---------> To configure the build for my particular system.
time make  ----------> to build the software.

Here was the output of running this command:

real    0m5.912s
user    0m4.992s
sys    0m0.472s

To run the software, I found the binary file in this location:  ./src/nano

Also, here is the output of running the "file" command to make sure that "nano" is a executable file:

>file nano-2.2.6/src/nano
nano-2.2.6/src/nano: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped

I also found another package which was "wdiff". According to GNU wdiff website, http://www.gnu.org/software/wdiff/, the program wdiff is a front end to diff for comparing files on a word per word basis. A word is anything between whitespace. This is useful for comparing two texts in which a few words have been changed and for which paragraphs have been refilled.
So, I decided to build this package. The process of building this package was exactly as the same as "nano" package(untar,configure,and make). The time of making was different and here was the result of running "time make":

real    0m1.688s
user    0m1.016s
sys    0m0.394s

The binary file for wdiff  is ./src/wdiff
I enjoyed when I ran these free useful software.

Regards

Tuesday, January 11, 2011

SBR600 communication lab

Hello All,
My full name is Khosro Taraghi and I am a CTY student at Seneca@York.
I am a big fan of Open Source community since I love freedom and believe it.
Before I became a student, I didn't have any idea about Open Source. Now, My
mind has completely changed. 

My contacts:
*****************
Email: ktaraghi@learn.senecac.on.ca
IRC: khosro
Seneca wiki: http://zenit.senecac.on.ca/wiki/index.php/User:Ktaraghi
Fedora wiki: https://fedoraproject.org/wiki/User:Ktaraghi