Autres distribs Linux

Mageia : Compiler ses propres paquets rpm avec Mageia

Cet article a été mis à jour, vous consultez ici une archive de cet article!
Table des matières

Présentation





Quel intérêt ?

Et bien c'est simple, vous avez une Mageia stable, et vous voulez un paquet présent dans la version de développement (Cauldron) ou qui est "plus à jour", il peut être intéressant de se fabriquer un RPM maison Mageia2.



Lorsque j'ai réalisé cet article, la version stable de Mageia était la 2, et la version Cauldron sera la future 3.

Les paquets .mga2 sont donc les stables, et les .mga3 sont les Cauldron.

Ma machine est une 64bits, les paquets seront de type x86_64.




Pour télécharger les fichiers sources, On peut utiliser le site http://pkgs.org . La recherche de paquets est simple.



Installation des prérequis





Tout d'abord, pas de bricolage sans marteau, donc pas de compilation sans scripts et programmes pour compiler nos paquets.



Préparons le terrain, installons les outils :



Code BASH :
urpmi rpm-build rpm-sign




Il est bon de noter qu'un paquet compilé, ou "buildé" en franglais, sera de la même architecture et version que votre Mageia.

Si vous possédez une Mageia 2 64bits, vous aurez un paquet xxxxxxxx.mga2.x86_64.rpm






Créer ses paquets





Depuis une source d'une version Cauldron.





Je vais illustrer la création d'un paquet Mageia2 du logiciel pbzip2 (Parallel implementation de bzip2) qui n'est disponible que dans Cauldron.



Dans un premier temps, je télécharge le fichier source depuis internet :



Code BASH :
wget http://mirror.internode.on.net/pub/mageia/distrib/cauldron/SRPMS/core/release/pbzip2-1.1.8-3.mga3.src.rpm




Caché :
[root@supermachine ~]# wget http://mirror.internode.on.net/pub/mageia/distrib/cauldron/SRPMS/core/release/pbzip2-1.1.8-3.mga3.src.rpm

--2013-02-18 21:17:20-- http://mirror.internode.on.net/pub/mageia/distrib/cauldron/SRPMS/core/release/pbzip2-1.1.8-3.mga3.src.rpm

Résolution de mirror.internode.on.net (mirror.internode.on.net)... 150.101.135.3

Connexion vers mirror.internode.on.net (mirror.internode.on.net)|150.101.135.3|:80...connecté.

requête HTTP transmise, en attente de la réponse...200 OK

Longueur: 58946 (58K) [application/x-redhat-package-manager]

Sauvegarde en : «pbzip2-1.1.8-3.mga3.src.rpm»



100%[==========================================================================================================================================>] 58 946 40,2K/s ds 1,4s



2013-02-18 21:17:23 (40,2 KB/s) - «pbzip2-1.1.8-3.mga3.src.rpm» sauvegardé [58946/58946]





Ensuite, la deuxième étape consiste à télécharger les build requires, c'est à dire les paquets nécessaires au bon fonctionnement de la future application à packager:



Code BASH :
urpmi --buildrequires pbzip2-1.1.8-3.mga3.src.rpm 




Caché :
[root@supermachine ~]# urpmi --buildrequires pbzip2-1.1.8-3.mga3.src.rpm

Pour satisfaire les dépendances, le paquetage suivant va être installé :

Paquetage Version Révision Arch

(média « Core Release »)

lib64bzip2-devel 1.0.6 1.mga2 x86_64

un espace additionnel de 467Ko sera utilisé.

156Ko de paquets seront récupérés.

Procéder à l'installation d'un paquetage ? (O/n) o





rsync://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/2/x86_64/media/core/release/lib64bzip2-devel-1.0.6-1.mga2.x86_64.rpm

installation de lib64bzip2-devel-1.0.6-1.mga2.x86_64.rpm depuis /var/cache/urpmi/rpms

Préparation... #################################################################################################################################################

1/1: lib64bzip2-devel #################################################################################################################################################





Il peut arriver que les dépendances n'existent pas, car elles aussi sont seulement dans les dépôts Cauldron, les compiler avant en suivant cette partie et la suivante)



Dernière étape, on build notre paquet :



Code BASH :
rpmbuild --rebuild pbzip2-1.1.8-3.mga3.src.rpm 




Caché :
[root@localhost ~]# rpmbuild --rebuild pbzip2-1.1.8-3.mga3.src.rpm

Installation de pbzip2-1.1.8-3.mga3.src.rpm

attention: utilisateur iurt inexistant - utilisation de root

