From 56697ec2321e16b6320f88a179ab4acbc32adb44 Mon Sep 17 00:00:00 2001 From: stevenpritchard Date: Fri, 16 Mar 2007 18:16:02 +0000 Subject: [PATCH] Handle .bz2 files. --- Build.PL | 1 + Changes | 1 + cpanspec | 24 +++++++++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Build.PL b/Build.PL index 2193a6d..fb0453e 100644 --- a/Build.PL +++ b/Build.PL @@ -10,6 +10,7 @@ my $builder = Module::Build->new( requires => { 'Archive::Tar' => 0, 'Archive::Zip' => 0, + 'IO::Uncompress::Bunzip2' => 0, 'File::Basename' => 0, 'FileHandle' => 0, 'Getopt::Long' => 0, diff --git a/Changes b/Changes index 89e2f1c..bf059e1 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ 1.71 * It's 2007 now, so update the copyright. +* Handle .bz2 files. 1.70 2007-03-12 diff --git a/cpanspec b/cpanspec index 82fe08d..61277e6 100755 --- a/cpanspec +++ b/cpanspec @@ -10,7 +10,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: cpanspec,v 1.46 2007/03/12 23:28:50 stevenpritchard Exp $ +# $Id: cpanspec,v 1.47 2007/03/16 18:16:02 stevenpritchard Exp $ our $NAME="cpanspec"; our $VERSION='1.71'; @@ -568,7 +568,7 @@ my @processed=(); for my $file (@args) { my ($name,$version,$type); - if ($file =~ /^(?:.*\/)?(.*)-([^-]+)\.(tar)\.gz$/) { + if ($file =~ /^(?:.*\/)?(.*)-([^-]+)\.(tar)\.(?:gz|bz2)$/) { $name=$1; $version=$2; $type=$3; @@ -619,7 +619,25 @@ for my $file (@args) { my $archive; if ($type eq 'tar') { - $archive=Archive::Tar->new($file, 1) + my $f=$file; + if ($file=~/\.bz2$/) { + eval { + use IO::Uncompress::Bunzip2; + }; + + if ($@) { + warn "Failed to load IO::Uncompress::Bunzip2: $@\n"; + warn "Skipping $file...\n"; + next; + } + + $f=IO::Uncompress::Bunzip2->new($file); + if (!defined($f)) { + warn "IO::Uncompress::Bunzip2->new() failed on $file: $!\n"; + next; + } + } + $archive=Archive::Tar->new($f, 1) or die "Archive::Tar->new() failed: $!\n"; } elsif ($type eq 'zip') { $archive=Archive::Zip->new() or die "Archive::Zip->new() failed: $!\n";