App-perlbrew

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

1.02
	- Released at 2025-07-18T21:08:37+0900
	- Thanks to our contributors: Andrii Nugged, Marius Feraru
	- `uninstall` command now has shorter names: `rm` and `delete`.
	- `patchperl` is now an optional dependency.
	- bashrc now works better with `set -u` ("use strict" in bash) is in place. PR #850.

1.01
	- Released at 2024-11-18T20:46:04+0900
	- fix: `perlbrew install skaji-relocatable-perl-$version` on macOS.

1.00
	- Released at 2024-10-04T10:48:40+0900
	- Experimental: `perlbrew install` now accept names like skaji-relocatable-perl-$version.

0.99
	- Released at 2024-09-07T16:30:28+0900
	- Thanks to our contributors: Graham Knop, Joelle Maslak, Luke Closs, jonasbn
	- bashrc executes properly in bash shells with +h option set
	- Allow specification of non-standard Perl location
	- make-pp now requires the input to be specified with `-i` or `--input`.
	- Tests are ported to Test2. Big thanks to Luke Closs.
        - Command make-pp now expects the input to be the path of an existing executable perl program, and would not be searching through $PATH.

Changes  view on Meta::CPAN


0.53
	- Released at 2012-10-14T17:41:17+0200
	- New command: `info`.
	- requires CPAN::Perl::Releases 0.76 for 5.14.3 info.
	- Skip "." in @INC to deal with a `list-module` issue. GH #245.
	- Environment variable cleanups and minor bashrc rewrite.

0.52
	- Released at 2012-10-04T21:30:40+0200
	- userelocatableinc is no longer default. Meanwhile PERLBREW_CONFIGURE_FLAGS can still be used.
	- Fix GH #197 again. Also make sure perlbrew-unrelated PERL5LIB values are preserved.
	- Fix an issue that MANPATH contains unwanted values even after switch/use/off.

0.51
	- Released at 2012-09-29T09:17:14+0200
	- Fix a start-up warning message from bashrc when perlbrew is not active
	- Fix a breakage on CentOS due to the use of `manpath` command.

0.50
	- Released at 2012-09-01T11:25:41+0200
	- properly remove perlbrew-related PERL5LIB entries. GH #197
	- minor documentation tweak.

0.49
	- Released at 2012-08-25T22:32:22+0200
	- Fix the build for perl-5.12 and 5.14 -- userelocatableinc are not working properly. https://github.com/gugod/App-perlbrew/issues/232

0.48
	- Released at 2012-08-24T07:07:52+0200
	- The build log output "build.log" is now named after the installation name for easier reference.
	- Fix the invokation configure command to actually contains -Duserelocatableinc
	- Experimental: bash/zsh users may put this to shell init instead: eval "$(~/perl5/perlbrew/bin/perlbrew init -)"
	- A few output message updates

0.47
	- Released at 2012-08-23T07:59:53+0200
	- New command: download.
	- New env var: PERLBREW_CONFIGURE_FLAGS
	- userelocatableinc is enabled by default when the installing perl version is greater than or equals to 5.8.9. It should make some use cases easier. In particular, you can move PERLBREW_ROOT directory to another place.
	- fix https://github.com/gugod/App-perlbrew/issues/216 for bash users and zsh users

0.46
	- fix: The deprecation warning when running `self-upgrde`
	- fix: system MANPATH detection
	- improvement: Specifying multiple perl: `exec --with perl-5.14.2,perl-5.16.0`

0.45
	- New command: install-ack . This install the standalone version of ack under $PERLBREW_ROOT/bin
	- New command: list-modules

lib/App/Perlbrew/Util.pm  view on Meta::CPAN

package App::Perlbrew::Util;
use strict;
use warnings;
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
    make_skaji_relocatable_perl_url
);

sub uniq {
    my %seen;
    grep { !$seen{$_}++ } @_;
}

sub min(@) {
    my $m = $_[0];
    for(@_) {

lib/App/Perlbrew/Util.pm  view on Meta::CPAN

    } @$tokens;

    if (@similar_tokens) {
        my $best_score = $similar_tokens[0][1];
        @similar_tokens = map { $_->[0] } grep { $_->[1] == $best_score } @similar_tokens;
    }

    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",
    };