attention: groupe iurt inexistant - utilisation de root

attention: utilisateur iurt inexistant - utilisation de root

attention: groupe iurt inexistant - utilisation de root

Exécution_de(%prep): /bin/sh -e /var/tmp/rpm-tmp.BPO73I

+ umask 022

+ cd /root/rpmbuild/BUILD

+ '[' 1 -eq 1 ']'

+ '[' 1 -eq 1 ']'

+ '[' 1 -eq 1 ']'

+ cd /root/rpmbuild/BUILD

+ rm -rf pbzip2-1.1.8

+ /bin/tar -xf -

+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/pbzip2-1.1.8.tar.gz

+ STATUS=0

+ '[' 0 -ne 0 ']'

+ cd pbzip2-1.1.8

+ sed -i -e 's/ -O2/ -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 /' Makefile

+ exit 0

Exécution_de(%build): /bin/sh -e /var/tmp/rpm-tmp.OTLaGK

+ umask 022

+ cd /root/rpmbuild/BUILD

+ cd pbzip2-1.1.8

+ '[' 1 -eq 1 ']'

+ '[' 1 -eq 1 ']'

+ make

g++ -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_POSIX_PTHREAD_SEMANTICS -DUSE_STACKSIZE_CUSTOMIZATION -pthread pbzip2.cpp BZ2StreamScanner.cpp ErrorContext.cpp -o pbzip2 -lbz2 -lpthread

pbzip2.cpp: In function ‘int producer_decompress(int, off_t, queue*)’:

pbzip2.cpp:1484:45: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat]

pbzip2.cpp: In function ‘void* fileWriter(void*)’:

pbzip2.cpp:2093:91: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat]

pbzip2.cpp: In function ‘int directcompress(int, off_t, int, const char*)’:

pbzip2.cpp:2336:91: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat]

pbzip2.cpp: In function ‘void outputBufferInit(size_t)’:

pbzip2.cpp:3071:103: attention : format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat]

pbzip2.cpp: In function ‘int main(int, char**)’:

pbzip2.cpp:4003:101: attention : format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘long unsigned int’ [-Wformat]

pbzip2.cpp:4372:89: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat]

pbzip2.cpp:4447:101: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat]

pbzip2.cpp:4494:159: attention : format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat]

pbzip2.cpp: In function ‘int directdecompress(const char*, const char*)’:

pbzip2.cpp:2498:66: attention : ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]

pbzip2.cpp:2519:63: attention : ignoring return value of ‘size_t fwrite(const void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]

BZ2StreamScanner.cpp: In member function ‘void pbzip2::BZ2StreamScanner::printCurrentState()’:

BZ2StreamScanner.cpp:500:27: attention : format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat]

BZ2StreamScanner.cpp:500:27: attention : format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat]

BZ2StreamScanner.cpp:500:27: attention : format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long int’ [-Wformat]

BZ2StreamScanner.cpp:500:27: attention : format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘long int’ [-Wformat]

+ exit 0

Exécution_de(%install): /bin/sh -e /var/tmp/rpm-tmp.0gtMfR

+ umask 022

+ cd /root/rpmbuild/BUILD

+ '[' /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64 '!=' / ']'

+ rm -rf /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

++ dirname /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

+ mkdir -p /root/rpmbuild/BUILDROOT

+ mkdir /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

+ cd pbzip2-1.1.8

+ '[' 1 -eq 1 ']'

+ rm -rf /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

+ install -D -m755 pbzip2 /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/bin/pbzip2

+ install -D -m644 pbzip2.1 /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/share/man/man1/pbzip2.1

+ ln -sf ./pbzip2 /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/bin/pbunzip2

+ ln -sf ./pbzip2 /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/bin/pbzcat

+ /usr/lib/rpm/mageia/find-debuginfo.sh /root/rpmbuild/BUILD/pbzip2-1.1.8



extracting debug info from /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/bin/pbzip2

symlinked /usr/lib/debug/usr/bin/pbzip2.debug to /usr/lib/debug/usr/bin/pbunzip2.debug

symlinked /usr/lib/debug/usr/bin/pbzip2.debug to /usr/lib/debug/usr/bin/pbzcat.debug

cpio: /home/iurt/rpm/BUILD/glibc-2.14.1/csu: échec de la fonction : stat: Aucun fichier ou dossier de ce type

cpio: pbzip2-1.1.8/<interne>: échec de la fonction : stat: Aucun fichier ou dossier de ce type

323 blocs

+ '[' -n '' ']'

