Skip to content

Commit

Permalink
Merge branch 'release/0.87'
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Oct 25, 2019
2 parents d867af7 + 93c8f1c commit 7c75d9c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 144 deletions.
66 changes: 11 additions & 55 deletions lib/App/perlbrew.pm
Expand Up @@ -1286,7 +1286,11 @@ sub do_install_url {
my ($dist_version) = $dist =~ m/-([\d.]+(?:-RC\d+)?|git)\./;
my ($dist_tarball) = $dist =~ m{/([^/]*)$};
my $dist_tarball_path = $self->root->dists ($dist_tarball);
if (! $dist_version && $dist =~ /blead\.tar.gz$/) {
$dist_version = "blead";
}
my $dist_tarball_path = $self->root->dists($dist_tarball);
my $dist_tarball_url = $dist;
$dist = "$dist_name-$dist_version"; # we install it as this name later
Expand Down Expand Up @@ -1340,63 +1344,15 @@ sub do_extract_tarball {
return $extracted_dir;
}
# Search for directories inside a extracted tarball downloaded as perl "blead"
# This pattern has to what's inside the extracted tarball from: https://github.com/Perl/perl5/tarball/blead
# Parameters:
# - $build_dir: A directory for building perls. It is supposed to have "blead" subdir inside.
# Returs:
# - A path to the extracted "blead" tarball. This should be a subdir inside "${build_dir}/blead"
sub search_blead_dir {
my ($build_dir) = @_;
my $blead_dir = $build_dir->child("blead");
return unless -d $blead_dir;
local *DIRH;
opendir DIRH, $blead_dir or die "Couldn't open ${blead_dir}: $!";
my @contents = grep { !/^\./ && -d $blead_dir->child($_) } readdir DIRH;
closedir DIRH or warn "Couldn't close ${blead_dir}: $!";
my @candidates = grep { m/^Perl-perl5-[0-9a-f]{4,40}$/ } @contents;
@candidates = map { $_->[0] }
sort { $b->[1] <=> $a->[1] } # descending
map { [ $_, (stat( $blead_dir->child ($_) ))[9] ] } @candidates;
if (scalar(@candidates) > 0) {
# take the newest one
return $blead_dir->child($candidates[0]);
} else {
return;
}
}
sub do_install_blead {
my ($self, $dist) = @_;
my $dist_name = 'perl';
my $dist_version = 'blead';
my ($self) = @_;
# We always blindly overwrite anything that's already there,
# because blead is a moving target.
my $dist_tarball = 'blead.tar.gz';
my $dist_tarball_path = $self->root->dists($dist_tarball);
print "Downloading blead from https://github.com/Perl/perl5/tarball/blead as $dist_tarball_path\n";
my $dist_tarball_path = $self->root->dists("blead.tar.gz");
unlink($dist_tarball_path) if -f $dist_tarball_path;
my $error = http_download("https://github.com/Perl/perl5/tarball/blead", $dist_tarball_path);
if ($error) {
die "\nERROR: Failed to download perl-blead tarball.\n\n";
}
# Returns the wrong extracted dir for blead
$self->do_extract_tarball($dist_tarball_path);
my $build_dir = $self->builddir;
my $dist_extracted_subdir = search_blead_dir($build_dir);
die "Could not identify where is the source code to build under $build_dir, aborting..." unless (defined($dist_extracted_subdir));
$self->do_install_this($dist_extracted_subdir, $dist_version, "$dist_name-$dist_version");
return;
$self->do_install_url("https://github.com/Perl/perl5/archive/blead.tar.gz");
}
sub resolve_stable_version {
Expand Down Expand Up @@ -1466,7 +1422,7 @@ sub run_command_install {
}
if ($dist_type eq 'perl' && $dist_version eq 'blead') {
$self->do_install_blead($dist);
$self->do_install_blead();
}
else {
$self->do_install_release($dist, $dist_version);
Expand Down Expand Up @@ -1688,8 +1644,8 @@ sub do_install_archive {
}
my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);
$self->do_install_this($dist_extracted_path, $dist_version, $installation_name);
return;
}
sub do_install_this {
Expand Down
66 changes: 11 additions & 55 deletions perlbrew
Expand Up @@ -1584,7 +1584,11 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my ($dist_version) = $dist =~ m/-([\d.]+(?:-RC\d+)?|git)\./;
my ($dist_tarball) = $dist =~ m{/([^/]*)$};

my $dist_tarball_path = $self->root->dists ($dist_tarball);
if (! $dist_version && $dist =~ /blead\.tar.gz$/) {
$dist_version = "blead";
}

my $dist_tarball_path = $self->root->dists($dist_tarball);
my $dist_tarball_url = $dist;
$dist = "$dist_name-$dist_version"; # we install it as this name later

Expand Down Expand Up @@ -1638,63 +1642,15 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
return $extracted_dir;
}

# Search for directories inside a extracted tarball downloaded as perl "blead"
# This pattern has to what's inside the extracted tarball from: https://github.com/Perl/perl5/tarball/blead
# Parameters:
# - $build_dir: A directory for building perls. It is supposed to have "blead" subdir inside.
# Returs:
# - A path to the extracted "blead" tarball. This should be a subdir inside "${build_dir}/blead"
sub search_blead_dir {
my ($build_dir) = @_;

my $blead_dir = $build_dir->child("blead");
return unless -d $blead_dir;

local *DIRH;
opendir DIRH, $blead_dir or die "Couldn't open ${blead_dir}: $!";
my @contents = grep { !/^\./ && -d $blead_dir->child($_) } readdir DIRH;
closedir DIRH or warn "Couldn't close ${blead_dir}: $!";

my @candidates = grep { m/^Perl-perl5-[0-9a-f]{4,40}$/ } @contents;

@candidates = map { $_->[0] }
sort { $b->[1] <=> $a->[1] } # descending
map { [ $_, (stat( $blead_dir->child ($_) ))[9] ] } @candidates;

if (scalar(@candidates) > 0) {
# take the newest one
return $blead_dir->child($candidates[0]);
} else {
return;
}
}

sub do_install_blead {
my ($self, $dist) = @_;
my $dist_name = 'perl';
my $dist_version = 'blead';
my ($self) = @_;

# We always blindly overwrite anything that's already there,
# because blead is a moving target.
my $dist_tarball = 'blead.tar.gz';
my $dist_tarball_path = $self->root->dists($dist_tarball);
print "Downloading blead from https://github.com/Perl/perl5/tarball/blead as $dist_tarball_path\n";
my $dist_tarball_path = $self->root->dists("blead.tar.gz");
unlink($dist_tarball_path) if -f $dist_tarball_path;

my $error = http_download("https://github.com/Perl/perl5/tarball/blead", $dist_tarball_path);

if ($error) {
die "\nERROR: Failed to download perl-blead tarball.\n\n";
}

# Returns the wrong extracted dir for blead
$self->do_extract_tarball($dist_tarball_path);

my $build_dir = $self->builddir;
my $dist_extracted_subdir = search_blead_dir($build_dir);

die "Could not identify where is the source code to build under $build_dir, aborting..." unless (defined($dist_extracted_subdir));
$self->do_install_this($dist_extracted_subdir, $dist_version, "$dist_name-$dist_version");
return;
$self->do_install_url("https://github.com/Perl/perl5/archive/blead.tar.gz");
}

sub resolve_stable_version {
Expand Down Expand Up @@ -1764,7 +1720,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
}

if ($dist_type eq 'perl' && $dist_version eq 'blead') {
$self->do_install_blead($dist);
$self->do_install_blead();
}
else {
$self->do_install_release($dist, $dist_version);
Expand Down Expand Up @@ -1986,8 +1942,8 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
}

my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path);

