r71149 - in /branches/upstream/perlbrew/current: Changes META.yml bin/perlbrew lib/App/perlbrew.pm

ghedo-guest at users.alioth.debian.org ghedo-guest at users.alioth.debian.org
Fri Mar 11 11:45:53 UTC 2011


Author: ghedo-guest
Date: Fri Mar 11 11:45:45 2011
New Revision: 71149

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=71149
Log:
[svn-upgrade] new version perlbrew (0.17)

Modified:
    branches/upstream/perlbrew/current/Changes
    branches/upstream/perlbrew/current/META.yml
    branches/upstream/perlbrew/current/bin/perlbrew
    branches/upstream/perlbrew/current/lib/App/perlbrew.pm

Modified: branches/upstream/perlbrew/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/perlbrew/current/Changes?rev=71149&op=diff
==============================================================================
--- branches/upstream/perlbrew/current/Changes (original)
+++ branches/upstream/perlbrew/current/Changes Fri Mar 11 11:45:45 2011
@@ -1,3 +1,11 @@
+0.17:
+- UPDATE NOTES: you need to init, off and switch back to the version you want;
+- Fix "perlbrew use" to work even if we are switched to a specific version
+- Fix "perlbrew env" to use current version, sets PERLBREW_PERL and proper PATH
+- Feature: "perlbrew use" shows current version in use
+- Feature: "perlbrew switch /path/to/special/perl name-of-special-perl" names for adhoc perl's
+- 'perlbrew exec' now excludes those non-brewed perl by frankcuny++ according to the discussion here: https://github.com/gugod/App-perlbrew/pull/43
+
 0.16:
 - Use 'test_harness' for perl >= 5.7.3. avar++
 - Use gtar on Solaris - RT #61042. doherty++

Modified: branches/upstream/perlbrew/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/perlbrew/current/META.yml?rev=71149&op=diff
==============================================================================
--- branches/upstream/perlbrew/current/META.yml (original)
+++ branches/upstream/perlbrew/current/META.yml Fri Mar 11 11:45:45 2011
@@ -24,4 +24,4 @@
 resources:
   license: http://opensource.org/licenses/mit-license.php
   repository: git://github.com/gugod/App-perlbrew.git
-version: 0.16
+version: 0.17

Modified: branches/upstream/perlbrew/current/bin/perlbrew
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/perlbrew/current/bin/perlbrew?rev=71149&op=diff
==============================================================================
--- branches/upstream/perlbrew/current/bin/perlbrew (original)
+++ branches/upstream/perlbrew/current/bin/perlbrew Fri Mar 11 11:45:45 2011
@@ -11,6 +11,7 @@
 
 perlbrew - Perl Environment manager.
 
+
 =head1 SYNOPSIS
 
     perlbrew <command> [options] [arguments]
@@ -21,19 +22,25 @@
         list           List installed perls
         use            Use the specified perl in current shell
         switch         Permanently use the specified perl as default
-        mirror         Pick a preffered mirror site
+        mirror         Pick a preferred mirror site
         off            Permanently turn off perlbrew
         version        Display version
-        help           Read more detail instructions
+        help           Read more detailed instructions
 
     Examples:
-        perlbrew install perl-5.12.2
+        perlbrew install perl-5.12.3
         perlbrew install perl-5.13.6
 
         perlbrew list
 
         perlbrew use perl-5.13.6
-        perlbrew switch perl-5.12.2
+        perlbrew switch perl-5.12.3
+
+        perlbrew switch /path/to/special/perl
+        perlbrew switch /path/to/special/perl special-perl
+        # later
+        perlbrew switch special-perl
+
 
 =head1 COMMANDS
 
@@ -44,78 +51,82 @@
 Run this once to setup the C<perlbrew> directory ready for installing
 perls into. Run it again if you decide to change C<PERLBREW_ROOT>.
 
+
 =item B<mirror>
 
 Run this if you want to choose a specific CPAN mirror to install the
 perls from. It will display a list of mirrors for you to pick
 from. Hit 'q' to cancel the selection.
 
+
 =item B<install> perl-<version>
 
 Build and install the given version of perl.
+
 
 =item B<install> /path/to/perl/git/checkout/dir
 
 Build and install from the given git checkout dir.
 