+ /usr/share/spec-helper/clean_files

+ '[' -n '' ']'

+ /usr/share/spec-helper/compress_files .xz

+ '[' -n '' ']'

+ /usr/share/spec-helper/relink_symlinks

+ '[' -n '' ']'

+ /usr/share/spec-helper/clean_perl

+ '[' -n '' ']'

+ /usr/share/spec-helper/lib_symlinks

+ '[' -n '' ']'

+ /usr/share/spec-helper/gprintify

+ '[' -n '' ']'

+ /usr/share/spec-helper/fix_mo

+ '[' -n '' ']'

+ /usr/share/spec-helper/translate_menu

+ '[' -n '' ']'

+ /usr/share/spec-helper/fix_pamd

+ '[' -n '' ']'

+ /usr/share/spec-helper/remove_info_dir

+ '[' -n '' ']'

+ /usr/share/spec-helper/fix_eol

+ '[' -n '' ']'

+ /usr/share/spec-helper/check_elf_files

Warning: unused libraries in /usr/bin/pbzip2: libm.so.6



+ /usr/lib/rpm/mageia/brp-java-repack-jars

Processing files: pbzip2-1.1.8-3.mga2.x86_64

Exécution_de(%doc): /bin/sh -e /var/tmp/rpm-tmp.7Vm06Z

+ umask 022

+ cd /root/rpmbuild/BUILD

+ cd pbzip2-1.1.8

+ DOCDIR=/root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/share/doc/pbzip2

+ export DOCDIR

+ /bin/mkdir -p /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/share/doc/pbzip2

+ cp -pr AUTHORS ChangeLog COPYING README /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64/usr/share/doc/pbzip2

+ exit 0

Finding Provides: /usr/lib/rpm/mageia/filter.sh ' ' ' ' '/root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64' /usr/lib/rpm/mageia/find-provides

Finding Requires: /usr/lib/rpm/mageia/filter.sh ' ' ' ' '/root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64' /usr/lib/rpm/mageia/find-requires /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64 x86_64

Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1

Requires: libbz2.so.1()(64bit) libc.so.6()(64bit) libc.so.6(GLIBC_2.14)(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.3.4)(64bit) libc.so.6(GLIBC_2.4)(64bit) libgcc_s.so.1()(64bit) libgcc_s.so.1(GCC_3.0)(64bit) libm.so.6()(64bit) libpthread.so.0()(64bit) libpthread.so.0(GLIBC_2.2.5)(64bit) libpthread.so.0(GLIBC_2.3.2)(64bit) libstdc++.so.6()(64bit) libstdc++.so.6(GLIBCXX_3.4)(64bit) rtld(GNU_HASH)

Processing files: pbzip2-debug-1.1.8-3.mga2.x86_64

Vérification des fichiers non empaquetés: /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

Ecrit: /root/rpmbuild/RPMS/x86_64/pbzip2-1.1.8-3.mga2.x86_64.rpm

Ecrit: /root/rpmbuild/RPMS/x86_64/pbzip2-debug-1.1.8-3.mga2.x86_64.rpm

Exécution_de(%clean): /bin/sh -e /var/tmp/rpm-tmp.lDINby

+ umask 022

+ cd /root/rpmbuild/BUILD

+ cd pbzip2-1.1.8

+ /bin/rm -rf /root/rpmbuild/BUILDROOT/pbzip2-1.1.8-3.mga3.x86_64

+ exit 0

Exécution_de(--clean): /bin/sh -e /var/tmp/rpm-tmp.JKrRUJ

+ umask 022

+ cd /root/rpmbuild/BUILD

+ rm -rf pbzip2-1.1.8

+ exit 0





Avant de compiler le paquet, je me suis placé dans le /root, avec l'utilisateur root.



Mon paquet nouvellement buildé se trouve alors dans /root/rpmbuild/RPMS/x86_64



Code BASH :
ls /root/rpmbuild/RPMS/x86_64
pbzip2-1.1.8-3.mga2.x86_64.rpm  pbzip2-debug-1.1.8-3.mga2.x86_64.rpm




Je tente l'installation de mon paquet:



Code BASH :
urpmi pbzip2-1.1.8-3.mga2.x86_64.rpm 




Caché :
[root@localhost x86_64]# urpmi pbzip2-1.1.8-3.mga2.x86_64.rpm





installation de pbzip2-1.1.8-3.mga2.x86_64.rpm

Préparation... #################################################################################################################################################

1/1: pbzip2 #################################################################################################################################################





Voila, notre logiciel est installé.



