6a5cde9
diff -up perl-5.10.0/lib/Archive/Extract/t/01_Archive-Extract.t.BAD perl-5.10.0/lib/Archive/Extract/t/01_Archive-Extract.t
6a5cde9
--- perl-5.10.0/lib/Archive/Extract/t/01_Archive-Extract.t.BAD	2007-12-18 05:47:07.000000000 -0500
6a5cde9
+++ perl-5.10.0/lib/Archive/Extract/t/01_Archive-Extract.t	2008-03-08 14:55:53.000000000 -0500
6a5cde9
@@ -58,6 +58,7 @@ use_ok($Class);
6a5cde9
 $Archive::Extract::VERBOSE  = $Archive::Extract::VERBOSE = $Debug;
6a5cde9
 $Archive::Extract::WARN     = $Archive::Extract::WARN    = $Debug ? 1 : 0;
6a5cde9
 
6a5cde9
+
6a5cde9
 my $tmpl = {
6a5cde9
     ### plain files
6a5cde9
     'x.bz2' => {    programs    => [qw[bunzip2]],
6a5cde9
@@ -105,6 +106,11 @@ my $tmpl = {
6a5cde9
                     method      => 'is_zip',
6a5cde9
                     outfile     => 'a',
6a5cde9
                 },                
6a5cde9
+    'x.lzma' => {   programs    => [qw[unlzma]],
6a5cde9
+                    modules     => [qw[Compress::unLZMA]],
6a5cde9
+                    method      => 'is_lzma',
6a5cde9
+                    outfile     => 'a',
6a5cde9
+                },
6a5cde9
     ### with a directory
6a5cde9
     'y.tbz'     => {    programs    => [qw[bunzip2 tar]],
6a5cde9
                         modules     => [qw[Archive::Tar 
6a5cde9
@@ -291,7 +297,7 @@ for my $switch (0,1) {
6a5cde9
         ### where to extract to -- try both dir and file for gz files
6a5cde9
         ### XXX test me!
6a5cde9
         #my @outs = $ae->is_gz ? ($abs_path, $OutDir) : ($OutDir);
6a5cde9
-        my @outs = $ae->is_gz || $ae->is_bz2 || $ae->is_Z 
6a5cde9
+        my @outs = $ae->is_gz || $ae->is_bz2 || $ae->is_Z || $ae->is_lzma
6a5cde9
                         ? ($abs_path) 
6a5cde9
                         : ($OutDir);
6a5cde9
 
6a5cde9
diff -up perl-5.10.0/lib/Archive/Extract.pm.BAD perl-5.10.0/lib/Archive/Extract.pm
6a5cde9
--- perl-5.10.0/lib/Archive/Extract.pm.BAD	2007-12-18 05:47:07.000000000 -0500
6a5cde9
+++ perl-5.10.0/lib/Archive/Extract.pm	2008-03-08 14:55:15.000000000 -0500
6a5cde9
@@ -28,14 +28,15 @@ use constant ZIP            => 'zip';
6a5cde9
 use constant BZ2            => 'bz2';
6a5cde9
 use constant TBZ            => 'tbz';
6a5cde9
 use constant Z              => 'Z';
6a5cde9
+use constant LZMA           => 'lzma';
6a5cde9
 
6a5cde9
 use vars qw[$VERSION $PREFER_BIN $PROGRAMS $WARN $DEBUG];
6a5cde9
 
6a5cde9
-$VERSION        = '0.24';
6a5cde9
+$VERSION        = '0.26';
6a5cde9
 $PREFER_BIN     = 0;
6a5cde9
 $WARN           = 1;
6a5cde9
 $DEBUG          = 0;
6a5cde9
-my @Types       = ( TGZ, TAR, GZ, ZIP, BZ2, TBZ, Z ); # same as all constants
6a5cde9
+my @Types       = ( TGZ, TAR, GZ, ZIP, BZ2, TBZ, Z, LZMA ); # same as all constants
6a5cde9
 
6a5cde9
 local $Params::Check::VERBOSE = $Params::Check::VERBOSE = 1;
6a5cde9
 
6a5cde9
@@ -75,6 +76,7 @@ Archive::Extract - A generic archive ext
6a5cde9
     $ae->is_zip;    # is it a .zip file?
6a5cde9
     $ae->is_bz2;    # is it a .bz2 file?
6a5cde9
     $ae->is_tbz;    # is it a .tar.bz2 or .tbz file?
6a5cde9
+    $ae->is_lzma;   # is it a .lzma file?
6a5cde9
 
6a5cde9
     ### absolute path to the archive you provided ###
6a5cde9
     $ae->archive;
6a5cde9
@@ -84,13 +86,14 @@ Archive::Extract - A generic archive ext
6a5cde9
     $ae->bin_gzip    # path to /bin/gzip, if found
6a5cde9
     $ae->bin_unzip   # path to /bin/unzip, if found
6a5cde9
     $ae->bin_bunzip2 # path to /bin/bunzip2 if found
6a5cde9
+    $ae->bin_unlzma  # path to /bin/unlzma if found
6a5cde9
 
6a5cde9
 =head1 DESCRIPTION
6a5cde9
 
6a5cde9
 Archive::Extract is a generic archive extraction mechanism.
6a5cde9
 
6a5cde9
 It allows you to extract any archive file of the type .tar, .tar.gz,
6a5cde9
-.gz, .Z, tar.bz2, .tbz, .bz2 or .zip without having to worry how it 
6a5cde9
+.gz, .Z, tar.bz2, .tbz, .bz2, .zip or .lzma without having to worry how it 
6a5cde9
 does so, or use different interfaces for each type by using either 
6a5cde9
 perl modules, or commandline tools on your system.
6a5cde9
 
6a5cde9
@@ -101,7 +104,7 @@ See the C<HOW IT WORKS> section further 
6a5cde9
 
6a5cde9
 ### see what /bin/programs are available ###
6a5cde9
 $PROGRAMS = {};
6a5cde9
-for my $pgm (qw[tar unzip gzip bunzip2 uncompress]) {
6a5cde9
+for my $pgm (qw[tar unzip gzip bunzip2 uncompress unlzma]) {
6a5cde9
     $PROGRAMS->{$pgm} = can_run($pgm);
6a5cde9
 }
6a5cde9
 
6a5cde9
@@ -114,6 +117,7 @@ my $Mapping = {
6a5cde9
     is_tbz  => '_untar',
6a5cde9
     is_bz2  => '_bunzip2',
6a5cde9
     is_Z    => '_uncompress',
6a5cde9
+    is_lzma => '_unlzma',
6a5cde9
 };
6a5cde9
 
6a5cde9
 {
6a5cde9
@@ -183,6 +187,11 @@ Corresponds to a C<.bz2> suffix.
6a5cde9
 Bzip2 compressed tar file, as produced by, for exmample C</bin/tar -j>.
6a5cde9
 Corresponds to a C<.tbz> or C<.tar.bz2> suffix.
6a5cde9
 
6a5cde9
+=item lzma
6a5cde9
+
6a5cde9
+Lzma compressed file, as produced by C</bin/lzma>.
6a5cde9
+Corresponds to a C<.lzma> suffix.
6a5cde9
+
6a5cde9
 =back
6a5cde9
 
6a5cde9
 Returns a C<Archive::Extract> object on success, or false on failure.
6a5cde9
@@ -209,6 +218,7 @@ Returns a C<Archive::Extract> object on 
6a5cde9
                 $ar =~ /.+?\.(?:tbz2?|tar\.bz2?)$/i ? TBZ   :
6a5cde9
                 $ar =~ /.+?\.bz2$/i                 ? BZ2   :
6a5cde9
                 $ar =~ /.+?\.Z$/                    ? Z     :
6a5cde9
+                $ar =~ /.+?\.lzma$/                 ? LZMA  :
6a5cde9
                 '';
6a5cde9
 
6a5cde9
         }
6a5cde9
@@ -283,9 +293,9 @@ sub extract {
6a5cde9
     ### to.
6a5cde9
     my $dir;
6a5cde9
     {   ### a foo.gz file
6a5cde9
-        if( $self->is_gz or $self->is_bz2 or $self->is_Z) {
6a5cde9
+        if( $self->is_gz or $self->is_bz2 or $self->is_Z or $self->is_lzma ) {
6a5cde9
     
6a5cde9
-            my $cp = $self->archive; $cp =~ s/\.(?:gz|bz2?|Z)$//i;
6a5cde9
+            my $cp = $self->archive; $cp =~ s/\.(?:gz|bz2?|Z|lzma)$//i;
6a5cde9
         
6a5cde9
             ### to is a dir?
6a5cde9
             if ( -d $to ) {
6a5cde9
@@ -418,6 +428,11 @@ See the C<new()> method for details.
6a5cde9
 Returns true if the file is of type C<.zip>.
6a5cde9
 See the C<new()> method for details.
6a5cde9
 
6a5cde9
+=head2 $ae->is_lzma
6a5cde9
+
6a5cde9
+Returns true if the file is of type C<.lzma>.
6a5cde9
+See the C<new()> method for details.
6a5cde9
+
6a5cde9
 =cut
6a5cde9
 
6a5cde9
 ### quick check methods ###
6a5cde9
@@ -428,6 +443,7 @@ sub is_zip  { return $_[0]->type eq ZIP 
6a5cde9
 sub is_tbz  { return $_[0]->type eq TBZ }
6a5cde9
 sub is_bz2  { return $_[0]->type eq BZ2 }
6a5cde9
 sub is_Z    { return $_[0]->type eq Z   }
6a5cde9
+sub is_lzma { return $_[0]->type eq LZMA }
6a5cde9
 
6a5cde9
 =pod
6a5cde9
 
6a5cde9
@@ -443,6 +459,10 @@ Returns the full path to your gzip binar
6a5cde9
 
6a5cde9
 Returns the full path to your unzip binary, if found
6a5cde9
 
6a5cde9
+=head2 $ae->bin_unlzma
6a5cde9
+
6a5cde9
+Returns the full path to your unlzma binary, if found
6a5cde9
+
6a5cde9
 =cut
6a5cde9
 
6a5cde9
 ### paths to commandline tools ###
6a5cde9
@@ -452,6 +472,8 @@ sub bin_tar         { return $PROGRAMS->
6a5cde9
 sub bin_bunzip2     { return $PROGRAMS->{'bunzip2'} if $PROGRAMS->{'bunzip2'} }
6a5cde9
 sub bin_uncompress  { return $PROGRAMS->{'uncompress'} 
6a5cde9
                                                  if $PROGRAMS->{'uncompress'} }
6a5cde9
+sub bin_unlzma      { return $PROGRAMS->{'unlzma'}  if $PROGRAMS->{'unlzma'} }
6a5cde9
+
6a5cde9
 =head2 $bool = $ae->have_old_bunzip2
6a5cde9
 
6a5cde9
 Older versions of C</bin/bunzip2>, from before the C<bunzip2 1.0> release,
6a5cde9
@@ -478,8 +500,16 @@ sub have_old_bunzip2 {
6a5cde9
     ### $ echo $?
6a5cde9
     ### 1
6a5cde9
     ### HATEFUL!
6a5cde9
+    
6a5cde9
+    ### double hateful: bunzip2 --version also hangs if input is a pipe
6a5cde9
+    ### See #32370: Archive::Extract will hang if stdin is a pipe [+PATCH]
6a5cde9
+    ### So, we have to provide *another* argument which is a fake filename,
6a5cde9
+    ### just so it wont try to read from stdin to print it's version..
6a5cde9
+    ### *sigh*
6a5cde9
+    ### Even if the file exists, it won't clobber or change it.
6a5cde9
     my $buffer;
6a5cde9
-    scalar run( command => [$self->bin_bunzip2, '--version'],
6a5cde9
+    scalar run( 
6a5cde9
+         command => [$self->bin_bunzip2, '--version', 'NoSuchFile'],
6a5cde9
          verbose => 0,
6a5cde9
          buffer  => \$buffer
6a5cde9
     );
6a5cde9
@@ -499,7 +529,6 @@ sub have_old_bunzip2 {
6a5cde9
 #
6a5cde9
 #################################
6a5cde9
 
6a5cde9
-
6a5cde9
 ### untar wrapper... goes to either Archive::Tar or /bin/tar
6a5cde9
 ### depending on $PREFER_BIN
6a5cde9
 sub _untar {
6a5cde9
@@ -1141,6 +1170,96 @@ sub _bunzip2_cz2 {
6a5cde9
 
6a5cde9
 #################################
6a5cde9
 #
6a5cde9
+# unlzma code
6a5cde9
+#
6a5cde9
+#################################
6a5cde9
+
6a5cde9
+### unlzma wrapper... goes to either Compress::unLZMA or /bin/unlzma
6a5cde9
+### depending on $PREFER_BIN
6a5cde9
+sub _unlzma {
6a5cde9
+    my $self = shift;
6a5cde9
+
6a5cde9
+    my @methods = qw[_unlzma_cz _unlzma_bin];
6a5cde9
+       @methods = reverse @methods if $PREFER_BIN;
6a5cde9
+
6a5cde9
+    for my $method (@methods) {
6a5cde9
+        $self->_extractor($method) && return 1 if $self->$method();
6a5cde9
+    }
6a5cde9
+
6a5cde9
+    return $self->_error(loc("Unable to unlzma file '%1'", $self->archive));
6a5cde9
+}
6a5cde9
+
6a5cde9
+sub _unlzma_bin {
6a5cde9
+    my $self = shift;
6a5cde9
+
6a5cde9
+    ### check for /bin/unlzma -- we need it ###
6a5cde9
+    return $self->_error(loc("No '%1' program found", '/bin/unlzma'))
6a5cde9
+        unless $self->bin_unlzma;
6a5cde9
+
6a5cde9
+    my $fh = FileHandle->new('>'. $self->_gunzip_to) or
6a5cde9
+        return $self->_error(loc("Could not open '%1' for writing: %2",
6a5cde9
+                            $self->_gunzip_to, $! ));
6a5cde9
+
6a5cde9
+    my $cmd = [ $self->bin_unlzma, '-c', $self->archive ];
6a5cde9
+
6a5cde9
+    my $buffer;
6a5cde9
+    unless( scalar run( command => $cmd,
6a5cde9
+                        verbose => $DEBUG,
6a5cde9
+                        buffer  => \$buffer )
6a5cde9
+    ) {
6a5cde9
+        return $self->_error(loc("Unable to unlzma '%1': %2",
6a5cde9
+                                    $self->archive, $buffer));
6a5cde9
+    }
6a5cde9
+
6a5cde9
+    ### no buffers available?
6a5cde9
+    if( !IPC::Cmd->can_capture_buffer and !$buffer ) {
6a5cde9
+        $self->_error( $self->_no_buffer_content( $self->archive ) );
6a5cde9
+    }
6a5cde9
+
6a5cde9
+    print $fh $buffer if defined $buffer;
6a5cde9
+
6a5cde9
+    close $fh;
6a5cde9
+
6a5cde9
+    ### set what files where extract, and where they went ###
6a5cde9
+    $self->files( [$self->_gunzip_to] );
6a5cde9
+    $self->extract_path( File::Spec->rel2abs(cwd()) );
6a5cde9
+
6a5cde9
+    return 1;
6a5cde9
+}
6a5cde9
+
6a5cde9
+sub _unlzma_cz {
6a5cde9
+    my $self = shift;
6a5cde9
+
6a5cde9
+    my $use_list = { 'Compress::unLZMA' => '0.0' };
6a5cde9
+    unless( can_load( modules => $use_list ) ) {
6a5cde9
+        return $self->_error(loc("You do not have '%1' installed - Please " .
6a5cde9
+                       "install it as soon as possible.", 'Compress::unLZMA'));
6a5cde9
+    }
6a5cde9
+
6a5cde9
+    my $fh = FileHandle->new('>'. $self->_gunzip_to) or
6a5cde9
+        return $self->_error(loc("Could not open '%1' for writing: %2",
6a5cde9
+                            $self->_gunzip_to, $! ));
6a5cde9
+
6a5cde9
+    my $buffer;
6a5cde9
+    $buffer = Compress::unLZMA::uncompressfile( $self->archive );
6a5cde9
+    unless ( defined $buffer ) {
6a5cde9
+        return $self->_error(loc("Could not unlzma '%1': %2",
6a5cde9
+                                    $self->archive, $@));
6a5cde9
+    }
6a5cde9
+
6a5cde9
+    print $fh $buffer if defined $buffer;
6a5cde9
+
6a5cde9
+    close $fh;
6a5cde9
+
6a5cde9
+    ### set what files where extract, and where they went ###
6a5cde9
+    $self->files( [$self->_gunzip_to] );
6a5cde9
+    $self->extract_path( File::Spec->rel2abs(cwd()) );
6a5cde9
+
6a5cde9
+    return 1;
6a5cde9
+}
6a5cde9
+
6a5cde9
+#################################
6a5cde9
+#
6a5cde9
 # Error code
6a5cde9
 #
6a5cde9
 #################################
6a5cde9
@@ -1208,7 +1327,7 @@ C<Archive::Extract> will not be able to 
6a5cde9
 
6a5cde9
 C<Archive::Extract> can use either pure perl modules or command line
6a5cde9
 programs under the hood. Some of the pure perl modules (like 
6a5cde9
-C<Archive::Tar> take the entire contents of the archive into memory,
6a5cde9
+C<Archive::Tar> and Compress::unLZMA) take the entire contents of the archive into memory,
6a5cde9
 which may not be feasible on your system. Consider setting the global
6a5cde9
 variable C<$Archive::Extract::PREFER_BIN> to C<1>, which will prefer
6a5cde9
 the use of command line programs and won't consume so much memory.
30d1b9a
diff -up perl-5.10.0/lib/Archive/Extract/t/src/x.lzma.packed.BAD perl-5.10.0/lib/Archive/Extract/t/src/x.lzma.packed
30d1b9a
--- perl-5.10.0/lib/Archive/Extract/t/src/x.lzma.packed.BAD	2008-03-08 19:20:41.000000000 -0500
30d1b9a
+++ perl-5.10.0/lib/Archive/Extract/t/src/x.lzma.packed	2008-03-08 19:20:33.000000000 -0500
30d1b9a
@@ -0,0 +1,16 @@
30d1b9a
+#########################################################################
30d1b9a
+This is a binary file that was packed with the 'uupacktool.pl' which
30d1b9a
+is included in the Perl distribution.
30d1b9a
+
30d1b9a
+To unpack this file use the following command:
30d1b9a
+
30d1b9a
+     uupacktool.pl -u lib/Archive/Extract/t/src/x.lzma.packed lib/Archive/Extract/t/src/x.lzma
30d1b9a
+
30d1b9a
+To recreate it use the following command:
30d1b9a
+
30d1b9a
+     uupacktool.pl -p lib/Archive/Extract/t/src/x.lzma lib/Archive/Extract/t/src/x.lzma.packed
30d1b9a
+
30d1b9a
+Created at Sat Mar  8 19:20:33 2008
30d1b9a
+#########################################################################
30d1b9a
+__UU__
30d1b9a
+270``@```````````````````