Skip to content
Browse files

Merge branch 'release/0.75'

  • Loading branch information...
2 parents acb35f8 + b389f8c commit a6318f9847a9fc1ea138212e165a40839a0a5f63 @gugod committed Mar 16, 2016
Showing with 458 additions and 440 deletions.
  1. +1 −0 .travis.yml
  2. +8 −0 Changes
  3. +1 −1 LICENSE
  4. +2 −0 Makefile.PL
  5. +143 −208 README
  6. +2 −5 README.md
  7. +11 −5 bin/perlbrew
  8. +2 −2 doc/MIT-LICENSE
  9. +84 −107 lib/App/perlbrew.pm
  10. +95 −112 perlbrew
  11. +109 −0 t/12.destdir.t
View
1 .travis.yml
@@ -1,6 +1,7 @@
sudo: false
language: perl
perl:
+ - "5.22"
- "5.20"
- "5.20-shrplib"
- "5.18"
View
8 Changes
@@ -1,3 +1,11 @@
+0.75: # 2016-03-16T23:41:41+0100
+- Thanks to our contributors: Dave Cross, Dean Hamstead, Mark J. Reed, Mohammed El-Afifi,
+- Add '--no-patchperl' install option for skip running patchperl.
+- Add '--destdir' install option.
+- "uninstall" command now also delete associated libs.
+- "mirror" command is removed.
+- "config" command is removed.
+
0.74: # 2015-11-24T20:55:02+0100
- A big thanks for our contributers: Aristotle Pagaltzis, Dave Jacoby, Dylan Cali, John Krull, Kevin Johnson, Nathan Day, Paul Cochrane, Tudor Constantin, Yanick Champoux, tm604
- support PERLBREW_LIB_PREFIX. https://github.com/gugod/App-perlbrew/commit/c29813cd4633683bd049964178a9ac96647986bc
View
2 LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2010,2011,2012,2013 Kang-min Liu
+Copyright (c) 2010-2016 Kang-min Liu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
2 Makefile.PL
@@ -4,6 +4,8 @@ license 'mit';
all_from 'lib/App/perlbrew.pm';
+abstract 'App::perlbrew - Manage perl installations in your $HOME';
+
repository 'git://github.com/gugod/App-perlbrew.git';
requires
View
351 README
@@ -1,236 +1,171 @@
-Name:
- App::perlbrew - Manage perl installations in your $HOME
+# NAME
- Synopsis:
- # Installation
- curl -L http://install.perlbrew.pl | bash
+[App::perlbrew](https://metacpan.org/pod/App::perlbrew) - Manage perl installations in your `$HOME`
- # Initialize
- perlbrew init
+## SYNOPSIS
- # Pick a preferred CPAN mirror
- perlbrew mirror
+ # Installation
+ curl -L http://install.perlbrew.pl | bash
- # See what is available
- perlbrew available
+ # Initialize
+ perlbrew init
- # Install some Perls
- perlbrew install 5.18.2
- perlbrew install perl-5.8.1
- perlbrew install perl-5.19.9
+ # See what is available
+ perlbrew available
- # See what were installed
- perlbrew list
+ # Install some Perls
+ perlbrew install 5.18.2
+ perlbrew install perl-5.8.1
+ perlbrew install perl-5.19.9
- # Swith to an installation and set it as default
- perlbrew switch perl-5.18.2
+ # See what were installed
+ perlbrew list
- # Temporarily use another version only in current shell.
- perlbrew use perl-5.8.1
- perl -v
+ # Swith to an installation and set it as default
+ perlbrew switch perl-5.18.2
- # Or turn it off completely. Useful when you messed up too deep.
- # Or want to go back to the system Perl.
- perlbrew off
+ # Temporarily use another version only in current shell.
+ perlbrew use perl-5.8.1
+ perl -v
- # Use 'switch' command to turn it back on.
- perlbrew switch perl-5.12.2
+ # Or turn it off completely. Useful when you messed up too deep.
+ # Or want to go back to the system Perl.
+ perlbrew off
- # Exec something with all perlbrew-ed perls
- perlbrew exec -- perl -E 'say $]'
+ # Use 'switch' command to turn it back on.
+ perlbrew switch perl-5.12.2
- Description:
- perlbrew is a program to automate the building and installation of perl
- in an easy way. It provides multiple isolated perl environments, and a
- mechanism for you to switch between them.
+ # Exec something with all perlbrew-ed perls
+ perlbrew exec -- perl -E 'say $]'
- Everything are installed unter "~/perl5/perlbrew". You then need to
- include a bashrc/cshrc provided by perlbrew to tweak the PATH for you.
- You then can benefit from not having to run "sudo" commands to install
- cpan modules because those are installed inside your "HOME" too.
+## DESCRIPTION
- For the documentation of perlbrew usage see perlbrew command on MetaCPAN
- <https://metacpan.org/>, or by running "perlbrew help", or by visiting
- perlbrew's official website <http://perlbrew.pl/>. The following
- documentation features the API of "App::perlbrew" module, and may not be
- remotely close to what your want to read.
+[perlbrew](https://metacpan.org/pod/perlbrew) is a program to automate the building and installation of perl in an
+easy way. It provides multiple isolated perl environments, and a mechanism
+for you to switch between them.
- Installation:
- It is the simplest to use the perlbrew installer, just paste this
- statement to your terminal:
+Everything are installed unter `~/perl5/perlbrew`. You then need to include a
+bashrc/cshrc provided by perlbrew to tweak the PATH for you. You then can
+benefit from not having to run `sudo` commands to install
+cpan modules because those are installed inside your `HOME` too.
- curl -L http://install.perlbrew.pl | bash
+For the documentation of perlbrew usage see [perlbrew](https://metacpan.org/pod/perlbrew) command
+on [MetaCPAN](https://metacpan.org/), or by running `perlbrew help`,
+or by visiting [perlbrew's official website](http://perlbrew.pl/). The following documentation
+features the API of `App::perlbrew` module, and may not be remotely
+close to what your want to read.
- Or this one, if you have "fetch" (default on FreeBSD):
+## INSTALLATION
- fetch -o- http://install.perlbrew.pl | sh
+It is the simplest to use the perlbrew installer, just paste this statement to
+your terminal:
- After that, "perlbrew" installs itself to "~/perl5/perlbrew/bin", and
- you should follow the instruction on screen to modify your shell rc file
- to put it in your PATH.
+ curl -L http://install.perlbrew.pl | bash
- The installed perlbrew command is a standalone executable that can be
- run with system perl. The minimum system perl version requirement is
- 5.8.0, which should be good enough for most of the OSes these days.
+Or this one, if you have `fetch` (default on FreeBSD):
- A fat-packed version of patchperl is also installed to
- "~/perl5/perlbrew/bin", which is required to build old perls.
+ fetch -o- http://install.perlbrew.pl | sh
- The directory "~/perl5/perlbrew" will contain all install perl
- executables, libraries, documentations, lib, site_libs. In the
- documentation, that directory is referred as "perlbrew root". If you
- need to set it to somewhere else because, say, your "HOME" has limited
- quota, you can do that by setting "PERLBREW_ROOT" environment variable
- before running the installer:
+After that, `perlbrew` installs itself to `~/perl5/perlbrew/bin`, and you
+should follow the instruction on screen to modify your shell rc file to put it
+in your PATH.
- export PERLBREW_ROOT=/opt/perl5
- curl -L http://install.perlbrew.pl | bash
-
- As a result, different users on the same machine can all share the same
- perlbrew root directory (although only original user that made the
- installation would have the permission to perform perl installations.)
-
- You may also install perlbrew from CPAN:
-
- cpan App::perlbrew
-
- In this case, the perlbrew command is installed as "/usr/bin/perlbrew"
- or "/usr/local/bin/perlbrew" or others, depending on the location of
- your system perl installation.
-
- Please make sure not to run this with one of the perls brewed with
- perlbrew. It's the best to turn perlbrew off before you run that, if
- you're upgrading.
+The installed perlbrew command is a standalone executable that can be run with
+system perl. The minimum system perl version requirement is 5.8.0, which should
+be good enough for most of the OSes these days.
- perlbrew off
- cpan App::perlbrew
+A fat-packed version of [patchperl](https://metacpan.org/pod/patchperl) is also installed to
+`~/perl5/perlbrew/bin`, which is required to build old perls.
- You should always use system cpan (like /usr/bin/cpan) to install
- "App::perlbrew" because it will be installed under a system PATH like
- "/usr/bin", which is not affected by perlbrew "switch" or "use" command.
+The directory `~/perl5/perlbrew` will contain all install perl executables,
+libraries, documentations, lib, site\_libs. In the documentation, that directory
+is referred as `perlbrew root`. If you need to set it to somewhere else because,
+say, your `HOME` has limited quota, you can do that by setting `PERLBREW_ROOT`
+environment variable before running the installer:
- The "self-upgrade" command will not upgrade the perlbrew installed by
- cpan command, but it is also easy to upgrade perlbrew by running "cpan
- App::perlbrew" again.
+ export PERLBREW_ROOT=/opt/perl5
+ curl -L http://install.perlbrew.pl | bash
- Methods:
- (Str) current_perl
- Return the "current perl" object attribute string, or, if absent,
- the value of "PERLBREW_PERL" environment variable.
-
- (Str) current_perl (Str)
- Set the "current_perl" object attribute to the given value.
-
- Project Development:
- perlbrew project <http://perlbrew.pl/> uses github
- <http://github.com/gugod/App-perlbrew/issues> and RT
- <https://rt.cpan.org/Dist/Display.html?Queue=App-perlbrew> for issue
- tracking. Issues sent to these two systems will eventually be reviewed
- and handled.
-
- See <https://github.com/gugod/App-perlbrew/contributors> for a list of
- project contributors.
-
-Configuration:
- PERLBREW_ROOT
- By default, perlbrew builds and installs perls into
- "$ENV{HOME}/perl5/perlbrew" directory. To use a different directory,
- set this environment variable in your "bashrc" to the directory in
- your shell RC before sourcing perlbrew's RC.
-
- It is possible to share one perlbrew root with multiple user account
- on the same machine. Therefore people do not have to install the
- same version of perl over an over. Let's say "/opt/perl5" is the
- directory we want to share. All users should be able append this
- snippet to their bashrc to make it effective:
-
- export PERLBREW_ROOT=/opt/perl5
- source ${PERLBREW_ROOT}/etc/bashrc
-
- After doing so, everyone's PATH should include "/opt/perl5/bin" and
- "/opt/perl5/perls/${PERLBREW_PERL}/bin". Each user can invoke
- "perlbrew switch" and "perlbrew use" to independently switch to
- different perl environment of their choice. However, only the user
- with write permission to $PERLBREW_ROOT may install CPAN modules.
- This is both good and bad depending on the working convention of
- your team.
-
- If you wish to install CPAN modules only for yourself, you should
- use the "lib" command to construct a personal local::lib
- environment. local::lib environments are personal, and are not
- shared between different users. For more detail, read "perlbrew help
- lib" and the documentation of local::lib.
-
- If you want even a cooler module isolation and wish to install CPAN
- modules used for just one project, you should use carton for this
- purpose.
-
- It is also possible to set this variable before installing perlbrew
- to make perlbrew install itself under the given PERLBREW_ROOT:
-
- export PERLBREW_ROOT=/opt/perl5
- curl -kL http://install.perlbrew.pl | bash
-
- After doing this, the perlbrew executable is installed as
- "/opt/perl5/bin/perlbrew"
-
- PERLBREW_HOME
- By default, perlbrew stores per-user setting to
- "$ENV{HOME}/.perlbrew" directory. To use a different directory, set
- this environment variable in your shell RC before sourcing
- perlbrew's RC.
-
- In some cases, say, your home directory is on NFS and shared across
- multiple machines, you may wish to have several different perlbrew
- setting per-machine. To do so, you can use the "PERLBREW_HOME"
- environment variable to tell perlbrew where to look for the
- initialization file. Here's a brief bash snippet for the given
- scenario.
-
- if [ "$(hostname)" == "machine-a" ]; then
- export PERLBREW_HOME=~/.perlbrew-a
- elif [ "$(hostname)" == "machine-b" ]; then
- export PERLBREW_HOME=~/.perlbrew-b
- fi
-
- source ~/perl5/perlbrew/etc/bashrc
-
- PERLBREW_CONFIGURE_FLAGS
- This environment variable specify the list of command like flags to
- pass through to 'sh Configure'. By default it is '-de'.
-
- PERLBREW_CPAN_MIRROR
- The CPAN mirror url of your choice.
-
-Author:
- Kang-min Liu "<gugod@gugod.org>"
-
-Copyright:
- Copyright (c) 2010,2011,2012,2013,2014,2015 Kang-min Liu
- "<gugod@gugod.org>".
-
- Licence:
- The MIT License
-
- Disclaimer of Warranty:
- BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
- EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
- ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
- YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
- NECESSARY SERVICING, REPAIR, OR CORRECTION.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
- TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
- CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
- SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
- RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
- FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
- SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- DAMAGES.
+As a result, different users on the same machine can all share the same perlbrew
+root directory (although only original user that made the installation would
+have the permission to perform perl installations.)
+You may also install perlbrew from CPAN:
+
+ cpan App::perlbrew
+
+In this case, the perlbrew command is installed as `/usr/bin/perlbrew` or
+`/usr/local/bin/perlbrew` or others, depending on the location of your system
+perl installation.
+
+Please make sure not to run this with one of the perls brewed with
+perlbrew. It's the best to turn perlbrew off before you run that, if you're
+upgrading.
+
+ perlbrew off
+ cpan App::perlbrew
+
+You should always use system cpan (like /usr/bin/cpan) to install
+`App::perlbrew` because it will be installed under a system PATH like
+`/usr/bin`, which is not affected by perlbrew `switch` or `use` command.
+
+The `self-upgrade` command will not upgrade the perlbrew installed by cpan
+command, but it is also easy to upgrade perlbrew by running `cpan App::perlbrew`
+again.
+
+## METHODS
+
+- (Str) current\_perl
+
+ Return the "current perl" object attribute string, or, if absent, the value of
+ `PERLBREW_PERL` environment variable.
+
+- (Str) current\_perl (Str)
+
+ Set the `current_perl` object attribute to the given value.
+
+## PROJECT DEVELOPMENT
+
+[perlbrew project](http://perlbrew.pl/) uses github
+[http://github.com/gugod/App-perlbrew/issues](http://github.com/gugod/App-perlbrew/issues) and RT
+<https://rt.cpan.org/Dist/Display.html?Queue=App-perlbrew> for issue
+tracking. Issues sent to these two systems will eventually be reviewed
+and handled.
+
+See [https://github.com/gugod/App-perlbrew/contributors](https://github.com/gugod/App-perlbrew/contributors) for a list
+of project contributors.
+
+# AUTHOR
+
+Kang-min Liu `<gugod@gugod.org>`
+
+# COPYRIGHT
+
+Copyright (c) 2010-2016 Kang-min Liu `<gugod@gugod.org>`.
+
+### LICENCE
+
+The MIT License
+
+## DISCLAIMER OF WARRANTY
+
+BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
+THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
View
7 README.md
@@ -10,9 +10,6 @@
# Initialize
perlbrew init
- # Pick a preferred CPAN mirror
- perlbrew mirror
-
# See what is available
perlbrew available
@@ -53,7 +50,7 @@ benefit from not having to run `sudo` commands to install
cpan modules because those are installed inside your `HOME` too.
For the documentation of perlbrew usage see [perlbrew](https://metacpan.org/pod/perlbrew) command
-on [MetaCPAN](https://metacpan.org/), or by running `perlbrew help`,
+on [MetaCPAN](https://metacpan.org/), or by running `perlbrew help`,
or by visiting [perlbrew's official website](http://perlbrew.pl/). The following documentation
features the API of `App::perlbrew` module, and may not be remotely
close to what your want to read.
@@ -144,7 +141,7 @@ Kang-min Liu `<gugod@gugod.org>`
# COPYRIGHT
-Copyright (c) 2010,2011,2012,2013,2014,2015 Kang-min Liu `<gugod@gugod.org>`.
+Copyright (c) 2010-2016 Kang-min Liu `<gugod@gugod.org>`.
### LICENCE
View
16 bin/perlbrew
@@ -96,7 +96,7 @@ It is also possible to set this variable before installing perlbrew
to make perlbrew install itself under the given PERLBREW_ROOT:
export PERLBREW_ROOT=/opt/perl5
- curl -kL http://install.perlbrew.pl | bash
+ curl -L http://install.perlbrew.pl | bash
After doing this, the perlbrew executable is installed as C</opt/perl5/bin/perlbrew>
@@ -127,7 +127,7 @@ to 'sh Configure'. By default it is '-de'.
=item PERLBREW_CPAN_MIRROR
-The CPAN mirror url of your choice.
+The CPAN mirror url of your choice. The default value is "http://www.cpan.org"
=back
@@ -226,9 +226,14 @@ Options for C<install> command:
--ld Build perl with uselongdouble enabled
--debug Build perl with DEBUGGING enabled
--clang Build perl using the clang compiler
+ --no-patchperl
+ Skip calling patchperl
-D,-U,-A Switches passed to perl Configure script.
- ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U uselargefiles>
+ ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U versiononly>
+
+ --destdir $path
+ Install perl as per 'make install DESTDIR=$path'
--sitecustomize $filename
Specify a file to be installed as sitecustomize.pl
@@ -290,7 +295,8 @@ Another example using custom compilation flags:
Usage: perlbrew uninstall <name>
Uninstalls the given perl installation. The name is the installation name as in
-the output of `perlbrew list`
+the output of `perlbrew list`. This effectively deletes the specified perl installation,
+and all libs associated with it.
=head1 COMMAND: USE
@@ -497,7 +503,7 @@ This command install perlbrew itself to C<$PERLBREW_ROOT/bin>. It is intended to
be used by the perlbrew installer. However, you could manually do the following
to re-install only the C<perlbrew> executable:
- curl -kL http://get.perlbrew.pl -o perlbrew
+ curl https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew -o perlbrew
perl ./perlbrew self-install
It is slightly different from running the perlbrew installer because
View
4 doc/MIT-LICENSE
@@ -1,6 +1,6 @@
-The MIT License
+nThe MIT License
-Copyright (c) 2010 Kang-mil Liu
+Copyright (c) 2010-2016 Kang-mil Liu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
191 lib/App/perlbrew.pm
@@ -2,7 +2,7 @@ package App::perlbrew;
use strict;
use warnings;
use 5.008;
-our $VERSION = "0.74";
+our $VERSION = "0.75";
use Config;
BEGIN {
@@ -19,7 +19,7 @@ BEGIN {
@INC = @oldinc;
}
-use File::Glob ':glob';
+use File::Glob 'bsd_glob';
use Getopt::Long ();
sub min(@) {
@@ -142,7 +142,7 @@ sub files_are_the_same {
fetch => {
test => '--version >/dev/null 2>&1',
get => '-o - {url}',
- download => '{url}',
+ download => '-o {output} {url}',
order => 3,
}
);
@@ -281,10 +281,11 @@ sub new {
U => [],
A => [],
sitecustomize => '',
+ destdir => '',
noman => '',
variation => '',
both => [],
- append => '',
+ append => '',
);
$opt{$_} = '' for keys %flavor;
@@ -324,9 +325,9 @@ sub parse_cmdline {
return Getopt::Long::GetOptions(
$params,
- 'force|f!',
- 'notest|n!',
- 'quiet|q!',
+ 'force|f',
+ 'notest|n',
+ 'quiet|q',
'verbose|v',
'as=s',
'append=s',
@@ -336,6 +337,7 @@ sub parse_cmdline {
'switch',
'all',
'shell=s',
+ 'no-patchperl',
# options passed directly to Configure
'D=s@',
@@ -345,6 +347,7 @@ sub parse_cmdline {
'j=i',
# options that affect Configure and customize post-build
'sitecustomize=s',
+ 'destdir=s',
'noman',
# flavors support
@@ -367,6 +370,16 @@ sub root {
return $self->{root} || $PERLBREW_ROOT;
}
+sub home {
+ my ($self, $new_home) = @_;
+
+ if (defined($new_home)) {
+ $self->{home} = $new_home;
+ }
+
+ return $self->{home} || $PERLBREW_HOME;
+}
+
sub current_perl {
my ($self, $v) = @_;
$self->{current_perl} = $v if $v;
@@ -704,13 +717,15 @@ sub available_perls {
sub perl_release {
my ($self, $version) = @_;
+ my $mirror = $self->cpan_mirror();
+
# try src/5.0 symlinks, either perl-5.X or perl5.X; favor .tar.bz2 over .tar.gz
my $index = http_get("http://www.cpan.org/src/5.0/");
if ($index) {
for my $prefix ( "perl-", "perl" ){
for my $suffix ( ".tar.bz2", ".tar.gz" ) {
my $dist_tarball = "$prefix$version$suffix";
- my $dist_tarball_url = $self->cpan_mirror() . "/src/5.0/$dist_tarball";
+ my $dist_tarball_url = "$mirror/src/5.0/$dist_tarball";
return ( $dist_tarball, $dist_tarball_url )
if ( $index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms );
}
@@ -725,14 +740,11 @@ sub perl_release {
if ($x) {
my $dist_tarball = (split("/", $x))[-1];
- my $dist_tarball_url = $self->cpan_mirror() . "/authors/id/$x";
+ my $dist_tarball_url = "$mirror/authors/id/$x";
return ($dist_tarball, $dist_tarball_url);
}
- # try to find it on search.cpan.org
- my $mirror = $self->config->{mirror};
- my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
- my $html = http_get("http://search.cpan.org/dist/perl-${version}", $header);
+ my $html = http_get("http://search.cpan.org/dist/perl-${version}", { 'Cookie' => "cpan=$mirror" });
unless ($html) {
die "ERROR: Failed to locate perl-${version} tarball.";
@@ -808,10 +820,10 @@ sub run_command_init {
}
my $root_dir = $self->path_with_tilde($self->root);
- my $pb_home_dir = $self->path_with_tilde($PERLBREW_HOME);
+ my $pb_home_dir = $self->path_with_tilde($self->home);
my $code = qq( source $root_dir/etc/${shrc});
- if ($PERLBREW_HOME ne joinpath($self->env('HOME'), ".perlbrew")) {
+ if ($self->home ne joinpath($self->env('HOME'), ".perlbrew")) {
$code = " export PERLBREW_HOME=$pb_home_dir\n" . $code;
}
@@ -1212,7 +1224,7 @@ sub run_command_download {
sub purify {
my ($self, $envname) = @_;
- my @paths = grep { index($_, $PERLBREW_HOME) < 0 && index($_, $self->root) < 0 } split /:/, $self->env($envname);
+ my @paths = grep { index($_, $self->home) < 0 && index($_, $self->root) < 0 } split /:/, $self->env($envname);
return wantarray ? @paths : join(":", @paths);
}
@@ -1293,6 +1305,7 @@ sub do_install_this {
my @u_options = @{ $self->{U} };
my @a_options = @{ $self->{A} };
my $sitecustomize = $self->{sitecustomize};
+ my $destdir = $self->{destdir};
$installation_name = $self->{as} if $self->{as};
$installation_name .= "$variation$append";
@@ -1312,8 +1325,8 @@ sub do_install_this {
$self->{$flavor} and push @d_options, $flavor{$flavor}{d_option}
}
- my $perlpath = $self->root . "/perls/$installation_name";
- my $patchperl = $self->root . "/bin/patchperl";
+ my $perlpath = joinpath($self->root, "perls", $installation_name);
+ my $patchperl = joinpath($self->root, "bin", "patchperl");
unless (-x $patchperl && -f _) {
$patchperl = "patchperl";
@@ -1343,8 +1356,8 @@ INSTALL
my @preconfigure_commands = (
"cd $dist_extracted_dir",
"rm -f config.sh Policy.sh",
- $patchperl,
);
+ push @preconfigure_commands, $patchperl unless $self->{"no-patchperl"};
my $configure_flags = $self->env("PERLBREW_CONFIGURE_FLAGS") || '-de';
@@ -1376,7 +1389,9 @@ INSTALL
local $ENV{TEST_JOBS}=$self->{j}
if $test_target eq "test_harness" && ($self->{j}||1) > 1;
- my @install_commands = $self->{notest} ? "make install" : ("make $test_target", "make install");
+ my @install_commands = ("make install" . ($destdir ? " DESTDIR=$destdir" : q||));
+ unshift @install_commands, "make $test_target" unless $self->{notest};
+ # Whats happening here? we optionally join with && based on $self->{force}, but then subsequently join with && anyway?
@install_commands = join " && ", @install_commands unless($self->{force});
my $cmd = join " && ",
@@ -1396,7 +1411,7 @@ INSTALL
$cmd = "($cmd) >> '$self->{log_file}' 2>&1 ";
}
- delete $ENV{$_} for qw(PERL5LIB PERL5OPT);
+ delete $ENV{$_} for qw(PERL5LIB PERL5OPT AWKPATH);
if ($self->do_system($cmd)) {
my $newperl = joinpath($self->root, "perls", $installation_name, "bin", "perl");
@@ -1408,7 +1423,11 @@ INSTALL
if ( $sitecustomize ) {
my $capture = $self->do_capture("$newperl -V:sitelib");
- my ($sitelib) = $capture =~ /sitelib='(.*)';/;
+ my ($sitelib) = $capture =~ m/sitelib='([^']*)';/;
+ # This should probably all use File::Path
+ if ($destdir) {
+ $sitelib = $destdir . $sitelib
+ }
mkpath($sitelib) unless -d $sitelib;
my $target = "$sitelib/sitecustomize.pl";
open my $dst, ">", $target
@@ -1438,7 +1457,7 @@ INSTALL
sub do_install_program_from_url {
my ($self, $url, $program_name, $body_filter) = @_;
- my $out = $self->root . "/bin/" . $program_name;
+ my $out = joinpath($self->root, "bin", $program_name);
if (-f $out && !$self->{force}) {
require ExtUtils::MakeMaker;
@@ -1518,10 +1537,10 @@ sub installed_perls {
my @result;
my $root = $self->root;
- for (<$root/perls/*>) {
- my ($name) = $_ =~ m/\/([^\/]+$)/;
- my $executable = joinpath($_, 'bin', 'perl');
- my $version_file = joinpath($_,'.version');
+ for my $installation_dir (<$root/perls/*>) {
+ my ($name) = $installation_dir =~ m/\/([^\/]+$)/;
+ my $executable = joinpath($installation_dir, 'bin', 'perl');
+ my $version_file = joinpath($installation_dir,'.version');
my $orig_version;
if ( -e $version_file ){
open my $fh, '<', $version_file;
@@ -1543,7 +1562,8 @@ sub installed_perls {
version => $self->format_perl_version($orig_version),
is_current => ($self->current_perl eq $name) && !($self->current_lib),
libs => [ $self->local_libs($name) ],
- executable => $executable
+ executable => $executable,
+ dir => $installation_dir,
};
}
@@ -1553,24 +1573,21 @@ sub installed_perls {
sub local_libs {
my ($self, $perl_name) = @_;
- my @libs = map { substr($_, length($PERLBREW_HOME) + 6) } bsd_glob("$PERLBREW_HOME/libs/*");
-
- if ($perl_name) {
- @libs = grep { /^$perl_name\@/ } @libs;
- }
-
my $current = $self->current_perl . '@' . ($self->env("PERLBREW_LIB") || '');
-
- @libs = map {
- my ($p, $l) = split(/@/, $_);
-
+ my @libs = map {
+ my $name = substr($_, length($self->home) + 6);
+ my ($p, $l) = split(/@/, $name);
+{
- name => $_,
- is_current => $_ eq $current,
+ name => $name,
+ is_current => $name eq $current,
perl_name => $p,
- lib_name => $l
+ lib_name => $l,
+ dir => $_,
}
- } @libs;
+ } bsd_glob(joinpath($self->home, "libs", "*"));
+ if ($perl_name) {
+ @libs = grep { $perl_name eq $_->{perl_name} } @libs;
+ }
return @libs;
}
@@ -1611,10 +1628,11 @@ sub perlbrew_env {
);
require local::lib;
+ my $pb_home = $self->home;
my $current_local_lib_root = $self->env("PERL_LOCAL_LIB_ROOT") || "";
my $current_local_lib_context = local::lib->new;
- my @perlbrew_local_lib_root = uniq(grep { /\Q${PERLBREW_HOME}\E/ } split(/:/, $current_local_lib_root));
- if ($current_local_lib_root =~ /^\Q$PERLBREW_HOME\E/) {
+ my @perlbrew_local_lib_root = uniq(grep { /\Q${pb_home}\E/ } split(/:/, $current_local_lib_root));
+ if ($current_local_lib_root =~ /^\Q${pb_home}\E/) {
$current_local_lib_context = $current_local_lib_context->activate($_) for @perlbrew_local_lib_root;
}
@@ -1628,7 +1646,7 @@ sub perlbrew_env {
if ($lib_name) {
$current_local_lib_context = $current_local_lib_context->deactivate($_) for @perlbrew_local_lib_root;
- my $base = "$PERLBREW_HOME/libs/${perl_name}\@${lib_name}";
+ my $base = joinpath($self->home, "libs", "${perl_name}\@${lib_name}");
if (-d $base) {
$current_local_lib_context = $current_local_lib_context->activate($base);
@@ -1784,7 +1802,7 @@ sub switch_to {
if ($self->env("PERLBREW_BASHRC_VERSION")) {
local $ENV{PERLBREW_PERL} = $dist;
my $HOME = $self->env('HOME');
- my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
+ my $pb_home = $self->home;
mkpath($pb_home);
system("$0 env $dist > " . joinpath($pb_home, "init"));
@@ -1803,7 +1821,7 @@ sub run_command_off {
sub run_command_switch_off {
my $self = shift;
- my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
+ my $pb_home = $self->home;
mkpath($pb_home);
system("env PERLBREW_PERL= $0 env > " . joinpath($pb_home, "init"));
@@ -1896,7 +1914,7 @@ sub run_command_self_upgrade {
die "Your perlbrew installation appears to be system-wide. Please upgrade through your package manager.\n";
}
- http_get('http://get.perlbrew.pl', undef, sub {
+ http_get('https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew', undef, sub {
my ( $body ) = @_;
open my $fh, '>', $TMP_PERLBREW or die "Unable to write perlbrew: $!";
@@ -1928,16 +1946,21 @@ sub run_command_uninstall {
exit(-1);
}
- my $dir = "@{[ $self->root ]}/perls/$target";
+ my @installed = $self->installed_perls(@_);
+
+ my ($to_delete) = grep { $_->{name} eq $target } @installed;
+
+ die "'$target' is not installed\n" unless $to_delete;
- if (-l $dir) {
- die "\nThe given name `$target` is an alias, not a real installation. Cannot perform uninstall.\nTo delete the alias, run:\n\n perlbrew alias delete $target\n\n";
+ my @dir_to_delete;
+ for (@{$to_delete->{libs}}) {
+ push @dir_to_delete, $_->{dir};
}
+ push @dir_to_delete, $to_delete->{dir};
- unless(-d $dir) {
- die "'$target' is not installed\n";
+ for (@dir_to_delete) {
+ rmpath($_);
}
- exec 'rm', '-rf', $dir;
}
sub run_command_exec {
@@ -1976,7 +1999,7 @@ sub run_command_exec {
my $overall_success = 1;
for my $i ( @exec_with ) {
- next if -l $self->root . '/perls/' . $i->{name}; # Skip Aliases
+ next if -l joinpath($self->root, 'perls', $i->{name}); # Skip Aliases
my %env = $self->perlbrew_env($i->{name});
next if !$env{PERLBREW_PERL};
@@ -2129,7 +2152,7 @@ sub run_command_lib_create {
}
my $fullname = $perl_name . '@' . $lib_name;
- my $dir = joinpath($PERLBREW_HOME, "libs", $fullname);
+ my $dir = joinpath($self->home, "libs", $fullname);
if (-d $dir) {
die "$fullname is already there.\n";
@@ -2156,7 +2179,7 @@ sub run_command_lib_delete {
my $current = $self->current_perl . '@' . $self->current_lib;
- my $dir = joinpath($PERLBREW_HOME, "libs", $fullname);
+ my $dir = joinpath($self->home, "libs", $fullname);
if (-d $dir) {
@@ -2178,7 +2201,7 @@ sub run_command_lib_delete {
sub run_command_lib_list {
my ($self) = @_;
- my $dir = joinpath($PERLBREW_HOME, "libs");
+ my $dir = joinpath($self->home, "libs");
return unless -d $dir;
opendir my $dh, $dir or die "open $dir failed: $!";
@@ -2247,7 +2270,7 @@ sub run_command_upgrade_perl {
$value_wo_D =~ s/^-D//;
push @{$self->{D}} , $value_wo_D if grep {/$value/} @d_options;
}
-
+
$self->do_install_release($dist, $dist_version);
}
@@ -2323,49 +2346,6 @@ sub run_command_info {
print $self->format_info_output(@_);
}
-
-sub config {
- my($self) = @_;
- $self->_load_config if ! $CONFIG;
- return $CONFIG;
-}
-
-sub config_file {
- my ($self) = @_;
- joinpath( $self->root, 'Config.pm' );
-}
-
-sub _save_config {
- my($self) = @_;
- require Data::Dumper;
- open my $FH, '>', $self->config_file or die "Unable to open config (@{[ $self->config_file ]}): $!";
- my $d = Data::Dumper->new([$CONFIG],['App::perlbrew::CONFIG']);
- print $FH $d->Dump;
- close $FH;
-}
-
-sub _load_config {
- my($self) = @_;
-
- if ( ! -e $self->config_file ) {
- local $CONFIG = {} if ! $CONFIG;
- $self->_save_config;
- }
-
- open my $FH, '<', $self->config_file or die "Unable to open config (@{[ $self->config_file ]}): $!\n";
- my $raw = do { local $/; my $rv = <$FH>; $rv };
- close $FH;
-
- my $rv = eval $raw;
- if ( $@ ) {
- warn "Error loading conf: $@\n";
- $CONFIG = {};
- return;
- }
- $CONFIG = {} if ! $CONFIG;
- return;
-}
-
sub BASHRC_CONTENT() {
return "export PERLBREW_BASHRC_VERSION=$VERSION\n" .
(exists $ENV{PERLBREW_ROOT} ? "export PERLBREW_ROOT=$PERLBREW_ROOT\n" : "") . "\n" . <<'RC';
@@ -2868,9 +2848,6 @@ L<App::perlbrew> - Manage perl installations in your C<$HOME>
# Initialize
perlbrew init
- # Pick a preferred CPAN mirror
- perlbrew mirror
-
# See what is available
perlbrew available
@@ -2911,7 +2888,7 @@ benefit from not having to run C<sudo> commands to install
cpan modules because those are installed inside your C<HOME> too.
For the documentation of perlbrew usage see L<perlbrew> command
-on L<MetaCPAN|https://metacpan.org/>, or by running C<perlbrew help>,
+on L<MetaCPAN|https://metacpan.org/>, or by running C<perlbrew help>,
or by visiting L<perlbrew's official website|http://perlbrew.pl/>. The following documentation
features the API of C<App::perlbrew> module, and may not be remotely
close to what your want to read.
@@ -3006,7 +2983,7 @@ Kang-min Liu C<< <gugod@gugod.org> >>
=head1 COPYRIGHT
-Copyright (c) 2010,2011,2012,2013,2014,2015 Kang-min Liu C<< <gugod@gugod.org> >>.
+Copyright (c) 2010-2016 Kang-min Liu C<< <gugod@gugod.org> >>.
=head3 LICENCE
View
207 perlbrew
@@ -19,7 +19,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
use strict;
use warnings;
use 5.008;
- our $VERSION = "0.74";
+ our $VERSION = "0.75";
use Config;
BEGIN {
@@ -36,7 +36,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
@INC = @oldinc;
}
- use File::Glob ':glob';
+ use File::Glob 'bsd_glob';
use Getopt::Long ();
sub min(@) {
@@ -159,7 +159,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
fetch => {
test => '--version >/dev/null 2>&1',
get => '-o - {url}',
- download => '{url}',
+ download => '-o {output} {url}',
order => 3,
}
);
@@ -298,10 +298,11 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
U => [],
A => [],
sitecustomize => '',
+ destdir => '',
noman => '',
variation => '',
both => [],
- append => '',
+ append => '',
);
$opt{$_} = '' for keys %flavor;
@@ -341,9 +342,9 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
return Getopt::Long::GetOptions(
$params,
- 'force|f!',
- 'notest|n!',
- 'quiet|q!',
+ 'force|f',
+ 'notest|n',
+ 'quiet|q',
'verbose|v',
'as=s',
'append=s',
@@ -353,6 +354,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
'switch',
'all',
'shell=s',
+ 'no-patchperl',
# options passed directly to Configure
'D=s@',
@@ -362,6 +364,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
'j=i',
# options that affect Configure and customize post-build
'sitecustomize=s',
+ 'destdir=s',
'noman',
# flavors support
@@ -384,6 +387,16 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
return $self->{root} || $PERLBREW_ROOT;
}
+ sub home {
+ my ($self, $new_home) = @_;
+
+ if (defined($new_home)) {
+ $self->{home} = $new_home;
+ }
+
+ return $self->{home} || $PERLBREW_HOME;
+ }
+
sub current_perl {
my ($self, $v) = @_;
$self->{current_perl} = $v if $v;
@@ -721,13 +734,15 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub perl_release {
my ($self, $version) = @_;
+ my $mirror = $self->cpan_mirror();
+
# try src/5.0 symlinks, either perl-5.X or perl5.X; favor .tar.bz2 over .tar.gz
my $index = http_get("http://www.cpan.org/src/5.0/");
if ($index) {
for my $prefix ( "perl-", "perl" ){
for my $suffix ( ".tar.bz2", ".tar.gz" ) {
my $dist_tarball = "$prefix$version$suffix";
- my $dist_tarball_url = $self->cpan_mirror() . "/src/5.0/$dist_tarball";
+ my $dist_tarball_url = "$mirror/src/5.0/$dist_tarball";
return ( $dist_tarball, $dist_tarball_url )
if ( $index =~ /href\s*=\s*"\Q$dist_tarball\E"/ms );
}
@@ -742,14 +757,11 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
if ($x) {
my $dist_tarball = (split("/", $x))[-1];
- my $dist_tarball_url = $self->cpan_mirror() . "/authors/id/$x";
+ my $dist_tarball_url = "$mirror/authors/id/$x";
return ($dist_tarball, $dist_tarball_url);
}
- # try to find it on search.cpan.org
- my $mirror = $self->config->{mirror};
- my $header = $mirror ? { 'Cookie' => "cpan=$mirror->{url}" } : undef;
- my $html = http_get("http://search.cpan.org/dist/perl-${version}", $header);
+ my $html = http_get("http://search.cpan.org/dist/perl-${version}", { 'Cookie' => "cpan=$mirror" });
unless ($html) {
die "ERROR: Failed to locate perl-${version} tarball.";
@@ -825,10 +837,10 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
}
my $root_dir = $self->path_with_tilde($self->root);
- my $pb_home_dir = $self->path_with_tilde($PERLBREW_HOME);
+ my $pb_home_dir = $self->path_with_tilde($self->home);
my $code = qq( source $root_dir/etc/${shrc});
- if ($PERLBREW_HOME ne joinpath($self->env('HOME'), ".perlbrew")) {
+ if ($self->home ne joinpath($self->env('HOME'), ".perlbrew")) {
$code = " export PERLBREW_HOME=$pb_home_dir\n" . $code;
}
@@ -1229,7 +1241,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub purify {
my ($self, $envname) = @_;
- my @paths = grep { index($_, $PERLBREW_HOME) < 0 && index($_, $self->root) < 0 } split /:/, $self->env($envname);
+ my @paths = grep { index($_, $self->home) < 0 && index($_, $self->root) < 0 } split /:/, $self->env($envname);
return wantarray ? @paths : join(":", @paths);
}
@@ -1310,6 +1322,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my @u_options = @{ $self->{U} };
my @a_options = @{ $self->{A} };
my $sitecustomize = $self->{sitecustomize};
+ my $destdir = $self->{destdir};
$installation_name = $self->{as} if $self->{as};
$installation_name .= "$variation$append";
@@ -1329,8 +1342,8 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
$self->{$flavor} and push @d_options, $flavor{$flavor}{d_option}
}
- my $perlpath = $self->root . "/perls/$installation_name";
- my $patchperl = $self->root . "/bin/patchperl";
+ my $perlpath = joinpath($self->root, "perls", $installation_name);
+ my $patchperl = joinpath($self->root, "bin", "patchperl");
unless (-x $patchperl && -f _) {
$patchperl = "patchperl";
@@ -1360,8 +1373,8 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my @preconfigure_commands = (
"cd $dist_extracted_dir",
"rm -f config.sh Policy.sh",
- $patchperl,
);
+ push @preconfigure_commands, $patchperl unless $self->{"no-patchperl"};
my $configure_flags = $self->env("PERLBREW_CONFIGURE_FLAGS") || '-de';
@@ -1393,7 +1406,9 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
local $ENV{TEST_JOBS}=$self->{j}
if $test_target eq "test_harness" && ($self->{j}||1) > 1;
- my @install_commands = $self->{notest} ? "make install" : ("make $test_target", "make install");
+ my @install_commands = ("make install" . ($destdir ? " DESTDIR=$destdir" : q||));
+ unshift @install_commands, "make $test_target" unless $self->{notest};
+ # Whats happening here? we optionally join with && based on $self->{force}, but then subsequently join with && anyway?
@install_commands = join " && ", @install_commands unless($self->{force});
my $cmd = join " && ",
@@ -1413,7 +1428,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
$cmd = "($cmd) >> '$self->{log_file}' 2>&1 ";
}
- delete $ENV{$_} for qw(PERL5LIB PERL5OPT);
+ delete $ENV{$_} for qw(PERL5LIB PERL5OPT AWKPATH);
if ($self->do_system($cmd)) {
my $newperl = joinpath($self->root, "perls", $installation_name, "bin", "perl");
@@ -1425,7 +1440,11 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
if ( $sitecustomize ) {
my $capture = $self->do_capture("$newperl -V:sitelib");
- my ($sitelib) = $capture =~ /sitelib='(.*)';/;
+ my ($sitelib) = $capture =~ m/sitelib='([^']*)';/;
+ # This should probably all use File::Path
+ if ($destdir) {
+ $sitelib = $destdir . $sitelib
+ }
mkpath($sitelib) unless -d $sitelib;
my $target = "$sitelib/sitecustomize.pl";
open my $dst, ">", $target
@@ -1455,7 +1474,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub do_install_program_from_url {
my ($self, $url, $program_name, $body_filter) = @_;
- my $out = $self->root . "/bin/" . $program_name;
+ my $out = joinpath($self->root, "bin", $program_name);
if (-f $out && !$self->{force}) {
require ExtUtils::MakeMaker;
@@ -1535,10 +1554,10 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my @result;
my $root = $self->root;
- for (<$root/perls/*>) {
- my ($name) = $_ =~ m/\/([^\/]+$)/;
- my $executable = joinpath($_, 'bin', 'perl');
- my $version_file = joinpath($_,'.version');
+ for my $installation_dir (<$root/perls/*>) {
+ my ($name) = $installation_dir =~ m/\/([^\/]+$)/;
+ my $executable = joinpath($installation_dir, 'bin', 'perl');
+ my $version_file = joinpath($installation_dir,'.version');
my $orig_version;
if ( -e $version_file ){
open my $fh, '<', $version_file;
@@ -1560,7 +1579,8 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
version => $self->format_perl_version($orig_version),
is_current => ($self->current_perl eq $name) && !($self->current_lib),
libs => [ $self->local_libs($name) ],
- executable => $executable
+ executable => $executable,
+ dir => $installation_dir,
};
}
@@ -1570,24 +1590,21 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub local_libs {
my ($self, $perl_name) = @_;
- my @libs = map { substr($_, length($PERLBREW_HOME) + 6) } bsd_glob("$PERLBREW_HOME/libs/*");
-
- if ($perl_name) {
- @libs = grep { /^$perl_name\@/ } @libs;
- }
-
my $current = $self->current_perl . '@' . ($self->env("PERLBREW_LIB") || '');
-
- @libs = map {
- my ($p, $l) = split(/@/, $_);
-
+ my @libs = map {
+ my $name = substr($_, length($self->home) + 6);
+ my ($p, $l) = split(/@/, $name);
+{
- name => $_,
- is_current => $_ eq $current,
+ name => $name,
+ is_current => $name eq $current,
perl_name => $p,
- lib_name => $l
+ lib_name => $l,
+ dir => $_,
}
- } @libs;
+ } bsd_glob(joinpath($self->home, "libs", "*"));
+ if ($perl_name) {
+ @libs = grep { $perl_name eq $_->{perl_name} } @libs;
+ }
return @libs;
}
@@ -1628,10 +1645,11 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
);
require local::lib;
+ my $pb_home = $self->home;
my $current_local_lib_root = $self->env("PERL_LOCAL_LIB_ROOT") || "";
my $current_local_lib_context = local::lib->new;
- my @perlbrew_local_lib_root = uniq(grep { /\Q${PERLBREW_HOME}\E/ } split(/:/, $current_local_lib_root));
- if ($current_local_lib_root =~ /^\Q$PERLBREW_HOME\E/) {
+ my @perlbrew_local_lib_root = uniq(grep { /\Q${pb_home}\E/ } split(/:/, $current_local_lib_root));
+ if ($current_local_lib_root =~ /^\Q${pb_home}\E/) {
$current_local_lib_context = $current_local_lib_context->activate($_) for @perlbrew_local_lib_root;
}
@@ -1645,7 +1663,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
if ($lib_name) {
$current_local_lib_context = $current_local_lib_context->deactivate($_) for @perlbrew_local_lib_root;
- my $base = "$PERLBREW_HOME/libs/${perl_name}\@${lib_name}";
+ my $base = joinpath($self->home, "libs", "${perl_name}\@${lib_name}");
if (-d $base) {
$current_local_lib_context = $current_local_lib_context->activate($base);
@@ -1801,7 +1819,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
if ($self->env("PERLBREW_BASHRC_VERSION")) {
local $ENV{PERLBREW_PERL} = $dist;
my $HOME = $self->env('HOME');
- my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
+ my $pb_home = $self->home;
mkpath($pb_home);
system("$0 env $dist > " . joinpath($pb_home, "init"));
@@ -1820,7 +1838,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub run_command_switch_off {
my $self = shift;
- my $pb_home = $self->env("PERLBREW_HOME") || $PERLBREW_HOME;
+ my $pb_home = $self->home;
mkpath($pb_home);
system("env PERLBREW_PERL= $0 env > " . joinpath($pb_home, "init"));
@@ -1913,7 +1931,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
die "Your perlbrew installation appears to be system-wide. Please upgrade through your package manager.\n";
}
- http_get('http://get.perlbrew.pl', undef, sub {
+ http_get('https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew', undef, sub {
my ( $body ) = @_;
open my $fh, '>', $TMP_PERLBREW or die "Unable to write perlbrew: $!";
@@ -1945,16 +1963,21 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
exit(-1);
}
- my $dir = "@{[ $self->root ]}/perls/$target";
+ my @installed = $self->installed_perls(@_);
+
+ my ($to_delete) = grep { $_->{name} eq $target } @installed;
+
+ die "'$target' is not installed\n" unless $to_delete;
- if (-l $dir) {
- die "\nThe given name `$target` is an alias, not a real installation. Cannot perform uninstall.\nTo delete the alias, run:\n\n perlbrew alias delete $target\n\n";
+ my @dir_to_delete;
+ for (@{$to_delete->{libs}}) {
+ push @dir_to_delete, $_->{dir};
}
+ push @dir_to_delete, $to_delete->{dir};
- unless(-d $dir) {
- die "'$target' is not installed\n";
+ for (@dir_to_delete) {
+ rmpath($_);
}
- exec 'rm', '-rf', $dir;
}
sub run_command_exec {
@@ -1993,7 +2016,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my $overall_success = 1;
for my $i ( @exec_with ) {
- next if -l $self->root . '/perls/' . $i->{name}; # Skip Aliases
+ next if -l joinpath($self->root, 'perls', $i->{name}); # Skip Aliases
my %env = $self->perlbrew_env($i->{name});
next if !$env{PERLBREW_PERL};
@@ -2146,7 +2169,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
}
my $fullname = $perl_name . '@' . $lib_name;
- my $dir = joinpath($PERLBREW_HOME, "libs", $fullname);
+ my $dir = joinpath($self->home, "libs", $fullname);
if (-d $dir) {
die "$fullname is already there.\n";
@@ -2173,7 +2196,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
my $current = $self->current_perl . '@' . $self->current_lib;
- my $dir = joinpath($PERLBREW_HOME, "libs", $fullname);
+ my $dir = joinpath($self->home, "libs", $fullname);
if (-d $dir) {
@@ -2195,7 +2218,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
sub run_command_lib_list {
my ($self) = @_;
- my $dir = joinpath($PERLBREW_HOME, "libs");
+ my $dir = joinpath($self->home, "libs");
return unless -d $dir;
opendir my $dh, $dir or die "open $dir failed: $!";
@@ -2264,7 +2287,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
$value_wo_D =~ s/^-D//;
push @{$self->{D}} , $value_wo_D if grep {/$value/} @d_options;
}
-
+
$self->do_install_release($dist, $dist_version);
}
@@ -2340,49 +2363,6 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
print $self->format_info_output(@_);
}
-
- sub config {
- my($self) = @_;
- $self->_load_config if ! $CONFIG;
- return $CONFIG;
- }
-
- sub config_file {
- my ($self) = @_;
- joinpath( $self->root, 'Config.pm' );
- }
-
- sub _save_config {
- my($self) = @_;
- require Data::Dumper;
- open my $FH, '>', $self->config_file or die "Unable to open config (@{[ $self->config_file ]}): $!";
- my $d = Data::Dumper->new([$CONFIG],['App::perlbrew::CONFIG']);
- print $FH $d->Dump;
- close $FH;
- }
-
- sub _load_config {
- my($self) = @_;
-
- if ( ! -e $self->config_file ) {
- local $CONFIG = {} if ! $CONFIG;
- $self->_save_config;
- }
-
- open my $FH, '<', $self->config_file or die "Unable to open config (@{[ $self->config_file ]}): $!\n";
- my $raw = do { local $/; my $rv = <$FH>; $rv };
- close $FH;
-
- my $rv = eval $raw;
- if ( $@ ) {
- warn "Error loading conf: $@\n";
- $CONFIG = {};
- return;
- }
- $CONFIG = {} if ! $CONFIG;
- return;
- }
-
sub BASHRC_CONTENT() {
return "export PERLBREW_BASHRC_VERSION=$VERSION\n" .
(exists $ENV{PERLBREW_ROOT} ? "export PERLBREW_ROOT=$PERLBREW_ROOT\n" : "") . "\n" . <<'RC';
@@ -2885,9 +2865,6 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
# Initialize
perlbrew init
- # Pick a preferred CPAN mirror
- perlbrew mirror
-
# See what is available
perlbrew available
@@ -2928,7 +2905,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
cpan modules because those are installed inside your C<HOME> too.
For the documentation of perlbrew usage see L<perlbrew> command
- on L<MetaCPAN|https://metacpan.org/>, or by running C<perlbrew help>,
+ on L<MetaCPAN|https://metacpan.org/>, or by running C<perlbrew help>,
or by visiting L<perlbrew's official website|http://perlbrew.pl/>. The following documentation
features the API of C<App::perlbrew> module, and may not be remotely
close to what your want to read.
@@ -3023,7 +3000,7 @@ $fatpacked{"App/perlbrew.pm"} = '#line '.(1+__LINE__).' "'.__FILE__."\"\n".<<'AP
=head1 COPYRIGHT
- Copyright (c) 2010,2011,2012,2013,2014,2015 Kang-min Liu C<< <gugod@gugod.org> >>.
+ Copyright (c) 2010-2016 Kang-min Liu C<< <gugod@gugod.org> >>.
=head3 LICENCE
@@ -5899,7 +5876,7 @@ It is also possible to set this variable before installing perlbrew
to make perlbrew install itself under the given PERLBREW_ROOT:
export PERLBREW_ROOT=/opt/perl5
- curl -kL http://install.perlbrew.pl | bash
+ curl -L http://install.perlbrew.pl | bash
After doing this, the perlbrew executable is installed as C</opt/perl5/bin/perlbrew>
@@ -5930,7 +5907,7 @@ to 'sh Configure'. By default it is '-de'.
=item PERLBREW_CPAN_MIRROR
-The CPAN mirror url of your choice.
+The CPAN mirror url of your choice. The default value is "http://www.cpan.org"
=back
@@ -6029,9 +6006,14 @@ Options for C<install> command:
--ld Build perl with uselongdouble enabled
--debug Build perl with DEBUGGING enabled
--clang Build perl using the clang compiler
+ --no-patchperl
+ Skip calling patchperl
-D,-U,-A Switches passed to perl Configure script.
- ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U uselargefiles>
+ ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U versiononly>
+
+ --destdir $path
+ Install perl as per 'make install DESTDIR=$path'
--sitecustomize $filename
Specify a file to be installed as sitecustomize.pl
@@ -6093,7 +6075,8 @@ Another example using custom compilation flags:
Usage: perlbrew uninstall <name>
Uninstalls the given perl installation. The name is the installation name as in
-the output of `perlbrew list`
+the output of `perlbrew list`. This effectively deletes the specified perl installation,
+and all libs associated with it.
=head1 COMMAND: USE
@@ -6300,7 +6283,7 @@ This command install perlbrew itself to C<$PERLBREW_ROOT/bin>. It is intended to
be used by the perlbrew installer. However, you could manually do the following
to re-install only the C<perlbrew> executable:
- curl -kL http://get.perlbrew.pl -o perlbrew
+ curl https://raw.githubusercontent.com/gugod/App-perlbrew/master/perlbrew -o perlbrew
perl ./perlbrew self-install
It is slightly different from running the perlbrew installer because
View
109 t/12.destdir.t
@@ -0,0 +1,109 @@
+#!perl
+use strict;
+use Path::Class;
+use Capture::Tiny qw/capture/;
+use IO::All;
+use App::perlbrew;
+use File::Temp qw( tempdir );
+
+$App::perlbrew::PERLBREW_ROOT = tempdir( CLEANUP => 1 );
+$App::perlbrew::PERLBREW_HOME = tempdir( CLEANUP => 1 );
+$ENV{PERLBREW_ROOT} = $App::perlbrew::PERLBREW_ROOT;
+my $DESTDIR = tempdir( CLEANUP => 1 );
+
+use Test::More;
+
+## setup
+
+App::perlbrew::rmpath( $ENV{PERLBREW_ROOT} );
+
+## mock
+
+no warnings 'redefine';
+
+sub App::perlbrew::do_system {
+ my ($self, $cmd) = @_;
+ if ($cmd =~ /sitelib/) {
+ print "sitelib='$ENV{PERLBREW_ROOT}/perls/perl-5.14.2/lib/site_perl/5.14.2';\n";
+ print "installprefix='$ENV{PERLBREW_ROOT}/perls/perl-5.14.2';\n";
+ print "installstyle='lib';\n";
+ return 1;
+ }
+ elsif ($cmd =~ /Configure/) {
+ # pretend to succeed
+ return 1;
+ }
+ else {
+ # fail to run
+ $? = 1<<8;
+ $! = "Could not run '$cmd'";
+ return 0;
+ }
+}
+
+sub App::perlbrew::do_install_release {
+ my ($self, $dist) = @_;
+ my ($dist_name, $dist_version) = $dist =~ m/^(.*)-([\d.]+(?:-RC\d+)?)$/;
+
+ my $name = $dist;
+ $name = $self->{as} if $self->{as};
+
+ my $root = dir($DESTDIR, $ENV{PERLBREW_ROOT});
+ my $installation_dir = $root->subdir("perls", $name);
+ App::perlbrew::mkpath($installation_dir);
+ App::perlbrew::mkpath($root->subdir("perls", $name, "bin"));
+
+ my $perl = $root->subdir("perls", $name, "bin")->file("perl");
+ io($perl)->print("#!/bin/sh\nperl \"\$@\";\n");
+ chmod 0755, $perl;
+
+ # fake the install
+ $self->do_install_this("/tmp/fake-src/perl-5.14.2", $dist_version, $dist);
+}
+
+use warnings;
+
+## main
+
+note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";
+note "DESTDIR set to $DESTDIR";
+
+subtest "No perls yet installed" => sub {
+ my $app = App::perlbrew->new;
+ my @installed = grep { !$_->{is_external} } $app->installed_perls;
+ is 0+@installed, 0, "no perls installed";
+};
+
+subtest "--destdir option can be set" => sub {
+ my $app = App::perlbrew->new('install', 'perl-5.14.2',
+ '--destdir=/tmp/foo'
+ );
+
+ is join(' ', $app->args), join(' ', qw(install perl-5.14.2)), "post-option args correct";
+ is $app->{destdir}, '/tmp/foo', '--destdir set as expected';
+};
+
+subtest "mock installing" => sub {
+ my $sitefile = File::Temp->new;
+ print $sitefile "use strict;\n";
+ close $sitefile;
+ my $app = App::perlbrew->new('install', 'perl-5.14.2',
+ "--destdir=$DESTDIR", "--sitecustomize=$sitefile"
+ );
+ my ($output,$error) = capture { $app->run };
+
+ my @installed = grep { !$_->{is_external} } $app->installed_perls;
+use Data::Dumper; print Dumper \@installed;
+ is 0+@installed, 0, "found 0 installed perl (as it's installed in DESTDIR)";
+
+ my $root = dir($DESTDIR, $ENV{PERLBREW_ROOT});
+ my $perldir = $root->subdir("perls", "perl-5.14.2");
+ my $installedsite = $perldir->file('lib', 'site_perl', '5.14.2', 'sitecustomize.pl');
+ ok( -f $installedsite, "sitecustomize.pl installed in DESTDIR" );
+
+ my $guts = do { local (@ARGV, $/) = $installedsite; <> };
+ is( $guts, "use strict;\n", "sitecustomize.pl contents correct in DESTDIR" );
+};
+
+done_testing;
+# vim: ts=4 sts=4 sw=4 et:

0 comments on commit a6318f9

Please sign in to comment.
Something went wrong with that request. Please try again.