diff options
author | Kaleb S KEITHLEY <kkeithle@redhat.com> | 2016-03-08 22:50:41 -0500 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2016-03-09 13:11:44 -0800 |
commit | 73f415353b0d70a4e6e4a4cedc05cd9b8418625f (patch) | |
tree | bd0c1f43d8506768ef1c9ebd7697b4fdcbf692b4 | |
parent | df1b06d24d5f699f397d7936dda740364c5126cd (diff) |
packaging: rpm scriptlet cleanup, handle -p /sbin/ldconfig
The RPM documention indicates that during an rpm install or erase, the
script(lets): %post, %preun, and %postun (and %pre, %build, %install,
etc.) are copied to a temp file, and then the temp file is run as a
(/bin/sh or bash) script.
Unfortunately the documentation is not clear about how rpmbuild and/or
rpm determine where the end of any scriptlet is when it is copied to
the file.
Most things in the glusterfs.spec work correctly as is. These are the
%preun, %post, and %postun scriptlets that are "closed" by a following
%preun, %post, and %postun, or poetentially another scriptlet, e.g.
%file.
The ones that don't work correctly (only one actually) are those where
there is a comment in the spec file before it is closed by another
scriptlet. Further complicating things is that the type of scriptlet
affects what rpm does and what `rpm -qp --scripts ...` shows.
The specific one that didn't work was the "%postun libs" scriptlet. It
is followed by a comment before being "closed" by the %files section (or
scriptlet). It can be written two ways: "%postun libs\n/sbin/ldconfig"
or "%postun libs -p /sbin/ldconfig" Either way it's written, `rpm -qp
--scripts glusterfs-libs...` will include the comment lines between the
%postun libs line and the following %files line.
But the way rpm executes these depends on how they're written. If
written as "%postun libs\n/sbin/ldconfig" rpm will simply run
/sbin/ldconfig with no command line options, i.e.
execve ("/sbin/ldconfig", [ "/sbin/ldconfig" ], [ ]);
But when written as "%postun libs -p /sbin/ldconfig", it will copy
the comment lines to a temp file, and pass the temp file name and "1"
as (command line) parameters, i.e.
execve ("/sbin/ldconfig", [ "/sbin/ldconfig", "/tmp/tmpXXXXXX", "1" ],
[ ]);
Which results in ldconfig exiting with an error. (Remember, both ways show
the comment in `rpm -qp --scripts ...`)
(Note though, that the similar "%postun api -p /sbin/ldconfig" is run
correctly, because it is "closed" by the following "%postun server"
scriptlet.)
Finally, through trial and error, it appears that rpm can be tricked with
a hack, and "closure" of the scriptlet forcedlike this:
%postun libs -p /sbin/ldconfig
%if ( 0%{?_undocumented_hack_closes_scriptlets} )
%postun
%endif
in which case ldconfig appears to run correctly. Note also that here too
the comment will be included in the output of `rpm -qp --scripts ...`
But that's very ugly hack.
backport of:
>Change-Id: I587a490ddcdf47d01605479bc8ef8b0e439108fb
>BUG: 1315024
>Reviewed-on http://review.gluster.org/#/c/13613/
Change-Id: Ia45162ba0282db00026b3da5396811fdef5e6515
BUG: 1315935
Signed-off-by: Kaleb S KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/13650
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r-- | glusterfs.spec.in | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/glusterfs.spec.in b/glusterfs.spec.in index 38ad3f816b4..d1d274befe9 100644 --- a/glusterfs.spec.in +++ b/glusterfs.spec.in @@ -48,7 +48,7 @@ %{?_without_syslog:%global _without_syslog --disable-syslog} # disable syslog forcefully as rhel <= 6 doesn't have rsyslog or rsyslog-mmcount -# Fedora deprecated syslog, see +# Fedora deprecated syslog, see # https://fedoraproject.org/wiki/Changes/NoDefaultSyslog # (And what about RHEL7?) %if ( 0%{?fedora} && 0%{?fedora} >= 20 ) || ( 0%{?rhel} && 0%{?rhel} <= 6 ) @@ -78,7 +78,7 @@ %endif ##----------------------------------------------------------------------------- -## All %global definitions should be placed here and keep them sorted +## All %%global definitions should be placed here and keep them sorted ## %if ( 0%{?fedora} && 0%{?fedora} > 16 ) || ( 0%{?rhel} && 0%{?rhel} > 6 ) @@ -258,8 +258,6 @@ Summary: GlusterFS api library Group: System Environment/Daemons Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}-client-xlators%{?_isa} = %{version}-%{release} -# we provide the Python package/namespace 'gluster' -#Provides: python-gluster = %{version}-%{release} %description api GlusterFS is a distributed file-system capable of scaling to several @@ -770,33 +768,34 @@ install -p -m 0744 -D extras/command-completion/gluster.bash \ rm -rf %{buildroot} ##----------------------------------------------------------------------------- -## All %post should be placed here and keep them sorted +## All %%post should be placed here and keep them sorted ## %post +/sbin/ldconfig %if ( 0%{!?_without_syslog:1} ) %if ( 0%{?fedora} ) || ( 0%{?rhel} && 0%{?rhel} >= 6 ) %_init_restart rsyslog +exit 0 %endif %endif -%post api -/sbin/ldconfig +%post api -p /sbin/ldconfig -%post fuse %if ( 0%{?rhel} == 5 ) +%post fuse modprobe fuse +exit 0 %endif %if ( 0%{!?_without_georeplication:1} ) %post geo-replication -#restart glusterd. if [ $1 -ge 1 ]; then %_init_restart glusterd fi +exit 0 %endif -%post libs -/sbin/ldconfig +%post libs -p /sbin/ldconfig %post server # Legacy server @@ -870,9 +869,10 @@ else #rpm_script_t context. rm -rf /var/run/glusterd.socket fi +exit 0 ##----------------------------------------------------------------------------- -## All %preun should be placed here and keep them sorted +## All %%preun should be placed here and keep them sorted ## %preun server if [ $1 -eq 0 ]; then @@ -891,9 +891,10 @@ if [ $1 -ge 1 ]; then fi %_init_restart glusterd fi +exit 0 ##----------------------------------------------------------------------------- -## All %postun should be placed here and keep them sorted +## All %%postun should be placed here and keep them sorted ## %postun /sbin/ldconfig @@ -903,23 +904,21 @@ fi %endif %endif -%postun api -/sbin/ldconfig +%postun api -p /sbin/ldconfig + +%postun libs -p /sbin/ldconfig -%postun server %if (0%{?_with_firewalld:1}) +%postun server #reload service files if firewalld running if $(systemctl is-active firewalld 1>/dev/null 2>&1); then firewall-cmd --reload fi +exit 0 %endif - -%postun libs -/sbin/ldconfig - ##----------------------------------------------------------------------------- -## All files should be placed here and keep them grouped +## All %%files should be placed here and keep them grouped ## %files %doc ChangeLog COPYING-GPLV2 COPYING-LGPLV3 INSTALL README.md THANKS @@ -971,7 +970,6 @@ fi %{_tmpfilesdir}/gluster.conf %endif - %files api %exclude %{_libdir}/*.so # libgfapi files @@ -1219,6 +1217,9 @@ fi %changelog +* Tue Mar 8 2016 Kaleb S. KEITHLEY <kkeithle@redhat.com> +- %%pre, %%post etc. scriptlet cleanup, ... -p /sbin/ldconfig (#1315935) + * Wed Feb 24 2016 Aravinda VK <avishwan@redhat.com> - Added schedule_georep.py script to glusterfs-georep rpm (#1309191) @@ -1368,7 +1369,7 @@ fi * Wed Apr 02 2014 Arumugam Balamurugan <barumuga@redhat.com> - add version/release dynamically (#1074919) -* Thu Mar 26 2014 Kaleb S. KEITHLEY <kkeithle@redhat.com> +* Thu Mar 27 2014 Kaleb S. KEITHLEY <kkeithle@redhat.com> - attr dependency (#1184626) * Wed Mar 26 2014 Poornima G <pgurusid@redhat.com> |