[packages/poldek] add pre and post hooks support for install command

glen glen at pld-linux.org
Sun May 31 18:42:47 CEST 2015


commit c5d1808a4ce32966f9bd4444fc9bcce26b6143f3
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun May 31 19:41:16 2015 +0300

    add pre and post hooks support for install command

 pm-hooks.patch | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 poldek.spec    | 22 ++++++++++++++++++---
 2 files changed, 80 insertions(+), 3 deletions(-)
---
diff --git a/poldek.spec b/poldek.spec
index 5ec92d3..e4797f1 100644
--- a/poldek.spec
+++ b/poldek.spec
@@ -30,7 +30,7 @@
 %define		ver_rpm		5.4.10
 %endif
 
-%define		rel	7
+%define		rel	8
 Summary:	RPM packages management helper tool
 Summary(hu.UTF-8):	RPM csomagkezelést segítő eszköz
 Summary(pl.UTF-8):	Pomocnicze narzędzie do zarządzania pakietami RPM
@@ -57,6 +57,7 @@ Source102:	%{name}-debuginfo-snap.conf
 Patch0:		%{name}-size-type.patch
 Patch1:		%{name}-config.patch
 Patch2:		%{name}-missing-include.patch
+Patch3:		pm-hooks.patch
 URL:		http://poldek.pld-linux.org/
 BuildRequires:	%{db_pkg}-devel >= %{ver_db}-%{ver_db_rel}
 BuildRequires:	autoconf
@@ -101,8 +102,8 @@ Requires:	%{name}-libs = %{version}-%{release}
 Requires:	rpm >= %{ver_rpm}
 Requires:	rpm-db-ver = %{ver_db}
 Requires:	rpm-lib >= %{ver_rpm}
-# vf* scripts use sed
 Requires:	sed
+Conflicts:	etckeeper < 1.18-2
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 %define		_libexecdir	%{_prefix}/lib/%{name}
@@ -220,6 +221,7 @@ Moduły języka Python dla poldka.
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %{__rm} m4/libtool.m4 m4/lt*.m4
 
@@ -260,7 +262,7 @@ CPPFLAGS="%{rpmcppflags} -std=gnu99 -fgnu89-inline"
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_sysconfdir}/%{name}/repos.d,/var/cache/%{name}}
+install -d $RPM_BUILD_ROOT/var/cache/%{name}
 
 %{__make} install -j1 \
 	DESTDIR=$RPM_BUILD_ROOT
@@ -460,10 +462,23 @@ if [ -f %{_sysconfdir}/%{name}/repos.d/pld-%{SNAP}-multilib.conf.rpmsave ]; then
 	%{__mv} -v %{_sysconfdir}/%{name}/repos.d/pld-%{SNAP}-multilib.conf.rpmsave %{_sysconfdir}/%{name}/repos.d/pld-%{SNAP}-%{ftp_alt_arch}.conf
 fi
 
+%triggerpostun -- %{name} < 0.30.1-8
+if [ $1 -le 1 ]; then
+	# revert change on  --downgrade
+	%{__sed} -i -re 's,^pm command = %{_libexecdir}/pm-command.sh,#&,' /etc/poldek/poldek.conf
+else
+	# setup pm command
+	%{__sed} -i -re 's,#?(pm command =).*,\1 %{_libexecdir}/pm-command.sh,' /etc/poldek/poldek.conf
+fi
+
 %files -f %{name}.lang
 %defattr(644,root,root,755)
 %doc ChangeLog README* NEWS TODO configs
 %dir %{_sysconfdir}/%{name}
