wok-current rev 4909

xarchive: add udeb sfs arj pak arc j uc2 zoo 7z bcj bcj2 support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 13 11:28:10 2010 +0100 (2010-02-13)
parents c7d323dc380c
children abac6afe28b6
files xarchive/stuff/slitaz-wrap.sh
line diff
     1.1 --- a/xarchive/stuff/slitaz-wrap.sh	Fri Feb 12 22:25:57 2010 +0100
     1.2 +++ b/xarchive/stuff/slitaz-wrap.sh	Sat Feb 13 11:28:10 2010 +0100
     1.3 @@ -1,844 +1,544 @@
     1.4  #!/bin/sh
     1.5 -# slitaz-wrap.sh - sh slitaz core wrapper for xarchive frontend
     1.6 -# Copyright (C) 2005 Lee Bigelow <ligelowbee@yahoo.com> 
     1.7 -# Copyright (C) 2009 Pascal Bellard <pascal.bellard@slitaz.org> 
     1.8 -# 
     1.9 +#
    1.10 +# slitaz-wrap.sh - slitaz core wrapper for xarchive frontend
    1.11 +# Copyright (C) 2005 Lee Bigelow <ligelowbee@yahoo.com>
    1.12 +# Copyright (C) 2010 Pascal Bellard <pascal.bellard@slitaz.org>
    1.13 +#
    1.14  # This program is free software; you can redistribute it and/or modify
    1.15  # it under the terms of the GNU General Public License as published by
    1.16  # the Free Software Foundation; either version 2 of the License, or
    1.17  # (at your option) any later version.
    1.18 -# 
    1.19 +#
    1.20  # This program is distributed in the hope that it will be useful,
    1.21  # but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23  # GNU General Public License for more details.
    1.24 -# 
    1.25 +#
    1.26  # You should have received a copy of the GNU General Public License
    1.27  # along with this program; if not, write to the Free Software
    1.28  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.29  
    1.30 -# set up exit status variables
    1.31 -E_UNSUPPORTED=65
    1.32 +UNSUPPORTED=65
    1.33  
    1.34 -# Supported file extentions for tar 
    1.35 -TAR_EXTS="tar"
    1.36 -GZIP_EXTS="tar.gz tgz"
    1.37 +GZIP_EXTS="tar.gz tgz cpio.gz"
    1.38  LZMA_EXTS="tar.lz tar.lzma tlz"
    1.39  BZIP2_EXTS="tar.bz tbz tar.bz2 tbz2"
    1.40 +COMPRESS_EXTS="tar.z tar.Z"
    1.41 +TAR_EXTS="tar tar.gz tgz $LZMA_EXTS $BZIP2_EXTS $COMPRESS_EXTS"
    1.42  XZ_EXTS="tar.xz txz"
    1.43 -COMPRESS_EXTS="tar.z tar.Z"
    1.44  IPK_EXTS="ipk"
    1.45 -CPIO_EXTS="cpio"
    1.46 -CPIOGZ_EXTS="cpio.gz"
    1.47 +CPIO_EXTS="cpio cpio.gz"
    1.48  CPIOXZ_EXTS="cpio.xz"
    1.49  ZIP_EXTS="zip cbz jar"
    1.50  RPM_EXTS="rpm"
    1.51 -DEB_EXTS="deb"
    1.52 +DEB_EXTS="deb udeb"
    1.53  TAZPKG_EXTS="tazpkg spkg"
    1.54  ISO_EXTS="iso"
    1.55 -SQUASHFS_EXTS="sqfs squashfs"
    1.56 -CROMFS_EXTS="cromfs"
    1.57 +SQUASHFS_EXTS="sfs sqfs squashfs"
    1.58 +CROMFS_EXTS="cfs cromfs"
    1.59  FS_EXTS="ext2 ext3 dos fat vfat xfs fd fs loop"
    1.60  CLOOP_EXTS="cloop"
    1.61  RAR_EXTS="rar cbr"
    1.62  LHA_EXTS="lha lzh lzs"
    1.63  LZO_EXTS="lzo"
    1.64 +ARJ_EXTS="arj pak arc j uc2 zoo"
    1.65 +_7Z_EXTS="7z bcj bcj2"
    1.66  
    1.67 -# Setup awk program
    1.68 -AWK_PROGS="mawk gawk awk"
    1.69 -AWK_PROG=""
    1.70 -for awkprog in $AWK_PROGS; do
    1.71 -    if [ "$(which $awkprog)" ]; then
    1.72 -        AWK_PROG="$awkprog"
    1.73 -        break
    1.74 -    fi
    1.75 -done
    1.76 +while read var progs; do
    1.77 +	eval $var=""
    1.78 +	for i in $progs; do
    1.79 +		[ "$(which $i)" ] || continue
    1.80 +		eval $var="$i"
    1.81 +		break
    1.82 +	done
    1.83 +done <<EOT
    1.84 +AWK_PROG	mawk gawk awk
    1.85 +XTERM_PROG	xterm rxvt xvt wterm aterm Eterm false
    1.86 +EOT
    1.87  
    1.88 -# Setup xterm program to use
    1.89 -XTERM_PROGS="xterm rxvt xvt wterm aterm Eterm"
    1.90 -XTERM_PROG=""
    1.91 -for xtermprog in $XTERM_PROGS; do
    1.92 -    if [ "$(which $xtermprog)" ]; then
    1.93 -        XTERM_PROG="$xtermprog"
    1.94 -        break
    1.95 -    fi
    1.96 -done
    1.97 -
    1.98 -# setup variables opt and archive.
    1.99 -# the shifting will leave the files passed as
   1.100 -# all the remaining args "$@"
   1.101 +# the shifting will leave the files passed as all the remaining args "$@"
   1.102  opt="$1"
   1.103 -test -z $1 || shift 1
   1.104 -archive="$1"
   1.105 -test -z $1 || shift 1
   1.106 +archive="$2"
   1.107 +lc_ext="$(echo ${2##*.} |tr [:upper:] [:lower:])"
   1.108 +shift 2
   1.109  
   1.110  tazpkg2cpio()
   1.111  {
   1.112 -	tmpcpio="$(mktemp -d -t tmpcpio.XXXXXX)"
   1.113 -	cd $tmpcpio
   1.114 -	cpio -i > /dev/null < "$1"
   1.115 -	case "$(ls fs.cpio* 2> /dev/null)" in
   1.116 -	fs.cpio.lzma) unlzma -c fs.cpio.lzma;;
   1.117 -	fs.cpio.gz)   zcat fs.cpio.gz;;
   1.118 -	esac
   1.119 -	cd -
   1.120 -	rm -rf $tmpcpio
   1.121 +tmp="$(mktemp -d -t tmpcpio.XXXXXX)"
   1.122 +case "$(cd $tmp; cpio -iv < "$1")" in
   1.123 +*lzma) unlzma -c $tmp/fs.cpio.lzma;;
   1.124 +*gz)   zcat $tmp/fs.cpio.gz
   1.125 +esac
   1.126 +rm -rf $tmp
   1.127  }
   1.128  
   1.129  decompress_ipk()
   1.130  {
   1.131 -	tar xOzf "$1" ./data.tar.gz | gzip -dc
   1.132 +tar xOzf "$1" ./data.tar.gz | gzip -dc
   1.133  }
   1.134  
   1.135 -# set up compression variables for our compression functions. 
   1.136 -# translate archive name to lower case for pattern matching.
   1.137 -# use compressor -c option to output to stdout and direct it where we want
   1.138 -lc_archive="$(echo $archive|tr [:upper:] [:lower:])"
   1.139 +# variables for our compression functions.
   1.140  DECOMPRESS="cat"
   1.141  COMPRESS="cat"
   1.142 -for ext in $IPK_EXTS; do
   1.143 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.144 -        DECOMPRESS="decompress_ipk"
   1.145 -    fi
   1.146 -done
   1.147 -for ext in $GZIP_EXTS $CPIOGZ_EXTS; do
   1.148 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.149 -        DECOMPRESS="gzip -dc"
   1.150 -        COMPRESS="gzip -c"
   1.151 -    fi
   1.152 -done
   1.153 -for ext in $BZIP2_EXTS; do
   1.154 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.155 -        DECOMPRESS="bunzip2 -c" 
   1.156 -        COMPRESS="bzip2 -c"
   1.157 -    fi
   1.158 -done
   1.159 -for ext in $LZMA_EXTS; do
   1.160 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.161 -        DECOMPRESS="unlzma -c" 
   1.162 -        COMPRESS="lzma e -si -so"
   1.163 -    fi
   1.164 -done
   1.165 -for ext in $XZ_EXTS $CPIOXZ_EXTS; do
   1.166 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.167 -        [ -x /usr/bin/xz ] || exit $E_UNSUPPORTED
   1.168 -        DECOMPRESS="xz -dc"
   1.169 -        COMPRESS="xz -c"
   1.170 -    fi
   1.171 -done
   1.172 -for ext in $COMPRESS_EXTS; do
   1.173 -    if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.174 -        DECOMPRESS="uncompress -dc" 
   1.175 -        COMPRESS="compress -c"
   1.176 -    fi
   1.177 -done
   1.178 +while read d c exts; do
   1.179 +	case " $exts " in *\ $lc_ext\ *)
   1.180 +		[ "$d" == "${d% *}" -o "$(which ${d% *})" ] || exit $UNSUPPORTED
   1.181 +		DECOMPRESS="$d"
   1.182 +		COMPRESS="$c"
   1.183 +		[ "$(which ${c% *})" ] || COMPRESS="false"
   1.184 +		break
   1.185 +	esac
   1.186 +done <<EOT
   1.187 +unlzma\ -c		lzma\ e\ -si\ -so	$LZMA_EXTS
   1.188 +bunzip2\ -c		bzip2\ -c		$BZIP2_EXTS
   1.189 +gzip\ -dc		gzip\ -c		$GZIP_EXTS
   1.190 +xz\ -dc			xz\ -c			$XZ_EXTS $CPIOXZ_EXTS
   1.191 +uncompress\ -dc		compress\ -c		$COMPRESS_EXTS
   1.192 +rpm2cpio		false			$RPM_EXTS
   1.193 +tazpkg2cpio		false			$TAZPKG_EXTS
   1.194 +decompress_ipk		false			$IPK_EXTS
   1.195 +EOT
   1.196  
   1.197 -do_decompress()
   1.198 -{
   1.199 -	$DECOMPRESS "$1"
   1.200 -}
   1.201 -
   1.202 -# Compression functions
   1.203  decompress_func()
   1.204  {
   1.205 -    if [ "$DECOMPRESS" != "cat" ]; then 
   1.206 -        tmpname="$(mktemp -t tartmp.XXXXXX)"
   1.207 -        if [ -f "$archive" ]; then 
   1.208 -            $DECOMPRESS "$archive" > "$tmpname" 
   1.209 -        fi
   1.210 -        # store old name for when we recompress
   1.211 -        oldarch="$archive"
   1.212 -        # change working file to decompressed tmp 
   1.213 -        archive="$tmpname"
   1.214 -    fi
   1.215 +[ "$DECOMPRESS" = "cat" ] && return
   1.216 +tmp="$(mktemp -t tartmp.XXXXXX)"
   1.217 +[ -f "$archive" ] && $DECOMPRESS "$archive" > "$tmp"
   1.218 +# store old name for compress_func
   1.219 +oldarch="$archive"
   1.220 +# change working file
   1.221 +archive="$tmp"
   1.222  }
   1.223  
   1.224  compress_func()
   1.225  {
   1.226 -    if [ "$COMPRESS" != "cat" ] && [ "$oldarch" ]; then
   1.227 -        [ -f "$oldarch" ] && rm "$oldarch"
   1.228 -        if $COMPRESS < "$archive" > "$oldarch"; then
   1.229 -            rm "$archive"
   1.230 -        fi
   1.231 -    fi
   1.232 +status=$?
   1.233 +if [ "$COMPRESS" != "cat" -a -n "$oldarch" ]; then
   1.234 +       	[ -f "$oldarch" ] && rm "$oldarch"
   1.235 +       	$COMPRESS < "$archive" > "$oldarch" && rm "$archive"
   1.236 +fi
   1.237 +exit $status
   1.238  }
   1.239  
   1.240  not_busybox()
   1.241  {
   1.242 -    case "$(readlink $(which $1))" in
   1.243 -    *busybox*) return 1;;
   1.244 -    esac
   1.245 -    return 0
   1.246 -}
   1.247 -
   1.248 -addtar()
   1.249 -{
   1.250 -	tar -cf - $@
   1.251 -}
   1.252 -
   1.253 -extracttar()
   1.254 -{
   1.255 -	tar -xf -
   1.256 +[ "$(basename $(readlink $(which $1)))" != "busybox" ]
   1.257  }
   1.258  
   1.259  addcpio()
   1.260  {
   1.261 -	find $@ | cpio -o -H newc
   1.262 +find $@ | cpio -o -H newc
   1.263  }
   1.264  
   1.265 -extractcpio()
   1.266 +a_file()
   1.267  {
   1.268 -	cpio -id > /dev/null
   1.269 +( cd $2 ; tar -cf - $1 ) | tar -xf -
   1.270  }
   1.271  
   1.272 -add_file()
   1.273 +r_file()
   1.274  {
   1.275 -	( cd $2 ; tar -cf - $1 ) | tar -xf -
   1.276 +rm -rf ./$1
   1.277  }
   1.278  
   1.279 -remove_file()
   1.280 +dpkg_c()
   1.281  {
   1.282 -	rm -rf ./$1
   1.283 -}
   1.284 -
   1.285 -update_tar_cpio()
   1.286 -{
   1.287 -    action=$1
   1.288 -    shift
   1.289 -    tardir="$(dirname "$archive")"
   1.290 -    if [ $(expr "$lc_archive" : ".*\."$BZIP2_EXTS"$") -gt 0 ]; then
   1.291 -         [ "$(which bzip2)" ] || return
   1.292 -    fi
   1.293 -    if not_busybox tar && [ "$action" != "new_archive" ]; then
   1.294 -	for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $XZ_EXTS \
   1.295 -		   $COMPRESS_EXTS $LZMA_EXTS; do
   1.296 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.297 -	        decompress_func
   1.298 -		case "$action" in
   1.299 -		remove_file)
   1.300 -			tar --delete -f "$archive" "$@";;
   1.301 -		add_file)
   1.302 -			cd "$tardir"
   1.303 -			while [ -n "$1" ]; do
   1.304 -			    tar -rf "$archive" "${1#$tardir/}"
   1.305 -			done;;
   1.306 -		esac
   1.307 -		status=$?
   1.308 -		compress_func
   1.309 -		exit $status
   1.310 -            fi
   1.311 -	done
   1.312 -    fi
   1.313 -    while read add extract exts; do
   1.314 -      for ext in $exts; do
   1.315 -        if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.316 -	    if [ "$action" = "new_archive" ]; then
   1.317 -	        decompress_func
   1.318 -		cd "$tardir"
   1.319 -		$add "${1#$tardir/}" > "$archive"
   1.320 -		status=$?
   1.321 -		compress_func
   1.322 -		exit $status
   1.323 -	    fi
   1.324 -            tmptar="$(mktemp -d -t tartmp.XXXXXX)"
   1.325 -	    here="$(pwd)"
   1.326 -	    cd $tmptar
   1.327 -            $DECOMPRESS "$archive" | $extract
   1.328 -            status=$?
   1.329 -	    if [ $status -eq 0 -a -n "$1" ]; then
   1.330 -                while [ "$1" ]; do
   1.331 -		    	$action "${1#$tardir/}" $here
   1.332 -			shift
   1.333 -		done
   1.334 -		$add $(ls -a | grep -v ^\.$  | grep -v ^\.\.$) | \
   1.335 -			$COMPRESS > "$archive"
   1.336 -                status=$?
   1.337 -	    fi
   1.338 -	    cd $here
   1.339 -	    rm -rf $tmptar
   1.340 -	    exit $status
   1.341 -	fi
   1.342 -      done
   1.343 -    done <<EOT
   1.344 -addtar	extracttar   $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $XZ_EXTS $COMPRESS_EXTS $LZMA_EXTS
   1.345 -addcpio	extractcpio  $CPIO_EXTS $CPIOGZ_EXTS $CPIOXZ_EXTS
   1.346 -EOT
   1.347 +dpkg-deb -c "$archive"
   1.348  }
   1.349  
   1.350  loop_fs()
   1.351  {
   1.352 -    tmpfs="$(mktemp -d -t fstmp.XXXXXX)"
   1.353 -    umnt="umount -d"
   1.354 -    ext=${lc_archive##*.}
   1.355 -    case " $CROMFS_EXTS " in 
   1.356 -    *\ $ext\ *) umnt="fusermount -u"
   1.357 -    		cromfs-driver "$archive" $tmpfs;;
   1.358 -    esac
   1.359 -    case " $CLOOP_EXTS " in
   1.360 -    *\ $ext\ *) mount -o loop=/dev/cloop,ro "$archive" $tmpfs;;
   1.361 -    esac
   1.362 -    case " $FS_EXTS " in 
   1.363 -    *\ $ext\ *) mount -o loop,rw "$archive" $tmpfs;;
   1.364 -    esac
   1.365 -    case " $ISO_EXTS $SQUASHFS_EXTS " in 
   1.366 -    *\ $ext\ *) mount -o loop,ro "$archive" $tmpfs;;
   1.367 -    esac
   1.368 -    rmdir $tmpfs 2> /dev/null && exit $E_UNSUPPORTED
   1.369 -    cmd=$1
   1.370 -    shift
   1.371 -    case "$cmd" in
   1.372 -    stat)	find $tmpfs | while read f; do
   1.373 -    		    [ "$f" = "$tmpfs" ] && continue
   1.374 -		    link="-"
   1.375 -		    [ -L "$f" ] && link=$(readlink "$f")
   1.376 -		    date=$(stat -c "%y" $f | awk \
   1.377 -		    	'{ printf "%s;%s\n",$1,substr($2,0,8)}')
   1.378 -		    echo "${f#$tmpfs/};$(stat -c "%s;%A;%U;%G" $f);$date;$link"
   1.379 -    		done;;
   1.380 -    copy)	if [ -z "$1" ]; then
   1.381 -    		    ( cd $tmpfs ; tar cf - . ) | tar xf -
   1.382 -    		else
   1.383 -		    while [ -n "$1" ]; do
   1.384 -    			( cd $tmpfs ; tar cf - "$1" ) | tar xf -
   1.385 -			shift;
   1.386 -		    done
   1.387 -		fi;;
   1.388 -    add)	tar cf - "$@" | ( cd $tmpfs ; tar xf - );;
   1.389 -    remove)	while [ -n "$1" ]; do
   1.390 -    			rm -rf $tmpfs/$1
   1.391 -    		done;;
   1.392 -    esac
   1.393 -    $umnt $tmpfs
   1.394 -    rmdir $tmpfs
   1.395 -    exit 0
   1.396 +[ "$1" = "-n" ] && retrun
   1.397 +cmd=$1
   1.398 +shift
   1.399 +tmp="$(mktemp -d -t fstmp.XXXXXX)"
   1.400 +while read command exts umnt; do
   1.401 +	case " $exts " in *\ $lc_ext\ *)
   1.402 +		$command "$archive" $tmp
   1.403 +		break
   1.404 +	esac
   1.405 +done <<EOT
   1.406 +cromfs-driver			fusermount\ -u	$CROMFS_EXTS
   1.407 +mount\ -o\ loop=/dev/cloop,ro	umount\ -d	$CLOOP_EXTS
   1.408 +mount\ -o\ loop,rw		umount\ -d	$FS_EXTS
   1.409 +mount\ -o\ loop,ro		umount\ -d	$ISO_EXTS $SQUASHFS_EXTS
   1.410 +EOT
   1.411 +rmdir $tmp 2> /dev/null && return
   1.412 +case "$cmd" in
   1.413 +-o)	find $tmp | while read f; do
   1.414 +		[ "$f" = "$tmp" ] && continue
   1.415 +		link="-"
   1.416 +		[ -L "$f" ] && link=$(readlink "$f")
   1.417 +		date=$(stat -c "%y" $f | $AWK_PROG \
   1.418 +			'{ printf "%s;%s\n",$1,substr($2,0,8)}')
   1.419 +		echo "${f#$tmp/};$(stat -c "%s;%A;%U;%G" $f);$date;$link"
   1.420 +    	done;;
   1.421 +-e)	( cd $tmp ; tar cf - "$@" ) | tar xf - ;;
   1.422 +-a)	tar cf - "$@" | ( cd $tmp ; tar xf - );;
   1.423 +-r)	( cd $tmp ; rm -rf "$@" )
   1.424 +esac
   1.425 +$umnt $tmp
   1.426 +rmdir $tmp
   1.427 +exit
   1.428  }
   1.429  
   1.430 -# the option switches
   1.431 +update()
   1.432 +{
   1.433 +loop_fs "$@"
   1.434 +[ "$COMPRESS" = "false" ] && return
   1.435 +action=$1
   1.436 +shift
   1.437 +tardir="$(dirname "$archive")"
   1.438 +if not_busybox tar && [ "$action" != "-n" ]; then
   1.439 +	case " $TAR_EXTS $XZ_EXTS " in *\ $lc_ext\ *)
   1.440 +		decompress_func
   1.441 +		case "$action" in
   1.442 +		-r)	tar --delete -f "$archive" "$@";;
   1.443 +		-a)	cd "$tardir"
   1.444 +			while [ -n "$1" ]; do
   1.445 +				tar -rf "$archive" "${1#$tardir/}"
   1.446 +			done
   1.447 +		esac
   1.448 +		compress_func
   1.449 +	esac
   1.450 +fi
   1.451 +while read add extract exts; do
   1.452 +	case " $exts " in *\ $lc_ext\ *)
   1.453 +		if [ "$action" = "-n" ]; then
   1.454 +			decompress_func
   1.455 +			cd "$tardir"
   1.456 +			$add "${1#$tardir/}" > "$archive"
   1.457 +			compress_func
   1.458 +		fi
   1.459 +		tmp="$(mktemp -d -t tartmp.XXXXXX)"
   1.460 +		cd $tmp
   1.461 +		$DECOMPRESS "$archive" | $extract
   1.462 +		status=$?
   1.463 +		if [ $status -eq 0 -a -n "$1" ]; then
   1.464 +			while [ "$1" ]; do
   1.465 +				${action#-}_file "${1#$tardir/}" $here
   1.466 +				shift
   1.467 +			done
   1.468 +			$add $(ls -a | grep -v ^\.$  | grep -v ^\.\.$) | \
   1.469 +				$COMPRESS > "$archive"
   1.470 +			status=$?
   1.471 +		fi
   1.472 +		cd - >/dev/null
   1.473 +		rm -rf $tmp
   1.474 +		exit $status
   1.475 +	esac
   1.476 +done <<EOT
   1.477 +tar\ -cf\ -	tar\ -xf\ -			$TAR_EXTS $XZ_EXTS
   1.478 +addcpio		cpio\ -id\ >\ /dev/null		$CPIO_EXTS $CPIOXZ_EXTS
   1.479 +EOT
   1.480 +}
   1.481 +
   1.482 +# main: option switches
   1.483  case "$opt" in
   1.484      -i) # info: output supported extentions for progs that exist
   1.485 -        for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS \
   1.486 -                   $CPIO_EXTS $CPIOGZ_EXTS $ZIP_EXTS $DEB_EXTS $RPM_EXTS \
   1.487 -                   $TAZPKG_EXTS $ISO_EXTS $FS_EXTS $IPK_EXTS; do
   1.488 -            printf "%s;" $ext
   1.489 -            if [ "$ext" = "zip" -a ! "$(which zip)" ]; then
   1.490 -                echo warning: zip not found, extract only >/dev/stderr
   1.491 -            fi
   1.492 -        done
   1.493 -        [ -x /usr/bin/xz ] && for ext in $XZ_EXTS $CPIOXZ_EXTS; do
   1.494 -            printf "%s;" $ext
   1.495 -        done
   1.496 -	while read mod exts; do
   1.497 -	    [ -f /lib/modules/$(uname -r)/kernel/$mod ] || continue
   1.498 -	    for ext in $exts; do
   1.499 -                printf "%s;" $ext
   1.500 -	    done
   1.501 +	while read exe exts; do
   1.502 +		[ "$(which $exe)" -o -f /lib/modules/$(uname -r)/kernel/$exe.ko ] &&
   1.503 +		echo -n "$exts " | sed 's/ /;/g'
   1.504  	done <<EOT
   1.505 -fs/squashfs/squashfs.ko	$SQUASHFS_EXTS
   1.506 -drivers/block/cloop.ko	$CLOOP_EXTS
   1.507 -EOT
   1.508 -	while read exe exts; do
   1.509 -            [ "$(which $exe)" ] || continue
   1.510 -	    for ext in $exts; do
   1.511 -                printf "%s;" $ext
   1.512 -	    done
   1.513 -	done <<EOT
   1.514 -cromfs-driver	$CROMFS_EXTS
   1.515 +tar		$TAR_EXTS $IPK_EXTS
   1.516 +cpio		$CPIO_EXTS $TAZPKG_EXTS
   1.517 +unzip		$ZIP_EXTS
   1.518 +dpkg-deb	$DEB_EXTS
   1.519 +rpm2cpio	$RPM_EXTS
   1.520 +mount		$ISO_EXTS $FS_EXTS
   1.521 +xz		$XZ_EXTS $CPIOXZ_EXTS
   1.522  rar		$RAR_EXTS
   1.523  unace		ace
   1.524 -arj		arj
   1.525 -7za		7z
   1.526 +arj		$ARJ_EXTS
   1.527 +7zr		$_7Z_EXTS
   1.528  lha		$LHA_EXTS
   1.529  lzop		$LZO_EXTS
   1.530 +cabextract	cab
   1.531 +cromfs-driver	$CROMFS_EXTS
   1.532 +fs/squashfs/squashfs	$SQUASHFS_EXTS
   1.533 +drivers/block/cloop	$CLOOP_EXTS
   1.534  EOT
   1.535 -        printf "\n"
   1.536 -        exit
   1.537 -        ;;
   1.538 +	echo ""
   1.539 +	exit
   1.540 +	;;
   1.541 +    -o) # open: mangle output for xarchive
   1.542 +	AWK_MISC='
   1.543 +BEGIN {
   1.544 +	attr="-"
   1.545 +	link="-"
   1.546 +	uid=uuid
   1.547 +	gid=uuid
   1.548 +}
   1.549 +function getlink(arg)
   1.550 +{
   1.551 +	split(arg, x, " -> ")
   1.552 +	name=x[1]
   1.553 +	link=x[2]
   1.554 +	if (!link) link="-"
   1.555 +}
   1.556  
   1.557 -    -o) # open: mangle output of tar cmd for xarchive 
   1.558 -	while read cmd filter exts; do
   1.559 -            for ext in $exts; do
   1.560 -        # format of cpio output:
   1.561 +function getname(arg)
   1.562 +{
   1.563 +	# works with filenames that start with a space (evil!)
   1.564 +	split($0,x, arg)
   1.565 +	getlink(x[2])
   1.566 +}
   1.567 +
   1.568 +function getid(arg)
   1.569 +{
   1.570 +	if (uuid != "") return
   1.571 +	split(arg,x,"/")
   1.572 +	uid=x[1]
   1.573 +	gid=x[2]
   1.574 +}
   1.575 +
   1.576 +function getattr(arg)
   1.577 +{
   1.578 +	attr=arg
   1.579 +	if (index(attr, "D") != 0) attr="drwxr-xr-x"
   1.580 +	else if (index(attr, ".") != 0 || attr !~ /^[rwx-]/) attr="-rw-r--r--"
   1.581 +}
   1.582 +
   1.583 +function display()
   1.584 +{
   1.585 +	if (name != "") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.586 +}
   1.587 +
   1.588 +function show(arg)
   1.589 +{
   1.590 +	getid($2)
   1.591 +	getname(arg)
   1.592 +	if (uid != "blocks") display()
   1.593 +}'
   1.594 +	AWKU="$AWK_PROG -v uuid=$(id -u -n) $AWK_MISC"
   1.595 +	AWK="$AWK_PROG $AWK_MISC"
   1.596 +	while read filter exts; do
   1.597  # lrwxrwxrwx USR/GRP       0 2005-05-12 00:32:03 file -> /path/to/link
   1.598 -# -rw-r--r-- USR/GRP    6622 2005-04-22 12:29:14 file 
   1.599 -# 1          2          3    4          5        6
   1.600 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.601 -                $cmd "$archive" | $filter | $AWK_PROG '
   1.602 -        {
   1.603 -          attr=$1
   1.604 -          split($2,ids,"/") #split up the 2nd field to get uid/gid
   1.605 -          uid=ids[1]
   1.606 -          gid=ids[2]
   1.607 -          size=$3
   1.608 -          date=$4
   1.609 -          time=$5
   1.610 -          
   1.611 -          #this method works with filenames that start with a space (evil!)
   1.612 -          #split line a time and a space
   1.613 -          split($0,linesplit, $5 " ")
   1.614 -          #then split the second item (name&link) at the space arrow space
   1.615 -          split(linesplit[2], nlsplit, " -> ")
   1.616 -
   1.617 -          name=nlsplit[1]
   1.618 -          link=nlsplit[2]
   1.619 -
   1.620 -          if (! link) {link="-"} #if there was no link set it to a dash
   1.621 -
   1.622 -          if (name != "" && uid != "blocks") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.623 -        }'
   1.624 -                exit 0
   1.625 -	    fi
   1.626 -        done
   1.627 -        done <<EOT
   1.628 -do_decompress	cpio\ -tv	$CPIO_EXTS $CPIOGZ_EXTS $CPIOXZ_EXTS
   1.629 -do_decompress	tar\ -tvf\ -	$TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $XZ_EXTS $COMPRESS_EXTS $LZMA_EXTS $IPK_EXTS
   1.630 -rpm2cpio	cpio\ -tv	$RPM_EXTS
   1.631 -tazpkg2cpio	cpio\ -tv	$TAZPKG_EXTS
   1.632 +		case " $exts " in *\ $lc_ext\ *)
   1.633 +			$DECOMPRESS "$archive" | $filter | $AWK'
   1.634 +{
   1.635 +	attr=$1
   1.636 +	size=$3
   1.637 +	date=$4
   1.638 +	time=$5
   1.639 +	show($5 " ")
   1.640 +}'
   1.641 +		esac
   1.642 +	done <<EOT
   1.643 +cpio\ -tv	$CPIO_EXTS $CPIOXZ_EXTS $RPM_EXTS $TAZPKG_EXTS
   1.644 +tar\ -tvf\ -	$TAR_EXTS $XZ_EXTS $IPK_EXTS
   1.645 +dpkg_c		$DEB_EXTS
   1.646  EOT
   1.647 -        for ext in $ZIP_EXTS; do
   1.648 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.649 +	loop_fs $opt
   1.650 +	case " $ZIP_EXTS " in *\ $lc_ext\ *)
   1.651  		if [ "$(which zipinfo)" ]; then
   1.652 -                    # format of zipinfo -T -s-h- output:
   1.653 -                    # -rw-r--r--  2.3 unx    11512 tx defN YYYYMMDD.HHMMSS file 
   1.654 -                    # 1           2   3      4     5  6    7               8
   1.655 -                    zipinfo -T -s-h-t "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
   1.656 -        {
   1.657 -          attr=$1; size=$4
   1.658 -          
   1.659 -          year=substr($7,1,4)
   1.660 -          month=substr($7,5,2)
   1.661 -          day=substr($7,7,2)
   1.662 -          date=year "-" month "-" day
   1.663 -
   1.664 -          hours=substr($7,10,2)
   1.665 -          mins=substr($7,12,2)
   1.666 -          secs=substr($7,14,2)
   1.667 -          time=hours ":" mins ":" secs
   1.668 -
   1.669 -          uid=uuid; gid=uuid; link="-"
   1.670 -          #split line at the time and a space, second item is our name
   1.671 -          split($0, linesplit, ($7 " "))
   1.672 -          name=linesplit[2]
   1.673 -          printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.674 -        }'            
   1.675 -                    exit 0
   1.676 +# -rw-r--r--  2.3 unx    11512 tx defN YYYYMMDD.HHMMSS file
   1.677 +			zipinfo -T -s-h-t "$archive" | $AWKU'
   1.678 +{
   1.679 +	attr=$1
   1.680 +	size=$4
   1.681 +	date=substr($7,1,4)  "-" substr($7,5,2)  "-" substr($7,7,2)
   1.682 +	time=substr($7,10,2) ":" substr($7,12,2) ":" substr($7,14,2)
   1.683 +	show($7 " ")
   1.684 +}'
   1.685  		else
   1.686 -                    # format of unzip -l output:
   1.687 -                    # 6622 2005-04-22 12:29:14 file 
   1.688 -                    # 1    2          3        4
   1.689 -                    unzip -l "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
   1.690 -	BEGIN { n = 0}
   1.691 -        {
   1.692 -	  n=n+1
   1.693 -	  attr=""
   1.694 -          uid=uuid; gid=uuid
   1.695 -          size=$1
   1.696 -          date=$2
   1.697 -          time=$3
   1.698 -          
   1.699 -          #this method works with filenames that start with a space (evil!)
   1.700 -          #split line a time and a space
   1.701 -          split($0,linesplit, $3 "   ")
   1.702 -          #then split the second item (name&link) at the space arrow space
   1.703 -          split(linesplit[2], nlsplit, " -> ")
   1.704 -
   1.705 -          name=nlsplit[1]
   1.706 -          link=nlsplit[2]
   1.707 -
   1.708 -          if (! link) {link="-"} #if there was no link set it to a dash
   1.709 -
   1.710 -          if (name != "" && n > 3) printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.711 -        }'
   1.712 -                    exit 0
   1.713 +# 6622 2005-04-22 12:29:14 file
   1.714 +			unzip -l "$archive" | $AWKU'
   1.715 +/-[0-9]+-/ {
   1.716 +	size=$1
   1.717 +	date=$2
   1.718 +	time=$3
   1.719 +	show($3 "   ")
   1.720 +}'
   1.721  		fi
   1.722 -	    fi
   1.723 -        done
   1.724 -
   1.725 -        for ext in $ISO_EXTS $SQUASHFS_EXTS $CROMFS_EXTS $CLOOP_EXTS $FS_EXTS; do
   1.726 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.727 -	    	loop_fs stat
   1.728 -            fi
   1.729 -	done
   1.730 -        for ext in $RAR_EXTS; do
   1.731 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.732 -        # format of rar output:
   1.733 +	esac
   1.734 +# -----------+---------------------+-------
   1.735 +#       6622 | 22.04.2005 12:29:14 | file
   1.736 +	[ "$lc_ext" == "cab" ] && cabextract -q -l "$archive" | $AWKU'
   1.737 +/[0-9]+ |/ {
   1.738 +	size=$1
   1.739 +	date=$3
   1.740 +	time=$4
   1.741 +	show($4 " | ")
   1.742 +}'
   1.743 +	case " $RAR_EXTS " in *\ $lc_ext\ *)
   1.744  #-------------------------------------
   1.745  # bookmarks/mozilla_bookmarks.html
   1.746  #            11512     5231  45% 28-02-05 16:19 -rw-r--r-- F3F3477F m3b 2.9
   1.747  #       (or  11512     5231  45% 28-02-05 16:19 .D....     00000000 m3b 2.9)
   1.748 -#       (or  11512     5231  45% 28-02-05 16:19 .....S     F3F3477F m3b 2.9)
   1.749 -#            1         2     3   4        5     6          7        8   9
   1.750 -#-------------------------------------
   1.751 -        
   1.752 -        rar v -c- "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
   1.753 -        # The body of info we wish to process starts with a dashed line 
   1.754 -        # so set a flag to signal when to start and stop processing.
   1.755 -        # The name is on one line with the info on the next so toggle
   1.756 -        # a line flag letting us know what kinda info to get.  
   1.757 -        BEGIN { flag=0; line=0 }
   1.758 -        /^------/ { flag++; if (flag > 1) exit 0; next} #line starts with dashs
   1.759 -        {
   1.760 -          if (flag == 0) next #not in the body yet so grab the next line
   1.761 -          if (line == 0) #this line contains the name
   1.762 -          { 
   1.763 -            name=substr($0,2) #strip the single space from start of name
   1.764 -            line++  #next line will contain the info so increase the flag
   1.765 -            next
   1.766 -          }
   1.767 -          else #we got here so this line contains the info
   1.768 -          {
   1.769 -            size=$1
   1.770 -            date=$4
   1.771 -            time=$5
   1.772 -            
   1.773 -            #modify attributes to read more unix like if they are not
   1.774 -            if (index($6, "D") != 0) {attr="drwxr-xr-x"}
   1.775 -            else if (index($6, ".") != 0) {attr="-rw-r--r--"}
   1.776 -            else {attr=$6}
   1.777 -
   1.778 -            uid=uuid
   1.779 -            gid=uuid
   1.780 -            link="-"
   1.781 -
   1.782 -            printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.783 -            line=0 #next line will be a name so reset the flag
   1.784 -          }
   1.785 -        }'
   1.786 -                exit 0
   1.787 -	    fi
   1.788 -	done
   1.789 -        for ext in ace; do
   1.790 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.791 -        # format of ace output:
   1.792 -        # Date    ³Time ³Packed     ³Size     ³Ratio³File
   1.793 -        # 17.09.02³00:32³     394116³   414817³  95%³ OggDS0993.exe 
   1.794 -	# 1                   2         3        4    5
   1.795 -	unace v -c- "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
   1.796 -        #only process lines starting with two numbers and a dot
   1.797 -        /^[0-9][0-9]\./ {
   1.798 -          date=substr($1,1,8)
   1.799 -          time=substr($1,10,5)
   1.800 -          #need to strip the funky little 3 off the end of size
   1.801 -          size=substr($3,1,(length($3)-1))
   1.802 -          
   1.803 -          #split line at ratio and a space, second item is our name
   1.804 -          split($0, linesplit, ($4 " "))
   1.805 -          name=linesplit[2]
   1.806 -          
   1.807 -          uid=uuid; gid=uuid; link="-"; attr="-"
   1.808 -          printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
   1.809 -        }'
   1.810 -                exit 0
   1.811 -	    fi
   1.812 -	done
   1.813 -        for ext in arj; do
   1.814 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.815 -        # format of arj output:
   1.816 -        # 001) ANKETA.FRG
   1.817 -        #   3 MS-DOS          356        121 0.340 92-04-12 11:39:46                  1  
   1.818 -        
   1.819 -	arj v "$archive" | $AWK_PROG -v uuid=$(id -u -n) '{ 
   1.820 -		if (($0 ~ /^[0-9]+\) .*/)||($0 ~ /^------------ ---------- ---------- -----/)){
   1.821 -			if (filestr ~ /^[0-9]+\) .*/) {
   1.822 -				printf "%s;%d;%s;%d;%d;%02d-%02d-%02d;%02d:%02d;%s\n", file, size, perm, uid, gid, date[1], date[3], date[2], time[1], time[2], symfile
   1.823 -				perm=""
   1.824 -				file=""
   1.825 -				symfile=""
   1.826 -				filestr=""
   1.827 -			}
   1.828 -		}
   1.829 -
   1.830 -		if ($0 ~ /^[0-9]+\) .*/) {
   1.831 -			filestr=$0
   1.832 -			sub(/^[0-9]*\) /, "")
   1.833 -			file=$0
   1.834 -			uid=uuid
   1.835 -			gid=0
   1.836 -		}
   1.837 -
   1.838 -		if ($0 ~ /^.* [0-9]+[\t ]+[0-9]+ [0-9]\.[0-9][0-9][0-9] [0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].*/) {
   1.839 -			size=$3
   1.840 -			split($6, date, "-")
   1.841 -			split($7, time, ":")
   1.842 -			if ($8 ~ /^[rwx-]/) {perm=$8;} else {perm="-rw-r--r--"}
   1.843 -		}
   1.844 -
   1.845 -		if ($0 ~ /^[\t ]+SymLink -> .*/) {
   1.846 -			symfile = $3
   1.847 -			perm="l"substr(perm, 2)
   1.848 -		} else {symfile="-"}
   1.849 -
   1.850 -		if ($0 ~ /^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/) {
   1.851 -			uid=$3
   1.852 -			gid=$5
   1.853 -			owner=1
   1.854 -		}
   1.855 -	}'
   1.856 -                exit 0
   1.857 -	    fi
   1.858 -	done
   1.859 -        for ext in 7z; do
   1.860 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.861 -        # format of 7za output:
   1.862 -	# ------------------- ----- ------------ ------------  ------------
   1.863 -	# 1992-04-12 11:39:46 ....A          356               ANKETA.FRG
   1.864 -        
   1.865 -	7za l "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
   1.866 -	BEGIN { flag=0; }
   1.867 -	/^-------/ { flag++; if (flag > 1) exit 0; next }
   1.868 -	{
   1.869 -		if (flag == 0) next
   1.870 -
   1.871 -		year=substr($1, 1, 4)
   1.872 -		month=substr($1, 6, 2)
   1.873 -		day=substr($1, 9, 2)
   1.874 -		time=substr($2, 1, 5)
   1.875 -
   1.876 -		if (index($3, "D") != 0) {attr="drwxr-xr-x"}
   1.877 -		else if (index($3, ".") != 0) {attr="-rw-r--r--"}
   1.878 -
   1.879 -		size=$4
   1.880 -
   1.881 -		$0=substr($0, 54)
   1.882 -		if (NF > 1) {name=$0}
   1.883 -		else {name=$1}
   1.884 -		gsub(/\\/, "/", name)
   1.885 -
   1.886 -		printf "%s;%d;%s;%d;%d;%d-%02d-%02d;%s;-\n", name, size, attr, uid, 0, year, month, day, time
   1.887 -	}'
   1.888 -                exit 0
   1.889 -	    fi
   1.890 -	done
   1.891 -        for ext in $LHA_EXTS; do
   1.892 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.893 -        # format of lha output:
   1.894 -	# Desktop/up -> ..
   1.895 -	# lrwxrwxrwx     0/0           0       0 ****** -lhd- 0000 2009-05-03 16:59:03 [2]
   1.896 -
   1.897 -	lha v -q -v  "$archive" | $AWK_PROG '
   1.898 -	{
   1.899 -		if ($4 == "") {
   1.900 -          		split($0, nlsplit, " -> ")
   1.901 -          		name=nlsplit[1]
   1.902 -         		link=nlsplit[2]
   1.903 -       			if (! link) {link="-"}
   1.904 -			next
   1.905 -		}
   1.906 -		attr=$1
   1.907 -		ids=$2
   1.908 -		split($2,ids,"/") #split up the 2nd field to get uid/gid
   1.909 -		uid=ids[1]
   1.910 -		gid=ids[2]
   1.911 -		size=$4
   1.912 -
   1.913 -		year=substr($8, 1, 4)
   1.914 -		month=substr($8, 6, 2)
   1.915 -		day=substr($8, 9, 2)
   1.916 -		time=substr($9, 1, 5)
   1.917 -
   1.918 -		printf "%s;%d;%s;%d;%d;%d-%02d-%02d;%s;-\n", name, size, attr, uid, gid, year, month, day, time
   1.919 -	}'
   1.920 -                exit 0
   1.921 -	    fi
   1.922 -	done
   1.923 -        for ext in $LZO_EXTS; do
   1.924 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
   1.925 -        # format of lzo output:
   1.926 -# Method         Length    Packed  Ratio     Date    Time   Name
   1.927 +		rar v -c- "$archive" | $AWKU'
   1.928 +/-[0-9]+-/ {
   1.929 +	getattr($6)
   1.930 +	size=$1
   1.931 +	date=$4
   1.932 +	time=$5
   1.933 +	display()
   1.934 +}
   1.935 +{
   1.936 +	name=substr($0,2)
   1.937 +}'
   1.938 +	esac
   1.939 +	case "$lc_ext" in
   1.940 +	ace)
   1.941 +# Date    ³Time ³Packed     ³Size     ³Ratio³File
   1.942 +# 17.09.02³00:32³     394116³   414817³  95%³ OggDS0993.exe
   1.943 +		unace v -c- "$archive" | $AWKU'
   1.944 +/^[0-9][0-9]\./ {
   1.945 +	# strip the funky little 3 off the end of size
   1.946 +	size=substr($3,1,(length($3)-1))
   1.947 +	date=substr($1,1,8)
   1.948 +	time=substr($1,10,5)
   1.949 +	show($4 " ")
   1.950 +}'
   1.951 +		;;
   1.952 +	7z|bcj|bcj2)
   1.953 +# ------------------- ----- ------------ ------------  ------------
   1.954 +# 1992-04-12 11:39:46 ....A          356               ANKETA.FRG
   1.955 +		7zr l "$archive" | $AWKU'
   1.956 +/^[0-9]+-/ {
   1.957 +	date=$1
   1.958 +	time=$2
   1.959 +	getattr($3)
   1.960 +	size=$4
   1.961 +	$0=substr($0, 54)
   1.962 +	name=$1
   1.963 +	if (NF > 1) name=$0
   1.964 +	gsub(/\\/, "/", name)
   1.965 +	display()
   1.966 +}'
   1.967 +	esac
   1.968 +	case " $ARJ_EXTS " in *\ $lc_ext\ *)
   1.969 +# 001) ANKETA.FRG
   1.970 +#   3 MS-DOS          356        121 0.340 92-04-12 11:39:46                  1
   1.971 +		arj v "$archive" | $AWKU'
   1.972 +BEGIN { name="" }
   1.973 +/^[0-9]+\) / {
   1.974 +	display()
   1.975 +	getname($1 " ")
   1.976 +}
   1.977 +/^[\t ]+[0-9]+/ {
   1.978 +	size=$3
   1.979 +	date=$6
   1.980 +	time=$7
   1.981 +	getattr($8)
   1.982 +}
   1.983 +/^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/ { uid=$3; gid=$5 }
   1.984 +/^[\t ]+SymLink -> / { link=$3; attr="l"substr(attr, 2) }
   1.985 +/^---/ { display() }
   1.986 +'
   1.987 +	esac
   1.988 +	case " $LHA_EXTS " in *\ $lc_ext\ *)
   1.989 +# Desktop/up -> ..
   1.990 +# lrwxrwxrwx     0/0           0       0 ****** -lhd- 0000 2009-05-03 16:59:03 [2]
   1.991 +		lha v -q -v  "$archive" | $AWK'
   1.992 +{
   1.993 +	if ($4 == "") { getlink($0); next }
   1.994 +	attr=$1
   1.995 +	getid($2)
   1.996 +	size=$4
   1.997 +	date=$8
   1.998 +	time=$9
   1.999 +	display()
  1.1000 +}'
  1.1001 +	esac
  1.1002 +	case " $LZO_EXTS " in *\ $lc_ext\ *)
  1.1003  # ------         ------    ------  -----     ----    ----   ----
  1.1004 -# LZO1X-1           626       526  84.0%  2009-05-27 09:52  file
  1.1005  # LZO1X-1         10057      5675  56.4%  2005-07-25 16:26  path/file
  1.1006 -#               -------   -------  -----                    ----
  1.1007 -# 1               2          3     4      5          6      7
  1.1008 -                lzop -Plv "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
  1.1009 -	BEGIN { show = 0}
  1.1010 -        {
  1.1011 -          if ($5 == "----" || $4 == "----") {
  1.1012 -          	show = 1 - show
  1.1013 -          	next
  1.1014 -          }
  1.1015 -	  attr="-rw-r--r--"
  1.1016 -          uid=uuid; gid=uuid
  1.1017 -          size=$2
  1.1018 -          date=$5
  1.1019 -          time=$6
  1.1020 -          
  1.1021 -          #this method works with filenames that start with a space (evil!)
  1.1022 -          #split line a time and a space
  1.1023 -          split($0,linesplit, $6 "  ")
  1.1024 -
  1.1025 -          name=linesplit[2]
  1.1026 -          link="-"	# links are not supported
  1.1027 -
  1.1028 -          if (show == 1) printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
  1.1029 -        }'
  1.1030 -                exit 0
  1.1031 -	    fi
  1.1032 -	done
  1.1033 -        exit $E_UNSUPPORTED
  1.1034 -        ;;
  1.1035 -
  1.1036 -    -a) # add to archive passed files
  1.1037 -	update_tar_cpio add_file "$@"
  1.1038 -        for ext in $FS_EXTS; do
  1.1039 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1040 -	    	loop_fs add "$@"
  1.1041 -	    fi
  1.1042 -	done
  1.1043 +		lzop -Plv "$archive" | $AWKU'
  1.1044 +/-[0-9]+-/ {
  1.1045 +	size=$2
  1.1046 +	date=$5
  1.1047 +	time=$6
  1.1048 +	show($6 "  ")
  1.1049 +}'
  1.1050 +	esac
  1.1051 +	exit 0
  1.1052 +	;;
  1.1053 +    -a|-n) # add to archive / new: create new archive
  1.1054 +	update $opt "$@"
  1.1055  	while read exe args exts; do
  1.1056 -	    [ "$(which $exe)" ] || continue
  1.1057 -	    for ext in $exts; do
  1.1058 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1059 -                # we only want to add the file's basename, not
  1.1060 -                # the full path so...
  1.1061 -                while [ "$1" ]; do
  1.1062 -                    cd "$(dirname "$1")"
  1.1063 -                    $exe $args "$archive" "$(basename "$1")"
  1.1064 -                    wrapper_status=$?
  1.1065 -                    shift 1
  1.1066 -                done
  1.1067 -                exit $wrapper_status
  1.1068 -	    fi
  1.1069 -	    done
  1.1070 +		[ "$(which $exe)" ] || continue
  1.1071 +		[ "$opt$exe" = "-nzip" ] && args="-r"
  1.1072 +		case " $exts " in *\ $lc_ext\ *)
  1.1073 +			# only add the file's basename, not the full path
  1.1074 +			while [ "$1" ]; do
  1.1075 +				cd "$(dirname "$1")"
  1.1076 +				$exe $args "$archive" "$(basename "$1")"
  1.1077 +				status=$?
  1.1078 +				shift
  1.1079 +			done
  1.1080 +			exit $status
  1.1081 +		esac
  1.1082  	done <<EOT
  1.1083  zip	-g\ -r		$ZIP_EXTS
  1.1084  rar	a		$RAR_EXTS
  1.1085 -arj	a		arj
  1.1086 -7za	a\ -ms=off	7z
  1.1087 +arj	a		$ARJ_EXTS
  1.1088 +7zr	a\ -ms=off	$_7Z_EXTS
  1.1089  lha	a		$LHA_EXTS
  1.1090  EOT
  1.1091 -        exit $E_UNSUPPORTED
  1.1092 -        ;;
  1.1093 -
  1.1094 -    -n) # new: create new archive with passed files 
  1.1095 -	update_tar_cpio new_archive "$@"
  1.1096 +	;;
  1.1097 +    -r) # remove from archive passed files
  1.1098 +	update $opt "$@"
  1.1099  	while read exe args exts; do
  1.1100 -	    [ "$(which $exe)" ] || continue
  1.1101 -	    for ext in $exts; do
  1.1102 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1103 -                # create will only be passed the first file, the
  1.1104 -                # rest will be "added" to the new archive
  1.1105 -                cd "$(dirname "$1")"
  1.1106 -                $exe $args "$archive" "$(basename "$1")"
  1.1107 -	    fi
  1.1108 -	    done
  1.1109 +		[ "$(which $exe)" ] || continue
  1.1110 +		case " $exts " in *\ $lc_ext\ *)
  1.1111 +			$exe $args "$archive" "$@" | grep -q E_NOTIMPL && {
  1.1112 +				echo -e "7z cannot delete files from solid archive." >&2
  1.1113 +				exit $UNSUPPORTED
  1.1114 +			}
  1.1115 +			exit 0
  1.1116 +		esac
  1.1117  	done <<EOT
  1.1118 -zip	-r		$ZIP_EXTS
  1.1119 -rar	a		$RAR_EXTS
  1.1120 -arj	a		arj
  1.1121 -7za	a\ -ms=off	7z
  1.1122 -lha	a		$LHA_EXTS
  1.1123 -EOT
  1.1124 -        exit $E_UNSUPPORTED
  1.1125 -        ;;
  1.1126 -
  1.1127 -    -r) # remove: from archive passed files 
  1.1128 -	update_tar_cpio remove_file "$@"
  1.1129 -	while read exe args exts; do
  1.1130 -	    [ "$(which $exe)" ] || continue
  1.1131 -	    for ext in $exts; do
  1.1132 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1133 -                $exe $args "$archive" "$@"
  1.1134 -                exit $?
  1.1135 -	    fi
  1.1136 -	    done
  1.1137 -	done <<EOT
  1.1138 -loop_fs	remove	$FS_EXTS
  1.1139  zip	-d	$ZIP_EXTS
  1.1140  rar	d	$RAR_EXTS
  1.1141 -arj	d	arj
  1.1142 +arj	d	$ARJ_EXTS
  1.1143  lha	d	$LHA_EXTS
  1.1144 +7zr	d	$_7Z_EXTS
  1.1145  EOT
  1.1146 -    	wrapper_status=0
  1.1147 -	[ "$(which 7za)" ] && [ $(expr "$lc_archive" : ".*\.7z$") -gt 0 ] && 
  1.1148 -	while [ "$1" ]; do
  1.1149 -		7za l "$archive" 2>/dev/null | grep -q "[.][/]" >&/dev/null \
  1.1150 -			&& EXFNAME=*./"$1" || EXFNAME="$1"
  1.1151 -		7za d "$archive" "$EXFNAME" 2>&1 \
  1.1152 -		| grep -q E_NOTIMPL &> /dev/null && {
  1.1153 -			echo -e "Function not implemented: 7z cannot delete files from solid archive." >&2
  1.1154 -			wrapper_status=$E_UNSUPPORTED
  1.1155 -		}
  1.1156 -		shift 1;
  1.1157 -	done
  1.1158 -        exit $E_UNSUPPORTED
  1.1159 -        ;;
  1.1160 -
  1.1161 -    -e) # extract: from archive passed files 
  1.1162 -        for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS \
  1.1163 -        	   $IPK_EXTS $XZ_EXTS; do
  1.1164 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1165 -                # xarchive will put is the right extract dir
  1.1166 -                # so we just have to extract.
  1.1167 -		$DECOMPRESS "$archive" | tar -xf - "$@"
  1.1168 -                exit $?
  1.1169 -	    fi
  1.1170 -	done
  1.1171 -
  1.1172 -	while read exe exts; do
  1.1173 -	    [ "$(which $exe)" ] || continue
  1.1174 -	    for ext in $exts; do
  1.1175 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1176 -	        if [ -n "$1" ]; then
  1.1177 -                    while [ "$1" ]; do
  1.1178 -                       $exe "$archive" | cpio -idv "$1"
  1.1179 -                       shift 1
  1.1180 -                    done
  1.1181 -		else
  1.1182 -                    $exe "$archive" | cpio -idv
  1.1183 -		fi
  1.1184 -                exit $?
  1.1185 -	    fi
  1.1186 -            done
  1.1187 +	;;
  1.1188 +    -e) # extract from archive passed files
  1.1189 +	while read arch exts; do
  1.1190 +		case " $exts " in *\ $lc_ext\ *)
  1.1191 +			$DECOMPRESS "$archive" | $arch "$@"
  1.1192 +			exit $?
  1.1193 +		esac
  1.1194  	done <<EOT
  1.1195 -rpm2cpio	$RPM_EXTS
  1.1196 -do_decompress	$CPIO_EXTS $CPIOGZ_EXTS $CPIOXZ_EXTS
  1.1197 -tazpkg2cpio	$TAZPKG_EXTS
  1.1198 +tar\ -xf\ -	$TAR_EXTS $IPK_EXTS $XZ_EXTS
  1.1199 +cpio\ -idm	$CPIO_EXTS $CPIOXZ_EXTS $RPM_EXTS $TAZPKG_EXTS
  1.1200  EOT
  1.1201 -
  1.1202 -	while read exe args exts; do
  1.1203 -	    [ "$(which $exe)" ] || continue
  1.1204 -	    for ext in $exts; do
  1.1205 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1206 -                $exe $args "$archive" "$@"
  1.1207 -                exit $?
  1.1208 -	    fi
  1.1209 -	done
  1.1210 +	while read exe x p exts; do
  1.1211 +		[ "$(which $exe)" ] || continue
  1.1212 +		case " $exts " in *\ $lc_ext\ *)
  1.1213 +			[ "$x" != "N/A" ] && $exe $x "$archive" "$@"
  1.1214 +			status=$?
  1.1215 +			if [ "$p" != "N/A" -a $status -ne 0 ]; then
  1.1216 +				echo Password protected, opening an x-term...
  1.1217 +				$XTERM_PROG -e $exe $p "$archive" "$@"
  1.1218 +				exit $?
  1.1219 +			fi
  1.1220 +			exit $status
  1.1221 +		esac
  1.1222  	done <<EOT
  1.1223 -loop_fs		copy	$ISO_EXTS $SQUASHFS_EXTS $CROMFS_EXTS $CLOOP_EXTS $FS_EXTS
  1.1224 -unzip		-n	$ZIP_EXTS
  1.1225 -dpkg-deb	-X	$DEB_EXTS
  1.1226 -lha		x	$LHA_EXTS
  1.1227 -lzop		-x	$LZO_EXTS
  1.1228 +unzip		-n		N/A		$ZIP_EXTS
  1.1229 +dpkg-deb	-X		N/A		$DEB_EXTS
  1.1230 +lha		x		N/A		$LHA_EXTS
  1.1231 +lzop		-x		N/A		$LZO_EXTS
  1.1232 +rar		x\ -o-\ -p-	x\ -o-		$RAR_EXTS
  1.1233 +arj		x\ -y		x\ -y\ -g?	$ARJ_EXTS
  1.1234 +7zr		x\ -y\ -p-	x\ -y		$_7Z_EXTS
  1.1235 +unace		N/A		x\ -o\ -y	ace
  1.1236 +cabextract	-q		N/A		cab
  1.1237  EOT
  1.1238 -	while read exe args argpass exts; do
  1.1239 -	    [ "$(which $exe)" ] || continue
  1.1240 -	    for ext in $exts; do
  1.1241 -            if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
  1.1242 -	        [ $exe != unace ] && $exe $args "$archive" "$@"
  1.1243 -	        if [ "$?" -ne "0" ] && [ "$XTERM_PROG" ]; then
  1.1244 -	            echo Probably password protected,
  1.1245 -	            echo Opening an x-terminal...
  1.1246 -	            $XTERM_PROG -e $exe $argpass "$archive" "$@"
  1.1247 -	        fi
  1.1248 -                exit 0
  1.1249 -	    fi
  1.1250 -	    done
  1.1251 -	done <<EOT
  1.1252 -rar	x\ -o-\ -p-	x\ -o-		$RAR_EXTS
  1.1253 -arj	x\ -y		x\ -y\ -g?	arj
  1.1254 -7za	x\ -y\ -p-	x\ -y		7z
  1.1255 -unace	-UNUSED-	x\ -o\ -y	ace
  1.1256 +	loop_fs $opt "$@"
  1.1257 +	;;
  1.1258 +     *) cat <<EOT
  1.1259 +error, option $opt not supported
  1.1260 +use one of these:
  1.1261 +-i			#info
  1.1262 +-o archive		#open
  1.1263 +-a archive files	#add
  1.1264 +-n archive file		#new
  1.1265 +-r archive files	#remove
  1.1266 +-e archive files	#extract
  1.1267  EOT
  1.1268 -        exit $E_UNSUPPORTED
  1.1269 -        ;;
  1.1270 -
  1.1271 -     *) echo "error, option $opt not supported"
  1.1272 -        echo "use one of these:" 
  1.1273 -        echo "-i                #info" 
  1.1274 -        echo "-o archive        #open" 
  1.1275 -        echo "-a archive files  #add" 
  1.1276 -        echo "-n archive file   #new" 
  1.1277 -        echo "-r archive files  #remove" 
  1.1278 -        echo "-e archive files  #extract" 
  1.1279 -        exit
  1.1280  esac
  1.1281 +exit $UNSUPPORTED