From e0346b36fc0e6e17c80c047b13997448ccf1c76e Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Sun, 11 Oct 2015 18:27:45 +0200 Subject: [PATCH] rpm: replace literal paths with RPM macros The only place we should write out literal paths is in the RPM scriptlets, and there only for things that are not installed by this package. Signed-off-by: Nathan Cutler --- ceph.spec.in | 56 ++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/ceph.spec.in b/ceph.spec.in index 113d40204c9..7abff096eeb 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -37,16 +37,16 @@ %{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null || echo 0.0.0)} %define relabel_files() \ -restorecon -R /usr/bin/ceph-mon > /dev/null 2>&1; \ -restorecon -R /usr/bin/ceph-osd > /dev/null 2>&1; \ -restorecon -R /usr/bin/ceph-mds > /dev/null 2>&1; \ -restorecon -R /usr/bin/radosgw > /dev/null 2>&1; \ +restorecon -R %{_bindir}/ceph-mon > /dev/null 2>&1; \ +restorecon -R %{_bindir}/ceph-osd > /dev/null 2>&1; \ +restorecon -R %{_bindir}/ceph-mds > /dev/null 2>&1; \ +restorecon -R %{_bindir}/radosgw > /dev/null 2>&1; \ restorecon -R /etc/rc\.d/init\.d/ceph > /dev/null 2>&1; \ restorecon -R /etc/rc\.d/init\.d/radosgw > /dev/null 2>&1; \ -restorecon -R /var/run/ceph > /dev/null 2>&1; \ -restorecon -R /var/lib/ceph > /dev/null 2>&1; \ -restorecon -R /var/log/ceph > /dev/null 2>&1; \ -restorecon -R /var/log/radosgw > /dev/null 2>&1; +restorecon -R %{_localstatedir}/run/ceph > /dev/null 2>&1; \ +restorecon -R %{_localstatedir}/lib/ceph > /dev/null 2>&1; \ +restorecon -R %{_localstatedir}/log/ceph > /dev/null 2>&1; \ +restorecon -R %{_localstatedir}/log/radosgw > /dev/null 2>&1; %endif %{!?_udevrulesdir: %global _udevrulesdir /lib/udev/rules.d} @@ -632,8 +632,8 @@ export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed -e 's/i386/i486/'` %{configure} CPPFLAGS="$java_inc" \ --prefix=/usr \ --libexecdir=%{_libexecdir} \ - --localstatedir=/var \ - --sysconfdir=/etc \ + --localstatedir=%{_localstatedir} \ + --sysconfdir=%{_sysconfdir} \ %if 0%{?rhel} && ! 0%{?centos} --enable-subman \ %endif @@ -877,8 +877,8 @@ DISABLE_RESTART_ON_UPDATE="yes" CEPH_GROUP_ID=167 CEPH_USER_ID=167 %if 0%{?rhel} || 0%{?fedora} -%{_sbindir}/groupadd ceph -g $CEPH_GROUP_ID -o -r 2>/dev/null || : -%{_sbindir}/useradd ceph -u $CEPH_USER_ID -o -r -g ceph -s /sbin/nologin -c "Ceph daemons" -d %{_localstatedir}/lib/ceph 2>/dev/null || : +/usr/sbin/groupadd ceph -g $CEPH_GROUP_ID -o -r 2>/dev/null || : +/usr/sbin/useradd ceph -u $CEPH_USER_ID -o -r -g ceph -s /sbin/nologin -c "Ceph daemons" -d %{_localstatedir}/lib/ceph 2>/dev/null || : %endif %if 0%{?suse_version} if ! getent group ceph >/dev/null ; then @@ -900,8 +900,8 @@ exit 0 %postun common # Package removal cleanup if [ "$1" -eq "0" ] ; then - rm -rf /var/log/ceph - rm -rf /etc/ceph + rm -rf %{_localstatedir}/log/ceph + rm -rf %{_sysconfdir}/ceph fi ################################################################################# @@ -943,7 +943,7 @@ DISABLE_RESTART_ON_UPDATE="yes" if [ $FIRST_ARG -ge 1 ] ; then # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then source $SYSCONF_CEPH fi @@ -994,7 +994,7 @@ DISABLE_RESTART_ON_UPDATE="yes" if [ $FIRST_ARG -ge 1 ] ; then # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then source $SYSCONF_CEPH fi @@ -1055,7 +1055,7 @@ DISABLE_RESTART_ON_UPDATE="yes" if [ $FIRST_ARG -ge 1 ] ; then # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then source $SYSCONF_CEPH fi @@ -1115,7 +1115,7 @@ DISABLE_RESTART_ON_UPDATE="yes" if [ $FIRST_ARG -ge 1 ] ; then # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then source $SYSCONF_CEPH fi @@ -1138,7 +1138,7 @@ fi %{_mandir}/man8/ceph-disk.8* %{_mandir}/man8/ceph-osd.8* %if 0%{?rhel} && ! 0%{?centos} -/etc/cron.hourly/subman +%{_sysconfdir}/cron.hourly/subman %endif %{_unitdir}/ceph-osd@.service %{_unitdir}/ceph-osd.target @@ -1176,7 +1176,7 @@ DISABLE_RESTART_ON_UPDATE="yes" if [ $FIRST_ARG -ge 1 ] ; then # Restart on upgrade, but only if "CEPH_AUTO_RESTART_ON_UPGRADE" is set to # "yes". In any case: if units are not running, do not touch them. - SYSCONF_CEPH=/etc/sysconfig/ceph + SYSCONF_CEPH=%{_sysconfdir}/sysconfig/ceph if [ -f $SYSCONF_CEPH -a -r $SYSCONF_CEPH ] ; then source $SYSCONF_CEPH fi @@ -1399,13 +1399,13 @@ ln -sf %{_libdir}/librbd.so.1 /usr/lib64/qemu/librbd.so.1 %post selinux # Install the policy -OLD_POLVER=$(%{_sbindir}/semodule -l | grep -P '^ceph[\t ]' | awk '{print $2}') -%{_sbindir}/semodule -n -i %{_datadir}/selinux/packages/ceph.pp -NEW_POLVER=$(%{_sbindir}/semodule -l | grep -P '^ceph[\t ]' | awk '{print $2}') +OLD_POLVER=$(/usr/sbin/semodule -l | grep -P '^ceph[\t ]' | awk '{print $2}') +/usr/sbin/semodule -n -i /usr/share/selinux/packages/ceph.pp +NEW_POLVER=$(/usr/sbin/semodule -l | grep -P '^ceph[\t ]' | awk '{print $2}') # Load the policy if SELinux is enabled -if %{_sbindir}/selinuxenabled; then - %{_sbindir}/load_policy +if /usr/sbin/selinuxenabled; then + /usr/sbin/load_policy else # Do not relabel if selinux is not enabled exit 0 @@ -1438,11 +1438,11 @@ exit 0 %postun selinux if [ $1 -eq 0 ]; then # Remove the module - %{_sbindir}/semodule -n -r ceph + /usr/sbin/semodule -n -r ceph # Reload the policy if SELinux is enabled - if %{_sbindir}/selinuxenabled ; then - %{_sbindir}/load_policy + if /usr/sbin/selinuxenabled ; then + /usr/sbin/load_policy else # Do not relabel if SELinux is not enabled exit 0 -- 2.47.3