File build-drop-old-config-file-transition-code-from-rpm-.patch of Package pcp.13957

From 34c83f7ee46224fe410572f33c57a739f7bd044f Mon Sep 17 00:00:00 2001
From: Nathan Scott <nathans@redhat.com>
Date: Sun, 6 Oct 2019 14:10:40 +1100
Subject: [PATCH] build: drop old config file transition code from rpm specs

Its been many years since this transition was done, good time
now with pcp-5.0.0 to full this old shell code.  Also remove
the Fedora crontab transition logic as thats completely moved
over to systemd now.
---
 build/rpm/GNUmakefile |  1 +
 build/rpm/fedora.spec | 57 +-----------------------------------------------
 build/rpm/pcp.spec.in | 60 ++-------------------------------------------------
 3 files changed, 4 insertions(+), 114 deletions(-)

Index: pcp-3.11.9/build/rpm/GNUmakefile
===================================================================
--- pcp-3.11.9.orig/build/rpm/GNUmakefile
+++ pcp-3.11.9/build/rpm/GNUmakefile
@@ -102,6 +102,7 @@ pcp.spec: pcp.spec.in
 	    -e's|@pcp_sysconf_dir@|$(PCP_SYSCONF_DIR)|g' \
 	    -e's|@pcp_share_dir@|$(PCP_SHARE_DIR)|g' \
 	    -e's|@pcp_log_dir@|$(PCP_LOG_DIR)|g' \
+	    -e's|@pcp_sa_dir@|$(PCP_SA_DIR)|g' \
 	    -e's|@pcp_var_dir@|$(PCP_VAR_DIR)|g' \
 	    -e's|@pcp_etc_dir@|$(PCP_ETC_DIR)|g' \
 	    -e's|@pcp_selinux_dir@|$(PCP_SELINUX_DIR)|g' \
Index: pcp-3.11.9/build/rpm/fedora.spec
===================================================================
--- pcp-3.11.9.orig/build/rpm/fedora.spec
+++ pcp-3.11.9/build/rpm/fedora.spec
@@ -2056,56 +2056,6 @@ exit 0
 getent group pcp >/dev/null || groupadd -r pcp
 getent passwd pcp >/dev/null || \
   useradd -c "Performance Co-Pilot" -g pcp -d %{_localstatedir}/lib/pcp -M -r -s /sbin/nologin pcp
-PCP_CONFIG_DIR=%{_localstatedir}/lib/pcp/config
-PCP_SYSCONF_DIR=%{_confdir}
-PCP_LOG_DIR=%{_logsdir}
-PCP_ETC_DIR=%{_sysconfdir}
-# rename crontab files to align with current Fedora packaging guidelines
-for crontab in pmlogger pmie
-do
-    test -f "$PCP_ETC_DIR/cron.d/$crontab" || continue
-    mv -f "$PCP_ETC_DIR/cron.d/$crontab" "$PCP_ETC_DIR/cron.d/pcp-$crontab"
-done
-# produce a script to run post-install to move configs to their new homes
-save_configs_script()
-{
-    _new="$1"
-    shift
-    for _dir
-    do
-        [ "$_dir" = "$_new" ] && continue
-        if [ -d "$_dir" ]
-        then
-            ( cd "$_dir" ; find . -maxdepth 1 -type f ) | sed -e 's/^\.\///' \
-            | while read _file
-            do
-                [ "$_file" = "control" ] && continue
-                _want=true
-                if [ -f "$_new/$_file" ]
-                then
-                    # file exists in both directories, pick the more
-                    # recently modified one
-                    _try=`find "$_dir/$_file" -newer "$_new/$_file" -print`
-                    [ -n "$_try" ] || _want=false
-                fi
-                $_want && echo cp -p "$_dir/$_file" "$_new/$_file"
-            done
-        fi
-    done
-}
-# migrate and clean configs if we have had a previous in-use installation
-[ -d "$PCP_LOG_DIR" ] || exit 0	# no configuration file upgrades required
-rm -f "$PCP_LOG_DIR/configs.sh"
-for daemon in pmie pmlogger
-do
-    save_configs_script >> "$PCP_LOG_DIR/configs.sh" "$PCP_CONFIG_DIR/$daemon" \
-        "$PCP_SYSCONF_DIR/$daemon"
-done
-for daemon in pmcd pmproxy
-do
-    save_configs_script >> "$PCP_LOG_DIR/configs.sh" "$PCP_SYSCONF_DIR/$daemon"\
-        "$PCP_CONFIG_DIR/$daemon" /etc/$daemon
-done
 exit 0
 
 %if !%{disable_microhttpd}
@@ -2426,12 +2376,7 @@ fi
 %endif
 
 %post
-PCP_LOG_DIR=%{_logsdir}
 PCP_PMNS_DIR=%{_pmnsdir}
-# restore saved configs, if any
-test -s "$PCP_LOG_DIR/configs.sh" && source "$PCP_LOG_DIR/configs.sh"
-rm -f $PCP_LOG_DIR/configs.sh
-
 chown -R pcp:pcp %{_logsdir}/pmcd 2>/dev/null
 chown -R pcp:pcp %{_logsdir}/pmlogger 2>/dev/null
 chown -R pcp:pcp %{_logsdir}/pmie 2>/dev/null
