From 99211786100275e502299f58e822c0b5a64300f0 Mon Sep 17 00:00:00 2001 From: Justin Davis Date: Tue, 16 Aug 2011 11:38:09 -0400 Subject: Mimick makepkg's symlinking of tarball to avoid downloading twice. --- bin/macros/perl-cpan | 8 ++------ bin/macros/perl-dist | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'bin/macros') 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{\[Download\]} 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) = @_; -- cgit v1.2.3-24-g4f1b