+
 =item B<list>
 
 List the installed versions of perl.
 
-=item B<use> perl-<version>
+
+=item B<use> [perl-<version>]
 
 Notice: this only works in bash and zsh.
 
 Switch to the given version of perl only in the current shell. This
 will not effect newly opened shells.
 
-=item B<switch> perl-<version>
+You can use as C<perl-version> the special keyword C<system> to stop
+using any perlbrew-based perl.
 
-Switch to the given version. You may need to run 'rehash' (or 'hash
--r') after this command.
+Without a parameter, shows the version of perl currently in use.
+
+
+=item B<switch> [perl-<version>]
+
+Switch to the given version, and makes it the default for this and all
+future terminal sessions.
+
+Without a parameter, shows the version of perl currently selected.
+
+
+=item B<off>
+
+Disable perlbrew. Use C<switch> command to re-enable it.
+
+
+=item B<env> [perl-version]
+
+Low-level command. Use this command to see the list of environment
+variables that are set by C<perlbrew> itself for shell integration.
+
+The output is something similar to this (if your shell is bash):
+
+    export PERLBREW_ROOT=/Users/gugod/perl5/perlbrew
+    export PERLBREW_VERSION=0.13
+    export PERLBREW_PATH=/Users/gugod/perl5/perlbrew/bin:/Users/gugod/perl5/perlbrew/perls/current/bin
+    export PERLBREW_PERL=perl-5.12.3
+
+You can also ask for the proper variables for a specific perl version.
+
+
+=item B<install-cpanm>
+
+Install the C<cpanm> standalone executable in C<$PERLBREW_ROOT/bin>.
+
 
 =item B<version>
 
 Show the version of perbrew.
 
-=item B<off>
-
-Disable perlbrew. Use C<switch> command to re-enable it.
-
-=item B<env>
-
-Low-level command. Use this command to see the list of environment
-variables that are set by C<perlbrew> itself for bash integration.
-
-The output is something similar to this:
-
-    export PERLBREW_ROOT=/Users/gugod/perl5/perlbrew
-    export PERLBREW_VERSION=0.13
-    export PERLBREW_PATH=/Users/gugod/perl5/perlbrew/bin
-
-=item B<symlink_executables> <perl-version>
-
-Low-level command. Use this command to create the C<perl> executable
-symbolic link to C<perl5.13.6>.
-
-You don't need to do this unless you were using old perlbrew to
-install perls. The installation layout is changed since version 0.11.
-
-If you just upgraded perlbrew and found C<perlbrew switch> failed to work
-after you switch to a development release of perl, say, perl-5.13.6, run this command:
-
-    perlbrew symlink_executables perl-5.13.6
-
-This essentially creates this symlink:
-
-   ${PERLBREW_ROOT}/perls/perl-5.13.6/bin/perl
-   -> ${PERLBREW_ROOT}/perls/perl-5.13.6/bin/perl5.13.6
-
-=item B<install-cpanm>
-
-Install the C<cpanm> standalone executable in C<$PERLBREW_ROOT/bin>.
 
 =back
+
 
 =head1 OPTIONS
 
@@ -155,6 +166,7 @@
 
 =back
 
+
 =head1 CONFIGURATION
 
 =over 4
@@ -168,6 +180,18 @@
 
 =back
 
+
+=head1 UPGRADE NOTES
+
+If you upgraded C<perlbrew> from version 0.16 or older, you should do
+this cleanup your setup. Failure to do so might make the C<use>
+command to fail.
+
+Note the version of perl currently selected with C<perlbrew switch>.
+Then turn C<perlbrew off>, and switched back again with C<perlbrew
+switch previous-perl-version>.
+
+
 =head1 SEE ALSO
 
 L<App::perlbrew>, L<App::cpanminus>

Modified: branches/upstream/perlbrew/current/lib/App/perlbrew.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/perlbrew/current/lib/App/perlbrew.pm?rev=71149&op=diff
==============================================================================
--- branches/upstream/perlbrew/current/lib/App/perlbrew.pm (original)
+++ branches/upstream/perlbrew/current/lib/App/perlbrew.pm Fri Mar 11 11:45:45 2011
@@ -5,7 +5,7 @@
 use Getopt::Long ();
 use File::Spec::Functions qw( catfile );
 
-our $VERSION = "0.16";
+our $VERSION = "0.17";
 our $CONF;
 
 my $ROOT         = $ENV{PERLBREW_ROOT} || "$ENV{HOME}/perl5/perlbrew";
@@ -23,6 +23,10 @@
 short_option=""
 
 __perlbrew_reinit () {
+    if [[ ! -d $HOME/.perlbrew ]]; then
+        mkdir -p $HOME/.perlbrew
+    fi
+
     echo '# DO NOT EDIT THIS FILE' > $HOME/.perlbrew/init
     command perlbrew $short_option env $1 >> $HOME/.perlbrew/init
     source $HOME/.perlbrew/init
@@ -31,6 +35,7 @@
 
 __perlbrew_set_path () {
     [[ -z "$PERLBREW_ROOT" ]] && return 1
+    hash -d perl 2>/dev/null
     export PATH_WITHOUT_PERLBREW=$(perl -e 'print join ":", grep { index($_, $ENV{PERLBREW_ROOT}) } split/:/,$ENV{PATH};')
     export PATH=$PERLBREW_PATH:$PATH_WITHOUT_PERLBREW
 }
@@ -38,6 +43,7 @@
 
 perlbrew () {
     local exit_status
+    export SHELL
 
     if [[ `echo $1 | awk 'BEGIN{FS=""}{print $1}'` = '-' ]]; then
         short_option=$1
@@ -46,12 +52,15 @@
 
     case $1 in
         (use)
-            if [[ -x "$PERLBREW_ROOT/perls/$2/bin/perl" ]]; then
+            if [[ -z "$2" ]] ; then
+                if [[ -z "$PERLBREW_PERL" ]] ; then
+                    echo "No version in use; defaulting to system"
+                else
+                    echo "Using $PERLBREW_PERL version"
+                fi
+            elif [[ -x "$PERLBREW_ROOT/perls/$2/bin/perl" || "$2" = "system" ]]; then
+                unset PERLBREW_PERL
                 eval $(command perlbrew $short_option env $2)
-                __perlbrew_set_path
-            elif [[ "$2" = "system" ]]; then
-                unset PERLBREW_PERL
-                eval $(command perlbrew $short_option env)
                 __perlbrew_set_path
             else
                 echo "$2 is not installed" >&2
@@ -60,27 +69,15 @@
             ;;
 
         (switch)
-            if [[ ! -d $HOME/.perlbrew ]]; then
-                mkdir -p $HOME/.perlbrew
-            fi
-
-            if [[ -x "$PERLBREW_ROOT/perls/$2/bin/perl" ]]; then
-                __perlbrew_reinit $2
-
-            elif [[ "$2" = "system" ]]; then
-                perlbrew off
-                return $?
-            else
-                echo "$2 is not installed" >&2
-                exit_status=1
-            fi
-            ;;
+              command perlbrew $short_option $*
+              exit_status=$?
+
+              if [[ -n "$2" ]] ; then
+                  __perlbrew_reinit
+              fi
+              ;;
 
         (off)
-            if [[ ! -d $HOME/.perlbrew ]]; then
-                mkdir -p $HOME/.perlbrew
-            fi
-
             unset PERLBREW_PERL
             command perlbrew $short_option off
 
@@ -224,6 +221,12 @@
     return \%ENV;
 }
 
+sub is_shell_csh {
+    my ($self) = @_;
+    return 1 if $self->env('SHELL') =~ /(t?csh)/;
+    return 0;
+}
+
 sub run {
     my($self) = @_;
     $self->run_command($self->get_args);
@@ -291,7 +294,7 @@
 RC
 
     my ( $shrc, $yourshrc );
-    if ( $self->env('SHELL') =~ /(t?csh)/ ) {
+    if ( $self->is_shell_csh) {
         $shrc     = 'cshrc';
         $yourshrc = $1 . "rc";
     }
@@ -496,10 +499,6 @@
         delete $ENV{$_} for qw(PERL5LIB PERL5OPT);
 
         if (!system($cmd)) {
-            if ($dist_version =~ /5\.1[13579]|git/) {
-                $self->run_command_symlink_executables($as);
-            }
-
             print <<SUCCESS;
 Installed $dist as $as successfully. Run the following command to switch to it.
 
@@ -567,9 +566,15 @@
         PERLBREW_ROOT => $ROOT
     );
 
-    if ($perl && -d "$ROOT/perls/$perl/bin") {
-        $env{PERLBREW_PERL} = $perl;
-        $env{PERLBREW_PATH} .= ":$ROOT/perls/$perl/bin";
+    if ($perl) {
+        if(-d "$ROOT/perls/$perl/bin") {
+            $env{PERLBREW_PERL} = $perl;
+            $env{PERLBREW_PATH} .= ":$ROOT/perls/$perl/bin";
+        }
+    }
+    elsif (-d "$ROOT/perls/current/bin") {
+        $env{PERLBREW_PERL} = readlink("$ROOT/perls/current");
+        $env{PERLBREW_PATH} .= ":$ROOT/perls/current/bin";
     }
 
     return %env;
@@ -583,8 +588,27 @@
     }
 }
 
+sub run_command_use {
+    my $self = shift;
+
+    if ($self->is_shell_csh) {
+        my $shell = $self->env('SHELL');
+        print "You shell '$shell' does not support the 'use' command at this time\n";
+        exit(1);
+    }
+
+    print <<WARNING;
+Your perlbrew setup is not complete!
+
+Please make sure you run `perlbrew init` first and follow the
+instructions, specially the bits about changing your .bashrc
+and exiting the current terminal and starting a new one.
+
+WARNING
+}
+
 sub run_command_switch {
-    my ( $self, $dist ) = @_;
+    my ( $self, $dist, $alias ) = @_;
 
     unless ( $dist ) {
         # If no args were given to switch, show the current perl.
@@ -596,22 +620,26 @@
         return;
     }
 
+    die "Cannot use for alias something that starts with 'perl-'\n"
+      if $alias && $alias =~ /^perl-/;
+
+    my $vers = $dist;
     if (-x $dist) {
-        unlink "$ROOT/perls/current";
-        system "ln -fs $dist $ROOT/bin/perl";
-        print "Switched to $dist\n";
-        return;
+        $alias = 'custom' unless $alias;
+        my $bin_dir = "$ROOT/perls/$alias/bin";
+        my $perl = catfile($bin_dir, 'perl');
+        mkpath($bin_dir);
+        unlink $perl;
+        symlink $dist, $perl;
+        $dist = $alias;
+        $vers = "$vers as $alias";
     }
 
     die "${dist} is not installed\n" unless -d "$ROOT/perls/${dist}";
-    unlink "$ROOT/perls/current";
-    system "cd $ROOT/perls; ln -s $dist current";
-    for my $executable (<$ROOT/perls/current/bin/*>) {
-        my ($name) = $executable =~ m/bin\/(.+?)(5\.\d.*)?$/;
-        my $target = "$ROOT/bin/${name}";
-        next unless -l $target || !-e $target;
-        system("ln -fs $executable $target");
-    }
+    chdir "$ROOT/perls";
+    unlink "current";
+    symlink $dist, "current";
+    print "Switched to $vers\n";
 }
 
 sub run_command_off {
@@ -694,14 +722,7 @@
 }
 
 sub run_command_symlink_executables {
-    my($self, $perl) = @_;
-
-    return "" unless $perl;
-
-    for my $executable (<$ROOT/perls/$perl/bin/*>) {
-        my ($name, $version) = $executable =~ m/bin\/(.+?)(5\.\d.*)?$/;
-        system("ln -fs $executable $ROOT/perls/$perl/bin/$name") if $version;
-    }
+    ## Ignore it silently for now
 }
 
 sub run_command_install_cpanm {
@@ -720,6 +741,8 @@
 
     for my $i ( $self->installed_perls ) {
         my %env = $self->perlbrew_env($i->{name});
+        next if !$env{PERLBREW_PERL};
+
         my $command = "";
 
         while ( my($name, $value) = each %env) {
@@ -816,6 +839,9 @@
 
     # Use 'switch' command to turn it back on.
     perlbrew switch perl-5.12.2
+
+    # Exec something with all perlbrew-ed perls
+    perlbrew exec perl -E 'say $]'
 
 =head1 DESCRIPTION
 




More information about the Pkg-perl-cvs-commits mailing list