Saturday, February 20, 2010

Building RPMs Part 2

So, lets continue with the rpm creation process. (part1)

Part 1 covers how to download and check the files involved with most packages.

NOW the fun begins!!!

I'm going to explain how I created a package rpm for Irssi.


First I downloaded the tarball from http://www.irssi.org/files/irssi-0.8.14.tar.gz
which I than put it in the rpmbuild/SOURCE/ and created a new blank spec file using

rpmbuild-newspec irssi

First thing we need to do is fill in the fields on the top like Name, Version, etc... they are pretty straight forward and require very little google'ing to find the answers.

We need to understand how the file would install using just the source. Would you use a make and make install? Or ./configure, make, make install? This will affect the spec file depending on the procedure required to make the rpm package.

Here is my spec file:
Name: irssi
Version: 0.8.14
Release: 1%{?dist}
Summary: Command Line IRC Client
Group: Applications/Communications
License: GPLv2+
URL: http://www.irssi.org/
Source0: http://www.irssi.org/files/irssi-0.8.14.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: glib2-devel
BuildRequires: ncurses-devel
%description
Irssi is a terminal based IRC client for UNIX systems.

%prep
%setup -q

%build
%configure
make %{?_smp_mflags}

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

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc docs/*.txt docs/*.html AUTHORS COPYING NEWS README TODO
%config(noreplace) %{_sysconfdir}/%{name}.conf
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_includedir}/%{name}/
%{_mandir}/man1/%{name}.1*

%changelog
* Wed Feb 3 2010 - Dave - 0.8.14-1
- Initial build..
I'm not going to explain everything in a spec file because I'm still learning. Hopefully from looking at my spec file you can determine what everything does. My Irssi spec file is really basic so it's good to learn from.

Now we try testing the spec file by using

rpmbuild -ba ~/rpmbuild/SPECS/irssi.spec
Issuing this command will try to build using the spec file above. Which had no problems and the exit code was 0. And to even test the spec file further we can try using rpmlint.

rpmlint ~/rpmbuild/SPECS/irssi.spec
If you have no problems than we move on to 'mock' to test what the package requires.


TO BE CONTINUED...(Using Mock to test RPM requirements)

No comments:

Post a Comment