wok-4.x annotate xarchive/stuff/slitaz-wrap.sh @ rev 688

xarchive*: use slitaz-wrap.sh, remove from System tools
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Apr 25 21:50:15 2008 +0000 (2008-04-25)
parents
children cee7a7cd19eb
rev   line source
pascal@688 1 #!/bin/sh
pascal@688 2 # slitaz-wrap.sh - sh slitaz core wrapper for xarchive frontend
pascal@688 3 # Copyright (C) 2005 Lee Bigelow <ligelowbee@yahoo.com>
pascal@688 4 # Copyright (C) 2008 Pascal Bellard <pascal.bellard@slitaz.org>
pascal@688 5 #
pascal@688 6 # This program is free software; you can redistribute it and/or modify
pascal@688 7 # it under the terms of the GNU General Public License as published by
pascal@688 8 # the Free Software Foundation; either version 2 of the License, or
pascal@688 9 # (at your option) any later version.
pascal@688 10 #
pascal@688 11 # This program is distributed in the hope that it will be useful,
pascal@688 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@688 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@688 14 # GNU General Public License for more details.
pascal@688 15 #
pascal@688 16 # You should have received a copy of the GNU General Public License
pascal@688 17 # along with this program; if not, write to the Free Software
pascal@688 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
pascal@688 19
pascal@688 20 # set up exit status variables
pascal@688 21 E_UNSUPPORTED=65
pascal@688 22
pascal@688 23 # Supported file extentions for tar
pascal@688 24 TAR_EXTS="tar"
pascal@688 25 GZIP_EXTS="tar.gz tgz"
pascal@688 26 LZMA_EXTS="tar.lz tar.lzma tlz"
pascal@688 27 BZIP2_EXTS="tar.bz tbz tar.bz2 tbz2"
pascal@688 28 COMPRESS_EXTS="tar.z tar.Z"
pascal@688 29 CPIO_EXTS="cpio"
pascal@688 30 CPIOGZ_EXTS="cpio.gz"
pascal@688 31 ZIP_EXTS="zip cbz jar"
pascal@688 32 RPM_EXTS="rpm"
pascal@688 33 DEB_EXTS="deb"
pascal@688 34 TAZPKG_EXTS="tazpkg"
pascal@688 35
pascal@688 36 # Setup awk program
pascal@688 37 AWK_PROGS="mawk gawk awk"
pascal@688 38 AWK_PROG=""
pascal@688 39 for awkprog in $AWK_PROGS; do
pascal@688 40 if [ "$(which $awkprog)" ]; then
pascal@688 41 AWK_PROG="$awkprog"
pascal@688 42 break
pascal@688 43 fi
pascal@688 44 done
pascal@688 45
pascal@688 46 # setup variables opt and archive.
pascal@688 47 # the shifting will leave the files passed as
pascal@688 48 # all the remaining args "$@"
pascal@688 49 opt="$1"
pascal@688 50 test -z $1 || shift 1
pascal@688 51 archive="$1"
pascal@688 52 test -z $1 || shift 1
pascal@688 53
pascal@688 54 # set up compression variables for our compression functions.
pascal@688 55 # translate archive name to lower case for pattern matching.
pascal@688 56 # use compressor -c option to output to stdout and direct it where we want
pascal@688 57 lc_archive="$(echo $archive|tr [:upper:] [:lower:])"
pascal@688 58 DECOMPRESS="cat"
pascal@688 59 COMPRESS="cat"
pascal@688 60 COMPRESS2=""
pascal@688 61 TAR_COMPRESS_OPT=""
pascal@688 62 for ext in $GZIP_EXTS $CPIOGZ_EXTS; do
pascal@688 63 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 64 DECOMPRESS="gzip -dc"
pascal@688 65 COMPRESS="gzip -c"
pascal@688 66 TAR_COMPRESS_OPT="z"
pascal@688 67 fi
pascal@688 68 done
pascal@688 69 for ext in $BZIP2_EXTS; do
pascal@688 70 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 71 DECOMPRESS="bzip2 -dc"
pascal@688 72 COMPRESS="bzip2 -c"
pascal@688 73 TAR_COMPRESS_OPT="j"
pascal@688 74 fi
pascal@688 75 done
pascal@688 76 for ext in $LZMA_EXTS; do
pascal@688 77 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 78 DECOMPRESS="unlzma -c"
pascal@688 79 COMPRESS="lzma e"
pascal@688 80 COMPRESS2=" -so"
pascal@688 81 TAR_COMPRESS_OPT="a"
pascal@688 82 fi
pascal@688 83 done
pascal@688 84 for ext in $COMPRESS_EXTS; do
pascal@688 85 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 86 DECOMPRESS="uncompress -dc"
pascal@688 87 COMPRESS="compress -c"
pascal@688 88 TAR_COMPRESS_OPT="--use-compress-prog=compress"
pascal@688 89 fi
pascal@688 90 done
pascal@688 91
pascal@688 92 # Compression functions
pascal@688 93 decompress_func()
pascal@688 94 {
pascal@688 95 if [ "$DECOMPRESS" ]; then
pascal@688 96 tmpname="$(mktemp -t tartmp.XXXXXX)"
pascal@688 97 if [ -f "$archive" ]; then
pascal@688 98 $DECOMPRESS "$archive" > "$tmpname"
pascal@688 99 fi
pascal@688 100 # store old name for when we recompress
pascal@688 101 oldarch="$archive"
pascal@688 102 # change working file to decompressed tmp
pascal@688 103 archive="$tmpname"
pascal@688 104 fi
pascal@688 105 }
pascal@688 106
pascal@688 107 compress_func()
pascal@688 108 {
pascal@688 109 if [ "$COMPRESS" ] && [ "$oldarch" ]; then
pascal@688 110 [ -f "$oldarch" ] && rm "$oldarch"
pascal@688 111 if $COMPRESS "$archive" $COMPRESS2 > "$oldarch"; then
pascal@688 112 rm "$archive"
pascal@688 113 fi
pascal@688 114 fi
pascal@688 115 }
pascal@688 116
pascal@688 117 not_busybox()
pascal@688 118 {
pascal@688 119 case "$(readlink $(which $1))" in
pascal@688 120 *busybox*) return 1;;
pascal@688 121 esac
pascal@688 122 return 0
pascal@688 123 }
pascal@688 124
pascal@688 125 # the option switches
pascal@688 126 case "$opt" in
pascal@688 127 -i) # info: output supported extentions for progs that exist
pascal@688 128 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS \
pascal@688 129 $CPIO_EXTS $CPIOGZ_EXTS $ZIP_EXTS $DEB_EXTS $RPM_EXTS \
pascal@688 130 $TAZPKG_EXTS ; do
pascal@688 131 printf "%s;" $ext
pascal@688 132 if [ "$ext" = "zip" -a ! "$(which zip)" ]; then
pascal@688 133 echo warning: zip not found, extract only >/dev/stderr
pascal@688 134 fi
pascal@688 135 if [ "$ext" = "tar" ] && ! not_busybox tar; then
pascal@688 136 echo warning: gnu/tar not found, extract only >/dev/stderr
pascal@688 137 fi
pascal@688 138 done
pascal@688 139 printf "\n"
pascal@688 140 exit
pascal@688 141 ;;
pascal@688 142
pascal@688 143 -o) # open: mangle output of tar cmd for xarchive
pascal@688 144 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS; do
pascal@688 145 # format of tar output:
pascal@688 146 # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link
pascal@688 147 # -rw-r--r-- USR/GRP 6622 2005-04-22 12:29:14 file
pascal@688 148 # 1 2 3 4 5 6
pascal@688 149 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 150 tar -tv${TAR_COMPRESS_OPT}f "$archive" | $AWK_PROG '
pascal@688 151 {
pascal@688 152 attr=$1
pascal@688 153 split($2,ids,"/") #split up the 2nd field to get uid/gid
pascal@688 154 uid=ids[1]
pascal@688 155 gid=ids[2]
pascal@688 156 size=$3
pascal@688 157 date=$4
pascal@688 158 time=$5
pascal@688 159
pascal@688 160 #this method works with filenames that start with a space (evil!)
pascal@688 161 #split line a time and a space
pascal@688 162 split($0,linesplit, $5 " ")
pascal@688 163 #then split the second item (name&link) at the space arrow space
pascal@688 164 split(linesplit[2], nlsplit, " -> ")
pascal@688 165
pascal@688 166 name=nlsplit[1]
pascal@688 167 link=nlsplit[2]
pascal@688 168
pascal@688 169 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 170
pascal@688 171 printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 172 }'
pascal@688 173 exit
pascal@688 174 fi
pascal@688 175 done
pascal@688 176
pascal@688 177 for ext in $CPIO_EXTS $CPIOGZ_EXTS; do
pascal@688 178 # format of cpio output:
pascal@688 179 # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link
pascal@688 180 # -rw-r--r-- USR/GRP 6622 2005-04-22 12:29:14 file
pascal@688 181 # 1 2 3 4 5 6
pascal@688 182 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 183 $DECOMPRESS "$archive" | cpio -tv | $AWK_PROG '
pascal@688 184 {
pascal@688 185 attr=$1
pascal@688 186 split($2,ids,"/") #split up the 2nd field to get uid/gid
pascal@688 187 uid=ids[1]
pascal@688 188 gid=ids[2]
pascal@688 189 size=$3
pascal@688 190 date=$4
pascal@688 191 time=$5
pascal@688 192
pascal@688 193 #this method works with filenames that start with a space (evil!)
pascal@688 194 #split line a time and a space
pascal@688 195 split($0,linesplit, $5 " ")
pascal@688 196 #then split the second item (name&link) at the space arrow space
pascal@688 197 split(linesplit[2], nlsplit, " -> ")
pascal@688 198
pascal@688 199 name=nlsplit[1]
pascal@688 200 link=nlsplit[2]
pascal@688 201
pascal@688 202 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 203
pascal@688 204 if (name != "" && uid != "blocks") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 205 }'
pascal@688 206 exit
pascal@688 207 fi
pascal@688 208 done
pascal@688 209
pascal@688 210 for ext in $ZIP_EXTS; do
pascal@688 211 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 212 if which zipinfo; then
pascal@688 213 # format of zipinfo -T -s-h- output:
pascal@688 214 # -rw-r--r-- 2.3 unx 11512 tx defN YYYYMMDD.HHMMSS file
pascal@688 215 # 1 2 3 4 5 6 7 8
pascal@688 216 zipinfo -T -s-h-t "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
pascal@688 217 {
pascal@688 218 attr=$1; size=$4
pascal@688 219
pascal@688 220 year=substr($7,1,4)
pascal@688 221 month=substr($7,5,2)
pascal@688 222 day=substr($7,7,2)
pascal@688 223 date=year "-" month "-" day
pascal@688 224
pascal@688 225 hours=substr($7,10,2)
pascal@688 226 mins=substr($7,12,2)
pascal@688 227 secs=substr($7,14,2)
pascal@688 228 time=hours ":" mins ":" secs
pascal@688 229
pascal@688 230 uid=uuid; gid=uuid; link="-"
pascal@688 231 #split line at the time and a space, second item is our name
pascal@688 232 split($0, linesplit, ($7 " "))
pascal@688 233 name=linesplit[2]
pascal@688 234 printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 235 }'
pascal@688 236 exit
pascal@688 237 else
pascal@688 238 # format of unzip -l output:
pascal@688 239 # 6622 2005-04-22 12:29:14 file
pascal@688 240 # 1 2 3 4
pascal@688 241 unzip -l "$archive" | $AWK_PROG -v uuid=$(id -u -n) '
pascal@688 242 BEGIN { n = 0}
pascal@688 243 {
pascal@688 244 n=n+1
pascal@688 245 attr=""
pascal@688 246 uid=uuid; gid=uuid
pascal@688 247 size=$1
pascal@688 248 date=$2
pascal@688 249 time=$3
pascal@688 250
pascal@688 251 #this method works with filenames that start with a space (evil!)
pascal@688 252 #split line a time and a space
pascal@688 253 split($0,linesplit, $3 " ")
pascal@688 254 #then split the second item (name&link) at the space arrow space
pascal@688 255 split(linesplit[2], nlsplit, " -> ")
pascal@688 256
pascal@688 257 name=nlsplit[1]
pascal@688 258 link=nlsplit[2]
pascal@688 259
pascal@688 260 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 261
pascal@688 262 if (name != "" && n > 3) printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 263 }'
pascal@688 264 exit
pascal@688 265 fi
pascal@688 266 fi
pascal@688 267 done
pascal@688 268
pascal@688 269 for ext in $RPM_EXTS; do
pascal@688 270 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 271 rpm2cpio "$archive" | cpio -tv | $AWK_PROG '
pascal@688 272 {
pascal@688 273 attr=$1
pascal@688 274 split($2,ids,"/") #split up the 2nd field to get uid/gid
pascal@688 275 uid=ids[1]
pascal@688 276 gid=ids[2]
pascal@688 277 size=$3
pascal@688 278 date=$4
pascal@688 279 time=$5
pascal@688 280
pascal@688 281 #this method works with filenames that start with a space (evil!)
pascal@688 282 #split line a time and a space
pascal@688 283 split($0,linesplit, $5 " ")
pascal@688 284 #then split the second item (name&link) at the space arrow space
pascal@688 285 split(linesplit[2], nlsplit, " -> ")
pascal@688 286
pascal@688 287 name=substr(nlsplit[1],2)
pascal@688 288 link=nlsplit[2]
pascal@688 289
pascal@688 290 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 291
pascal@688 292 if (name != "" && uid != "blocks") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 293 }'
pascal@688 294 exit
pascal@688 295 fi
pascal@688 296 done
pascal@688 297
pascal@688 298 for ext in $DEB_EXTS; do
pascal@688 299 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 300 dpkg-deb -c "$archive" | $AWK_PROG '
pascal@688 301 {
pascal@688 302 attr=$1
pascal@688 303 split($2,ids,"/") #split up the 2nd field to get uid/gid
pascal@688 304 uid=ids[1]
pascal@688 305 gid=ids[2]
pascal@688 306 size=$3
pascal@688 307 date=$4
pascal@688 308 time=$5
pascal@688 309
pascal@688 310 #this method works with filenames that start with a space (evil!)
pascal@688 311 #split line a time and a space
pascal@688 312 split($0,linesplit, $5 " ")
pascal@688 313 #then split the second item (name&link) at the space arrow space
pascal@688 314 split(linesplit[2], nlsplit, " -> ")
pascal@688 315
pascal@688 316 name=substr(nlsplit[1],2)
pascal@688 317 link=nlsplit[2]
pascal@688 318
pascal@688 319 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 320
pascal@688 321 printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 322 }'
pascal@688 323 exit
pascal@688 324 fi
pascal@688 325 done
pascal@688 326
pascal@688 327 for ext in $TAZPKG_EXTS; do
pascal@688 328 # format of cpio output:
pascal@688 329 # lrwxrwxrwx USR/GRP 0 2005-05-12 00:32:03 file -> /path/to/link
pascal@688 330 # -rw-r--r-- USR/GRP 6622 2005-04-22 12:29:14 file
pascal@688 331 # 1 2 3 4 5 6
pascal@688 332 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 333 tmpcpio="$(mktemp -d -t cpiotmp.XXXXXX)"
pascal@688 334 here="$(pwd)"
pascal@688 335 cd $tmpcpio
pascal@688 336 cpio -i fs.cpio.gz > /dev/null < "$archive"
pascal@688 337 zcat fs.cpio.gz | cpio -tv | $AWK_PROG '
pascal@688 338 {
pascal@688 339 attr=$1
pascal@688 340 split($2,ids,"/") #split up the 2nd field to get uid/gid
pascal@688 341 uid=ids[1]
pascal@688 342 gid=ids[2]
pascal@688 343 size=$3
pascal@688 344 date=$4
pascal@688 345 time=$5
pascal@688 346
pascal@688 347 #this method works with filenames that start with a space (evil!)
pascal@688 348 #split line a time and a space
pascal@688 349 split($0,linesplit, $5 " ")
pascal@688 350 #then split the second item (name&link) at the space arrow space
pascal@688 351 split(linesplit[2], nlsplit, " -> ")
pascal@688 352
pascal@688 353 name=substr(nlsplit[1],3)
pascal@688 354 link=nlsplit[2]
pascal@688 355
pascal@688 356 if (! link) {link="-"} #if there was no link set it to a dash
pascal@688 357
pascal@688 358 if (name != "" && uid != "blocks") printf "%s;%s;%s;%s;%s;%s;%s;%s\n",name,size,attr,uid,gid,date,time,link
pascal@688 359 }'
pascal@688 360 cd $here
pascal@688 361 rm -rf $tmpcpio
pascal@688 362 exit
pascal@688 363 fi
pascal@688 364 done
pascal@688 365 exit $E_UNSUPPORTED
pascal@688 366 ;;
pascal@688 367
pascal@688 368 -a) # add to archive passed files
pascal@688 369 not_busybox tar && \
pascal@688 370 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS; do
pascal@688 371 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 372 # we only want to add the file's basename, not
pascal@688 373 # the full path so...
pascal@688 374 decompress_func
pascal@688 375 while [ "$1" ]; do
pascal@688 376 cd "$(dirname "$1")"
pascal@688 377 tar -rf "$archive" "$(basename "$1")"
pascal@688 378 wrapper_status=$?
pascal@688 379 shift 1
pascal@688 380 done
pascal@688 381 compress_func
pascal@688 382 exit $wrapper_status
pascal@688 383 fi
pascal@688 384 done
pascal@688 385 which zip >/dev/null && for ext in $ZIP_EXTS; do
pascal@688 386 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 387 # we only want to add the file's basename, not
pascal@688 388 # the full path so...
pascal@688 389 while [ "$1" ]; do
pascal@688 390 cd "$(dirname "$1")"
pascal@688 391 zip -g -r "$archive" "$(basename "$1")"
pascal@688 392 wrapper_status=$?
pascal@688 393 shift 1
pascal@688 394 done
pascal@688 395 exit $wrapper_status
pascal@688 396 fi
pascal@688 397 done
pascal@688 398 exit $E_UNSUPPORTED
pascal@688 399 ;;
pascal@688 400
pascal@688 401 -n) # new: create new archive with passed files
pascal@688 402 not_busybox tar && \
pascal@688 403 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS; do
pascal@688 404 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 405 # create will only be passed the first file, the
pascal@688 406 # rest will be "added" to the new archive
pascal@688 407 decompress_func
pascal@688 408 cd "$(dirname "$1")"
pascal@688 409 tar -cf "$archive" "$(basename "$1")"
pascal@688 410 wrapper_status=$?
pascal@688 411 compress_func
pascal@688 412 exit $wrapper_status
pascal@688 413 fi
pascal@688 414 done
pascal@688 415 which zip >/dev/null && for ext in $ZIP_EXTS; do
pascal@688 416 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 417 # create will only be passed the first file, the
pascal@688 418 # rest will be "added" to the new archive
pascal@688 419 cd "$(dirname "$1")"
pascal@688 420 zip -r "$archive" "$(basename "$1")"
pascal@688 421 fi
pascal@688 422 done
pascal@688 423 exit $E_UNSUPPORTED
pascal@688 424 ;;
pascal@688 425
pascal@688 426 -r) # remove: from archive passed files
pascal@688 427 not_busybox tar && \
pascal@688 428 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS; do
pascal@688 429 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 430 decompress_func
pascal@688 431 tar --delete -f "$archive" "$@"
pascal@688 432 wrapper_status=$?
pascal@688 433 compress_func
pascal@688 434 exit $wrapper_status
pascal@688 435 fi
pascal@688 436 done
pascal@688 437 which zip >/dev/null && for ext in $ZIP_EXTS; do
pascal@688 438 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 439 zip -d "$archive" "$@"
pascal@688 440 fi
pascal@688 441 done
pascal@688 442 exit $E_UNSUPPORTED
pascal@688 443 ;;
pascal@688 444
pascal@688 445 -e) # extract: from archive passed files
pascal@688 446 for ext in $TAR_EXTS $GZIP_EXTS $BZIP2_EXTS $COMPRESS_EXTS $LZMA_EXTS; do
pascal@688 447 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 448 # xarchive will put is the right extract dir
pascal@688 449 # so we just have to extract.
pascal@688 450 tar -x${TAR_COMPRESS_OPT}f "$archive" "$@"
pascal@688 451 exit $?
pascal@688 452 fi
pascal@688 453 done
pascal@688 454 for ext in $CPIO_EXTS $CPIOGZ_EXTS; do
pascal@688 455 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 456 if [ -n "$1" ]; then
pascal@688 457 while [ "$1" ]; do
pascal@688 458 $DECOMPRESS "$archive" | cpio -idv "$1"
pascal@688 459 shift 1
pascal@688 460 done
pascal@688 461 else
pascal@688 462 $DECOMPRESS "$archive" | cpio -idv
pascal@688 463 fi
pascal@688 464 exit $?
pascal@688 465 fi
pascal@688 466 done
pascal@688 467 for ext in $ZIP_EXTS; do
pascal@688 468 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 469 # xarchive will put is the right extract dir
pascal@688 470 # so we just have to extract.
pascal@688 471 unzip -n "$archive" "$@"
pascal@688 472 exit $?
pascal@688 473 fi
pascal@688 474 done
pascal@688 475 for ext in $RPM_EXTS; do
pascal@688 476 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 477 if [ -n "$1" ]; then
pascal@688 478 while [ "$1" ]; do
pascal@688 479 rpm2cpio "$archive" | cpio -idv "$1"
pascal@688 480 shift 1
pascal@688 481 done
pascal@688 482 else
pascal@688 483 rpm2cpio "$archive" | cpio -idv
pascal@688 484 fi
pascal@688 485 exit $?
pascal@688 486 fi
pascal@688 487 done
pascal@688 488
pascal@688 489 for ext in $DEB_EXTS; do
pascal@688 490 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 491 dpkg-deb -X "$archive" "$@"
pascal@688 492 exit $?
pascal@688 493 fi
pascal@688 494 done
pascal@688 495 for ext in $TAZPKG_EXTS; do
pascal@688 496 if [ $(expr "$lc_archive" : ".*\."$ext"$") -gt 0 ]; then
pascal@688 497 tmpcpio="$(mktemp -d -t cpiotmp.XXXXXX)"
pascal@688 498 here="$(pwd)"
pascal@688 499 cd $tmpcpio
pascal@688 500 cpio -i < "$archive" > /dev/null
pascal@688 501 zcat fs.cpio.gz | cpio -id > /dev/null
pascal@688 502 status=$?
pascal@688 503 if [ -n "$1" ]; then
pascal@688 504 while [ "$1" ]; do
pascal@688 505 dir=$(dirname "$here/$1")
pascal@688 506 mkdir -p "$dir" 2> /dev/null
pascal@688 507 mv "fs/$1" "$dir" 2> /dev/null
pascal@688 508 done
pascal@688 509 else
pascal@688 510 mv fs/* fs/.* $here 2> /dev/null
pascal@688 511 fi
pascal@688 512 cd $here
pascal@688 513 rm -rf $tmpcpio
pascal@688 514 exit $status
pascal@688 515 fi
pascal@688 516 done
pascal@688 517 exit $E_UNSUPPORTED
pascal@688 518 ;;
pascal@688 519
pascal@688 520 *) echo "error, option $opt not supported"
pascal@688 521 echo "use one of these:"
pascal@688 522 echo "-i #info"
pascal@688 523 echo "-o archive #open"
pascal@688 524 echo "-a archive files #add"
pascal@688 525 echo "-n archive file #new"
pascal@688 526 echo "-r archive files #remove"
pascal@688 527 echo "-e archive files #extract"
pascal@688 528 exit
pascal@688 529 esac