浏览代码

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 年之前
父节点
当前提交
26e290af87
共有 2 个文件被更改,包括 25 次插入0 次删除
  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>###
 ###<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
 # 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
 # not get run. To work around that issue, we run the post-install actions in the post-remove script
 # (which IS run)
 # (which IS run)

+ 10 - 0
initfiles/sbin/prerm.in

@@ -47,5 +47,15 @@ if [ -f ${CONFIG_DIR}/installed ] ; then
     rm ${CONFIG_DIR}/installed
     rm ${CONFIG_DIR}/installed
 fi
 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
 exit 0