jeudi 20 octobre 2011

rpmerizor

rpmerizor est un outil qui permet de générer très facilement un rpm lorsqu'on dispose des fichiers que le paquet est censé installer.
On le trouve ici.
Pour montrer comment cet outil peut être utilisé, nous allons revenir sur le cas traité dans le billet précédent.
Nous avons téléchargé le paquet libreoffice-sdbc-postgresql_0.8.0+LibO3.4.3-3ubuntu2_amd64.deb, puis nous en avons extrait le contenu...
[toto@rigel work]$ ar xv libreoffice-sdbc-postgresql_0.8.0+LibO3.4.3-3ubuntu2_amd64.deb
x - debian-binary
x - control.tar.gz
x - data.tar.lzma
[toto@rigel work]$ tar x --lzma -f data.tar.lzma
[toto@rigel work]$ tar xzf control.tar.gz
et effectué quelques petites manipulations:
[toto@rigel work]$ mv usr/lib usr/lib64
[toto@rigel work]$ mkdir work-b
[toto@rigel work]$ mv usr work-b
Et voilà, nous sommes prêts à utiliser rpmerizor. Après le lancement de la commande, il nous restera à fournir quelques informations (en bleu dans ce qui suit) dont certaines proviennent du fichier control du paquet debian (vive le copier-coller):
[toto@rigel work]$ rpmerizor -name libreoffice-sdbc-postgresql -version 0.8 --rootdir work-b
name: libreoffice-sdbc-postgresql
version: 0.8
A brief one line description.
SUMMARY> LibreOffice extension for PostgreSQL SDBC driver
The integer number of times you have built this rpm.
RELEASE> 0
toplevel_group/subclass (no biggie either way).
GROUP> Converted/misc
A sales pitch for the package.  A blank line means you are done.
DESCRIPTION> LibreOffice is a full-featured office productivity suite that provides
DESCRIPTION> a near drop-in replacement for Microsoft(R) Office.
DESCRIPTION> .
DESCRIPTION> The PostgreSQL SDBC Driver allows one to use the PostgreSQL database from
DESCRIPTION> LibreOffice without any wrapper layer such as ODBC or JDBC.
DESCRIPTION>
mkdir /home/toto/rpmbuild
mkdir /home/toto/rpmbuild/SPECS
write spec file on /home/toto/rpmbuild/SPECS/libreoffice-sdbc-postgresql-0.8.spec
Exécution_de(%prep): /bin/sh -e /var/tmp/rpm-tmp.spL2j6
+ umask 022
+ cd /home/toto/rpmbuild/BUILD
+ ln -s /home/toto/work/work-b /tmp/rpmerizor_buildroot
+ exit 0
Processing files: libreoffice-sdbc-postgresql-0.8-0.x86_64
Provides: config(libreoffice-sdbc-postgresql) = 0.8-0
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /bin/sh
attention: Ne peut canoniser le nom d'hôte: rigel
Ecrit: /home/toto/rpmbuild/RPMS/x86_64/libreoffice-sdbc-postgresql-0.8-0.x86_64.rpm
Exécution_de(%clean): /bin/sh -e /var/tmp/rpm-tmp.tMJEcA
+ umask 022
+ cd /home/toto/rpmbuild/BUILD
+ rm /tmp/rpmerizor_buildroot
+ exit 0
package can be found on /home/toto/rpmbuild/RPMS
[toto@rigel work]$
Le produit a créé une arborescence rpmbuild standard:
Nous constatons qu'il a aussi créé un fichier spec que nous pouvons éditer pour y ajouter par exemple quelques dépendances requises:
Summary: LibreOffice extension for PostgreSQL SDBC driver
Name: %{name}
Version: %{version}
Release: 2
License: GPL
Group: Converted/misc

Requires: libreoffice-ure >= 3.3.3 libreoffice-core

%description
LibreOffice is a full-featured office productivity suite that provides
a near drop-in replacement for Microsoft(R) Office.
.
The PostgreSQL SDBC Driver allows one to use the PostgreSQL database from
LibreOffice without any wrapper layer such as ODBC or JDBC.
On peut alors construire un nouvel rpm tenant compte du spec modifié:
[toto@rigel ~]$ rpmbuild -bb --buildroot=/tmp/rpmerizor_buildroot ~/rpmbuild/SPECS/libreoffice-sdbc-postgresql-0.8.spec
Exécution_de(%prep): /bin/sh -e /var/tmp/rpm-tmp.NxDuhU
+ umask 022
+ cd /home/toto/rpmbuild/BUILD
+ ln -s /home/toto/work/work-b /tmp/rpmerizor_buildroot
+ exit 0
Processing files: libreoffice-sdbc-postgresql-0.8-0.x86_64
Provides: config(libreoffice-sdbc-postgresql) = 0.8-0
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires: /bin/sh attention: Ne peut canoniser le nom d'hôte: rigel Ecrit: /home/toto/rpmbuild/RPMS/x86_64/libreoffice-sdbc-postgresql-0.8-0.x86_64.rpm Exécution_de(%clean): /bin/sh -e /var/tmp/rpm-tmp.4M2L2S + umask 022 + cd /home/toto/rpmbuild/BUILD + rm /tmp/rpmerizor_buildroot + exit 0
Cela n'apparait pas dans l'output, mais les dépendances requises ont bien été ajoutées au rpm
[toto@rigel ~]$ rpm -qp --requires ~/rpmbuild/RPMS/x86_64/libreoffice-sdbc-postgresql-0.8-0.x86_64.rpm
/bin/sh
config(libreoffice-sdbc-postgresql) = 0.8-0
libreoffice-core
libreoffice-ure >= 3.3.3
rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1