Moin Ingo!
Ingo Saitz schrieb am Sonntag, den 19. März 2000:

> ar x /pfad/zu/squid.deb data.tar.gz
> tar xzvf data.tar.gz etc/squid.conf

unp -u /pfad/zu/squid.deb

mfG
Eduard.
-- 
=====================================================================
Eduard Bloch <[EMAIL PROTECTED]>; HP: http://eduard.bloch.com/edecosi
0xEDF008C5(gpg): E6EB 98E2 B885 8FF0 6C04  5C1D E106 481E EDF0 08C5
#! /usr/bin/perl
# unp, Version 0.0.2
# -----------------------------------------------------------------------
# Originaly written by André Karwath, 1997
# [EMAIL PROTECTED]
# http://www.aka-online.de
#
# Modified by Eduard Bloch <[EMAIL PROTECTED]>, 2000
# http://www.eduard.bloch.com/edecosi/
#
# "unp" runs the correct unpack program depending on the file extension
# of the given parameter.
# 
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# -----------------------------------------------------------------------
# If you make changes to this script, please feel free to forward the new 
# version to [EMAIL PROTECTED] or [EMAIL PROTECTED]
# -----------------------------------------------------------------------
# You need some archiver and compressor programs for extracting:
# GNU tar, gzip, bzip2, ar, rpm, unrar or rar, unarj, unzip and lha

$not_found=": not found\n";
$not_read=": not readable\n";
$unsup=": unsupported format\n";
$usage="
usage: unp file [file]...
file: compressed file(s) to expand

Use -- to pass arguments to external programs, eg. some tar options:
unp fastgl.tgz xmnt.tgz -- -C /tmp

Special option:
  -u  extract data.tar.gz after each operation (for .deb-packages),
            then extract control.tar.gz in control/<filename>/

currently supported extensions and formats are
tar, gz, Z, tar.gz/tgz, tar.bz2, bz2, ar/deb, RPM, shar, rar, arj, zip and LHa
";
$tryfile=" - unknown extension, checking with \"file\"\n";
$testbz2=" contains bzip2-compressed data, determining data type...\n";
$testgz=" contains gzip-compressed data, determining data type...\n";
$skip=" exists allready, skipping...\n";
$is_dir=" is a directory, skipping...\n";

# localisation part (only german at the moment):
if($ENV{'LANG'}=~ "^de"){
$not_found=" wurde nicht gefunden!\n";
$not_read=" konnte nicht gelesen werden!\n";
$unsup=": dieses Format wird nicht unterstützt!\n";
$usage="
Aufruf: unp Datei [Datei] ...
Datei: eine oder mehrere komprimierte Datei(en) zum entpacken

Optionen:
  -u  Nach jeder Operation data.tar.gz entpacken (z.B. für .deb-Pakete),
            sowie control.tar.gz nach control/<Achiv-Name>/

Optionen nach -- werden an externe Programme übergeben, z.B. tar-Optionen:
unp fastgl.tgz xmnt.tgz -- -C /tmp

Derzeit unterstützte Erweiterungen und Formate:
tar, gz, Z, tar.gz/tgz, tar.bz2, bz2, ar/deb, RPM, shar, rar, arj, zip und LHa
";
$tryfile=" - Endung unbekannt, überprüfe mit \"file\"...
";
$testbz2=" enthält bzip2-komprimierte Daten, überprüfe den Datentyp...\n";
$testgz=" enthält gzip-komprimierte Daten, überprüfe den Datentyp...\n";
$skip=" existiert bereits, überspringe...\n";
$is_dir=" ist ein Verzeichnis\n";
}

