]> arthur.barton.de Git - bup.git/blob - t/lib.sh
464037932c295ff3dd587388a43ca97be15e3b21
[bup.git] / t / lib.sh
1 # Assumes shell is Bash.
2
3 force-delete()
4 {
5     local rc=0
6     # Try *hard* to delete $@.  Among other things, some systems have
7     # r-xr-xr-x for root and other system dirs.
8     rm -rf "$@" # Maybe we'll get lucky.
9     for f in "$@"; do
10         test -e "$f" || continue
11         if test "$(type -p setfacl)"; then
12             setfacl -Rb "$f"
13         fi
14         if test "$(type -p chattr)"; then
15             chattr -R -aisu "$f"
16         fi
17         chmod -R u+rwX "$f"
18         rm -r "$f"
19         if test -e "$f"; then
20             rc=1
21             find "$f" -ls
22             lsattr -aR "$f"
23             getfacl -R "$f"
24         fi
25     done
26     return $rc
27 }
28
29 realpath()
30 {
31     test "$#" -eq 1 || return $?
32     local script_home=$(cd "$(dirname $0)" && pwd)
33     echo "$1" | \
34         PYTHONPATH="${script_home}/../lib" python -c \
35         "import sys, bup.helpers; print bup.helpers.realpath(sys.stdin.readline())" \
36         || return $?
37 }