App-perlall
view release on metacpan or search on metacpan
script/perlall view on Meta::CPAN
#!/usr/local/bin/perl
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
# XXX 5.20-24 do not work with App::Rad
#BEGIN {$DB::single=1} # debug into attribute handling
# TODO:
# tee make test with -v (unbuffered IPC::Run or via fork-like callback?)
# maketest or -q: mark FAIL tests *RED*, p line bold black (see t/testc.sh)
# implement smoke, bench
# maketest --all (locally and testvm --all)
# more testvm_ctl: xen-shell, vmrun, VBoXManage
# uninstall: packfile of installed files instead of rather unsafe globbing
# cmd --help
# get msys compiled, bootstrap a mingw perl without strawberry
# build win32 from win32/
# TEST:
# init-modules: \ handling and `` expansion
# testvm logs back from forks
# fix testvm forked and --fork arg
# 'perlall=5.8* perlall do -m' should filter only main 5.8*
# testvm max balancing
# init is unstable (IO::Tee in IPC::Run) - refactored
# --as explicit and implicit - looks good, but no test
# non-critical TODO:
# 5.8.8 (centos5) fails with Attribute::Handler 0.78_02. monkeypatch or fail?
# build: test perlbrew and HOME friendly (no hardcoded paths)
# windows support (paths, tee, tools), die on other non-POSIX exots (VMS)...
# CPAN::Shell->expand("Devel::*"), not easy todo with metacpan.
use strict;
use 5.006;
our $VERSION = '0.51';
use Config;
use Cwd ();
use File::Spec ();
use File::Basename 'basename';
use Fcntl ();
my @extuse;
BEGIN { # check platform support: perldoc perlport
@extuse = qw(App::Rad IPC::Cmd IO::Scalar Devel::Platform::Info Devel::PatchPerl);
if ($^O !~ /^linux|freebsd|darwin|solaris|openbsd|cygwin$/) {
if ($^O =~ /^vms|dos|bsdos$/) {
die "unsupported OS $^O"; # fixes welcome
} elsif ($^O =~ /^MSWin32|msys/) {
warn "$^O not yet fully supported\n";
} else { # should theoretically work:
# netbsd sunos aix haiku beos hpux irix next svr4 unicos* plan9
# scary: VOS os390 os400 posix-bc vmesa riscos amigaos mpeix
warn "untested OS $^O. Feedback welcome";
# VOS forbids slashes in filenames. no big deal
}
}
sub _auto_use { # autoinstall the non-core modules, and use them
my @m;
for (@_) { push @m, $_ unless eval "require $_;" }
if (@m) { # Checked the API back to 1.76_01 (v5.8.4)
require CPAN; CPAN->import;
# TODO: skip core modules, perl-5
warn "CPAN::Shell->install(qw(@m))\n"; CPAN::Shell->install(@m); }
$_->import for @m;
}
_auto_use( @extuse );
}
# 5.8.4: solaris, 5.8.5: centos4, 5.8.8: centos5
# below dynamically parsed from git tags
our @main_releases = qw(5.6.2 5.8.4 5.8.5 5.8.8 5.8.9 5.10.1 5.12.5 5.14.4 5.16.3
5.18.4 5.20.3 5.22.4 5.24.4 5.26.3 5.28.2 5.30.0);
push @App::Rad::ISA, 'main';
our @opts = (
[ "skip=s", "skip versions (glob-style) or --skip=outdated" ],
[ "newer=s", "only newer and same versions (glob-style)" ],
[ "older=s", "only older versions (glob-style)" ],
[ "nogit", "skip @ git versions" ],
[ "main|m", "same as --skip=outdated" ],
[ "reverse|r","reverse, oldest first" ],
[ "quiet|q", "no TEST_VERBOSE, no system >STDOUT" ],
[ "verbose|v","Make perlall command say more" ],
[ "dryrun!", "do not execute commands, only print" ],
[ "nolog", "skip writing log file(s)" ],
[ "list|l", "shortcut for command list" ],
[ "help|h", "print usage for commands and options" ],
script/perlall view on Meta::CPAN
my $c = shift;
warn "additional arguments @{$c->argv} ignored\n" if @{$c->argv};
return join "\n", @{$c->stash->{perlall}};
}
=item B<set> version
Set alias p in .perlall
=cut
sub set
:Help('Set alias p in .perlall')
{
my $c = shift;
my $p = pop @{$c->argv};
warn "additional arguments @{$c->argv} ignored\n" if @{$c->argv};
$c->_set_alias($p);
return;
}
=item B<do> [<version>] commands...
Execute commands with all perls.
Specific Options:
--verbose|-v
--quiet|-q
--dryrun
--forked
--gittag="hex"
All other options and arguments are passed through to the perl.
For example, run a Hello program:
perlall do -E'say "Hello from $]"'
is expanded to something like:
for perl in /usr/local/bin/perl5*; do
p=$perl
echo $perl $*
$perl $*
done
Better restricts perls via ENV:
perlall="5.14.*d*" perlall do -E'say "Hello from $]"'
is expanded to something like:
for perl in /usr/local/bin/perl5.14.*d*; do
p=$perl
echo $p $*
$p $*
done
The output depends on your perl installations, and looks like this:
perl5.12.2-nt -E'say "Hello from $]"'
Hello from perl-5.012002
perl5.12.3-m -E'say "Hello from $]"'
Hello from perl-5.012003
perl5.14.2 -E'say "Hello from $]"'
Hello from perl-5.014002
perl5.14.2d -E'say "Hello from $]"'
Hello from perl-5.014002
perl5.14.2d-nt -E'say "Hello from $]"'
Hello from perl-5.014002
perl5.8.9-nt -E'say "Hello from $]"'
Unrecognized switch: -E (-h will show valid options).
perl5.6.2-nt -E'say "Hello from $]"'
Unrecognized switch: -E (-h will show valid options).
Notice that the commands are not executed in parallel.
=cut
sub do
:Help('Execute commands with all perls')
{
my $c = shift;
my $argv = join " ",@{$c->argv};
return "missing args" unless $argv;
$c->addopts( "verbose|v", "quiet|q", "dryrun!", 'forked', "gittag=s" );
# $c->options->{verbose} = 1 unless $c->options->{quiet};
for my $p (@{$c->stash->{perlall}}) {
$c->_lognew(_short($p));
local $ENV{p} = $p;
local $c->options->{quiet};
$c->_system0( "$p $argv");
}
$c->_set_alias() if @{$c->stash->{perlall}} < 5;
}
=item B<cpan> modules
like C<perlall do>, but calls C<perl5.* -S cpan args...> for all perls
=cut
sub cpan
:Help('Call cpan with args for all perls')
{
my $c = shift;
my $argv = join " ",@{$c->argv};
return "missing args" unless $argv;
$c->options->{verbose} = 1 unless $c->options->{quiet};
for my $p (@{$c->stash->{perlall}}) {
$c->_lognew(_short($p));
( run in 1.462 second using v1.01-cache-2.11-cpan-39bf76dae61 )