Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cperl from the output of available command #777

Merged
merged 6 commits into from
Jun 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Remove cperl from `available` and `install` command. Github PR: #777. cperl can still be installed by specifying the tarball, just not automatically, just not by their short names.

0.97
- Released at 2023-05-12T22:33:42+0900
- Thanks to our contributors: Elvin Aslanov, Graham Knop, Shoichi Kaji, Tomasz Konojacki, brian greenfield
Expand Down
99 changes: 8 additions & 91 deletions lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ sub run_command_available {
my @installed = $self->installed_perls(@_);
my $is_verbose = $self->{verbose};

my @sections = ( ['perl', 'available_perl_distributions'], ['cperl', 'available_cperl_distributions'], );
my @sections = ( ['perl', 'available_perl_distributions'] );

for (@sections) {
my ( $header, $method ) = @$_;
Expand Down Expand Up @@ -690,7 +690,7 @@ sub run_command_available {

sub available_perls {
my ($self) = @_;
my %dists = ( %{ $self->available_perl_distributions }, %{ $self->available_cperl_distributions }, );
my %dists = ( %{ $self->available_perl_distributions } );
return $self->sort_perl_versions( keys %dists );
}

Expand Down Expand Up @@ -722,30 +722,6 @@ sub available_perl_distributions {
return $perls;
}

# -> Map[ NameVersion => URL ]
sub available_cperl_distributions {
my ($self) = @_;
my %dist;

# cperl releases: https://github.com/perl11/cperl/tags
my $cperl_remote = 'https://github.com';
my $url_cperl_release_list = $cperl_remote . '/perl11/cperl/releases';

my $html = http_get($url_cperl_release_list);

unless ($html) {
die "\nERROR: Unable to retrieve the list of cperl releases from ${url_cperl_release_list}\n";
}

if ($html) {
while ( $html =~ m{href="(/perl11/cperl/releases/download/cperl-(5.+?)/cperl-.+?\.tar\.gz)"}g ) {
$dist{"cperl-$2"} = $cperl_remote . $1;
}
}

return \%dist;
}

# $perllist is an arrayref of arrayrefs. The inner arrayrefs are of the
# format: [ <perl_name>, <perl_url> ]
# perl_name = something like perl-5.28.0
Expand Down Expand Up @@ -822,24 +798,6 @@ sub perl_release {
return ( $dist_tarball, $dist_tarball_url );
}

sub cperl_release {
my ( $self, $version ) = @_;
my %url = (
"5.22.3" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.3/cperl-5.22.3.tar.gz",
"5.22.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.2/cperl-5.22.2.tar.gz",
"5.24.0-RC1" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.0-RC1/cperl-5.24.0-RC1.tar.gz",
);

# my %digest => {
# "5.22.3" => "bcf494a6b12643fa5e803f8e0d9cef26312b88fc",
# "5.22.2" => "8615964b0a519cf70d69a155b497de98e6a500d0",
# };

my $dist_tarball_url = $url{$version} or die "ERROR: Cannot find the tarball for cperl-$version\n";
my $dist_tarball = "cperl-${version}.tar.gz";
return ( $dist_tarball, $dist_tarball_url );
}

sub release_detail_perl_local {
my ( $self, $dist, $rd ) = @_;
$rd ||= {};
Expand Down Expand Up @@ -904,56 +862,11 @@ sub release_detail_perl_remote {
return ( $error, $rd );
}

sub release_detail_cperl_local {
my ( $self, $dist, $rd ) = @_;
$rd ||= {};
my %url = (
"cperl-5.22.3" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.3/cperl-5.22.3.tar.gz",
"cperl-5.22.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.2/cperl-5.22.2.tar.gz",
"cperl-5.24.0-RC1" =>
"https://github.com/perl11/cperl/releases/download/cperl-5.24.0-RC1/cperl-5.24.0-RC1.tar.gz",
"cperl-5.24.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.2/cperl-5.24.2.tar.gz",
"cperl-5.25.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.2/cperl-5.25.2.tar.gz",
"cperl-5.26.4" => "https://github.com/perl11/cperl/releases/download/cperl-5.26.4/cperl-5.26.4.tar.gz",
"cperl-5.26.5" => "https://github.com/perl11/cperl/releases/download/cperl-5.26.5/cperl-5.26.5.tar.gz",
"cperl-5.28.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.28.2/cperl-5.28.2.tar.gz",
"cperl-5.29.0" => "https://github.com/perl11/cperl/releases/download/cperl-5.29.0/cperl-5.29.0.tar.gz",
"cperl-5.29.1" => "https://github.com/perl11/cperl/releases/download/cperl-5.29.1/cperl-5.29.1.tar.gz",
"cperl-5.30.0" => "https://github.com/perl11/cperl/releases/download/cperl-5.30.0/cperl-5.30.0.tar.gz",
);

my $error = 1;
if ( my $u = $url{$dist} ) {
$rd->{tarball_name} = "${dist}.tar.gz";
$rd->{tarball_url} = $u;
$error = 0;
}
return ( $error, $rd );
}

sub release_detail_cperl_remote {
my ( $self, $dist, $rd ) = @_;
$rd ||= {};

my $expect_href = "/perl11/cperl/releases/download/${dist}/${dist}.tar.gz";
my $error = 1;

my $html = eval { http_get( 'https://github.com/perl11/cperl/releases/tag/' . $dist ); } || "";

if ( $html =~ m{ <a \s+ href="($expect_href)" }xsi ) {
$rd->{tarball_name} = "${dist}.tar.gz";
$rd->{tarball_url} = "https://github.com" . $1;
$error = 0;
}

return ( $error, $rd );
}

sub release_detail {
my ( $self, $dist ) = @_;
my ( $dist_type, $dist_version );

( $dist_type, $dist_version ) = $dist =~ /^ (?: (c?perl) -? )? ( [\d._]+ (?:-RC\d+)? |git|stable|blead)$/x;
( $dist_type, $dist_version ) = $dist =~ /^ (?: (perl) -? )? ( [\d._]+ (?:-RC\d+)? |git|stable|blead)$/x;
$dist_type = "perl" if $dist_version && !$dist_type;

my $rd = {
Expand All @@ -963,10 +876,14 @@ sub release_detail {
tarball_name => undef,
};

# dynamic methods: release_detail_perl_local, release_detail_cperl_local, release_detail_perl_remote, release_detail_cperl_remote
# dynamic methods: release_detail_perl_local, release_detail_perl_remote
my $m_local = "release_detail_${dist_type}_local";
my $m_remote = "release_detail_${dist_type}_remote";

unless ($self->can($m_local) && $self->can($m_remote)) {
die "ERROR: Unknown dist type: $dist_type\n";
}

my ($error) = $self->$m_local( $dist, $rd );
($error) = $self->$m_remote( $dist, $rd ) if $error;

Expand Down
9 changes: 0 additions & 9 deletions script/perlbrew
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ The format of <perl-release> looks like:

=item blead

=item cperl-<version>

=back

Version numbers usually look like "5.x.xx", or "perl-5.xx.x-RCx" for
Expand All @@ -208,13 +206,6 @@ mirror site configured before.
Version number alone without the "perl-" prefix means the official
release provided by perl5 porters.

The prefix "cperl" is a special release provided not by perl5 porters,
but from the community. The cperl distributions are downloaded from:

https://github.com/perl11/cperl/releases

See https://perl11.org/cperl/ for more information about cperl distribution.

Options for C<install> command:

-f --force Force installation
Expand Down
9 changes: 0 additions & 9 deletions t/08.error_available.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,4 @@ throws_ok(
qr[ERROR:]
);

throws_ok(
sub {
my $app = App::perlbrew->new("available");
my $ret = $app->available_cperl_distributions();
},
qr[ERROR:]
);


done_testing;
14 changes: 0 additions & 14 deletions t/16.release-detail.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,4 @@ subtest 'parse "5.18.2"' => sub {
is $rd->{version}, "5.18.2";
};

subtest 'parse "cperl-5.22.2"' => sub {
my $app = App::perlbrew->new();

my $rd = $app->release_detail("cperl-5.22.2");

ok defined( $rd->{type} );
ok defined( $rd->{version} );
ok defined( $rd->{tarball_url} );
ok defined( $rd->{tarball_name} );

is $rd->{type}, "cperl";
is $rd->{version}, "5.22.2";
};

done_testing;
22 changes: 0 additions & 22 deletions t/17.release-detail-cperl-local.t

This file was deleted.

36 changes: 0 additions & 36 deletions t/17.release-detail-cperl-remote.t

This file was deleted.

8 changes: 1 addition & 7 deletions t/command-available.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ my %available_perl_dists = (
'perl5.004_05' => 'http://www.cpan.org/src/5.0/perl5.004_05.tar.gz',
);

my %available_cperl_dists = (
'cperl-5.26.1' => 'https://github.com/perl11/cperl/archive/cperl-5.26.1.tar.gz',
'cperl-5.27.1' => 'https://github.com/perl11/cperl/archive/cperl-5.27.1.tar.gz',
);

sub mocked_perlbrew {
my $app = App::perlbrew->new( @_ );
$app->expects( 'available_perl_distributions' )->returns( \%available_perl_dists );
$app->expects( 'available_cperl_distributions' )->returns( \%available_cperl_dists );
return $app;
}

Expand Down Expand Up @@ -82,7 +76,7 @@ describe "available command output, when something installed locally," => sub {
(
\# .+ \n
(
\s{3,}c?perl-?\d\.\d{1,3}[_.]\d{1,2}
\s{3,}perl-?\d\.\d{1,3}[_.]\d{1,2}
\s+
(
INSTALLED \s on \s .+ \s via
Expand Down
Loading