4 #get params: / targz / targz --root / targz --root dir /
7 [ "$2" = "--root" ] && REMOVE_FROM_ROOT
=1 && ROOT
=/
8 [ ! -z "$3" ] && ROOT
="$3"
11 tempfile1
=`mktemp --suffix=-tmp1 2> /dev/null`
12 tempfile2
=`mktemp --suffix=-tmp2 2> /dev/null`
13 tempfile3
=`mktemp --suffix=-tmp3 2> /dev/null`
14 trap "rm -f $tempfile1 $tempfile2 $tempfile3" 0 1 2 5 15
17 if [ $REMOVE_FROM_ROOT = 0 ]; then
18 tar tzf
"$1" |
rev |
sort -V |
rev |
tee $tempfile1 |
grep "/$" > $tempfile2
20 if [ "$ROOT" = "/" ]; then
21 tar tzf
"$1" |
sed "s%.*%/&%" |
rev |
sort -V |
rev |
tee $tempfile1 |
grep "/$" > $tempfile2
23 tar tzf
"$1" |
sed "s%.*%$ROOT/&%" |
rev |
sort -V |
rev |
tee $tempfile1 |
grep "/$" > $tempfile2
27 grep -v "/$" $tempfile1 > $tempfile3
28 cat $tempfile3 |
tr '\n' '\0' |
xargs -0 -r rm 2> /dev
/null
29 sort -t / $tempfile2 |
tac > $tempfile1
30 cat $tempfile1 |
tr '\n' '\0' |
xargs -0 -r rmdir 2> /dev
/null