Code BASH :
which pbzip2
/usr/bin/pbzip2




Caché :
[root@localhost x86_64]# pbzip2 --help

Parallel BZIP2 v1.1.8 - by: Jeff Gilchrist [http://compression.ca]

[Jun. 10, 2012] (uses libbzip2 by Julian Seward)

Major contributions: Yavor Nikolov <[email protected]>



Usage: pbzip2 [-1 .. -9] [-b#cdfhklm#p#qrS#tVz] <filename> <filename2> <filenameN>

-1 .. -9 set BWT block size to 100k .. 900k (default 900k)

-b# Block size in 100k steps (default 9 = 900k)

-c,--stdout Output to standard out (stdout)

-d,--decompress Decompress file

-f,--force Overwrite existing output file

-h,--help Print this help message

-k,--keep Keep input file, don't delete

-l,--loadavg Load average determines max number processors to use

-m# Maximum memory usage in 1MB steps (default 100 = 100MB)

-p# Number of processors to use (default: autodetect [1])

-q,--quiet Quiet mode (default)

-r,--read Read entire input file into RAM and split between processors

-S# Child thread stack size in 1KB steps (default stack size if unspecified)

-t,--test Test compressed file integrity

-v,--verbose Verbose mode

-V,--version Display version info for pbzip2 then exit

-z,--compress Compress file (default)

--ignore-trailing-garbage=# Ignore trailing garbage flag (1 - ignored; 0 - forbidden)



If no file names are given, pbzip2 compresses or decompresses from standard input to standard output.



Example: pbzip2 -b15vk myfile.tar

Example: pbzip2 -p4 -r -5 myfile.tar second*.txt

Example: tar cf myfile.tar.bz2 --use-compress-prog=pbzip2 dir_to_compress/

Example: pbzip2 -d -m500 myfile.tar.bz2

Example: pbzip2 -dc myfile.tar.bz2 | tar x

Example: pbzip2 -c < myfile.txt > myfile.txt.bz2









Depuis un paquet rpm source étranger





A Rédiger :


dl rpm src

urpmi --buildrequires

rpm -ivh rpmsrc

mod le spec dans $HOME/rpmbuild/SPECS/fichier.spec

rpmbuild -ba $HOME/rpmbuild/SPECS/fichier.spec







Signer ses paquets





En cours de rédaction :




Clé GPG => Mettre



Créer à la racine du compte qui créé ses paquets ce fichier sous le nom de .rpmmacros. Adapter le chemin %_gpg_path et les noms %_gpg_name , %vendor et %packager En fonction de la clé générée précédemment.

Code BASH :
 
%_signature gpg
%_gpg_path /home/adrien/.gnupg
%_gpg_name MLO Packages (Team MLO) <packages@mageialinux-online.org>
%_gpgbin /usr/bin/gpg
%distribution     Mageia
%vendor           MLO <http://www.mageialinux-online.org>
%packager         Adrien.D (MLO Team) <adrien.d@mageialinux-online.org>
 






















Créer les infos de médias





Si les paquets sont hébergés sur un serveur, il est possible de créer les infos de médias, ainsi, il sera possible d'ajouter l'adresse http ou ftp de notre serveur dans les dépôts de logiciels.



Pour cela, se rendre sur le serveur, dans le dossier où se trouvent les RPM.



Exemple :

Code BASH :
cd ~/rpm/mga2/x86_64




Puis générer les fichiers adéquats via :

Code BASH :
genhdlist2 .
adding 7 new rpms not available in existing hdlist
replacing ./media_info/hdlist.cz with hdlist.cz.tmp
replacing ./media_info/synthesis.hdlist.cz with synthesis.hdlist.cz.tmp
updating ./media_info/MD5SUM
 




Le dossier media_info doit se trouver dans le même dossier que les RPM's.



Si les RPM sont dans ~/rpm/mga2/x86_64 vérifier que les fichiers hdlist.cz, synthesis.hdlist.cz et MD5SUM sont dans ~/rpm/mga2/x86_64/media_info



Ajouter le nouveau dépôt via :

Code BASH :
urpmi.addmedia --update <nom> <adresse_du_depôt>




l'option --update indique qu'il s'agit d'un média de mises à jour.





Tester ses RPM (vérifier les erreurs)





Pour vérifier les erreurs d'un RPM, qui se sont glissées dans le fichier SPEC, lancer la commande rpmlint :



Code BASH :
rpmlint le_nom_du_paquet.src.rpm
rpmlint le_nom_du_paquet.rpm