Pārlūkot izejas kodu

Merge pull request #7493 from mckellyln/rpmrease

HPCC-13672 Uninstall should not remove install dir if it is a symbolic link

Reviewed-By: Xiaoming Wang <xiaoming.wang@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 gadi atpakaļ
vecāks
revīzija
26e290af87
2 mainītis faili ar 25 papildinājumiem un 0 dzēšanām
  1. 15 0
      initfiles/bash/sbin/deb/postrm.in
  2. 10 0
      initfiles/sbin/prerm.in

+ 15 - 0
initfiles/bash/sbin/deb/postrm.in

@@ -17,6 +17,21 @@
 
 ###<REPLACE>###
 
+# Restore install link if it was present
+#######################
+linkf=/tmp/.hpccinslink
+if [[ -f ${linkf} ]] ; then
+   if [[ -n ${INSTALL_DIR} ]] ; then
+      if [[ ! -d ${INSTALL_DIR} ]] ; then
+         linkinfo=$(cat "${linkf}")
+         if [[ -n ${linkinfo} ]] ; then
+            ln -s ${linkinfo}
+         fi
+      fi
+   fi
+   rm -f ${linkf}
+fi
+
 # On some systems, when running an update (as opposed to a remove) the postinstall script does
 # not get run. To work around that issue, we run the post-install actions in the post-remove script
 # (which IS run)

+ 10 - 0
initfiles/sbin/prerm.in

@@ -47,5 +47,15 @@ if [ -f ${CONFIG_DIR}/installed ] ; then
     rm ${CONFIG_DIR}/installed
 fi
 
+# Check if install dir is a link
+#######################
+if [[ -n ${INSTALL_DIR} ]] ; then
+#  trim for readlink
+   ins_dir=$(echo "${INSTALL_DIR}" | sed 's/\/*$//')
+   if [[ -h ${ins_dir} ]] ; then
+       echo "$(readlink "${ins_dir}") ${INSTALL_DIR}" > /tmp/.hpccinslink
+   fi
+fi
+
 exit 0