From: Rob Browning Date: Tue, 3 Dec 2013 20:17:26 +0000 (-0600) Subject: Create t/force-delete from t/lib.sh force-delete and use it everywhere. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=99a6d3a3c27f79d271b58596a3bafee220be6e2c;p=packages%2Fb%2Fbup.git Create t/force-delete from t/lib.sh force-delete and use it everywhere. 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 --- diff --git a/Makefile b/Makefile index 0e2fc90..5c0cf6c 100644 --- 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 index 0000000..d43fd82 --- /dev/null +++ b/t/force-delete @@ -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" diff --git a/t/lib.sh b/t/lib.sh index 93b2e59..372f0d2 100644 --- 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()