Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

executable file 545 lines (342 sloc) 16.705 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
#!/usr/bin/perl
use strict;
use App::perlbrew;

my $app = App::perlbrew->new(@ARGV);
$app->run();

__END__

=head1 NAME

perlbrew - Perl environment manager.

=head1 SYNOPSIS

perlbrew command syntax:

perlbrew <command> [options] [arguments]

Commands:

init Initialize perlbrew environment.

install Install perl
uninstall Uninstall the given installation
available List perls available to install
lib Manage local::lib directories.
alias Give perl installations a new name
upgrade-perl Upgrade the current perl

list List perl installations
use Use the specified perl in current shell
off Turn off perlbrew in current shell
switch Permanently use the specified perl as default
switch-off Permanently turn off perlbrew (revert to system perl)
exec exec programs with specified perl enviroments.

self-install Install perlbrew itself under PERLBREW_ROOT/bin
self-upgrade Upgrade perlbrew itself.

install-patchperl Install patchperl
install-cpanm Install cpanm, a friendly companion.
install-ack Install ack

download Download the specified perl distribution tarball.
mirror Pick a preferred mirror site
version Display version
help Read more detailed instructions

Generic command options:

-q --quiet Be quiet on informative output message.
-v --verbose Tell me more about it.

See `perlbrew help` for the full documentation of perlbrew, or

See `perlbrew help <command>` for detail description of the command.

=head1 CONFIGURATION

=over 4

=item PERLBREW_ROOT

By default, perlbrew builds and installs perls into
C<$ENV{HOME}/perl5/perlbrew> directory. To use a different directory,
set this environment variable in your C<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 C</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, everone's PATH should include C</opt/perl5/bin> and
C</opt/perl5/perls/${PERLBREW_PERL}/bin>. Each user can invoke C<perlbrew
switch> and C<perlbrew use> to independently switch to different perl
environment of their choice. However, only the user with write permission to
C<$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 C<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
C<perlbrew help lib> and the documentation of L<local::lib>.

If you want even a cooler module isolation and wish to install CPAN modules used
for just one project, you should use L<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 C</opt/perl5/bin/perlbrew>

=item PERLBREW_HOME

By default, perlbrew stores per-user setting to C<$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 C<PERLBREW_HOME> environment variable to
tell perlbrew where to look for the initialization file. Here's a brief bash
snippet for the given senario.

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

=item PERLBREW_CONFIGURE_FLAGS

This environment variable specify the list of command like flags to pass through
to 'sh Configure'. By default it is '-de'.

=item PERLBREW_CPAN_MIRROR

The CPAN mirror url of your choice.

=back

=head1 COMMAND: INIT

Usage: perlbrew init

The C<init> command should be manually invoked whenever you (the perlbrew user)
upgrade or reinstall perlbrew.

If the upgrade is done with C<self-upgrade> command, or by running the
one-line installer manually, this command is invoked automatically.

=head1 COMMAND: INFO

Usage: perlbrew info

The `info` command dumps a page of handful information for the perlbrew
installation.

=head1 COMMAND: INSTALL

=over 4

=item B<install> [options] perl-<version>

=item B<install> [options] <version>

Build and install the given version of perl.

Version numbers usually look like "5.x.xx", or
"perl-5.xx.x-RCx" for release candidates.

The specified perl is downloaded from the offical CPAN website or from the
mirror site configured before.

To configure mirror site, invoke `mirror` command.

=item B<install> [options] perl-stable

=item B<install> [options] stable

A convenient way to install the most recent stable version of Perl, of those
that are available.

=item B<install> [options] perl-blead

=item B<install> [options] blead

A special way to install the blead version of perl, which is downloaded from
this specific URL regardless of mirror settings:

http://perl5.git.perl.org/perl.git/snapshot/blead.tar.gz

=item B<install> [options] /path/to/perl/git/checkout/dir

Build and install from the given git checkout dir.


=item B<install> [options] /path/to/perl-5.14.0.tar.gz

Build and install from the given archive file.

=item B<install> [options] http://example.com/mirror/perl-5.12.3.tar.gz

Build and install from the given URL. Supported URL schemes are C<http://>,
C<https://>, C<ftp://> and C<file://>.

=back

Options for C<install> command:

-f --force Force installation
-j $n Parallel building and testing. ex. C<perlbrew install -j 5 perl-5.14.2>
-n --notest Skip testing

--switch Automatically switch to this Perl once successfully
installed, as if with `perlbrew switch <version>`

--as Install the given version of perl by a name.
ex. C<perlbrew install perl-5.6.2 --as legacy-perl>

-D,-U,-A Switches passed to perl Configure script.
ex. C<perlbrew install perl-5.10.1 -D usemymalloc -U uselargefiles>

