wok-stable rev 5167

xarchive: fix open archive
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 26 22:01:29 2010 +0100 (2010-03-26)
parents cbeec8826bda
children 0ca665c79af1
files xarchive/stuff/slitaz-wrap.sh
line diff
     1.1 --- a/xarchive/stuff/slitaz-wrap.sh	Fri Mar 26 18:53:15 2010 +0100
     1.2 +++ b/xarchive/stuff/slitaz-wrap.sh	Fri Mar 26 22:01:29 2010 +0100
     1.3 @@ -68,8 +68,8 @@
     1.4  {
     1.5  tmp="$(mktemp -d -t tmpcpio.XXXXXX)"
     1.6  case "$(cd $tmp; cpio -iv < "$1")" in
     1.7 -*lzma) unlzma -c $tmp/fs.cpio.lzma;;
     1.8 -*gz)   zcat $tmp/fs.cpio.gz
     1.9 +*lzma*) unlzma -c $tmp/fs.cpio.lzma;;
    1.10 +*gz*)   zcat $tmp/fs.cpio.gz
    1.11  esac
    1.12  rm -rf $tmp
    1.13  }
    1.14 @@ -235,37 +235,7 @@
    1.15  EOT
    1.16  }
    1.17  
    1.18 -# main: option switches
    1.19 -case "$opt" in
    1.20 -    -i) # info: output supported extentions for progs that exist
    1.21 -	while read exe exts; do
    1.22 -		[ "$(which $exe)" -o -f /lib/modules/$(uname -r)/kernel/$exe.ko ] &&
    1.23 -		echo -n "$exts " | sed 's/ /;/g'
    1.24 -	done <<EOT
    1.25 -tar		$TAR_EXTS $IPK_EXTS
    1.26 -cpio		$CPIO_EXTS $TAZPKG_EXTS
    1.27 -unzip		$ZIP_EXTS
    1.28 -dpkg-deb	$DEB_EXTS
    1.29 -rpm2cpio	$RPM_EXTS
    1.30 -mount		$ISO_EXTS $FS_EXTS
    1.31 -xz		$XZ_EXTS $CPIOXZ_EXTS
    1.32 -lrzip		$LRZIP_EXTS $CPIOLRZIP_EXTS
    1.33 -rar		$RAR_EXTS
    1.34 -unace		ace
    1.35 -arj		$ARJ_EXTS
    1.36 -7zr		$_7Z_EXTS
    1.37 -lha		$LHA_EXTS
    1.38 -lzop		$LZO_EXTS
    1.39 -cabextract	cab
    1.40 -cromfs-driver	$CROMFS_EXTS
    1.41 -fs/squashfs/squashfs	$SQUASHFS_EXTS
    1.42 -drivers/block/cloop	$CLOOP_EXTS
    1.43 -EOT
    1.44 -	echo ""
    1.45 -	exit
    1.46 -	;;
    1.47 -    -o) # open: mangle output for xarchive
    1.48 -	AWK_MISC='
    1.49 +AWK_MISC='
    1.50  BEGIN {
    1.51  	attr="-"
    1.52  	link="-"
    1.53 @@ -313,12 +283,52 @@
    1.54  	getname(arg)
    1.55  	if (uid != "blocks") display()
    1.56  }'
    1.57 -	AWKU="$AWK_PROG -v uuid=$(id -u -n) $AWK_MISC"
    1.58 -	AWK="$AWK_PROG $AWK_MISC"
    1.59 +	
    1.60 +awk0()
    1.61 +{
    1.62 +	$AWK_PROG "$AWK_MISC $1"
    1.63 +}
    1.64 +
    1.65 +awku()
    1.66 +{
    1.67 +	$AWK_PROG -v uuid=$(id -u -n) "$AWK_MISC $1"
    1.68 +}
    1.69 +
    1.70 +
    1.71 +# main: option switches
    1.72 +case "$opt" in
    1.73 +    -i) # info: output supported extentions for progs that exist
    1.74 +	while read exe exts; do
    1.75 +		[ "$(which $exe)" -o -f /lib/modules/$(uname -r)/kernel/$exe.ko ] &&
    1.76 +		echo -n "$exts " | sed 's/ /;/g'
    1.77 +	done <<EOT
    1.78 +tar		$TAR_EXTS $IPK_EXTS
    1.79 +cpio		$CPIO_EXTS $TAZPKG_EXTS
    1.80 +unzip		$ZIP_EXTS
    1.81 +dpkg-deb	$DEB_EXTS
    1.82 +rpm2cpio	$RPM_EXTS
    1.83 +mount		$ISO_EXTS $FS_EXTS
    1.84 +xz		$XZ_EXTS $CPIOXZ_EXTS
    1.85 +lrzip		$LRZIP_EXTS $CPIOLRZIP_EXTS
    1.86 +rar		$RAR_EXTS
    1.87 +unace		ace
    1.88 +arj		$ARJ_EXTS
    1.89 +7zr		$_7Z_EXTS
    1.90 +lha		$LHA_EXTS
    1.91 +lzop		$LZO_EXTS
    1.92 +cabextract	cab
    1.93 +cromfs-driver	$CROMFS_EXTS
    1.94 +fs/squashfs/squashfs	$SQUASHFS_EXTS
    1.95 +drivers/block/cloop	$CLOOP_EXTS
    1.96 +EOT
    1.97 +	echo ""
    1.98 +	exit
    1.99 +	;;
   1.100 +    -o) # open: mangle output for xarchive
   1.101  	while read filter exts; do
   1.102  # lrwxrwxrwx USR/GRP       0 2005-05-12 00:32:03 file -> /path/to/link
   1.103  		case " $exts " in *\ $lc_ext\ *)
   1.104 -			$DECOMPRESS "$archive" | $filter | $AWK'
   1.105 +			$DECOMPRESS "$archive" | $filter | awk0 '
   1.106  {
   1.107  	attr=$1
   1.108  	size=$3
   1.109 @@ -336,7 +346,7 @@
   1.110  	case " $ZIP_EXTS " in *\ $lc_ext\ *)
   1.111  		if [ "$(which zipinfo)" ]; then
   1.112  # -rw-r--r--  2.3 unx    11512 tx defN YYYYMMDD.HHMMSS file
   1.113 -			zipinfo -T -s-h-t "$archive" | $AWKU'
   1.114 +			zipinfo -T -s-h-t "$archive" | awku '
   1.115  {
   1.116  	attr=$1
   1.117  	size=$4
   1.118 @@ -346,7 +356,7 @@
   1.119  }'
   1.120  		else
   1.121  # 6622 2005-04-22 12:29:14 file
   1.122 -			unzip -l "$archive" | $AWKU'
   1.123 +			unzip -l "$archive" | awku '
   1.124  /-[0-9]+-/ {
   1.125  	size=$1
   1.126  	date=$2
   1.127 @@ -357,7 +367,7 @@
   1.128  	esac
   1.129  # -----------+---------------------+-------
   1.130  #       6622 | 22.04.2005 12:29:14 | file
   1.131 -	[ "$lc_ext" == "cab" ] && cabextract -q -l "$archive" | $AWKU'
   1.132 +	[ "$lc_ext" == "cab" ] && cabextract -q -l "$archive" | awku '
   1.133  /[0-9]+ |/ {
   1.134  	size=$1
   1.135  	date=$3
   1.136 @@ -369,7 +379,7 @@
   1.137  # bookmarks/mozilla_bookmarks.html
   1.138  #            11512     5231  45% 28-02-05 16:19 -rw-r--r-- F3F3477F m3b 2.9
   1.139  #       (or  11512     5231  45% 28-02-05 16:19 .D....     00000000 m3b 2.9)
   1.140 -		rar v -c- "$archive" | $AWKU'
   1.141 +		rar v -c- "$archive" | awku '
   1.142  /-[0-9]+-/ {
   1.143  	getattr($6)
   1.144  	size=$1
   1.145 @@ -385,7 +395,7 @@
   1.146  	ace)
   1.147  # Date    ³Time ³Packed     ³Size     ³Ratio³File
   1.148  # 17.09.02³00:32³     394116³   414817³  95%³ OggDS0993.exe
   1.149 -		unace v -c- "$archive" | $AWKU'
   1.150 +		unace v -c- "$archive" | awku '
   1.151  /^[0-9][0-9]\./ {
   1.152  	# strip the funky little 3 off the end of size
   1.153  	size=substr($3,1,(length($3)-1))
   1.154 @@ -397,7 +407,7 @@
   1.155  	7z|bcj|bcj2)
   1.156  # ------------------- ----- ------------ ------------  ------------
   1.157  # 1992-04-12 11:39:46 ....A          356               ANKETA.FRG
   1.158 -		7zr l "$archive" | $AWKU'
   1.159 +		7zr l "$archive" | awku '
   1.160  /^[0-9]+-/ {
   1.161  	date=$1
   1.162  	time=$2
   1.163 @@ -413,7 +423,7 @@
   1.164  	case " $ARJ_EXTS " in *\ $lc_ext\ *)
   1.165  # 001) ANKETA.FRG
   1.166  #   3 MS-DOS          356        121 0.340 92-04-12 11:39:46                  1
   1.167 -		arj v "$archive" | $AWKU'
   1.168 +		arj v "$archive" | awku '
   1.169  BEGIN { name="" }
   1.170  /^[0-9]+\) / {
   1.171  	display()
   1.172 @@ -433,7 +443,7 @@
   1.173  	case " $LHA_EXTS " in *\ $lc_ext\ *)
   1.174  # Desktop/up -> ..
   1.175  # lrwxrwxrwx     0/0           0       0 ****** -lhd- 0000 2009-05-03 16:59:03 [2]
   1.176 -		lha v -q -v  "$archive" | $AWK'
   1.177 +		lha v -q -v  "$archive" | awk0 '
   1.178  {
   1.179  	if ($4 == "") { getlink($0); next }
   1.180  	attr=$1
   1.181 @@ -447,7 +457,7 @@
   1.182  	case " $LZO_EXTS " in *\ $lc_ext\ *)
   1.183  # ------         ------    ------  -----     ----    ----   ----
   1.184  # LZO1X-1         10057      5675  56.4%  2005-07-25 16:26  path/file
   1.185 -		lzop -Plv "$archive" | $AWKU'
   1.186 +		lzop -Plv "$archive" | awku '
   1.187  /-[0-9]+-/ {
   1.188  	size=$2
   1.189  	date=$5