lib/App/Perlbrew/Util.pm  view on Meta::CPAN


sub _arch_compat {
    my ($arch) = @_;
    my $compat = {
        x86_64 => "amd64",
        i386   => "amd64",
    };
    return $compat->{$arch} || $arch;
}

sub looks_like_sys_would_be_compatible_with_skaji_relocatable_perl {
    my ($detail, $sys) = @_;

    return (
        ($detail->{os} eq $sys->os)
        && (_arch_compat($detail->{arch}) eq _arch_compat($sys->arch))
    );
}

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' || $arch eq 'i386';

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

1;

lib/App/perlbrew.pm  view on Meta::CPAN

    require Cwd;
    @INC = @oldinc;
}

use Getopt::Long ();
use CPAN::Perl::Releases ();
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 make_skaji_relocatable_perl_url );
use App::Perlbrew::Path ();
use App::Perlbrew::Path::Root ();
use App::Perlbrew::HTTP qw( http_download http_get );
use App::Perlbrew::Patchperl qw( maybe_patchperl );
use App::Perlbrew::Sys;

### global variables

# set $ENV{SHELL} to executable path of parent process (= shell) if it's missing
# (e.g. if this script was executed by a daemon started with "service xxx start")

lib/App/perlbrew.pm  view on Meta::CPAN


    unless ( $self->root->exists ) {
        die( "ERROR: perlbrew root " . $self->root . " does not exist. Run `perlbrew init` to prepare it first.\n" );
    }

    unless ($dist) {
        $self->run_command_help("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);
        } else {
            die "ERROR: The given url points to a tarball for different os/arch.\n";
        }
    }

    $self->{dist_name} = $dist;    # for help msg generation, set to non
                                   # normalized name

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

lib/App/perlbrew.pm  view on Meta::CPAN


        print "$installation_name is successfully installed.\n";
    }
    else {
        eval { $self->append_log('##### Brew Failed #####') };
        die $self->INSTALLATION_FAILURE_MESSAGE;
    }
    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";

t/util-looks-like.t  view on Meta::CPAN

use Test2::V0;
use App::Perlbrew::Util qw(looks_like_url_of_skaji_relocatable_perl looks_like_sys_would_be_compatible_with_skaji_relocatable_perl);

subtest "looks_like_url_of_skaji_relocatable_perl", sub {
    is(
        looks_like_url_of_skaji_relocatable_perl($_),
        hash {
            field url => string($_);
            field version => string('5.40.0.0');
            field os => in_set(
                string('darwin'),
                string('linux'),
            );
            field arch => string("amd64");
            field original_filename => match(qr/^perl-(.+?)-amd64\.tar\.gz$/);
            end();
        },
        "positive case: $_"
    ) for qw(
                https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-darwin-amd64.tar.gz
                https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-amd64.tar.gz
        );

    is(looks_like_url_of_skaji_relocatable_perl($_), F(), "negative case: $_")
        for qw(
                  https://example.com/
                  https://gugod.org/
                  https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-x86_64.tar.gz
          );
};

subtest "looks_like_sys_would_be_compatible_with_skaji_relocatable_perl", sub {
    my $detail = looks_like_url_of_skaji_relocatable_perl("https://github.com/skaji/relocatable-perl/releases/download/5.40.0.0/perl-linux-amd64.tar.gz");

    my @positiveCases = (
        (mock {} =>
            add => [
                os => sub { "linux" },
                arch => sub { "amd64" },
            ]),
        (mock {} =>
            add => [
                os => sub { "linux" },

t/util-looks-like.t  view on Meta::CPAN

                arch => sub { "aarch64" },
            ]),
        (mock {} =>
            add => [
                os => sub { "darwin" },
                arch => sub { "x86_64" },
            ]),
    );


    is looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $_), T()
        for @positiveCases;

    is looks_like_sys_would_be_compatible_with_skaji_relocatable_perl($detail, $_), F()
        for @negativeCasse;
};

done_testing;



( run in 1.570 second using v1.01-cache-2.11-cpan-71847e10f99 )