wok annotate xarchive/stuff/slitaz-wrap.sh @ rev 23802

created recipe for pango-typelib
author Hans-G?nter Theisgen
date Sun May 24 07:28:37 2020 +0100 (2020-05-24)
parents 055ed706128d
children
rev   line source
pascal@688 1 #!/bin/sh
pascal@4909 2 #
pascal@4909 3 # slitaz-wrap.sh - slitaz core wrapper for xarchive frontend
pascal@4909 4 # Copyright (C) 2005 Lee Bigelow <ligelowbee@yahoo.com>
pascal@4909 5 # Copyright (C) 2010 Pascal Bellard <pascal.bellard@slitaz.org>
pascal@4909 6 #
pascal@688 7 # This program is free software; you can redistribute it and/or modify
pascal@688 8 # it under the terms of the GNU General Public License as published by
pascal@688 9 # the Free Software Foundation; either version 2 of the License, or
pascal@688 10 # (at your option) any later version.
pascal@4909 11 #
pascal@688 12 # This program is distributed in the hope that it will be useful,
pascal@688 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@688 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@688 15 # GNU General Public License for more details.
pascal@4909 16 #
pascal@688 17 # You should have received a copy of the GNU General Public License
pascal@688 18 # along with this program; if not, write to the Free Software
pascal@688 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
pascal@688 20
pascal@4909 21 UNSUPPORTED=65
pascal@688 22
pascal@4909 23 GZIP_EXTS="tar.gz tgz cpio.gz"
pascal@688 24 LZMA_EXTS="tar.lz tar.lzma tlz"
pascal@688 25 BZIP2_EXTS="tar.bz tbz tar.bz2 tbz2"
pascal@4909 26 COMPRESS_EXTS="tar.z tar.Z"
pascal@4909 27 TAR_EXTS="tar tar.gz tgz $LZMA_EXTS $BZIP2_EXTS $COMPRESS_EXTS"
pascal@4355 28 XZ_EXTS="tar.xz txz"
pascal@4955 29 LRZIP_EXTS="tar.lrz tlrz"
pascal@2080 30 IPK_EXTS="ipk"
pascal@4909 31 CPIO_EXTS="cpio cpio.gz"
pascal@4355 32 CPIOXZ_EXTS="cpio.xz"
pascal@4955 33 CPIOLRZIP_EXTS="cpio.lrz"
pascal@688 34 ZIP_EXTS="zip cbz jar"
pascal@688 35 RPM_EXTS="rpm"
pascal@4909 36 DEB_EXTS="deb udeb"
pascal@3530 37 TAZPKG_EXTS="tazpkg spkg"
pascal@942 38 ISO_EXTS="iso"
pascal@4909 39 SQUASHFS_EXTS="sfs sqfs squashfs"
pascal@4909 40 CROMFS_EXTS="cfs cromfs"
pascal@17256 41 FAT_EXTS="dos fat vfat"
pascal@17256 42 EXT2_EXTS="ext2 ext3 ext4"
pascal@17256 43 FS_EXTS="$EXT2_EXTS $FAT_EXTS xfs fd fs loop"
pascal@943 44 CLOOP_EXTS="cloop"
pascal@2877 45 RAR_EXTS="rar cbr"
pascal@2877 46 LHA_EXTS="lha lzh lzs"
pascal@3194 47 LZO_EXTS="lzo"
pascal@4909 48 ARJ_EXTS="arj pak arc j uc2 zoo"
pascal@19373 49 NZ_EXTS="nz"
pascal@17256 50 _7Z_EXTS="7z bcj bcj2 wim $BZIP2_EXTS $ZIP_EXTS $XZ_EXTS"
pascal@17256 51 _7Z_EXTS_X="chm cramfs dmg hfs mbr msi nsis ntfs udf vhd xar arj cab lzh rar \
pascal@17256 52 udf cpio $ISO_EXTS $FAT_EXTS $SQUASHFS_EXTS"
pascal@17380 53 ZPAQ_EXTS="zpaq"
pascal@688 54
pascal@4909 55 while read var progs; do
pascal@4909 56 eval $var=""
pascal@4909 57 for i in $progs; do
pascal@4909 58 [ "$(which $i)" ] || continue
pascal@4909 59 eval $var="$i"
pascal@4909 60 break
pascal@4909 61 done
pascal@4909 62 done <<EOT
pascal@4909 63 AWK_PROG mawk gawk awk
pascal@4909 64 XTERM_PROG xterm rxvt xvt wterm aterm Eterm false
pascal@4909 65 EOT
pascal@688 66
pascal@4909 67 # the shifting will leave the files passed as all the remaining args "$@"
pascal@688 68 opt="$1"
pascal@4909 69 archive="$2"
pascal@5209 70 lc="$(echo $2|tr [:upper:] [:lower:])"
pascal@4909 71 shift 2
pascal@688 72
pascal@5209 73 in_exts()
pascal@5209 74 {
pascal@5209 75 for i in $@; do
pascal@5209 76 [ $(expr "$lc" : ".*\."$i"$") -gt 0 ] && break
pascal@5209 77 done
pascal@5209 78 }
pascal@5209 79
pascal@2877 80 tazpkg2cpio()
pascal@2877 81 {
pascal@4909 82 tmp="$(mktemp -d -t tmpcpio.XXXXXX)"
pascal@4909 83 case "$(cd $tmp; cpio -iv < "$1")" in
pascal@5167 84 *lzma*) unlzma -c $tmp/fs.cpio.lzma;;
pascal@5167 85 *gz*) zcat $tmp/fs.cpio.gz
pascal@4909 86 esac
pascal@4909 87 rm -rf $tmp
pascal@2877 88 }
pascal@2877 89
pascal@2080 90 decompress_ipk()
pascal@2080 91 {
pascal@4909 92 tar xOzf "$1" ./data.tar.gz | gzip -dc
pascal@2080 93 }
pascal@2080 94
pascal@4909 95 # variables for our compression functions.
pascal@688 96 DECOMPRESS="cat"
pascal@688 97 COMPRESS="cat"
pascal@4909 98 while read d c exts; do
pascal@5209 99 in_exts $exts || continue
pascal@20892 100 [ "$d" = "${d% *}" -o "$(which ${d% *})" ] || exit $UNSUPPORTED
pascal@5209 101 DECOMPRESS="$d"
pascal@5209 102 COMPRESS="$c"
pascal@5209 103 [ "$(which ${c% *})" ] || COMPRESS="false"
pascal@5209 104 break
pascal@4909 105 done <<EOT
pascal@4909 106 unlzma\ -c lzma\ e\ -si\ -so $LZMA_EXTS
pascal@4909 107 bunzip2\ -c bzip2\ -c $BZIP2_EXTS
pascal@4909 108 gzip\ -dc gzip\ -c $GZIP_EXTS
pascal@4909 109 xz\ -dc xz\ -c $XZ_EXTS $CPIOXZ_EXTS
pascal@4954 110 lrzip\ -d lrzip $LRZIP_EXTS $CPIOLRZIP_EXTS
pascal@4909 111 uncompress\ -dc compress\ -c $COMPRESS_EXTS
pascal@4909 112 rpm2cpio false $RPM_EXTS
pascal@4909 113 tazpkg2cpio false $TAZPKG_EXTS
pascal@4909 114 decompress_ipk false $IPK_EXTS
pascal@4909 115 EOT
pascal@688 116
pascal@688 117 decompress_func()
pascal@688 118 {
pascal@4909 119 [ "$DECOMPRESS" = "cat" ] && return
pascal@4909 120 tmp="$(mktemp -t tartmp.XXXXXX)"
pascal@4909 121 [ -f "$archive" ] && $DECOMPRESS "$archive" > "$tmp"
pascal@4909 122 # store old name for compress_func
pascal@4909 123 oldarch="$archive"
pascal@4909 124 # change working file
pascal@4909 125 archive="$tmp"
pascal@688 126 }
pascal@688 127
pascal@688 128 compress_func()
pascal@688 129 {
pascal@4909 130 status=$?
pascal@4909 131 if [ "$COMPRESS" != "cat" -a -n "$oldarch" ]; then
pascal@4909 132 [ -f "$oldarch" ] && rm "$oldarch"
pascal@4909 133 $COMPRESS < "$archive" > "$oldarch" && rm "$archive"
pascal@4909 134 fi
pascal@4909 135 exit $status
pascal@688 136 }
pascal@688 137
pascal@2877 138 addcpio()
pascal@2877 139 {
pascal@4909 140 find $@ | cpio -o -H newc
pascal@2877 141 }
pascal@2877 142
pascal@4909 143 a_file()
pascal@2877 144 {
pascal@4909 145 ( cd $2 ; tar -cf - $1 ) | tar -xf -
pascal@2877 146 }
pascal@2877 147
pascal@4909 148 r_file()
pascal@941 149 {
pascal@4909 150 rm -rf ./$1
pascal@941 151 }
pascal@941 152
pascal@4909 153 dpkg_c()
pascal@941 154 {
pascal@4909 155 dpkg-deb -c "$archive"
pascal@941 156 }
pascal@941 157
pascal@942 158 loop_fs()
pascal@942 159 {
pascal@4909 160 [ "$1" = "-n" ] && retrun
pascal@4909 161 cmd=$1
pascal@4909 162 shift
pascal@4909 163 tmp="$(mktemp -d -t fstmp.XXXXXX)"
pascal@4914 164 while read command umnt exts; do
pascal@5209 165 in_exts $exts || continue
pascal@5209 166 $command "$archive" $tmp
pascal@5209 167 break
pascal@4909 168 done <<EOT
pascal@4909 169 cromfs-driver fusermount\ -u $CROMFS_EXTS
pascal@4909 170 mount\ -o\ loop=/dev/cloop,ro umount\ -d $CLOOP_EXTS
pascal@4909 171 mount\ -o\ loop,rw umount\ -d $FS_EXTS
pascal@4909 172 mount\ -o\ loop,ro umount\ -d $ISO_EXTS $SQUASHFS_EXTS
pascal@4909 173 EOT
pascal@4909 174 rmdir $tmp 2> /dev/null && return
pascal@4909 175 case "$cmd" in
pascal@4909 176 -o) find $tmp | while read f; do
pascal@4909 177 [ "$f" = "$tmp" ] && continue
pascal@4909 178 link="-"
pascal@4909 179 [ -L "$f" ] && link=$(readlink "$f")
pascal@4909 180 date=$(stat -c "%y" $f | $AWK_PROG \
pascal@4909 181 '{ printf "%s;%s\n",$1,substr($2,0,8)}')
pascal@4909 182 echo "${f#$tmp/};$(stat -c "%s;%A;%U;%G" $f);$date;$link"
pascal@4909 183 done;;
pascal@4909 184 -e) ( cd $tmp ; tar cf - "$@" ) | tar xf - ;;
pascal@4909 185 -a) tar cf - "$@" | ( cd $tmp ; tar xf - );;
pascal@4909 186 -r) ( cd $tmp ; rm -rf "$@" )
pascal@4909 187 esac
pascal@4909 188 $umnt $tmp
pascal@4909 189 rmdir $tmp
pascal@4909 190 exit
pascal@942 191 }
pascal@942 192
pascal@4909 193 update()
pascal@4909 194 {
pascal@4909 195 loop_fs "$@"
pascal@4909 196 [ "$COMPRESS" = "false" ] && return
pascal@4909 197 action=$1
pascal@4909 198 shift
pascal@4909 199 tardir="$(dirname "$archive")"
pascal@5209 200 if [ "$(readlink /bin/tar)" != "busybox" ] && [ "$action" != "-n" ] &&
pascal@5209 201 in_exts $TAR_EXTS $XZ_EXTS $LRZIP_EXTS ; then
pascal@5209 202 decompress_func
pascal@5209 203 case "$action" in
pascal@5209 204 -r) tar --delete -f "$archive" "$@";;
pascal@5209 205 -a) cd "$tardir"
pascal@5209 206 while [ -n "$1" ]; do
pascal@5209 207 tar -rf "$archive" "${1#$tardir/}"
pascal@5209 208 done
pascal@4909 209 esac
pascal@5209 210 compress_func
pascal@4909 211 fi
pascal@4909 212 while read add extract exts; do
pascal@5209 213 in_exts $exts || continue
pascal@5209 214 if [ "$action" = "-n" ]; then
pascal@5209 215 decompress_func
pascal@5209 216 cd "$tardir"
pascal@5209 217 $add "${1#$tardir/}" > "$archive"
pascal@5209 218 compress_func
pascal@5209 219 fi
pascal@5209 220 tmp="$(mktemp -d -t tartmp.XXXXXX)"
pascal@5209 221 cd $tmp
pascal@5209 222 $DECOMPRESS "$archive" | $extract
pascal@5209 223 status=$?
pascal@5209 224 if [ $status -eq 0 -a -n "$1" ]; then
pascal@5209 225 while [ "$1" ]; do
pascal@5209 226 ${action#-}_file "${1#$tardir/}" $here
pascal@5209 227 shift
pascal@5209 228 done
pascal@5209 229 $add $(ls -a | grep -v ^\.$ | grep -v ^\.\.$) | \
pascal@5209 230 $COMPRESS > "$archive"
pascal@4909 231 status=$?
pascal@5209 232 fi
pascal@5209 233 cd - >/dev/null
pascal@5209 234 rm -rf $tmp
pascal@5209 235 exit $status
pascal@4909 236 done <<EOT
pascal@4954 237 tar\ -cf\ - tar\ -xf\ - $TAR_EXTS $XZ_EXTS $LRZIP_EXTS
pascal@4954 238 addcpio cpio\ -id\ >\ /dev/null $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS
pascal@4909 239 EOT
pascal@4909 240 }
pascal@4909 241
pascal@5167 242 AWK_MISC='
pascal@4909 243 BEGIN {
pascal@4909 244 attr="-"
pascal@4909 245 link="-"
pascal@4909 246 uid=uuid
pascal@4909 247 gid=uuid
pascal@4909 248 }
pascal@4909 249 function getlink(arg)
pascal@4909 250 {
pascal@4909 251 split(arg, x, " -> ")
pascal@4909 252 name=x[1]
pascal@4909 253 link=x[2]
pascal@4909 254 if (!link) link="-"
pascal@4909 255 }
pascal@688 256
pascal@4909 257 function getname(arg)
pascal@4909 258 {
pascal@4909 259 # works with filenames that start with a space (evil!)
pascal@4909 260 split($0,x, arg)
pascal@4909 261 getlink(x[2])
pascal@4909 262 }
pascal@4909 263
pascal@4909 264 function getid(arg)
pascal@4909 265 {
pascal@4909 266 if (uuid != "") return
pascal@4909 267 split(arg,x,"/")
pascal@4909 268 uid=x[1]
pascal@4909 269 gid=x[2]
pascal@4909 270 }
pascal@4909 271
pascal@4909 272 function getattr(arg)
pascal@4909 273 {
pascal@4909 274 attr=arg
pascal@4909 275 if (index(attr, "D") != 0) attr="drwxr-xr-x"
pascal@4909 276 else if (index(attr, ".") != 0 || attr !~ /^[rwx-]/) attr="-rw-r--r--"
pascal@4909 277 }
pascal@4909 278
pascal@4909 279 function display()
pascal@4909 280 {
pascal@4909 281 if (name != "") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@4909 282 }
pascal@4909 283
pascal@4909 284 function show(arg)
pascal@4909 285 {
pascal@4909 286 getid($2)
pascal@4909 287 getname(arg)
pascal@4909 288 if (uid != "blocks") display()
pascal@4909 289 }'
pascal@5167 290
pascal@5167 291 awk0()
pascal@5167 292 {
pascal@5167 293 $AWK_PROG "$AWK_MISC $1"
pascal@5167 294 }
pascal@5167 295
pascal@5167 296 awku()
pascal@5167 297 {
pascal@5167 298 $AWK_PROG -v uuid=$(id -u -n) "$AWK_MISC $1"
pascal@5167 299 }
pascal@5167 300
pascal@5167 301 # main: option switches
pascal@5167 302 case "$opt" in
pascal@5167 303 -i) # info: output supported extentions for progs that exist
pascal@5167 304 while read exe exts; do
pascal@5167 305 [ "$(which $exe)" -o -f /lib/modules/$(uname -r)/kernel/$exe.ko ] &&
pascal@5167 306 echo -n "$exts " | sed 's/ /;/g'
pascal@5167 307 done <<EOT
pascal@5167 308 tar $TAR_EXTS $IPK_EXTS
pascal@5167 309 cpio $CPIO_EXTS $TAZPKG_EXTS
pascal@5167 310 unzip $ZIP_EXTS
pascal@5167 311 dpkg-deb $DEB_EXTS
pascal@5167 312 rpm2cpio $RPM_EXTS
pascal@5167 313 mount $ISO_EXTS $FS_EXTS
pascal@5167 314 xz $XZ_EXTS $CPIOXZ_EXTS
pascal@5167 315 lrzip $LRZIP_EXTS $CPIOLRZIP_EXTS
pascal@5167 316 rar $RAR_EXTS
pascal@5167 317 unace ace
pascal@5167 318 arj $ARJ_EXTS
pascal@19373 319 nz $NZ_EXTS
pascal@17256 320 7zr $_7Z_EXTS $_7Z_EXTS_X
pascal@5167 321 lha $LHA_EXTS
pascal@5167 322 lzop $LZO_EXTS
pascal@5167 323 cabextract cab
pascal@5167 324 cromfs-driver $CROMFS_EXTS
pascal@5167 325 fs/squashfs/squashfs $SQUASHFS_EXTS
pascal@5167 326 drivers/block/cloop $CLOOP_EXTS
pascal@17380 327 zpaq $ZPAQ_EXTS
pascal@5167 328 EOT
pascal@5167 329 echo ""
pascal@5167 330 exit
pascal@5167 331 ;;
pascal@5167 332 -o) # open: mangle output for xarchive
pascal@4909 333 while read filter exts; do
pascal@688 334 # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link
pascal@5209 335 in_exts $exts && $DECOMPRESS "$archive" | $filter | awk0 '
pascal@4909 336 {
pascal@4909 337 attr=$1
pascal@4909 338 size=$3
pascal@4909 339 date=$4
pascal@4909 340 time=$5
pascal@4909 341 show($5 " ")
pascal@4909 342 }'
pascal@4909 343 done <<EOT
pascal@4954 344 cpio\ -tv $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS $RPM_EXTS $TAZPKG_EXTS
pascal@4954 345 tar\ -tvf\ - $TAR_EXTS $XZ_EXTS $LRZIP_EXTS $IPK_EXTS
pascal@4909 346 dpkg_c $DEB_EXTS
pascal@2877 347 EOT
pascal@4909 348 loop_fs $opt
pascal@5209 349 if in_exts $ZIP_EXTS; then
pascal@2877 350 if [ "$(which zipinfo)" ]; then
pascal@4909 351 # -rw-r--r-- 2.3 unx 11512 tx defN YYYYMMDD.HHMMSS file
pascal@5167 352 zipinfo -T -s-h-t "$archive" | awku '
pascal@4909 353 {
pascal@4909 354 attr=$1
pascal@4909 355 size=$4
pascal@4909 356 date=substr($7,1,4) "-" substr($7,5,2) "-" substr($7,7,2)
pascal@4909 357 time=substr($7,10,2) ":" substr($7,12,2) ":" substr($7,14,2)
pascal@4909 358 show($7 " ")
pascal@4909 359 }'
pascal@688 360 else
pascal@4909 361 # 6622 2005-04-22 12:29:14 file
pascal@5167 362 unzip -l "$archive" | awku '
pascal@4909 363 /-[0-9]+-/ {
pascal@4909 364 size=$1
pascal@4909 365 date=$2
pascal@4909 366 time=$3
pascal@4909 367 show($3 " ")
pascal@4909 368 }'
pascal@688 369 fi
pascal@5209 370 fi
pascal@4909 371 # -----------+---------------------+-------
pascal@4909 372 # 6622 | 22.04.2005 12:29:14 | file
pascal@5209 373 in_exts cab && cabextract -q -l "$archive" | awku '
pascal@4909 374 /[0-9]+ |/ {
pascal@4909 375 size=$1
pascal@4909 376 date=$3
pascal@4909 377 time=$4
pascal@4909 378 show($4 " | ")
pascal@4909 379 }'
pascal@2877 380 #-------------------------------------
pascal@2877 381 # bookmarks/mozilla_bookmarks.html
pascal@2877 382 # 11512 5231 45% 28-02-05 16:19 -rw-r--r-- F3F3477F m3b 2.9
pascal@2877 383 # (or 11512 5231 45% 28-02-05 16:19 .D.... 00000000 m3b 2.9)
pascal@5209 384 in_exts $RAR_EXTS && rar v -c- "$archive" | awku '
pascal@4909 385 /-[0-9]+-/ {
pascal@4909 386 getattr($6)
pascal@4909 387 size=$1
pascal@4909 388 date=$4
pascal@4909 389 time=$5
pascal@4909 390 display()
pascal@4909 391 }
pascal@4909 392 {
pascal@4909 393 name=substr($0,2)
pascal@4909 394 }'
pascal@4909 395 # Date ³Time ³Packed ³Size ³Ratio³File
pascal@4909 396 # 17.09.02³00:32³ 394116³ 414817³ 95%³ OggDS0993.exe
pascal@5209 397 in_exts ace && unace v -c- "$archive" | awku '
pascal@4909 398 /^[0-9][0-9]\./ {
pascal@4909 399 # strip the funky little 3 off the end of size
pascal@4909 400 size=substr($3,1,(length($3)-1))
pascal@4909 401 date=substr($1,1,8)
pascal@4909 402 time=substr($1,10,5)
pascal@4909 403 show($4 " ")
pascal@4909 404 }'
pascal@4909 405 # ------------------- ----- ------------ ------------ ------------
pascal@4909 406 # 1992-04-12 11:39:46 ....A 356 ANKETA.FRG
pascal@5209 407 in_exts 7z bcj bcj2 && 7zr l "$archive" | awku '
pascal@4909 408 /^[0-9]+-/ {
pascal@4909 409 date=$1
pascal@4909 410 time=$2
pascal@4909 411 getattr($3)
pascal@4909 412 size=$4
pascal@4909 413 $0=substr($0, 54)
pascal@4909 414 name=$1
pascal@4909 415 if (NF > 1) name=$0
pascal@4909 416 gsub(/\\/, "/", name)
pascal@4909 417 display()
pascal@4909 418 }'
pascal@4909 419 # 001) ANKETA.FRG
pascal@4909 420 # 3 MS-DOS 356 121 0.340 92-04-12 11:39:46 1
pascal@5209 421 in_exts $ARJ_EXTS && arj v "$archive" | awku '
pascal@4909 422 BEGIN { name="" }
pascal@4909 423 /^[0-9]+\) / {
pascal@4909 424 display()
pascal@4909 425 getname($1 " ")
pascal@4909 426 }
pascal@4909 427 /^[\t ]+[0-9]+/ {
pascal@4909 428 size=$3
pascal@4909 429 date=$6
pascal@4909 430 time=$7
pascal@4909 431 getattr($8)
pascal@4909 432 }
pascal@4909 433 /^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/ { uid=$3; gid=$5 }
pascal@4909 434 /^[\t ]+SymLink -> / { link=$3; attr="l"substr(attr, 2) }
pascal@4909 435 /^---/ { display() }
pascal@4909 436 '
pascal@19373 437 # Archive: nz.nz
pascal@19373 438 # checksum perm yyyy-mmm-dd hh:mm:ss size file
pascal@19373 439 # 387b9923 0755 2016-Aug-10 13:29:41 1144 KB nz
pascal@19373 440 # a52758fb 0644 2016-Aug-10 13:29:41 371 B readme.txt
pascal@19373 441 # Total of 3 files, 1 181 184 bytes.
pascal@19373 442 in_exts $NZ_EXTS && nz l "$archive" | awku '
pascal@19373 443 {
pascal@19373 444 if ($1 == "checksum") show=1
pascal@19373 445 else if ($1 == "Total") exit
pascal@19373 446 else {
pascal@19373 447 attr=$2
pascal@19373 448 date=$3
pascal@19373 449 time=$4
pascal@19373 450 size=$5 $6
pascal@19373 451 name=$7
pascal@19373 452 display()
pascal@19373 453 }
pascal@19373 454 }
pascal@19373 455 '
pascal@17380 456 # Ver Date Time (UT) Attr Size Ratio File
pascal@17380 457 # ----- ---------- -------- ------ ------------ ------ ----
pascal@17380 458 # > 1 2012-04-10 11:47:56 100644 576 0.2611 /etc/skel/.profile
pascal@17380 459 in_exts $ZPAQ_EXTS && zpaq l "$archive" | awku '
pascal@17380 460 /^>/ {
pascal@17380 461 date=$3
pascal@17380 462 time=$4
pascal@17380 463 attr=$5
pascal@17380 464 size=$6
pascal@17380 465 name=$8
pascal@17380 466 display()
pascal@17380 467 }'
pascal@4909 468 # Desktop/up -> ..
pascal@4909 469 # lrwxrwxrwx 0/0 0 0 ****** -lhd- 0000 2009-05-03 16:59:03 [2]
pascal@5209 470 in_exts $LHA_EXTS && lha v -q -v "$archive" | awk0 '
pascal@4909 471 {
pascal@4909 472 if ($4 == "") { getlink($0); next }
pascal@4909 473 attr=$1
pascal@4909 474 getid($2)
pascal@4909 475 size=$4
pascal@4909 476 date=$8
pascal@4909 477 time=$9
pascal@4909 478 display()
pascal@4909 479 }'
pascal@3194 480 # ------ ------ ------ ----- ---- ---- ----
pascal@3194 481 # LZO1X-1 10057 5675 56.4% 2005-07-25 16:26 path/file
pascal@5209 482 in_exts $LZO_EXTS && lzop -Plv "$archive" | awku '
pascal@4909 483 /-[0-9]+-/ {
pascal@4909 484 size=$2
pascal@4909 485 date=$5
pascal@4909 486 time=$6
pascal@4909 487 show($6 " ")
pascal@4909 488 }'
pascal@4909 489 exit 0
pascal@4909 490 ;;
pascal@4909 491 -a|-n) # add to archive / new: create new archive
pascal@4909 492 update $opt "$@"
pascal@2877 493 while read exe args exts; do
pascal@5209 494 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@4909 495 [ "$opt$exe" = "-nzip" ] && args="-r"
pascal@5209 496 # only add the file's basename, not the full path
pascal@5209 497 while [ "$1" ]; do
pascal@5209 498 cd "$(dirname "$1")"
pascal@5209 499 $exe $args "$archive" "$(basename "$1")"
pascal@5209 500 status=$?
pascal@5209 501 shift
pascal@5209 502 done
pascal@5209 503 exit $status
pascal@2877 504 done <<EOT
pascal@2877 505 zip -g\ -r $ZIP_EXTS
pascal@2877 506 rar a $RAR_EXTS
pascal@4909 507 arj a $ARJ_EXTS
pascal@19373 508 nz a $NZ_EXTS
pascal@4909 509 7zr a\ -ms=off $_7Z_EXTS
pascal@2877 510 lha a $LHA_EXTS
pascal@17380 511 zpaq a $ZPAQ_EXTS
pascal@2877 512 EOT
pascal@4909 513 ;;
pascal@4909 514 -r) # remove from archive passed files
pascal@4909 515 update $opt "$@"
pascal@2877 516 while read exe args exts; do
pascal@5209 517 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@5209 518 $exe $args "$archive" "$@" | grep -q E_NOTIMPL && {
pascal@5209 519 echo -e "7z cannot delete files from solid archive." >&2
pascal@5209 520 exit $UNSUPPORTED
pascal@5209 521 }
pascal@5209 522 exit 0
pascal@2877 523 done <<EOT
pascal@2877 524 zip -d $ZIP_EXTS
pascal@2877 525 rar d $RAR_EXTS
pascal@4909 526 arj d $ARJ_EXTS
pascal@2877 527 lha d $LHA_EXTS
pascal@4909 528 7zr d $_7Z_EXTS
pascal@17380 529 zpaq d $ZPAQ_EXTS
pascal@2877 530 EOT
pascal@4909 531 ;;
pascal@4909 532 -e) # extract from archive passed files
pascal@4909 533 while read arch exts; do
pascal@5209 534 in_exts $exts || continue
pascal@5209 535 $DECOMPRESS "$archive" | $arch "$@"
pascal@5209 536 exit $?
pascal@2877 537 done <<EOT
pascal@4954 538 tar\ -xf\ - $TAR_EXTS $IPK_EXTS $XZ_EXTS $LRZIP_EXTS
pascal@4954 539 cpio\ -idm $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS $RPM_EXTS $TAZPKG_EXTS
pascal@2877 540 EOT
pascal@4909 541 while read exe x p exts; do
pascal@5209 542 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@5209 543 [ "$x" != "N/A" ] && $exe $x "$archive" "$@"
pascal@5209 544 status=$?
pascal@5209 545 if [ "$p" != "N/A" -a $status -ne 0 ]; then
pascal@5209 546 echo Password protected, opening an x-term...
pascal@5209 547 $XTERM_PROG -e $exe $p "$archive" "$@"
pascal@5209 548 exit $?
pascal@5209 549 fi
pascal@5209 550 exit $status
pascal@2877 551 done <<EOT
pascal@4909 552 unzip -n N/A $ZIP_EXTS
pascal@4909 553 dpkg-deb -X N/A $DEB_EXTS
pascal@4909 554 lha x N/A $LHA_EXTS
pascal@4909 555 lzop -x N/A $LZO_EXTS
pascal@4909 556 rar x\ -o-\ -p- x\ -o- $RAR_EXTS
pascal@4909 557 arj x\ -y x\ -y\ -g? $ARJ_EXTS
pascal@19373 558 nz x N/A $NZ_EXTS
pascal@17256 559 7zr x\ -y\ -p- x\ -y $_7Z_EXTS $_7Z_EXTS_X
pascal@4909 560 unace N/A x\ -o\ -y ace
pascal@4909 561 cabextract -q N/A cab
pascal@17380 562 zpaq x x\ -key $ZPAQ_EXTS
pascal@2877 563 EOT
pascal@4909 564 loop_fs $opt "$@"
pascal@4909 565 ;;
pascal@4909 566 *) cat <<EOT
pascal@4909 567 error, option $opt not supported
pascal@4909 568 use one of these:
pascal@4909 569 -i #info
pascal@4909 570 -o archive #open
pascal@4909 571 -a archive files #add
pascal@4909 572 -n archive file #new
pascal@4909 573 -r archive files #remove
pascal@4909 574 -e archive files #extract
pascal@2877 575 EOT
pascal@688 576 esac
pascal@4909 577 exit $UNSUPPORTED