@@ -2454,7 +2399,7 @@ chmod 644 "$PCP_PMNS_DIR/.NeedRebuild"
     /sbin/service pmproxy condrestart
 %endif
 
-cd $PCP_PMNS_DIR && ./Rebuild -s && rm -f .NeedRebuild
+cd "$PCP_PMNS_DIR" && ./Rebuild -s && rm -f .NeedRebuild
 cd
 
 %post libs -p /sbin/ldconfig
Index: pcp-3.11.9/build/rpm/pcp.spec.in
===================================================================
--- pcp-3.11.9.orig/build/rpm/pcp.spec.in
+++ pcp-3.11.9/build/rpm/pcp.spec.in
@@ -2377,68 +2377,6 @@ chown -R pcpqa:pcpqa @pcp_var_dir@/tests
 getent group pcp >/dev/null || groupadd -r pcp
 getent passwd pcp >/dev/null || \
     useradd -c "Performance Co-Pilot" -g pcp -d @pcp_var_dir@ -M -r -s /sbin/nologin pcp
-# new directories; they should match /etc/pcp.conf settings after install
-PCP_CONFIG_DIR=@pcp_var_dir@/config
-PCP_SYSCONF_DIR=@pcp_sysconf_dir@
-PCP_LOG_DIR=@pcp_log_dir@
-PCP_ETC_DIR=@pcp_etc_dir@
-
-# transition pmdadmcache over to pmdadm (device mapper)
-PCP_PMCDCONF_PATH=@pcp_pmcdconf_path@
-PCP_PMDAS_DIR=@pcp_pmdas_dir@
-if grep -q ^dmcache "$PCP_PMCDCONF_PATH" 2>/dev/null
-then
-    mkdir -p -m 755 "$PCP_PMDAS_DIR/dm"
-    touch "$PCP_PMDAS_DIR/dm/.NeedInstall"
-    touch "$PCP_PMDAS_DIR/dmcache/.NeedRemove"
-fi
-
-# rename crontab files to align with current Fedora packaging guidelines
-for crontab in pmlogger pmie
-do
-    test -f "$PCP_ETC_DIR/cron.d/$crontab" || continue
-    mv -f "$PCP_ETC_DIR/cron.d/$crontab" "$PCP_ETC_DIR/cron.d/pcp-$crontab"
-done
-# produce a script to run post-install to move configs to their new homes
-save_configs_script()
-{
-    _new="$1"
-    shift
-    for _dir
-    do
-        [ "$_dir" = "$_new" ] && continue
-        if [ -d "$_dir" ]
-        then
-            ( cd "$_dir" ; find . -maxdepth 1 -type f ) | sed -e 's/^\.\///' \
-            | while read _file
-            do
-                [ "$_file" = "control" ] && continue
-                _want=true
-                if [ -f "$_new/$_file" ]
-                then
-                    # file exists in both directories, pick the more
-                    # recently modified one
-                    _try=`find "$_dir/$_file" -newer "$_new/$_file" -print`
-                    [ -n "$_try" ] || _want=false
-                fi
-                $_want && echo cp -p "$_dir/$_file" "$_new/$_file"
-            done
-        fi
-    done
-}
-# migrate and clean configs if we have had a previous in-use installation
-[ -d "$PCP_LOG_DIR" ] || exit 0	# no configuration file upgrades required
-rm -f "$PCP_LOG_DIR/configs.sh"
-for daemon in pmie pmlogger
-do
-    save_configs_script >> "$PCP_LOG_DIR/configs.sh" "$PCP_CONFIG_DIR/$daemon" \
-        "$PCP_SYSCONF_DIR/$daemon"
-done
-for daemon in pmcd pmproxy
-do
-    save_configs_script >> "$PCP_LOG_DIR/configs.sh" "$PCP_SYSCONF_DIR/$daemon"\
-        "$PCP_CONFIG_DIR/$daemon" /etc/$daemon
-done
 exit 0
 
 %if "@enable_webapi@" == "true"
@@ -2783,10 +2721,7 @@ fi
 %post
 PCP_PMNS_DIR=@pcp_var_dir@/pmns
 PCP_LOG_DIR=@pcp_log_dir@
-
-# restore saved configs, if any
-test -s "$PCP_LOG_DIR/configs.sh" && source "$PCP_LOG_DIR/configs.sh"
-rm -f $PCP_LOG_DIR/configs.sh
+PCP_SA_DIR=@pcp_sa_dir@
 
 chown -R pcp:pcp "$PCP_LOG_DIR/pmcd" 2>/dev/null
 chown -R pcp:pcp "$PCP_LOG_DIR/pmlogger" 2>/dev/null
@@ -2810,7 +2745,7 @@ chmod 644 "$PCP_PMNS_DIR/.NeedRebuild"
     /sbin/service pmproxy condrestart
 %endif
 
-cd $PCP_PMNS_DIR && ./Rebuild -s && rm -f .NeedRebuild
+cd "$PCP_PMNS_DIR" && ./Rebuild -s && rm -f .NeedRebuild
 cd
 
 %post libs -p /sbin/ldconfig
openSUSE Build Service is sponsored by