[PATCH 2 of 2] Fixed errors when not all expected files exist on deinstallation

Wald Commits scm-commit at wald.intevation.org
Fri Jul 4 17:49:43 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404488966 -7200
# Node ID 96cac71834bad185ace37fd562c161b4b94a48a5
# Parent  d8c8e14b99538ed45079d65e15c6a08afff8a008
Fixed errors when not all expected files exist on deinstallation.

diff -r d8c8e14b9953 -r 96cac71834ba packaging/linux-installer.inc.in
--- a/packaging/linux-installer.inc.in	Fri Jul 04 17:27:55 2014 +0200
+++ b/packaging/linux-installer.inc.in	Fri Jul 04 17:49:26 2014 +0200
@@ -180,13 +180,23 @@
   # Recursively remove DIRECTORY and all it _parent_ directories as
   # long as they are empty.
   local directory="$1"
-  while [ "$directory" -a -z "$(ls -A "$directory")" ] ; do
+  while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do
     echo "Deleting empty directory '$directory' ..."
     rmdir "$directory"
     directory=`dirname "$directory"`
   done
 }
 
+rm_files()
+{
+  for file in "$@" ; do
+    if [ -e "$file" ] ; then
+        echo "Deleting $file ..."
+        rm "$file"
+    fi
+  done
+}
+
 setup_cronjob()
 {
   # FIXME: handle case of system wide installation.
@@ -209,7 +219,7 @@
 deinstall_certs()
 {
   local cinst="${oldinstcfg[PREFIX]}/bin/cinst"
-  local certlist=`ls -1  ${instdata_path}/list-*.txt | sort -nr | head -n 1`
+  local certlist=`ls 2>/dev/null -1  ${instdata_path}/list-*.txt | sort -nr | head -n 1`
 
   echo "Uninstalling certificates ..."
 
@@ -234,18 +244,13 @@
   local tbcfg_files=( "${instcfg_path}/TrustBridge.ini"
                       "${instcfg_path}/trustbridge-tray-starter.cfg"
                       "$instcfg_file" )
+
   echo "Removing certificate lists from: ${instdata_path}:"
-  for file in "$instdata_path"/list-*.txt ; do
-    echo "Deleting $file ..."
-    rm "$file"
-  done
+  rm_files "$instdata_path"/list-*.txt
   rm_empty_dirs "$instdata_path"
 
   echo "Removing configuration files:"
-  for file in "${tbcfg_files[@]}" ; do
-    echo "Deleting $file ..."
-    rm "$file"
-  done
+  rm_files "${tbcfg_files[@]}"
   rm_empty_dirs "$instcfg_path"
 }
 


More information about the Trustbridge-commits mailing list