]> arthur.barton.de Git - bup.git/commitdiff
Create t/force-delete from t/lib.sh force-delete and use it everywhere.
authorRob Browning <rlb@defaultvalue.org>
Tue, 3 Dec 2013 20:17:26 +0000 (14:17 -0600)
committerRob Browning <rlb@defaultvalue.org>
Tue, 3 Dec 2013 20:17:29 +0000 (14:17 -0600)
Move the t/lib.sh force-delete code to t/force-delete as a standalone
command, and use it everywhere -- particularly to delete t/tmp during
"make clean", given the recent move to run all tests inside t/ via
TMPDIR (18f838c9a66d521f9fa042eead3c5771ca99b03a).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Makefile
t/force-delete [new file with mode: 0755]
t/lib.sh

index 0e2fc90699c7c095422bd0253407a8aa54315aa4..5c0cf6c6edb3bb4317be6a3651858ecd27380b1d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -179,5 +179,5 @@ clean: Documentation/clean config/clean
        if test -e bupmeta.tmp/testfs-limited; \
          then umount bupmeta.tmp/testfs-limited || true; fi
        rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
-       if test -e t/tmp; then rm -r t/tmp; fi
+       if test -e t/tmp; then t/force-delete t/tmp; fi
        t/configure-sampledata --clean
diff --git a/t/force-delete b/t/force-delete
new file mode 100755 (executable)
index 0000000..d43fd82
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -o pipefail
+
+# Try *hard* to delete $@.  Among other things, some systems have
+# r-xr-xr-x for root and other system dirs.
+
+rc=0
+rm -rf "$@" # Maybe we'll get lucky.
+for f in "$@"; do
+    test -e "$f" || continue
+    if test "$(type -p setfacl)"; then
+        setfacl -Rb "$f"
+    fi
+    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
+
+if test "$rc" -ne 0; then
+    echo "Failed to delete everything" 1>&2
+fi
+
+exit "$rc"
index 93b2e598bb50b7ad62c90905c1e48f1c88d42bbf..372f0d20d5d5983ee0c8428d3a6cdda9473344c3 100644 (file)
--- a/t/lib.sh
+++ b/t/lib.sh
@@ -4,28 +4,7 @@ bup_t_lib_script_home=$(cd "$(dirname $0)" && pwd)
 
 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 "$f" || continue
-        if test "$(type -p setfacl)"; then
-            setfacl -Rb "$f"
-        fi
-        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
+    "$bup_t_lib_script_home/force-delete" "$@"
 }
 
 realpath()