# HG changeset patch # User Pascal Bellard # Date 1270234578 -7200 # Node ID 30da93cc3cd525396882c19455788ff9a47e6ea9 # Parent 5870b9a92261e33c1930d02d8181853e619499a0 xarchive: fix double suffix case (.tar.gz) diff -r 5870b9a92261 -r 30da93cc3cd5 xarchive/stuff/slitaz-wrap.sh --- a/xarchive/stuff/slitaz-wrap.sh Fri Apr 02 13:24:21 2010 +0000 +++ b/xarchive/stuff/slitaz-wrap.sh Fri Apr 02 20:56:18 2010 +0200 @@ -61,9 +61,16 @@ # the shifting will leave the files passed as all the remaining args "$@" opt="$1" archive="$2" -lc_ext="$(echo ${2##*.} |tr [:upper:] [:lower:])" +lc="$(echo $2|tr [:upper:] [:lower:])" shift 2 +in_exts() +{ +for i in $@; do + [ $(expr "$lc" : ".*\."$i"$") -gt 0 ] && break +done +} + tazpkg2cpio() { tmp="$(mktemp -d -t tmpcpio.XXXXXX)" @@ -83,13 +90,12 @@ DECOMPRESS="cat" COMPRESS="cat" while read d c exts; do - case " $exts " in *\ $lc_ext\ *) - [ "$d" == "${d% *}" -o "$(which ${d% *})" ] || exit $UNSUPPORTED - DECOMPRESS="$d" - COMPRESS="$c" - [ "$(which ${c% *})" ] || COMPRESS="false" - break - esac + in_exts $exts || continue + [ "$d" == "${d% *}" -o "$(which ${d% *})" ] || exit $UNSUPPORTED + DECOMPRESS="$d" + COMPRESS="$c" + [ "$(which ${c% *})" ] || COMPRESS="false" + break done < "$archive" - compress_func - fi - tmp="$(mktemp -d -t tartmp.XXXXXX)" - cd $tmp - $DECOMPRESS "$archive" | $extract + in_exts $exts || continue + if [ "$action" = "-n" ]; then + decompress_func + cd "$tardir" + $add "${1#$tardir/}" > "$archive" + compress_func + fi + tmp="$(mktemp -d -t tartmp.XXXXXX)" + cd $tmp + $DECOMPRESS "$archive" | $extract + status=$? + if [ $status -eq 0 -a -n "$1" ]; then + while [ "$1" ]; do + ${action#-}_file "${1#$tardir/}" $here + shift + done + $add $(ls -a | grep -v ^\.$ | grep -v ^\.\.$) | \ + $COMPRESS > "$archive" status=$? - if [ $status -eq 0 -a -n "$1" ]; then - while [ "$1" ]; do - ${action#-}_file "${1#$tardir/}" $here - shift - done - $add $(ls -a | grep -v ^\.$ | grep -v ^\.\.$) | \ - $COMPRESS > "$archive" - status=$? - fi - cd - >/dev/null - rm -rf $tmp - exit $status - esac + fi + cd - >/dev/null + rm -rf $tmp + exit $status done <\ /dev/null $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS @@ -294,7 +292,6 @@ $AWK_PROG -v uuid=$(id -u -n) "$AWK_MISC $1" } - # main: option switches case "$opt" in -i) # info: output supported extentions for progs that exist @@ -327,8 +324,7 @@ -o) # open: mangle output for xarchive while read filter exts; do # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link - case " $exts " in *\ $lc_ext\ *) - $DECOMPRESS "$archive" | $filter | awk0 ' + in_exts $exts && $DECOMPRESS "$archive" | $filter | awk0 ' { attr=$1 size=$3 @@ -336,14 +332,13 @@ time=$5 show($5 " ") }' - esac done < / { link=$3; attr="l"substr(attr, 2) } /^---/ { display() } ' - esac - case " $LHA_EXTS " in *\ $lc_ext\ *) # Desktop/up -> .. # lrwxrwxrwx 0/0 0 0 ****** -lhd- 0000 2009-05-03 16:59:03 [2] - lha v -q -v "$archive" | awk0 ' + in_exts $LHA_EXTS && lha v -q -v "$archive" | awk0 ' { if ($4 == "") { getlink($0); next } attr=$1 @@ -453,35 +438,30 @@ time=$9 display() }' - esac - case " $LZO_EXTS " in *\ $lc_ext\ *) # ------ ------ ------ ----- ---- ---- ---- # LZO1X-1 10057 5675 56.4% 2005-07-25 16:26 path/file - lzop -Plv "$archive" | awku ' + in_exts $LZO_EXTS && lzop -Plv "$archive" | awku ' /-[0-9]+-/ { size=$2 date=$5 time=$6 show($6 " ") }' - esac exit 0 ;; -a|-n) # add to archive / new: create new archive update $opt "$@" while read exe args exts; do - [ "$(which $exe)" ] || continue + in_exts $exts && [ "$(which $exe)" ] || continue [ "$opt$exe" = "-nzip" ] && args="-r" - case " $exts " in *\ $lc_ext\ *) - # only add the file's basename, not the full path - while [ "$1" ]; do - cd "$(dirname "$1")" - $exe $args "$archive" "$(basename "$1")" - status=$? - shift - done - exit $status - esac + # only add the file's basename, not the full path + while [ "$1" ]; do + cd "$(dirname "$1")" + $exe $args "$archive" "$(basename "$1")" + status=$? + shift + done + exit $status done <&2 - exit $UNSUPPORTED - } - exit 0 - esac + in_exts $exts && [ "$(which $exe)" ] || continue + $exe $args "$archive" "$@" | grep -q E_NOTIMPL && { + echo -e "7z cannot delete files from solid archive." >&2 + exit $UNSUPPORTED + } + exit 0 done <