Automatiser la construction des paquets rpm et src.rpm grâce aux autotools et Makefile.am
Par Ludovic Francois, jeudi 31 août 2006 à 23:24 :: code :: #26 :: rss
Automatiser la construction des paquets rpm et src.rpm grâce aux autotools et Makefile.am
- RPM Tree
- SPEC files
- Makefile.am
racine RPM
D'abord nous avons besoin de créer un répertoire de travail pour générer nos RPM.
Ci-dessous nous allons voir l'arborescence exacte de ce répertoire et où le définir.
Définir le répertoire parent dans notre fichier de macros rpm
ludo@idefix:~ % echo "%_topdir /home/ludo/rpm" > ~/.rpmmacros
Créer les différents répertoires nécessaires
ludo@idefix:~ % for dir in rpm rpm/BUILD rpm/SPECS rpm/SRPMS rpm/SOURCES rpm/RPMS rpm/RPMS/i386 for> do for> mkdir $dir for> done ludo@idefix:~ %
Fichier SPEC
Fichier spec utilisé dans notre exemple
ludo@idefix:.../common/s2a/api_tools/s2a_bin % cat packages/rpm/s2a.spec
Vendor: Ludovic Francois
Name: s2a
Release: 3
License: GPL (cf http://www.fsf.org)
Group: unsorted
Provides: s2a
Packager: lfrancois@datadirectnet.com
Version: 0.0.1
Summary: Monitoring and administration tools for DataDirect Networks s2a
Source: s2a-0.0.1.tar.gz
BuildRoot: /var/tmp/%{name}-buildroot
%description
Monitoring and administration tools for DataDirect Networks s2a appliances.
This tools supports:
- s2a6000
- s2a3000
- s2a8500
- s2a9500
You will find the main binary named s2a, with this binary you could
get a remote access on the storage system and make all cli monitoring
and administration tasks from your unix command line.
%prep
%setup
%build
./configure --prefix=/usr --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc/s2a
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
install -d -m 755 ${RPM_BUILD_ROOT}/etc/cron.d/
install -m 644 debian/cron.d ${RPM_BUILD_ROOT}/etc/cron.d/s2a
install -d -m 755 ${RPM_BUILD_ROOT}/usr/share/doc/s2a/
install -m 644 ChangeLog ${RPM_BUILD_ROOT}/usr/share/doc/s2a/ChangeLog
install -m 644 README ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README
install -m 644 TODO ${RPM_BUILD_ROOT}/usr/share/doc/s2a/TODO
install -m 644 src/scripts/README.ddn_disk_rebuild ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README.ddn_disk_rebuild
install -m 644 src/scripts/README.ddn_rrdtool ${RPM_BUILD_ROOT}/usr/share/doc/s2a/README.ddn_rrdtool
install -m 644 COPYING ${RPM_BUILD_ROOT}/usr/share/doc/s2a/copyright
%files
%defattr(-,root,root)
/etc/s2a/ddn_uptodate/ddn_uptodate_default.cfg
/etc/s2a/ddn_uptodate/ddn_uptodate_sgi.cfg
/etc/cron.d/s2a
/usr/bin/s2a
/usr/bin/ddn_tree
/usr/bin/ddn_disk_rebuild
/usr/bin/ddn_rrdtool
/usr/bin/ddn_diff
/usr/bin/ddn_dump
/usr/bin/ddn_restore
/usr/bin/ddn_richmedia
/usr/bin/ddn_uptodate
/usr/bin/ddn_temperature
/usr/share/s2a/images/ddn_logo.gif
/usr/share/s2a/images/DDNlogo.jpg
/usr/share/s2a/images/DDNtoasterview-logo.png
/usr/share/s2a/images/splash_s2a_bin.jpg
/usr/share/s2a/images/splash_s2a_bin.png
/usr/share/man/man1/s2a.1.gz
/usr/share/doc/s2a/README
/usr/share/doc/s2a/TODO
/usr/share/doc/s2a/README.ddn_disk_rebuild
/usr/share/doc/s2a/README.ddn_rrdtool
/usr/share/doc/s2a/copyright
/usr/share/doc/s2a/ChangeLog
ludo@idefix:.../common/s2a/api_tools/s2a_bin %
Makefile.am
régles permettant de construire notre rpm dans mon Makefile.am
# Build source and binary rpms. For rpm-3.0 and above, the ~/.rpmmacros
# must contain the following line:
# %_topdir /home/ludo/rpm
# cd /home/ludo/rpm ; mkdir -p SOURCES BUILD RPMS/i386 SPECS SRPMS
rpm:
$(MAKE) distdir ; \
mv $(PACKAGE)-$(VERSION) $(PACKAGE)-0.0.1 ; \
tar cvzf $(PACKAGE)-0.0.1.tar.gz $(PACKAGE)-0.0.1 ; \
$(RM) -rf $(PACKAGE)-0.0.1 ; \
RPM_TOPDIR=`rpm --showrc | perl -n -e 'print if(s/.*_topdir\s+(.*)/$$1/)'` ; \
cp $(srcdir)/packages/rpm/s2a.spec $$RPM_TOPDIR/SPECS ; \
cp $(PACKAGE)-0.0.1.tar.gz $$RPM_TOPDIR/SOURCES/ ; \
rpmbuild -ba --clean --rmsource $$RPM_TOPDIR/SPECS/$(PACKAGE).spec ; \
mv $$RPM_TOPDIR/RPMS/i386/$(PACKAGE)-*.rpm packages/rpm ; \
mv $$RPM_TOPDIR/SRPMS/$(PACKAGE)-*.src.rpm packages/rpm
finalement la commande à lancer pour générer le rpm
ludo@idefix:.../common/s2a/api_tools/s2a_bin % make rpm [...] Wrote: /home/ludo/rpm/SRPMS/s2a-0.0.1-3.src.rpm Wrote: /home/ludo/rpm/RPMS/i386/s2a-0.0.1-3.i386.rpm Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.96254 + umask 022 + cd /home/ludo/rpm/BUILD + rm -rf s2a-0.0.1 + exit 0 ludo@idefix:.../common/s2a/api_tools/s2a_bin %
résultats
ludo@idefix:.../common/s2a/api_tools/s2a_bin % find | egrep "s2a.*rpm" ./packages/rpm/s2a-0.0.1-3.i386.rpm ./packages/rpm/s2a-0.0.1-3.src.rpm ludo@idefix:.../common/s2a/api_tools/s2a_bin %
Erreurs
check-files
Vérifies si les fichiers indiqués dans le fichier spec correspondent bien à ceux réellement créés.
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/s2a-buildroot error: Installed (but unpackaged) file(s) found: /usr/bin/s2a
if you have some files you don't want in the BuildRoot add in your spec file at the files section the define below:
Si cette erreur est normale, ajouter la définition ci-dessous
%files %defattr(-,root,root) %define _unpackaged_files_terminate_build 0
Dans tous les cas, ne pas oublier de nettoyer son buildroot dans le fichier spec:
%install rm -rf $RPM_BUILD_ROOT
Commentaires
Aucun commentaire pour le moment.
Ajouter un commentaire