]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
Make force-delete more flexible, and more likely to succeed.
authorRob Browning <rlb@defaultvalue.org>
Tue, 29 Oct 2013 01:23:38 +0000 (20:23 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 1 Nov 2013 23:38:59 +0000 (18:38 -0500)
Thanks to Alexander Barton <alex@barton.de> for helping track down
the correct chattr invocation.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
t/lib.sh

index a2e94de1fd651105568023ecc3604ada733380cd..464037932c295ff3dd587388a43ca97be15e3b21 100644 (file)
--- a/t/lib.sh
+++ b/t/lib.sh
@@ -2,21 +2,28 @@
 
 force-delete()
 {
+    local rc=0
     # Try *hard* to delete $@.  Among other things, some systems have
     # r-xr-xr-x for root and other system dirs.
     rm -rf "$@" # Maybe we'll get lucky.
     for f in "$@"; do
-        test -e "$@" || continue
-        chmod -R u+w "$@"
-        if [[ $(uname) =~ Linux ]]; then
-            chattr -fR = "$@"
-            setfacl -Rb "$@"
+        test -e "$f" || continue
+        if test "$(type -p setfacl)"; then
+            setfacl -Rb "$f"
         fi
-        rm -r "$@"
-        if test -e "$@"; then
-            return 1
+        if test "$(type -p chattr)"; then
+            chattr -R -aisu "$f"
+        fi
+        chmod -R u+rwX "$f"
+        rm -r "$f"
+        if test -e "$f"; then
+            rc=1
+            find "$f" -ls
+            lsattr -aR "$f"
+            getfacl -R "$f"
         fi
     done
+    return $rc
 }
 
 realpath()