+%dir %{_sysconfdir}/%{name}/pre-install.d
+%{_sysconfdir}/%{name}/pre-install.d/README
+%dir %{_sysconfdir}/%{name}/post-install.d
+%{_sysconfdir}/%{name}/post-install.d/README
 %dir %{_sysconfdir}/%{name}/repos.d
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/*.conf
 %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{name}/repos.d/*.conf
@@ -471,6 +486,7 @@ fi
 %attr(755,root,root) %{_bindir}/poldek
 %attr(755,root,root) %{_bindir}/rpmvercmp
 %dir %{_libexecdir}
+%attr(755,root,root) %{_libexecdir}/pm-command.sh
 %attr(755,root,root) %{_libexecdir}/poldekuser-setup.sh
 %attr(755,root,root) %{_libexecdir}/vfcompr
 %attr(755,root,root) %{_libexecdir}/vfjuggle
diff --git a/pm-hooks.patch b/pm-hooks.patch
new file mode 100644
index 0000000..9a7d33b
--- /dev/null
+++ b/pm-hooks.patch
@@ -0,0 +1,61 @@
+this could be handled natively by poldek
+but implement as "pm command" hack for now
+
+--- /dev/null	2015-05-20 12:11:30.089022100 +0300
++++ poldek/pm-command.sh	2015-05-31 18:21:15.748917981 +0300
+@@ -0,0 +1,11 @@
++#!/bin/sh
++# wrapper to add pre-install.d and post-install.d support for pm command in poldek
++
++/bin/run-parts /etc/poldek/pre-install.d
++
++/bin/rpm "$@"
++rc=$?
++
++/bin/run-parts /etc/poldek/post-install.d
++
++exit $rc
+--- /dev/null	2015-05-20 12:11:30.089022100 +0300
++++ poldek/conf/pre-install.d/README	2015-05-31 18:18:35.539100326 +0300
+@@ -0,0 +1,2 @@
++Files in this directory are run before packages are installed, upgraded,
++etc.
+--- /dev/null	2015-05-20 12:11:30.089022100 +0300
++++ poldek/conf/post-install.d/README	2015-05-31 18:18:45.883922914 +0300
+@@ -0,0 +1 @@
++Files in this directory are run after packages are installed, upgraded, etc.
+--- poldek-0.30.1/conf/poldek.conf~	2015-05-31 18:25:35.000000000 +0300
++++ poldek-0.30.1/conf/poldek.conf	2015-05-31 18:26:28.410188923 +0300
+@@ -56,7 +56,7 @@
+ #exclude path = 
+ 
+ # Full path name to a PM (rpm for now) binary.
+-#pm command = /bin/rpm
++pm command = /usr/lib/poldek/pm-command.sh
+ 
+ # Full path name to sudo binary.
+ #sudo command = /usr/bin/sudo
+--- poldek-0.30.1/conf/Makefile.am	2015-05-31 18:28:29.319806773 +0300
++++ poldek-0.30.1/conf/Makefile.am	2015-05-31 19:12:22.206571793 +0300
+@@ -26,6 +26,10 @@
+ 
+ install-data-local: $(GENCONFIGS)
+ 	 $(MKDIR_P) $(DESTDIR)$(sysconfdir)/$(PACKAGE)/repos.d
++	 $(MKDIR_P) $(DESTDIR)$(sysconfdir)/$(PACKAGE)/pre-install.d
++	 $(INSTALL_DATA) pre-install.d/README $(DESTDIR)$(sysconfdir)/$(PACKAGE)/pre-install.d
++	 $(MKDIR_P) $(DESTDIR)$(sysconfdir)/$(PACKAGE)/post-install.d
++	 $(INSTALL_DATA) post-install.d/README $(DESTDIR)$(sysconfdir)/$(PACKAGE)/post-install.d
+ 	 for a in $(CONFIGS); do \
+ 	 	$(INSTALL_DATA) $(srcdir)/$$a $(DESTDIR)$(sysconfdir)/$(PACKAGE); \
+ 	 done
+--- poldek-0.30.1/Makefile.am~	2014-03-26 00:32:25.000000000 +0200
++++ poldek-0.30.1/Makefile.am	2015-05-31 19:10:22.240340180 +0300
+@@ -79,7 +79,7 @@
+ LDADD_              = @INTLLIBS@
+ 
+ vfscriptsdir = $(PKGLIBDIR)
+-vfscripts_SCRIPTS = zlib-in-rpm.sh vfjuggle vfcompr vfsmb poldekuser-setup.sh
++vfscripts_SCRIPTS = zlib-in-rpm.sh vfjuggle vfcompr vfsmb poldekuser-setup.sh pm-command.sh
+ 
+ EXTRA_DIST = \
+ 	     $(vfscripts_SCRIPTS) \
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/poldek.git/commitdiff/c5d1808a4ce32966f9bd4444fc9bcce26b6143f3



More information about the pld-cvs-commit mailing list