Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Sep 19, 2024
1 parent e36283e commit 0b1ee1e
Showing 1 changed file with 81 additions and 3 deletions.
84 changes: 81 additions & 3 deletions perlbrew
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ $fatpacked{"App/Perlbrew/Util.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".
use Exporter 'import';
our @EXPORT = qw( uniq min editdist files_are_the_same perl_version_to_integer );
our @EXPORT_OK = qw( find_similar_tokens );
our @EXPORT_OK = qw( find_similar_tokens looks_like_url_of_skaji_relocatable_perl );
sub uniq {
my %seen;
Expand Down Expand Up @@ -490,6 +490,22 @@ $fatpacked{"App/Perlbrew/Util.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".
return \@similar_tokens;
}
sub looks_like_url_of_skaji_relocatable_perl {
my ($str) = @_;
# https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-amd64.tar.gz
my $prefix = "https://github.com/skaji/relocatable-perl/releases/download";
my $version_re = qr/(5\.[0-9][0-9]\.[0-9][0-9]?.[0-9])/;
my $name_re = qr/perl-(linux|darwin)-(amd64|arm64)\.tar\.gz/;
return undef unless $str =~ m{ \Q$prefix\E / $version_re / $name_re }x;
return {
url => $str,
version => $1,
os => $2,
arch => $3,
original_filename => "perl-$2-$3.tar.gz",
};
}
1;
APP_PERLBREW_UTIL

Expand Down Expand Up @@ -517,10 +533,10 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
use Getopt::Long ();
use CPAN::Perl::Releases ();
use JSON::PP qw( decode_json );
use File::Copy qw( copy );
use File::Copy qw( copy move );
use Capture::Tiny ();
use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens );
use App::Perlbrew::Util qw( files_are_the_same uniq find_similar_tokens looks_like_url_of_skaji_relocatable_perl );
use App::Perlbrew::Path ();
use App::Perlbrew::Path::Root ();
use App::Perlbrew::HTTP qw( http_download http_get );
Expand Down Expand Up @@ -1723,6 +1739,10 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
exit(-1);
}
if ( my $detail = looks_like_url_of_skaji_relocatable_perl($dist) ) {
return $self->do_install_skaji_relocatable_perl($detail);
}
$self->{dist_name} = $dist; # for help msg generation, set to non
# normalized name
Expand Down Expand Up @@ -2126,6 +2146,64 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
return;
}
sub do_install_skaji_relocatable_perl {
my ($self, $detail) = @_;
my $installation_name = $self->{as} || ("skaji-relocatable-perl-" . $detail->{version});
my $installation_path = $self->root->perls->child($installation_name);
die "ERROR: Installation target \"${installation_name}\" already exists\n"
if $installation_path->exists;
my $path = $self->root->dists
->child("skaji-relocatable-perl")
->child($detail->{version})
->mkpath()
->child($detail->{original_filename});
if (-f $path) {
print "Re-using the downloaded $path\n";
} else {
my $url = $detail->{url};
print "Downloading $url as $path\n";
my $error = http_download( $detail->{url}, $path );
if ($error) {
die "Failed to download from $url\nError: $error";
}
}
my $extracted_path = $self->do_extract_skaji_relocatable_perl_tarball($detail, $path);
move $extracted_path, $installation_path;
print "$installation_name is installed at $installation_path.\n";
print "$installation_name is successfully installed.\n";
}
sub do_extract_skaji_relocatable_perl_tarball {
my ($self, $detail, $tarball_path) = @_;
my $workdir = $self->builddir
->child("skaji-relocatable-perl")
->child($detail->{version});
$workdir->rmpath()
if $workdir->exists();
$workdir->mkpath();
my $tarx = "tar xzf";
my $extract_command = "cd $workdir; $tarx $tarball_path";
system($extract_command) == 0
or die "Failed to extract $tarball_path";
my ($extracted_path) = $workdir->children;
return $extracted_path;
}
sub do_install_program_from_url {
my ( $self, $url, $program_name, $body_filter ) = @_;
Expand Down

0 comments on commit 0b1ee1e

Please sign in to comment.