&print_usage if ($#ARGV<0);
        
arglabel: foreach $arg (@ARGV){
        if("$arg" eq "-u"){$dataunp=1 ; next arglabel};
        if("$arg" eq "--"){$argvalue=1; next arglabel};
        if($argvalue){
                $ARGS="$ARGS $arg";
        }else{
                push(@FILES,$arg);
        }
}

LOOP: foreach $file (@FILES) {
  if (!-e $file) {
     print $file.$not_found;
     next LOOP;
  }

  if (!-r $file) {
     print $file.$not_read;
     next LOOP;
  }
  
        if (-d $file) {
     print $file.$is_dir;
     next LOOP;
  }
        undef $command;

  # not just gunzip, create new file with uncompressed data in the current
        # directory, same for bz2
        if ($file =~ /([^\/]*)\.(gz|Z)$/i) {if (-f $1){ print $1.$skip; next 
LOOP;}; $command="gunzip < \"$file\" > $1"; }
  if ($file =~ /([^\/]*)\.(bz2$)/i) {if (-f $1){ print $1.$skip; next LOOP;}; 
$command="bunzip2 < \"$file\" > $1"; }
        
        # check also for _tar, because of broken filenames
  if ($file =~ /(\.|_)tar$/i) { $command="tar -xvf \"$file\" $ARGS"; }
        if ($file =~ /(\.|_)rpm$/i) { $command="rpm2cpio < \"$file\" | cpio -i 
-d       --verbose $ARGS";}
        if ($file =~ /(\.|_)tar\.gz$/i) { $command="tar -xvzf \"$file\" $ARGS"; 
}
  if ($file =~ /(\.|_)tar\.bz2$/i) { $command="bunzip2 -c \"$file\" | tar -xvf 
- $ARGS"; }
        
        if ($file =~ /\.tgz$/i) { $command="tar -xvzf \"$file\" $ARGS"; }
  if ($file =~ /\.rar$/i) { $command="rar x \"$file\" $ARGS || unrar x 
\"$file\" $ARGS"; }
  if ($file =~ /\.(ar|deb)$/i) { $command="ar xv \"$file\" $ARGS"; }
  if ($file =~ /\.l(ha|zh)$/i) { $command="lha x $ARGS \"$file\""; }
  if ($file =~ /\.arj$/i) { $command="unarj x \"$file\""; }
  if ($file =~ /\.zip$/i) { $command="unzip \"$file\" $ARGS"; }
        
        # assume that exe is just an arcive with executable header and try
        # some programs
        if ($file =~ /\.exe$/i) { $command="unzip \"$file\" || unrar x 
\"$file\" || rar x \"$file\" || unarj x \"$file\" || lha x \"$file\"";}
        
  if ($command eq "") {
                print $file.$tryfile;
                $filestr=`file \"$file\"`;
                        if ($filestr =~ /(gzip)/gi){
                                print $file.$testgz;
                                $file=~/([^\/]*)$/i; $target="$1.unp";
                                if (-f $target){ print $target.$skip; next 
LOOP;}
                                $command=(`zcat \"$file\" | file -`=~/tar/i) ? 
"zcat \"$file\" | tar -xvf - $ARGS" : "zcat < \"$file\" > $target";
                        };
                        
                        if ($filestr =~ /(bzip2)/gi){
                                print $file.$testbz2; 
                                $file=~/([^\/]*)$/i; $target="$1.unp";
                                if (-f $target){ print $target.$skip; next 
LOOP;}
                                $command=(`bzcat \"$file\" | file -`=~/tar/i) ? 
"bzcat \"$file\" | tar -xvf - $ARGS" : "bzcat < \"$file\" > $target";
                        };
                        
                        if ($filestr =~ /RAR.*archive/i) { $command="rar x 
$ARGS \"$file\" || unrar x $ARGS \"$file\""; }
                        if ($filestr =~ /tar.*archive/i) { $command="tar -xvf 
\"$file\" $ARGS"; }
                        if ($filestr =~ /(Debian binary package|\ 
ar.*archive)/i) { $command="ar xv \"$file\" $ARGS"; }
                        if ($filestr =~ /LHa.*archive/i) { $command="lha x 
$ARGS \"$file\""; }
                        if ($filestr =~ /ARJ.*archive/i) { $command="unarj x 
\"$file\""; }
                        if ($filestr =~ /Zip.*archive/i) { $command="unzip 
\"$file\" $ARGS "; }
                        if ($filestr =~ /shell.*archive/i) { $command="unshar 
$ARGS \"$file\""; }
                        if ($filestr =~ /RPM/) { $command="rpm2cpio < \"$file\" 
| cpio -i -d    --verbose $ARGS";}
                        # RAR can also create executables
                        if ($filestr =~ /executable/i){$command="unrar x 
\"$file\" || rar x $file";}

                        # if still nothing could be found, print an error 
message
                        if ($command eq "") {
                                print $file.$unsup;
                                next LOOP;
                        }
  }

  system ($command);
        if ($dataunp){
         $file =~ /([^\/]*)\.deb$/i;
         system ("tar zxvf data.tar.gz; mkdir -p control/$1; cd control/$1; tar 
zxvf ../../control.tar.gz");
        }
}

die "\n";

# -----------------------------------------------------------------------------
sub print_usage {
  print $usage;
        die "\n";
}
# -----------------------------------------------------------------------------

Antwort per Email an