Rpmbuild avec modifications (ajout de patch)

De TechWik
Révision datée du 15 janvier 2019 à 13:39 par Toine (discussion | contributions) (créer le fichier de patch avec diff:)
Aller à : navigation, rechercher

Voir https://wiki.centos.org/HowTos/RebuildSRPM .

Exemple: recompiler patch bash pour activer SYSLOG_HISTORY:

installer le rpm source

puis extraire les sources:

 $ rpm -i bash-4.2.46-30.el7.src.rpm
 $ cd ~/rpmbuild/SPECS/ 
 $ rpmbuild -bp mypackage.spec 

trouver le fichier à modifier

Dans l'arborescence extraite sous ~/rpmbuild/BUILD/ :

 $ cd ~/rpmbuild/BUILD/
 $ find . -name config-top.h
   ./bash-4.2/config-top.h

copier le fichier origine avant de le modifier

 $ cp bash-4.2/config-top.h bash-4.2/config-top.h.histlog

modifier le fichier bash-4.2/config-top.h

On va décommenter la ligne "/* #define SYSLOG_HISTORY */" et éventuellement modifier SYSLOG_FACILITY/LEVEL.

créer le fichier de patch avec diff:

 $ diffcmd="diff -up bash-4.2/config-top.h.histlog bash-4.2/config-top.h"
 $ echo $diffcmd > ../SOURCES/histlog.patch
 $ $diffcmd >> ../SOURCES/histlog.patch 
 $ cat ../SOURCES/histlog.patch 
   diff -up bash-4.2/config-top.h.histlog bash-4.2/config-top.h
   --- bash-4.2/config-top.h.histlog       2018-07-22 18:16:19.894335183 +0200
   +++ bash-4.2/config-top.h       2018-07-22 18:16:20.085339645 +0200
   @@ -103,10 +103,10 @@
   
    /* Define if you want each line saved to the history list in bashhist.c:
   bash_add_history() to be sent to syslog(). */
   -/* #define SYSLOG_HISTORY */
   +#define SYSLOG_HISTORY
    #if defined (SYSLOG_HISTORY)
   -#  define SYSLOG_FACILITY LOG_USER
   -#  define SYSLOG_LEVEL LOG_INFO
   +#  define SYSLOG_FACILITY LOG_LOCAL6
   +#  define SYSLOG_LEVEL LOG_DEBUG
    #endif
   
    /* Define if you want to include code in shell.c to support wordexp(3) */

Nota: les 3 premières lignes sont nécessaires à patch pour retrouver le fichier à patcher (cf man patch et options passées dans le fichier spec ci-dessous, notamment le nombre de / avec -p1). A noter: patch va chercher le nom du fichier dans la 3eme ligne.

éditer bash.spec et ajouter la définition du nouveau patch

Voir dans le fichier pour un patch existant, il y a 2 entrées, la première déclare le patch, la seconde passe les options de la commande patch par ex:

 $ cd ~/rpmbuild/SPECS/
 $ vi bash.spec
 ... 
 Patch154: histlog.patch
 ...
 %patch154 -p1 -b .histlog
 ...

fabriquer le package modifié

 $ rpmbuild -ba bash.spec