--sitecustomize $filename
Specify a file to be installed as sitecustomize.pl

By default, all installations are configured after their name like this:

sh Configure -de -Dprefix=$PERLBREW_ROOT/perls/<name>

=head1 COMMAND: UNINSTALL

Usage: perlbrew uninstall <name>

Uninstalls the given perl installation. The name is the installation name as in
the output of `perlbrew list`

=head1 COMMAND: USE

Usage: perlbrew B<use> [perl-<version> | <version> | <name>]

Use the given version perl in current shell. This will not effect newly opened
shells.

Without a parameter, shows the version of perl currently in use.

=head1 COMMAND: SWITCH

Usage: perlbrew switch [ <name> ]

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.

=head1 COMMAND: LIST

Usage: perlbrew list

List the installed versions of perl.

=head1 COMMAND: AVAILABLE

Usage: perlbrew available

List the recently available versions of perl on CPAN.

The list is retrieved from the web page L<http://www.cpan.org/src/README.html>,
and is not the list of *all* perl versions ever released in the past.

NOTICE: This command might be gone in the future and becomes an option of 'list' command.

=head1 COMMAND: OFF

Usage: perlbrew off

Temporarily disable perlbrew in the current shell. Effectively re-enables the
default system Perl, whatever that is.

This command works only if you add the statement of `source $PERLBREW_ROOT/etc/bashrc`
in your shell initialization (bashrc / zshrc).

=head1 COMMAND: SWITCH-OFF

Usage: perlbrew switch-off

Permananently disable perlbrew. Use C<switch> command to re-enable it. Invoke
C<use> command to enable it only in the current shell.

Re-enables the default system Perl, whatever that is.

=head1 COMMAND: ALIAS

Usage: perlbrew alias [-f] create <name> <alias>

Create an alias for the installation named <name>.

Usage: perlbrew alias [-f] rename <old_alias> <new_alias>

Rename the alias to a new name.

Usage: perlbrew alias delete <alias>

Delete the given alias.

=head1 COMMAND: MIRROR

Usage: perlbrew 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.

=head1 COMMAND: EXEC

Usage: perlbrew exec [--with perl-name[,perl-name...]] <command> <args...>

Execute command for each perl installations, one by one.

For example, run a Hello program:

perlbrew exec perl -e 'print "Hello from $]\n"'

The output looks like this:

perl-5.12.2
==========
Hello word from perl-5.012002

perl-5.13.10
==========
Hello word from perl-5.013010

perl-5.14.0
==========
Hello word from perl-5.014000

Notice that the command is not executed in parallel.

When C<--with> arugemnt is provided, the command will be only executed with the
specified perl installations. The following command install Moose module into
perl-5.12, regardless the current perl:

perlbrew exec --with perl-5.12 cpanm Moose

Multiple installation names can be provided:

perlbrew exec --with perl-5.12,perl-5.12-debug,perl-5.14.2 cpanm Moo

The are splited by either spaces or commas. When spaces are used, it is required
to quote the whole specifiacion as one argument, but then commas can be used in
the installation names:

perlbrew exec --with '5.12 5.12,debug 5.14.2@nobita @shizuka' cpanm Moo

As demonstrated above, "perl-" prefix can be omitted, and lib names can be
specified too. Lib names can appear without a perl installation name, in such
cases it is assumed to be "current perl".

At the moment, any specified names that fails to be resolved as a real
installation names are silently ignored in the output. Also, the command exit
status are not populated back.

=head1 COMMAND: ENV

Usage: perlbrew env <name>

Low-level command. Invoke 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/zsh):

export PERLBREW_ROOT=/Users/gugod/perl5/perlbrew
export PERLBREW_VERSION=0.31
export PERLBREW_PATH=/Users/gugod/perl5/perlbrew/bin:/Users/gugod/perl5/perlbrew/perls/current/bin
export PERLBREW_PERL=perl-5.14.1

tcsh / csh users shall seens lines of 'setenv' statements instead of `export`.

=head1 COMMAND: SYMLINK-EXECUTABLES

Usage: perlbrew symlink-executables <name>

Low-level command. This command is used to create the C<perl> executable
symbolic link to, say, C<perl5.13.6>. This is only required for
development version of perls.

You don't need to do this unless you have been using old perlbrew to install
perls, and you find youself confused because the perl that you just installed
appears to be missing after invoking `use` or `switch`. perbrew changes its
installation layout since version 0.11, which generades symlinks to executables
in a better way.

If you just upgraded perlbrew (from 0.11 or earlier versions) and 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

Newly installed perls, whether they are development versions or not, does not
need manually treatment with this command.