$self->do_install_this($dist_extracted_path, $dist_version, $installation_name);
return;
}

sub do_install_this {
Expand Down
4 changes: 2 additions & 2 deletions t/08.error_install_blead.t
Expand Up @@ -21,15 +21,15 @@ throws_ok(
my $app = App::perlbrew->new("install", "perl-blead");
$app->run;
},
qr[ERROR: Failed to download perl-blead tarball.]
qr[ERROR: Failed to download https://.+/blead\.tar\.gz]
);

throws_ok(
sub {
my $app = App::perlbrew->new("install", "blead");
$app->run;
},
qr[ERROR: Failed to download perl-blead tarball.]
qr[ERROR: Failed to download https://.+/blead\.tar\.gz]
);

done_testing;
3 changes: 1 addition & 2 deletions t/command-install.t
Expand Up @@ -45,8 +45,7 @@ describe "command install" => sub {

it "should install blead perl" => sub {
arrange_command_line install => 'perl-blead';

expect_dispatch_via do_install_blead => [ 'perl-blead' ];
expect_dispatch_via do_install_blead => [];
};

it "should install git checkout" => sub {
Expand Down
30 changes: 0 additions & 30 deletions t/get_blead_perl.t

This file was deleted.

0 comments on commit 7c75d9c

Please sign in to comment.