Skip to content

Commit

Permalink
Merge pull request #822 from gugod/install-skaji-relocatable-perl-by-…
Browse files Browse the repository at this point in the history
…names

make `install` accept skaji-relocatable by name.
  • Loading branch information
gugod authored Sep 24, 2024
2 parents 9731ed8 + c40bdef commit bf4f411
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 19 additions & 1 deletion lib/App/Perlbrew/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use 5.008;

use Exporter 'import';
our @EXPORT = qw( uniq min editdist files_are_the_same perl_version_to_integer );
our @EXPORT_OK = qw( find_similar_tokens looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl );
our @EXPORT_OK = qw(
find_similar_tokens
looks_like_url_of_skaji_relocatable_perl
looks_like_sys_would_be_compatible_with_skaji_relocatable_perl
make_skaji_relocatable_perl_url
);

sub uniq {
my %seen;
Expand Down Expand Up @@ -132,4 +137,17 @@ sub looks_like_sys_would_be_compatible_with_skaji_relocatable_perl {
);
}

sub make_skaji_relocatable_perl_url {
my ($str, $sys) = @_;
if ($str =~ m/\Askaji-relocatable-perl-(5\.[0-9][0-9]\.[0-9][0-9]?.[0-9])\z/) {
my $version = $1;
my $os = $sys->os;
my $arch = $sys->arch;
$arch = "amd64" if $arch eq 'x86_64';

return "https:/skaji/relocatable-perl/releases/download/$version/perl-$os-$arch.tar.gz";
}
return undef;
}

1;
6 changes: 5 additions & 1 deletion lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use JSON::PP qw( decode_json );
use File::Copy qw( copy move );
use Capture::Tiny ();

use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl);
use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl make_skaji_relocatable_perl_url );
use App::Perlbrew::Path ();
use App::Perlbrew::Path::Root ();
use App::Perlbrew::HTTP qw( http_download http_get );
Expand Down Expand Up @@ -1230,6 +1230,10 @@ sub run_command_install {
exit(-1);
}
if ( my $url = make_skaji_relocatable_perl_url($dist, $self->sys) ) {
return $self->run_command_install($url);
}
if ( my $detail = looks_like_url_of_skaji_relocatable_perl($dist) ) {
if (looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $self->sys)) {
return $self->do_install_skaji_relocatable_perl($detail);
Expand Down

0 comments on commit bf4f411

Please sign in to comment.