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

Add perl-text-csv.
author Christopher Rogers <slaxemulator@gmail.com>
date Sun Jan 09 17:18:37 2011 +0000 (2011-01-09)
parents ea802196d3e8
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@4355 41 FS_EXTS="ext2 ext3 dos fat vfat xfs fd fs loop"
pascal@943 42 CLOOP_EXTS="cloop"
pascal@2877 43 RAR_EXTS="rar cbr"
pascal@2877 44 LHA_EXTS="lha lzh lzs"
pascal@3194 45 LZO_EXTS="lzo"
pascal@4909 46 ARJ_EXTS="arj pak arc j uc2 zoo"
pascal@4909 47 _7Z_EXTS="7z bcj bcj2"
pascal@688 48
pascal@4909 49 while read var progs; do
pascal@4909 50 eval $var=""
pascal@4909 51 for i in $progs; do
pascal@4909 52 [ "$(which $i)" ] || continue
pascal@4909 53 eval $var="$i"
pascal@4909 54 break
pascal@4909 55 done
pascal@4909 56 done <<EOT
pascal@4909 57 AWK_PROG mawk gawk awk
pascal@4909 58 XTERM_PROG xterm rxvt xvt wterm aterm Eterm false
pascal@4909 59 EOT
pascal@688 60
pascal@4909 61 # the shifting will leave the files passed as all the remaining args "$@"
pascal@688 62 opt="$1"
pascal@4909 63 archive="$2"
pascal@5209 64 lc="$(echo $2|tr [:upper:] [:lower:])"
pascal@4909 65 shift 2
pascal@688 66
pascal@5209 67 in_exts()
pascal@5209 68 {
pascal@5209 69 for i in $@; do
pascal@5209 70 [ $(expr "$lc" : ".*\."$i"$") -gt 0 ] && break
pascal@5209 71 done
pascal@5209 72 }
pascal@5209 73
pascal@2877 74 tazpkg2cpio()
pascal@2877 75 {
pascal@4909 76 tmp="$(mktemp -d -t tmpcpio.XXXXXX)"
pascal@4909 77 case "$(cd $tmp; cpio -iv < "$1")" in
pascal@5167 78 *lzma*) unlzma -c $tmp/fs.cpio.lzma;;
pascal@5167 79 *gz*) zcat $tmp/fs.cpio.gz
pascal@4909 80 esac
pascal@4909 81 rm -rf $tmp
pascal@2877 82 }
pascal@2877 83
pascal@2080 84 decompress_ipk()
pascal@2080 85 {
pascal@4909 86 tar xOzf "$1" ./data.tar.gz | gzip -dc
pascal@2080 87 }
pascal@2080 88
pascal@4909 89 # variables for our compression functions.
pascal@688 90 DECOMPRESS="cat"
pascal@688 91 COMPRESS="cat"
pascal@4909 92 while read d c exts; do
pascal@5209 93 in_exts $exts || continue
pascal@5209 94 [ "$d" == "${d% *}" -o "$(which ${d% *})" ] || exit $UNSUPPORTED
pascal@5209 95 DECOMPRESS="$d"
pascal@5209 96 COMPRESS="$c"
pascal@5209 97 [ "$(which ${c% *})" ] || COMPRESS="false"
pascal@5209 98 break
pascal@4909 99 done <<EOT
pascal@4909 100 unlzma\ -c lzma\ e\ -si\ -so $LZMA_EXTS
pascal@4909 101 bunzip2\ -c bzip2\ -c $BZIP2_EXTS
pascal@4909 102 gzip\ -dc gzip\ -c $GZIP_EXTS
pascal@4909 103 xz\ -dc xz\ -c $XZ_EXTS $CPIOXZ_EXTS
pascal@4954 104 lrzip\ -d lrzip $LRZIP_EXTS $CPIOLRZIP_EXTS
pascal@4909 105 uncompress\ -dc compress\ -c $COMPRESS_EXTS
pascal@4909 106 rpm2cpio false $RPM_EXTS
pascal@4909 107 tazpkg2cpio false $TAZPKG_EXTS
pascal@4909 108 decompress_ipk false $IPK_EXTS
pascal@4909 109 EOT
pascal@688 110
pascal@688 111 decompress_func()
pascal@688 112 {
pascal@4909 113 [ "$DECOMPRESS" = "cat" ] && return
pascal@4909 114 tmp="$(mktemp -t tartmp.XXXXXX)"
pascal@4909 115 [ -f "$archive" ] && $DECOMPRESS "$archive" > "$tmp"
pascal@4909 116 # store old name for compress_func
pascal@4909 117 oldarch="$archive"
pascal@4909 118 # change working file
pascal@4909 119 archive="$tmp"
pascal@688 120 }
pascal@688 121
pascal@688 122 compress_func()
pascal@688 123 {
pascal@4909 124 status=$?
pascal@4909 125 if [ "$COMPRESS" != "cat" -a -n "$oldarch" ]; then
pascal@4909 126 [ -f "$oldarch" ] && rm "$oldarch"
pascal@4909 127 $COMPRESS < "$archive" > "$oldarch" && rm "$archive"
pascal@4909 128 fi
pascal@4909 129 exit $status
pascal@688 130 }
pascal@688 131
pascal@2877 132 addcpio()
pascal@2877 133 {
pascal@4909 134 find $@ | cpio -o -H newc
pascal@2877 135 }
pascal@2877 136
pascal@4909 137 a_file()
pascal@2877 138 {
pascal@4909 139 ( cd $2 ; tar -cf - $1 ) | tar -xf -
pascal@2877 140 }
pascal@2877 141
pascal@4909 142 r_file()
pascal@941 143 {
pascal@4909 144 rm -rf ./$1
pascal@941 145 }
pascal@941 146
pascal@4909 147 dpkg_c()
pascal@941 148 {
pascal@4909 149 dpkg-deb -c "$archive"
pascal@941 150 }
pascal@941 151
pascal@942 152 loop_fs()
pascal@942 153 {
pascal@4909 154 [ "$1" = "-n" ] && retrun
pascal@4909 155 cmd=$1
pascal@4909 156 shift
pascal@4909 157 tmp="$(mktemp -d -t fstmp.XXXXXX)"
pascal@4914 158 while read command umnt exts; do
pascal@5209 159 in_exts $exts || continue
pascal@5209 160 $command "$archive" $tmp
pascal@5209 161 break
pascal@4909 162 done <<EOT
pascal@4909 163 cromfs-driver fusermount\ -u $CROMFS_EXTS
pascal@4909 164 mount\ -o\ loop=/dev/cloop,ro umount\ -d $CLOOP_EXTS
pascal@4909 165 mount\ -o\ loop,rw umount\ -d $FS_EXTS
pascal@4909 166 mount\ -o\ loop,ro umount\ -d $ISO_EXTS $SQUASHFS_EXTS
pascal@4909 167 EOT
pascal@4909 168 rmdir $tmp 2> /dev/null && return
pascal@4909 169 case "$cmd" in
pascal@4909 170 -o) find $tmp | while read f; do
pascal@4909 171 [ "$f" = "$tmp" ] && continue
pascal@4909 172 link="-"
pascal@4909 173 [ -L "$f" ] && link=$(readlink "$f")
pascal@4909 174 date=$(stat -c "%y" $f | $AWK_PROG \
pascal@4909 175 '{ printf "%s;%s\n",$1,substr($2,0,8)}')
pascal@4909 176 echo "${f#$tmp/};$(stat -c "%s;%A;%U;%G" $f);$date;$link"
pascal@4909 177 done;;
pascal@4909 178 -e) ( cd $tmp ; tar cf - "$@" ) | tar xf - ;;
pascal@4909 179 -a) tar cf - "$@" | ( cd $tmp ; tar xf - );;
pascal@4909 180 -r) ( cd $tmp ; rm -rf "$@" )
pascal@4909 181 esac
pascal@4909 182 $umnt $tmp
pascal@4909 183 rmdir $tmp
pascal@4909 184 exit
pascal@942 185 }
pascal@942 186
pascal@4909 187 update()
pascal@4909 188 {
pascal@4909 189 loop_fs "$@"
pascal@4909 190 [ "$COMPRESS" = "false" ] && return
pascal@4909 191 action=$1
pascal@4909 192 shift
pascal@4909 193 tardir="$(dirname "$archive")"
pascal@5209 194 if [ "$(readlink /bin/tar)" != "busybox" ] && [ "$action" != "-n" ] &&
pascal@5209 195 in_exts $TAR_EXTS $XZ_EXTS $LRZIP_EXTS ; then
pascal@5209 196 decompress_func
pascal@5209 197 case "$action" in
pascal@5209 198 -r) tar --delete -f "$archive" "$@";;
pascal@5209 199 -a) cd "$tardir"
pascal@5209 200 while [ -n "$1" ]; do
pascal@5209 201 tar -rf "$archive" "${1#$tardir/}"
pascal@5209 202 done
pascal@4909 203 esac
pascal@5209 204 compress_func
pascal@4909 205 fi
pascal@4909 206 while read add extract exts; do
pascal@5209 207 in_exts $exts || continue
pascal@5209 208 if [ "$action" = "-n" ]; then
pascal@5209 209 decompress_func
pascal@5209 210 cd "$tardir"
pascal@5209 211 $add "${1#$tardir/}" > "$archive"
pascal@5209 212 compress_func
pascal@5209 213 fi
pascal@5209 214 tmp="$(mktemp -d -t tartmp.XXXXXX)"
pascal@5209 215 cd $tmp
pascal@5209 216 $DECOMPRESS "$archive" | $extract
pascal@5209 217 status=$?
pascal@5209 218 if [ $status -eq 0 -a -n "$1" ]; then
pascal@5209 219 while [ "$1" ]; do
pascal@5209 220 ${action#-}_file "${1#$tardir/}" $here
pascal@5209 221 shift
pascal@5209 222 done
pascal@5209 223 $add $(ls -a | grep -v ^\.$ | grep -v ^\.\.$) | \
pascal@5209 224 $COMPRESS > "$archive"
pascal@4909 225 status=$?
pascal@5209 226 fi
pascal@5209 227 cd - >/dev/null
pascal@5209 228 rm -rf $tmp
pascal@5209 229 exit $status
pascal@4909 230 done <<EOT
pascal@4954 231 tar\ -cf\ - tar\ -xf\ - $TAR_EXTS $XZ_EXTS $LRZIP_EXTS
pascal@4954 232 addcpio cpio\ -id\ >\ /dev/null $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS
pascal@4909 233 EOT
pascal@4909 234 }
pascal@4909 235
pascal@5167 236 AWK_MISC='
pascal@4909 237 BEGIN {
pascal@4909 238 attr="-"
pascal@4909 239 link="-"
pascal@4909 240 uid=uuid
pascal@4909 241 gid=uuid
pascal@4909 242 }
pascal@4909 243 function getlink(arg)
pascal@4909 244 {
pascal@4909 245 split(arg, x, " -> ")
pascal@4909 246 name=x[1]
pascal@4909 247 link=x[2]
pascal@4909 248 if (!link) link="-"
pascal@4909 249 }
pascal@688 250
pascal@4909 251 function getname(arg)
pascal@4909 252 {
pascal@4909 253 # works with filenames that start with a space (evil!)
pascal@4909 254 split($0,x, arg)
pascal@4909 255 getlink(x[2])
pascal@4909 256 }
pascal@4909 257
pascal@4909 258 function getid(arg)
pascal@4909 259 {
pascal@4909 260 if (uuid != "") return
pascal@4909 261 split(arg,x,"/")
pascal@4909 262 uid=x[1]
pascal@4909 263 gid=x[2]
pascal@4909 264 }
pascal@4909 265
pascal@4909 266 function getattr(arg)
pascal@4909 267 {
pascal@4909 268 attr=arg
pascal@4909 269 if (index(attr, "D") != 0) attr="drwxr-xr-x"
pascal@4909 270 else if (index(attr, ".") != 0 || attr !~ /^[rwx-]/) attr="-rw-r--r--"
pascal@4909 271 }
pascal@4909 272
pascal@4909 273 function display()
pascal@4909 274 {
pascal@4909 275 if (name != "") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@4909 276 }
pascal@4909 277
pascal@4909 278 function show(arg)
pascal@4909 279 {
pascal@4909 280 getid($2)
pascal@4909 281 getname(arg)
pascal@4909 282 if (uid != "blocks") display()
pascal@4909 283 }'
pascal@5167 284
pascal@5167 285 awk0()
pascal@5167 286 {
pascal@5167 287 $AWK_PROG "$AWK_MISC $1"
pascal@5167 288 }
pascal@5167 289
pascal@5167 290 awku()
pascal@5167 291 {
pascal@5167 292 $AWK_PROG -v uuid=$(id -u -n) "$AWK_MISC $1"
pascal@5167 293 }
pascal@5167 294
pascal@5167 295 # main: option switches
pascal@5167 296 case "$opt" in
pascal@5167 297 -i) # info: output supported extentions for progs that exist
pascal@5167 298 while read exe exts; do
pascal@5167 299 [ "$(which $exe)" -o -f /lib/modules/$(uname -r)/kernel/$exe.ko ] &&
pascal@5167 300 echo -n "$exts " | sed 's/ /;/g'
pascal@5167 301 done <<EOT
pascal@5167 302 tar $TAR_EXTS $IPK_EXTS
pascal@5167 303 cpio $CPIO_EXTS $TAZPKG_EXTS
pascal@5167 304 unzip $ZIP_EXTS
pascal@5167 305 dpkg-deb $DEB_EXTS
pascal@5167 306 rpm2cpio $RPM_EXTS
pascal@5167 307 mount $ISO_EXTS $FS_EXTS
pascal@5167 308 xz $XZ_EXTS $CPIOXZ_EXTS
pascal@5167 309 lrzip $LRZIP_EXTS $CPIOLRZIP_EXTS
pascal@5167 310 rar $RAR_EXTS
pascal@5167 311 unace ace
pascal@5167 312 arj $ARJ_EXTS
pascal@5167 313 7zr $_7Z_EXTS
pascal@5167 314 lha $LHA_EXTS
pascal@5167 315 lzop $LZO_EXTS
pascal@5167 316 cabextract cab
pascal@5167 317 cromfs-driver $CROMFS_EXTS
pascal@5167 318 fs/squashfs/squashfs $SQUASHFS_EXTS
pascal@5167 319 drivers/block/cloop $CLOOP_EXTS
pascal@5167 320 EOT
pascal@5167 321 echo ""
pascal@5167 322 exit
pascal@5167 323 ;;
pascal@5167 324 -o) # open: mangle output for xarchive
pascal@4909 325 while read filter exts; do
pascal@688 326 # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link
pascal@5209 327 in_exts $exts && $DECOMPRESS "$archive" | $filter | awk0 '
pascal@4909 328 {
pascal@4909 329 attr=$1
pascal@4909 330 size=$3
pascal@4909 331 date=$4
pascal@4909 332 time=$5
pascal@4909 333 show($5 " ")
pascal@4909 334 }'
pascal@4909 335 done <<EOT
pascal@4954 336 cpio\ -tv $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS $RPM_EXTS $TAZPKG_EXTS
pascal@4954 337 tar\ -tvf\ - $TAR_EXTS $XZ_EXTS $LRZIP_EXTS $IPK_EXTS
pascal@4909 338 dpkg_c $DEB_EXTS
pascal@2877 339 EOT
pascal@4909 340 loop_fs $opt
pascal@5209 341 if in_exts $ZIP_EXTS; then
pascal@2877 342 if [ "$(which zipinfo)" ]; then
pascal@4909 343 # -rw-r--r-- 2.3 unx 11512 tx defN YYYYMMDD.HHMMSS file
pascal@5167 344 zipinfo -T -s-h-t "$archive" | awku '
pascal@4909 345 {
pascal@4909 346 attr=$1
pascal@4909 347 size=$4
pascal@4909 348 date=substr($7,1,4) "-" substr($7,5,2) "-" substr($7,7,2)
pascal@4909 349 time=substr($7,10,2) ":" substr($7,12,2) ":" substr($7,14,2)
pascal@4909 350 show($7 " ")
pascal@4909 351 }'
pascal@688 352 else
pascal@4909 353 # 6622 2005-04-22 12:29:14 file
pascal@5167 354 unzip -l "$archive" | awku '
pascal@4909 355 /-[0-9]+-/ {
pascal@4909 356 size=$1
pascal@4909 357 date=$2
pascal@4909 358 time=$3
pascal@4909 359 show($3 " ")
pascal@4909 360 }'
pascal@688 361 fi
pascal@5209 362 fi
pascal@4909 363 # -----------+---------------------+-------
pascal@4909 364 # 6622 | 22.04.2005 12:29:14 | file
pascal@5209 365 in_exts cab && cabextract -q -l "$archive" | awku '
pascal@4909 366 /[0-9]+ |/ {
pascal@4909 367 size=$1
pascal@4909 368 date=$3
pascal@4909 369 time=$4
pascal@4909 370 show($4 " | ")
pascal@4909 371 }'
pascal@2877 372 #-------------------------------------
pascal@2877 373 # bookmarks/mozilla_bookmarks.html
pascal@2877 374 # 11512 5231 45% 28-02-05 16:19 -rw-r--r-- F3F3477F m3b 2.9
pascal@2877 375 # (or 11512 5231 45% 28-02-05 16:19 .D.... 00000000 m3b 2.9)
pascal@5209 376 in_exts $RAR_EXTS && rar v -c- "$archive" | awku '
pascal@4909 377 /-[0-9]+-/ {
pascal@4909 378 getattr($6)
pascal@4909 379 size=$1
pascal@4909 380 date=$4
pascal@4909 381 time=$5
pascal@4909 382 display()
pascal@4909 383 }
pascal@4909 384 {
pascal@4909 385 name=substr($0,2)
pascal@4909 386 }'
pascal@4909 387 # Date ³Time ³Packed ³Size ³Ratio³File
pascal@4909 388 # 17.09.02³00:32³ 394116³ 414817³ 95%³ OggDS0993.exe
pascal@5209 389 in_exts ace && unace v -c- "$archive" | awku '
pascal@4909 390 /^[0-9][0-9]\./ {
pascal@4909 391 # strip the funky little 3 off the end of size
pascal@4909 392 size=substr($3,1,(length($3)-1))
pascal@4909 393 date=substr($1,1,8)
pascal@4909 394 time=substr($1,10,5)
pascal@4909 395 show($4 " ")
pascal@4909 396 }'
pascal@4909 397 # ------------------- ----- ------------ ------------ ------------
pascal@4909 398 # 1992-04-12 11:39:46 ....A 356 ANKETA.FRG
pascal@5209 399 in_exts 7z bcj bcj2 && 7zr l "$archive" | awku '
pascal@4909 400 /^[0-9]+-/ {
pascal@4909 401 date=$1
pascal@4909 402 time=$2
pascal@4909 403 getattr($3)
pascal@4909 404 size=$4
pascal@4909 405 $0=substr($0, 54)
pascal@4909 406 name=$1
pascal@4909 407 if (NF > 1) name=$0
pascal@4909 408 gsub(/\\/, "/", name)
pascal@4909 409 display()
pascal@4909 410 }'
pascal@4909 411 # 001) ANKETA.FRG
pascal@4909 412 # 3 MS-DOS 356 121 0.340 92-04-12 11:39:46 1
pascal@5209 413 in_exts $ARJ_EXTS && arj v "$archive" | awku '
pascal@4909 414 BEGIN { name="" }
pascal@4909 415 /^[0-9]+\) / {
pascal@4909 416 display()
pascal@4909 417 getname($1 " ")
pascal@4909 418 }
pascal@4909 419 /^[\t ]+[0-9]+/ {
pascal@4909 420 size=$3
pascal@4909 421 date=$6
pascal@4909 422 time=$7
pascal@4909 423 getattr($8)
pascal@4909 424 }
pascal@4909 425 /^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/ { uid=$3; gid=$5 }
pascal@4909 426 /^[\t ]+SymLink -> / { link=$3; attr="l"substr(attr, 2) }
pascal@4909 427 /^---/ { display() }
pascal@4909 428 '
pascal@4909 429 # Desktop/up -> ..
pascal@4909 430 # lrwxrwxrwx 0/0 0 0 ****** -lhd- 0000 2009-05-03 16:59:03 [2]
pascal@5209 431 in_exts $LHA_EXTS && lha v -q -v "$archive" | awk0 '
pascal@4909 432 {
pascal@4909 433 if ($4 == "") { getlink($0); next }
pascal@4909 434 attr=$1
pascal@4909 435 getid($2)
pascal@4909 436 size=$4
pascal@4909 437 date=$8
pascal@4909 438 time=$9
pascal@4909 439 display()
pascal@4909 440 }'
pascal@3194 441 # ------ ------ ------ ----- ---- ---- ----
pascal@3194 442 # LZO1X-1 10057 5675 56.4% 2005-07-25 16:26 path/file
pascal@5209 443 in_exts $LZO_EXTS && lzop -Plv "$archive" | awku '
pascal@4909 444 /-[0-9]+-/ {
pascal@4909 445 size=$2
pascal@4909 446 date=$5
pascal@4909 447 time=$6
pascal@4909 448 show($6 " ")
pascal@4909 449 }'
pascal@4909 450 exit 0
pascal@4909 451 ;;
pascal@4909 452 -a|-n) # add to archive / new: create new archive
pascal@4909 453 update $opt "$@"
pascal@2877 454 while read exe args exts; do
pascal@5209 455 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@4909 456 [ "$opt$exe" = "-nzip" ] && args="-r"
pascal@5209 457 # only add the file's basename, not the full path
pascal@5209 458 while [ "$1" ]; do
pascal@5209 459 cd "$(dirname "$1")"
pascal@5209 460 $exe $args "$archive" "$(basename "$1")"
pascal@5209 461 status=$?
pascal@5209 462 shift
pascal@5209 463 done
pascal@5209 464 exit $status
pascal@2877 465 done <<EOT
pascal@2877 466 zip -g\ -r $ZIP_EXTS
pascal@2877 467 rar a $RAR_EXTS
pascal@4909 468 arj a $ARJ_EXTS
pascal@4909 469 7zr a\ -ms=off $_7Z_EXTS
pascal@2877 470 lha a $LHA_EXTS
pascal@2877 471 EOT
pascal@4909 472 ;;
pascal@4909 473 -r) # remove from archive passed files
pascal@4909 474 update $opt "$@"
pascal@2877 475 while read exe args exts; do
pascal@5209 476 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@5209 477 $exe $args "$archive" "$@" | grep -q E_NOTIMPL && {
pascal@5209 478 echo -e "7z cannot delete files from solid archive." >&2
pascal@5209 479 exit $UNSUPPORTED
pascal@5209 480 }
pascal@5209 481 exit 0
pascal@2877 482 done <<EOT
pascal@2877 483 zip -d $ZIP_EXTS
pascal@2877 484 rar d $RAR_EXTS
pascal@4909 485 arj d $ARJ_EXTS
pascal@2877 486 lha d $LHA_EXTS
pascal@4909 487 7zr d $_7Z_EXTS
pascal@2877 488 EOT
pascal@4909 489 ;;
pascal@4909 490 -e) # extract from archive passed files
pascal@4909 491 while read arch exts; do
pascal@5209 492 in_exts $exts || continue
pascal@5209 493 $DECOMPRESS "$archive" | $arch "$@"
pascal@5209 494 exit $?
pascal@2877 495 done <<EOT
pascal@4954 496 tar\ -xf\ - $TAR_EXTS $IPK_EXTS $XZ_EXTS $LRZIP_EXTS
pascal@4954 497 cpio\ -idm $CPIO_EXTS $CPIOXZ_EXTS $CPIOLRZIP_EXTS $RPM_EXTS $TAZPKG_EXTS
pascal@2877 498 EOT
pascal@4909 499 while read exe x p exts; do
pascal@5209 500 in_exts $exts && [ "$(which $exe)" ] || continue
pascal@5209 501 [ "$x" != "N/A" ] && $exe $x "$archive" "$@"
pascal@5209 502 status=$?
pascal@5209 503 if [ "$p" != "N/A" -a $status -ne 0 ]; then
pascal@5209 504 echo Password protected, opening an x-term...
pascal@5209 505 $XTERM_PROG -e $exe $p "$archive" "$@"
pascal@5209 506 exit $?
pascal@5209 507 fi
pascal@5209 508 exit $status
pascal@2877 509 done <<EOT
pascal@4909 510 unzip -n N/A $ZIP_EXTS
pascal@4909 511 dpkg-deb -X N/A $DEB_EXTS
pascal@4909 512 lha x N/A $LHA_EXTS
pascal@4909 513 lzop -x N/A $LZO_EXTS
pascal@4909 514 rar x\ -o-\ -p- x\ -o- $RAR_EXTS
pascal@4909 515 arj x\ -y x\ -y\ -g? $ARJ_EXTS
pascal@4909 516 7zr x\ -y\ -p- x\ -y $_7Z_EXTS
pascal@4909 517 unace N/A x\ -o\ -y ace
pascal@4909 518 cabextract -q N/A cab
pascal@2877 519 EOT
pascal@4909 520 loop_fs $opt "$@"
pascal@4909 521 ;;
pascal@4909 522 *) cat <<EOT
pascal@4909 523 error, option $opt not supported
pascal@4909 524 use one of these:
pascal@4909 525 -i #info
pascal@4909 526 -o archive #open
pascal@4909 527 -a archive files #add
pascal@4909 528 -n archive file #new
pascal@4909 529 -r archive files #remove
pascal@4909 530 -e archive files #extract
pascal@2877 531 EOT
pascal@688 532 esac
pascal@4909 533 exit $UNSUPPORTED