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>
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
--- /dev/null
+#!/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"
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()