diff packaging/linux-installer.inc.in @ 728:2d64ff7e22e8

Factored out recursive deletion of empty dirs.
author Sascha Wilde <wilde@intevation.de>
date Thu, 03 Jul 2014 10:43:39 +0200
parents feaabee15e72
children efc2d16ab514
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Thu Jul 03 10:17:56 2014 +0200
+++ b/packaging/linux-installer.inc.in	Thu Jul 03 10:43:39 2014 +0200
@@ -173,13 +173,27 @@
   fi
 }
 
+rm_empty_dirs()
+{
+  # Args: $1 - DIRECTORY
+  #
+  # 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
+    echo "Deleting empty directory '$directory' ..."
+    rmdir "$directory"
+    directory=`dirname "$directory"`
+  done
+}
+
 deinstall_certs()
 {
   local cinst="${oldinstcfg[PREFIX]}/bin/cinst"
   local certlist=`ls -1  ${instdata_path}/list-*.txt | sort -nr | head -n 1`
 
   echo "Uninstalling certificates ..."
-  
+
   if [ "$certlist" ] ; then
       echo "Using certificate list '$certlist'."
       if [ -x "$cinst" ] ; then
@@ -205,11 +219,7 @@
         echo "Deleting '$path' ..."
         rm "$path" || echo >&2 "WARNING: Could not delete: '$path'!"
       done
-      while [ "$deinstdir" -a -z "$(ls -A "$deinstdir")" ] ; do
-        echo "Deleting empty directory '$deinstdir' ..."
-        rmdir "$deinstdir"
-        deinstdir=`dirname "$deinstdir"`
-      done
+      rm_empty_dirs "$deinstdir"
       echo "Removing installation configuration from: $instcfg_file ..."
       rm "$instcfg_file"
       echo "Deinstallation finished."

http://wald.intevation.org/projects/trustbridge/