=head1 COMMAND: INSTALL-CPANM

Usage: perlbrew install-cpanm

Install the C<cpanm> standalone executable in C<$PERLBREW_ROOT/bin>.

For more rationale about the existence of this command, read
<http://www.perlbrew.pl/Perlbrew-and-Friends.html>

=head1 COMMAND: INSTALL-PATCHPERL

Usage: perlbrew install-patchperl

Install the C<patchperl> standalone executable in C<$PERLBREW_ROOT/bin>. This
is automaticall invoked if your perlbrew installation is done with the
installer, but not with cpan.

For more rationale about the existence of this command, read
<http://www.perlbrew.pl/Perlbrew-and-Friends.html>

=head1 COMMAND: SELF-UPGRADE

Usage: perlbrew self-upgrade

This command upgrades Perlbrew to its latest version.

=head1 COMMAND: SELF-INSTALL

Usage: perlbrew self-install

NOTICE: You should not need to run this command in your daily routine.

This command install perlbrew itself to C<$PERLBREW_ROOT/bin>. It is intended
used by the perlbrew installer. However, you may manually do the following to
re-install only the C<perlbrew> executable:

curl -kL http://get.perlbrew.pl -o perlbrew
perl ./perlbrew self-install

It is slightly different from running the perlbrew installer because
C<patchperl> is not installed in this case.

=head1 COMMAND: VERSION

Usage: perlbrew version

Show the version of perlbrew.

=head1 COMMAND: LIB

Usage:

perlbrew lib list
perlbrew lib create <lib-name>
perlbrew lib delete <lib-name>

The `lib` command is used to manipulate local::lib roots inside perl
installations. Effectively it is similar to `perl
-Mlocal::lib=/path/to/lib-name`, but a little bit more than just that.

A lib name can be a short name, containing alphanumeric, like 'awesome', or a
full name, prefixed by a perl installation name and a '@' sign, for example,
'perl-5.14.2@awesome'.

Here are some a brief examples to invoke the `lib` command:

# Create libs by name
perlbrew lib create nobita
perlbrew lib create perl-5.12.3@shizuka

perlbrew list # See the list of use/switch targets.

# Activate a lib in current shell.
perlbrew use perl-5.12.3@nobita
perlbrew use perl-5.14.2@nobita

# Activate a lib as default.
perlbrew switch perl-5.14.2@nobita

# Delete the lib
perlbrew lib delete nobita
perlbrew lib delete perl-5.12.3@shizuka

Short lib names are local to current perl. A lib name 'nobita' can refer to
'perl-5.12.3@nobita' or 'perl-5.14.2@nobita', depending on your current perl.

When C<use>ing or C<switch>ing to a lib, always provide the long name. A simple
rule: the argument to C<use> or C<switch> command should appear in the output of
C<perlbrew list>.

=head1 COMMAND: UPGRADE-PERL

Usage: perlbrew upgrade-perl

Minor Perl releases (ex. 5.x.*) are binary compatible with one another, so this
command offers you the ability to upgrade older perlbrew environments in place.

It upgrades the currently activated perl to its latest released brothers. If you
have a shell with 5.14.0 activated, it upgrades it to 5.14.2.

=head1 COMMAND: DOWNLOAD

Usage:

perlbrew download perl-5.14.2
perlbrew download perl-5.16.1
perlbrew download perl-5.17.3

Download the specified version of perl distribution tarball under C<<
$PERLBREW_ROOT/dists/ >> directory.

=head1 COMMAND: INSTALL-ACK

Usage: perlbrew install-ack

Install the standalone version of C<ack> program under C<$PERLBREW_ROOT/bin>.

=head1 COMMAND: LIST-MODULES

List all installed cpan modules for the current perl.

This command can be used in conjunction with `perlbrew exec` to migrate
your module installation to different perl. The following command
re-installs all modules under perl-5.16.0:

perlbrew list-modules | perlbrew exec --with perl-5.16.0 cpanm

=head1 UPGRADE NOTES

If you are upgrading C<perlbrew> from 0.16 or ealier versions to a recent
one (0.40-ish), you should do these steps to adjust your perl installations
afterwards (you might need to change the value of PERLBREW_ROOT):

export PERLBREW_ROOT=${HOME}/perl5/perlbrew
rm -f $PERLBREW_ROOT/perls/current
rm -f `find $PERLBREW_ROOT/perls/bin -type l`
perlbrew symlink-executables
perlbrew init

Following the instructions on screen to tweak your shell a bit. Then it
should be good.

=head1 SEE ALSO

L<App::perlbrew>, L<App::cpanminus>, L<Devel::PatchPerl>

=cut
Something went wrong with that request. Please try again.