Created
February 19, 2010 09:58
-
-
Save gfx/308594 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/cpanm b/cpanm | |
| index abf9d09..b368a13 100755 | |
| --- a/cpanm | |
| +++ b/cpanm | |
| @@ -1,6 +1,7 @@ | |
| #!/usr/bin/perl | |
| use strict; | |
| use File::Basename qw(basename); | |
| +use Fatal qw(chdir); | |
| sub get($); | |
| sub mirror($$); | |
| @@ -27,7 +28,32 @@ if (eval { require LWP::Simple }) { | |
| } | |
| # TODO curl | |
| -if (eval { require Archive::Tar }) { | |
| +my $tar = `which tar`; | |
| +chomp $tar; | |
| + | |
| +if(-x $tar){ | |
| + *untar = sub { | |
| + my($tarfile) = @_; | |
| + my $opt = 'xvf'; # extract, verbose, file | |
| + if($tarfile =~ /bz2$/){ | |
| + $opt .= 'j'; | |
| + } | |
| + else{ | |
| + $opt .= 'z'; | |
| + } | |
| + | |
| + my @files = `$tar $opt $tarfile`; | |
| + if(@files){ | |
| + warn @files, "\n"; | |
| + chomp $files[0]; | |
| + return $files[0]; | |
| + } | |
| + else { | |
| + return undef; | |
| + } | |
| + } | |
| +} | |
| +elsif (eval { require Archive::Tar }) { # uses too much memory! | |
| *untar = sub { | |
| my $t = Archive::Tar->new($_[0]); | |
| my $root = ($t->list_files)[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment