Quick RPM lookaround

Timotheus Pokorra, April 2005

That is how I learnt about RPM packaging of software for Fedora Linux. My goal was to create Fedora packages for Kolab, which is packaged with OpenPKG.

Contents:

Links to RPM introductions

Basic Idea of SRPMS

rpm -i some-package-0.0.1.src.rpm
will put some tar file(s) and patches in /usr/src/redhat/SOURCES; and will put the some-package.spec file in /usr/src/redhat/SPECS
to build the src.rpm and the rpm, run rpmbuild -ba /usr/src/redhat/SPECS/some-package.spec
That will create the files /usr/src/redhat/SRPMS/some-package.src.rpm and /usr/src/redhat/RPMS/i386/some-package.rpm.

Converting OpenPKG spec file to Fedora

have a look at Building Packages with OpenPKG
See /usr/local/kolabopenpkg/etc/openpkg/rpmmacros to know what the macros (e.g. %l_musr) mean.

To get the spec file, install the OpenPKG source package:
/kolab/bin/openpkg rpm -i kolab-webadmin-0.4.0-20050318.src.rpm
Copy the /kolab/RPM/SRC/kolab-webadmin/kolab-webadmin.spec to /usr/src/redhat/SPECS;
Copy the other files (e.g. .tar.gz archives) to /usr/src/redhat/SOURCES

One special thing is that the required packages in OpenPKG don't only include the package name and required version number, but often also options that were included when configuring and building the package.
For example, cyrus-sasl::with_ldap would require that the cyrus-sasl::with_ldap is advertised in the Provides: tag in the spec file.
A common approach is not to advertise all compiling options, but to know the packages and test them thoroughly.

Remove the line:
Class: JUNK

To understand some of the macros, in the form %{something}, have a look at /usr/lib/rpm/macros and /usr/local/kolab/etc/openpkg/rpmmacros.

Insert these lines near the top:
%define l_prefix /kolab
%define l_make %{__make}
%define l_mflags -m
# m actually is ignored, compatibility
Replace all occurances of "apache" with "httpd" in your spec file.

It seems, the spaces before the %setup -q are not correct. Remove them!

Lines like  %{l_shtool} install: just remove all the  %{l_shtool}; install should work fine;
remove also the %{l_value -s -a} (though I am not sure what those characters stand for)

The file list conversion from OpenPKG

rpmtool:
One idea could be, to download the file from the OpenPKG CVS and save it to /usr/bin/rpmtool; you need to change the first line of that file to #!/bin/bash
Also add at the top of the spec file:
%define l_rpmtool /usr/bin/rpmtool
The other idea is, to install the OpenPKG source rpm of the package concerned:
/kolab/bin/openpkg rpm -i kolab-webadmin-0.4.0-20050318.src.rpm
In the /kolab/RPM/SRC/kolab-webadmin/kolab-webadmin.spec
insert after the l_rpmtool line:
cp files /usr/src/redhat/SOURCES/kolab-webadmin.files

Rebuild the package, which will create the kolab-webadmin.files:
/kolab/libexec/openpkg/rpmbuild -ba /kolab/RPM/SRC/kolab-webadmin/kolab-webadmin.spec

Perhaps need to change the paths, e.g. for perl:
in vi: :%s/\/kolab\/lib\/perl\/vendor_perl\/5.8.5/\/usr\/lib\/perl5\/vendor_perl\/5.8.3/g

You need to put it into an archive:
cd /usr/src/redhat/SOURCES/
tar cvf kolab-webadmin.files.tar kolab-webadmin.files

In the fedora spec file, /usr/src/redhat/SPECS/kolab-webadmin.spec, you would add in the sources:
Source1:      kolab-webadmin.files.tar

In the %prep section, insert:
%setup1 -D -T -b 1 -n kolab-webadmin-%{version}
As the parameter for -n, give the name of a directory that is created for the main tar file anyway.

In the %install section, remove the rpmtool lines; instead, you change the %files line:
%files -f ../kolab-webadmin.files

Package a Perl module

First check if somebody did already the job, e.g. on artfiles.org RPMS (SRPMS) or just for RPMS: RPMPan or this search site: Linux Software Directory .

You need to install perl-Archive-Tar-1.08-2.noarch.rpm and perl-RPM-Specfile-1.17-1.noarch.rpm.
A description of the module perl-RPM-Specfile can be found on cpan.
Download this perl script, called cpan-to-rpm.pl. It is described as followed:
Grab a module from CPAN and sock it into an RPM using cpanflute2
Call it this way:
 perl cpan-to-rpm.pl authors/id/M/MU/MUIR/modules/Net-Netmask-1.9011.tar.gz
 perl cpan-to-rpm.pl authors/id/D/DJ/DJKERNEN/Mail-IMAPClient-2.2.9.tar.gz

That will create
/usr/src/redhat/SRPMS/perl-Net-Netmask-1.9011-1.src.rpm
If you install it with
rpm -i /usr/src/redhat/SRPMS/perl-Net-Netmask-1.9011-1.src.rpm
you can build the rpm from it with
rpmbuild -ba /usr/src/redhat/SPECS/perl-Net-Netmask.spec
to see what an rpm provides: rpm -qlp --provides perl-LDAP-0.31-4.noarch.rpm

Use patched files in RPMs

see Packaging software with RPM

diff -uNr the_package/the_file the_package/the_file.new > the_file.patch

copy the patch file to /usr/src/redhat/SOURCES

The spec file has those lines:

After Sources:
Patch0: the_file.patch


After %setup, before %build
%patch -p1


To get your new version from the original file:
patch slapd.conf.template ../../slapd.conf.template.patch -o slapd.conf.template.new