[PATCH 2 of 3] Factored out recursive deletion of empty dirs
Wald Commits
scm-commit at wald.intevation.org
Thu Jul 3 11:02:07 CEST 2014
# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404377019 -7200
# Node ID 2d64ff7e22e8a6aafc9bd76b53c144db976fc618
# Parent feaabee15e72c7392fb85aa54d0db3d30a20bff3
Factored out recursive deletion of empty dirs.
diff -r feaabee15e72 -r 2d64ff7e22e8 packaging/linux-installer.inc.in
--- 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."
More information about the Trustbridge-commits
mailing list