summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Davis <jrcd83@gmail.com>2011-08-16 17:38:09 +0200
committerJustin Davis <jrcd83@gmail.com>2011-08-16 17:38:09 +0200
commit99211786100275e502299f58e822c0b5a64300f0 (patch)
tree9334d327e31807f7ecd8555259dcf1c4c24e4372
parentd6c783b734e2b4520dd75682ff5bd51c390c546d (diff)
downloadgenpkg-99211786100275e502299f58e822c0b5a64300f0.tar.gz
genpkg-99211786100275e502299f58e822c0b5a64300f0.tar.xz
Mimick makepkg's symlinking of tarball to avoid downloading twice.
-rwxr-xr-xbin/macros/perl-cpan8
-rwxr-xr-xbin/macros/perl-dist18
2 files changed, 19 insertions, 7 deletions
diff --git a/bin/macros/perl-cpan b/bin/macros/perl-cpan
index 0cd9bcd..cc87c4d 100755
--- a/bin/macros/perl-cpan
+++ b/bin/macros/perl-cpan
@@ -18,24 +18,20 @@ $resp = $resp->content;
my ($href) = $resp =~ m{\[<a href="([^"]+)">Download</a>\]}
or die "$0: no download link found at $url\n";
-unless (-d 'src') {
- mkdir 'src' or die "$0: mkdir src: $!"
-}
-
my $file = $href;
$file =~ s{\A.*/}{};
$href = "http://search.cpan.org" . $href;
STDERR->autoflush(1);
print STDERR "Downloading $file... ";
-$resp = $ua->get($href, ':content_file' => "src/$file");
+$resp = $ua->get($href, ':content_file' => $file);
die "$0: download of $file failed: ", $resp->status_line
unless $resp->is_success;
print STDERR "OK\n";
print "+ url $url\n";
print "+ source $href\n";
-system "perl-dist src/$file";
+system "perl-dist $file";
if ($? != 0) {
printf STDERR "$0: failed to run perl-dist%s\n", ($! ? " ($!)" : q{});
exit 1;
diff --git a/bin/macros/perl-dist b/bin/macros/perl-dist
index c822093..82d298b 100755
--- a/bin/macros/perl-dist
+++ b/bin/macros/perl-dist
@@ -286,7 +286,7 @@ sub _distofmod
package main;
use File::Basename qw(basename dirname);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
use File::Find qw(find);
use JSON::XS qw(decode_json); # parse META.{json,yml} files
@@ -334,6 +334,8 @@ sub main
my $file = basename($distpath);
my $info = distinfo($file);
+ $dir = catdir($dir, 'src');
+ prepsrcdir($dir, $file);
chdir $dir or die "chdir $dir: $!";
$dir = extractdist($file);
@@ -364,6 +366,20 @@ sub main
printjam(\%pbvars);
}
+sub prepsrcdir
+{
+ my ($srcdir, $distfile) = @_;
+
+ unless (-d $srcdir) {
+ mkdir $srcdir or die "mkdir $srcdir: $!";
+ }
+
+ symlink $distfile, catfile($srcdir, $distfile)
+ or die "symlink $distfile: $!";
+
+ return;
+}
+
sub envvar
{
my ($name) = @_;