Hello community, here is the log from the commit of package perl-App-perlbrew for openSUSE:Factory checked in at 2018-03-06 10:45:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-App-perlbrew (Old) and /work/SRC/openSUSE:Factory/.perl-App-perlbrew.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-App-perlbrew" Tue Mar 6 10:45:27 2018 rev:19 rq:578613 version:0.82 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-App-perlbrew/perl-App-perlbrew.changes 2016-11-22 18:58:56.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-App-perlbrew.new/perl-App-perlbrew.changes 2018-03-06 10:45:32.256078073 +0100 @@ -1,0 +2,25 @@ +Wed Feb 21 07:14:20 UTC 2018 - co...@suse.com + +- updated to 0.82 + see /usr/share/doc/packages/perl-App-perlbrew/Changes + + - Thanks to our contributors: Alceu Rodrigues de Freitas Junior, Paul Cochrane + - Fix regression of 'perlbrew install blead' + + 0.81: # 2017-12-09T15:12:04+0900 + - Thanks to our contributors: Luca Ferrari, Zac Bentley, perlancar, Nicolas R, gregor herrmann, Paul Cochrane + - New command: clone-modules + - Recognize tarball in .tar.xz extension + - The output of "availables" is now sorted by versions + - Unbreak the integration with cperl releases + - Make `perlbrew install` runs correctly on AIX + - support the current perl blead (5.28) + + 0.80: # 2017-06-30T07:40:45+0200 + - Fix version in META.yml in CPAN distribution. See: https://rt.cpan.org/Public/Bug/Display.html?id=122279 + + 0.79: # 2017-06-25T23:40:45+0200 + - deal with perl-5.26 change about @INC in Makefile.PL + - "available" command now also shows the URLs + +------------------------------------------------------------------- Old: ---- App-perlbrew-0.78.tar.gz New: ---- App-perlbrew-0.82.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-App-perlbrew.spec ++++++ --- /var/tmp/diff_new_pack.m9O70Z/_old 2018-03-06 10:45:33.152045702 +0100 +++ /var/tmp/diff_new_pack.m9O70Z/_new 2018-03-06 10:45:33.156045558 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-App-perlbrew # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,25 +17,27 @@ Name: perl-App-perlbrew -Version: 0.78 +Version: 0.82 Release: 0 %define cpan_name App-perlbrew Summary: Manage perl installations in your C<$HOME> License: MIT Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/App-perlbrew/ -Source0: http://www.cpan.org/authors/id/G/GU/GUGOD/%{cpan_name}-%{version}.tar.gz +Source0: https://cpan.metacpan.org/authors/id/G/GU/GUGOD/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros -BuildRequires: perl(CPAN::Perl::Releases) >= 2.60 +BuildRequires: perl(CPAN::Perl::Releases) >= 3.24 BuildRequires: perl(Capture::Tiny) >= 0.36 BuildRequires: perl(Devel::PatchPerl) >= 1.40 BuildRequires: perl(File::Temp) >= 0.2304 +BuildRequires: perl(File::Which) >= 1.21 BuildRequires: perl(IO::All) >= 0.51 BuildRequires: perl(Path::Class) >= 0.33 +BuildRequires: perl(Pod::Markdown) >= 2.002 BuildRequires: perl(Pod::Parser) >= 1.63 BuildRequires: perl(Pod::Usage) >= 1.68 BuildRequires: perl(Test::Exception) >= 0.320000 @@ -45,14 +47,16 @@ BuildRequires: perl(Test::Simple) >= 1.001002 BuildRequires: perl(Test::Spec) >= 0.47 BuildRequires: perl(local::lib) >= 2.000014 -Requires: perl(CPAN::Perl::Releases) >= 2.60 +Requires: perl(CPAN::Perl::Releases) >= 3.24 Requires: perl(Capture::Tiny) >= 0.36 Requires: perl(Devel::PatchPerl) >= 1.40 +Requires: perl(File::Temp) >= 0.2304 Requires: perl(Pod::Parser) >= 1.63 Requires: perl(Pod::Usage) >= 1.68 Requires: perl(local::lib) >= 2.000014 %{perl_requires} # MANUAL BEGIN +BuildRequires: curl BuildRequires: groff BuildRequires: wget # MANUAL END @@ -63,6 +67,9 @@ %prep %setup -q -n %{cpan_name}-%{version} find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644 +# MANUAL BEGIN +chmod a+x t/fake-bin/curl +# MANUAL END %build %{__perl} Makefile.PL INSTALLDIRS=vendor @@ -78,6 +85,7 @@ %files -f %{name}.files %defattr(-,root,root,755) -%doc Changes doc LICENSE README README.md +%doc Changes doc README README.md +%license LICENSE %changelog ++++++ App-perlbrew-0.78.tar.gz -> App-perlbrew-0.82.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/Changes new/App-perlbrew-0.82/Changes --- old/App-perlbrew-0.78/Changes 2016-11-20 23:06:40.000000000 +0100 +++ new/App-perlbrew-0.82/Changes 2017-12-17 01:50:53.000000000 +0100 @@ -1,3 +1,22 @@ +- Thanks to our contributors: Alceu Rodrigues de Freitas Junior, Paul Cochrane +- Fix regression of 'perlbrew install blead' + +0.81: # 2017-12-09T15:12:04+0900 +- Thanks to our contributors: Luca Ferrari, Zac Bentley, perlancar, Nicolas R, gregor herrmann, Paul Cochrane +- New command: clone-modules +- Recognize tarball in .tar.xz extension +- The output of "availables" is now sorted by versions +- Unbreak the integration with cperl releases +- Make `perlbrew install` runs correctly on AIX +- support the current perl blead (5.28) + +0.80: # 2017-06-30T07:40:45+0200 +- Fix version in META.yml in CPAN distribution. See: https://rt.cpan.org/Public/Bug/Display.html?id=122279 + +0.79: # 2017-06-25T23:40:45+0200 +- deal with perl-5.26 change about @INC in Makefile.PL +- "available" command now also shows the URLs + 0.78: # 2016-11-20T22:59:55+0100 - Thanks to our contributors: Manuel Streuhofer, Sergey Aleynikov - More fixes to accomodate changes on perl5.git.perl.org diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/MANIFEST new/App-perlbrew-0.82/MANIFEST --- old/App-perlbrew-0.78/MANIFEST 2016-11-20 23:05:18.000000000 +0100 +++ new/App-perlbrew-0.82/MANIFEST 2017-12-09 07:24:19.000000000 +0100 @@ -1,7 +1,6 @@ bin/perlbrew Changes doc/MIT-LICENSE -doc/notes.org doc/PERL-LICENSE inc/Module/Install.pm inc/Module/Install/AuthorRequires.pm @@ -63,7 +62,10 @@ t/do_system.t t/failure-command-install-cpanm.t t/failure-command-install-patchperl.t +t/fake-bin/curl t/http-program-control.t +t/http-ua-detect-non-curl.t +t/http-ua-detect.t t/http.t t/installation-perlbrew.t t/installation.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/META.yml new/App-perlbrew-0.82/META.yml --- old/App-perlbrew-0.78/META.yml 2016-11-20 23:07:31.000000000 +0100 +++ new/App-perlbrew-0.82/META.yml 2017-12-17 01:51:53.000000000 +0100 @@ -5,8 +5,10 @@ build_requires: ExtUtils::MakeMaker: 6.59 File::Temp: '0.2304' + File::Which: '1.21' IO::All: '0.51' Path::Class: '0.33' + Pod::Markdown: '2.002' Test::Exception: '0.32' Test::More: '1.001002' Test::NoWarnings: '1.04' @@ -29,9 +31,10 @@ - inc - t requires: - CPAN::Perl::Releases: '2.60' + CPAN::Perl::Releases: '3.24' Capture::Tiny: '0.36' Devel::PatchPerl: '1.40' + File::Temp: '0.2304' Pod::Parser: '1.63' Pod::Usage: '1.68' local::lib: '2.000014' @@ -39,4 +42,4 @@ resources: license: http://opensource.org/licenses/mit-license.php repository: git://github.com/gugod/App-perlbrew.git -version: '0.78' +version: '0.82' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/Makefile.PL new/App-perlbrew-0.82/Makefile.PL --- old/App-perlbrew-0.78/Makefile.PL 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/Makefile.PL 2017-12-09 07:24:55.000000000 +0100 @@ -1,3 +1,7 @@ + +use FindBin '$Bin'; +BEGIN { push @INC, $Bin; } + use inc::Module::Install; license 'mit'; @@ -9,18 +13,21 @@ repository 'git://github.com/gugod/App-perlbrew.git'; requires - 'CPAN::Perl::Releases' => '2.60', + 'CPAN::Perl::Releases' => '3.24', 'Capture::Tiny' => '0.36', 'Devel::PatchPerl' => '1.40', 'Pod::Parser' => '1.63', 'Pod::Usage' => '1.68', + 'File::Temp' => '0.2304', 'local::lib' => '2.000014'; test_requires 'ExtUtils::MakeMaker' => '6.86', 'File::Temp' => '0.2304', + 'File::Which' => '1.21', 'IO::All' => '0.51', 'Path::Class' => '0.33', + 'Pod::Markdown' => '2.002', 'Test::Exception' => '0.32', 'Test::More' => '1.001002', 'Test::NoWarnings' => '1.04', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/README.md new/App-perlbrew-0.82/README.md --- old/App-perlbrew-0.78/README.md 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/README.md 2017-12-04 14:59:30.000000000 +0100 @@ -18,6 +18,9 @@ perlbrew install perl-5.8.1 perlbrew install perl-5.19.9 + # Install with thread support + perlbrew install -v perl-5.18.2 -Dusethreads + # See what were installed perlbrew list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/bin/perlbrew new/App-perlbrew-0.82/bin/perlbrew --- old/App-perlbrew-0.78/bin/perlbrew 2016-11-20 23:06:34.000000000 +0100 +++ new/App-perlbrew-0.82/bin/perlbrew 2017-12-09 07:24:55.000000000 +0100 @@ -179,7 +179,7 @@ https://github.com/perl11/cperl/releases -See http://perl11.org/cperl/ for mor information about cperl distribution. +See http://perl11.org/cperl/ for more information about cperl distribution. =item B<install> [options] perl-stable @@ -617,6 +617,10 @@ Note that this installs the I<latest> versions of the Perl modules on the new perl, which are not necessarily the I<same> module versions you had installed previously. +=head1 COMMAND: CLONE-MODULES + +This command re-install all CPAN modules found from one installation to another. + =head1 SEE ALSO L<App::perlbrew>, L<App::cpanminus>, L<Devel::PatchPerl> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/doc/notes.org new/App-perlbrew-0.82/doc/notes.org --- old/App-perlbrew-0.78/doc/notes.org 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/doc/notes.org 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -# Here's some random notes about perlbrew that I take when I was thinking (or not.) - -* shell integration - -bashrc / cshrc should check if ~/.perlbrew/init before sourcing it. -If ~/.perlbrew/init is missing, it is the same as perlbrew is not in effect. - -* info command - - $ perlbrew info - - perlbrew version 0.30 - with bash integration - - PERLBREW_ROOT=... - PERLBREW_HOME=... - - Disk Usage: 230MB - - $ perlbrew info perl-5.14.2 - - perl version 5.14.2, installed at $PERLBREW_ROOT/perls/perl-5.14.2 - - #Show the platform section of `perl -V` - [x] Show the value of `Compiled at` from `perl -V` - -* When it is installed with cpan - - `which perlbrew` is, most likely, not equal to "$PERLBREW_ROOT/bin/perlbrew" - - Directories and files under $PERLBREW_ROOT/* might be absent - * as a result, user need to go through a initialization process. to get $PERLBREW_ROOT ready - - why ? can it be built on-the go ? - - etc/bashrc and etc/cshrc makes it harder - - When people run `perlbrew` for the very first time, perform `init` - - When people run `perlbrew install 5.14.2` the very first time, perform `init` - -* When it is installed with the perlbrew installer - -* Black box testing - - Suppose: A fresh bash user. - scripts to test the stand-alone `perlbrew` behaviour - scripts to test the cpan-installed `perlbrew` behaviour diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/lib/App/perlbrew.pm new/App-perlbrew-0.82/lib/App/perlbrew.pm --- old/App-perlbrew-0.78/lib/App/perlbrew.pm 2016-11-20 23:06:40.000000000 +0100 +++ new/App-perlbrew-0.82/lib/App/perlbrew.pm 2017-12-17 01:50:53.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; use 5.008; -our $VERSION = "0.78"; +our $VERSION = "0.82"; use Config; BEGIN { @@ -94,6 +94,7 @@ } } + ### functions sub joinpath { join "/", @_ } @@ -133,18 +134,27 @@ get => '--silent --location --fail -o - {url}', download => '--silent --location --fail -o {output} {url}', order => 1, + + # Exit code is 22 on 404s etc + die_on_error => sub { die 'Page not retrieved; HTTP error code 400 or above.' if ( $_[ 0 ] >> 8 == 22 ); }, }, wget => { test => '--version >/dev/null 2>&1', get => '--quiet -O - {url}', download => '--quiet -O {output} {url}', order => 2, + + # Exit code is not 0 on error + die_on_error => sub { die 'Page not retrieved: fetch failed.' if ( $_[ 0 ] ); }, }, fetch => { test => '--version >/dev/null 2>&1', get => '-o - {url}', download => '-o {output} {url}', order => 3, + + # Exit code is 8 on 404s etc + die_on_error => sub { die 'Server issued an error response.' if ( $_[ 0 ] >> 8 == 8 ); }, } ); @@ -219,21 +229,15 @@ my ($program, $command) = http_user_agent_command( get => { url => $url } ); open my $fh, '-|', $command - or die "open() for '$command': $!"; + or die "open() pipe for '$command': $!"; local $/; my $body = <$fh>; close $fh; - die 'Page not retrieved; HTTP error code 400 or above.' - if $program eq 'curl' # Exit code is 22 on 404s etc - and $? >> 8 == 22; # exit code is packed into $?; see perlvar - die 'Page not retrieved: fetch failed.' - if $program eq 'fetch' # Exit code is not 0 on error - and $?; - die 'Server issued an error response.' - if $program eq 'wget' # Exit code is 8 on 404s etc - and $? >> 8 == 8; + + # check if the download has failed and die automatically + $commands{ $program }{ die_on_error }->( $? ); return $cb ? $cb->($body) : $body; } @@ -296,6 +300,7 @@ variation => '', both => [], append => '', + reverse => 0, ); $opt{$_} = '' for keys %flavor; @@ -337,6 +342,7 @@ 'yes', 'force|f', + 'reverse', 'notest|n', 'quiet|q', 'verbose|v', @@ -350,6 +356,7 @@ 'shell=s', 'no-patchperl', + # options passed directly to Configure 'D=s@', 'U=s@', @@ -367,6 +374,7 @@ 'common-variations', @f, + @ext ) } @@ -403,6 +411,11 @@ return $self->{current_lib} || $self->env('PERLBREW_LIB') || ''; } +sub current_shell_is_bashish { + my ( $self ) = @_; + return $self->current_shell =~ /(ba|z)?sh/; +} + sub current_shell { my ($self, $x) = @_; $self->{current_shell} = $x if $x; @@ -478,6 +491,10 @@ return 0; } + +# Entry point method: handles all the arguments +# and dispatches to an appropriate internal +# method to execute the corresponding command. sub run { my($self) = @_; $self->run_command($self->args); @@ -485,6 +502,10 @@ sub args { my ( $self ) = @_; + + # keep 'force' and 'yes' coherent across commands + $self->{force} = $self->{yes} = 1 if ( $self->{force} || $self->{yes} ); + return @{ $self->{args} }; } @@ -502,7 +523,8 @@ foreach my $sym (keys %$symtable) { if($sym =~ /^run_command_/) { my $glob = $symtable->{$sym}; - if(defined *$glob{CODE}) { + if ( ref($glob) eq 'CODE' || defined *$glob{CODE} ) { + # with perl >= 5.27 stash entry can points to a CV directly $sym =~ s/^run_command_//; $sym =~ s/_/-/g; push @commands, $sym; @@ -517,6 +539,8 @@ my ( $self, $command ) = @_; my $SIMILAR_DISTANCE = 6; + $command =~ s/_/-/g; + my @commands = sort { $a->[1] <=> $b->[1] } map { @@ -532,6 +556,22 @@ return @commands; } +# This mehtod is called in the 'run' loop +# and executes every specific action depending +# on the type of command. +# +# The first argument to this method is a self reference, +# while the first "real" argument is the command to execute. +# Other parameters after the command to execute are +# considered as arguments for the command itself. +# +# In general the command is executed via a method named after the +# command itself and with the 'run_command' prefix. For instance +# the command 'exec' is handled by a method +# `run_command_exec` +# +# If no candidates can be found, an execption is thrown +# and a similar command is shown to the user. sub run_command { my ( $self, $x, @args ) = @_; my $command = $x; @@ -576,6 +616,13 @@ print "$0 - $package/$version\n"; } + +# Provides help information about a command. +# The idea is similar to the 'run_command' and 'run_command_$x' chain: +# this method dispatches to a 'run_command_help_$x' method +# if found in the class, otherwise it tries to extract the help +# documentation via the POD of the class itself using the +# section 'COMMAND: $x' with uppercase $x. sub run_command_help { my ($self, $status, $verbose, $return_text) = @_; @@ -661,6 +708,14 @@ } } +sub _firstrcfile { + my ( $self ) = @_; + foreach my $path (@_) { + return $path if -f joinpath($self->env('HOME'), $path); + } + return; +} + sub _compgen { my($self, $part, @reply) = @_; if(defined $part) { @@ -672,30 +727,92 @@ } } +# Internal utility function. +# Given a specific perl version, e.g., perl-5.27.4 +# returns a string with a formatted version number such +# as 05027004. Such string can be used as a number +# in order to make either a string comparison +# or a numeric comparison. +# +# In the case of cperl the major number is added by 6 +# so that it would match the project claim of being +# Perl 5+6 = 11. The final result is then +# multiplied by a negative factor (-1) in order +# to make cperl being "less" in the ordered list +# than a normal Perl installation. +sub comparable_perl_version { + my ( $self, $perl_version ) = @_; + if ( $perl_version =~ /^(?:(c?perl)-?)?(\d)\.(\d+).(\d+).*/ ){ + my $is_cperl = $1 && ($1 eq 'cperl'); + return ( $is_cperl ? -1 : 1 ) + * sprintf( '%02d%03d%03d', + $2 + ( $is_cperl ? 6 : 0 ), # major version + $3, # minor version + $4 ); # patch level + } + return 0; +} + +# Internal method. +# Performs a comparable sort of the perl versions specified as +# list. +sub sort_perl_versions { + my ( $self, @perls ) = @_; + + return map { $_->[ 0 ] } + sort { ( $self->{reverse} + ? $a->[ 1 ] <=> $b->[ 1 ] + : $b->[ 1 ] <=> $a->[ 1 ] ) } + map { [ $_, $self->comparable_perl_version( $_ ) ] } + @perls; +} + sub run_command_available { my ( $self, $dist, $opts ) = @_; - my @available = $self->available_perls(@_); + my $perls = $self->available_perls_with_urls(@_); my @installed = $self->installed_perls(@_); my $is_installed; - for my $available (@available) { - $is_installed = 0; + + # sort the keys of Perl installation (Randal to the rescue!) + my @sorted_perls = $self->sort_perl_versions( keys %$perls ); + + for my $available ( @sorted_perls ){ + my $url = $perls->{ $available }; + my $ctime; + for my $installed (@installed) { my $name = $installed->{name}; my $cur = $installed->{is_current}; if ( $available eq $installed->{name} ) { - $is_installed = 1; + $ctime = $installed->{ctime}; last; } } - print $is_installed ? 'i ' : ' ', $available, "\n"; + + print sprintf "\n%1s %12s %s <%s>", + $ctime ? 'i' : '', + $available, + $ctime ? 'INSTALLED on ' . $ctime . ' via ' : 'available from ', + $url ; } + + print "\n"; + + return @sorted_perls; } sub available_perls { + my ( $self ) = @_; + my $perls = $self->available_perls_with_urls; + return $self->sort_perl_versions( keys %$perls ); +} + + +sub available_perls_with_urls { my ( $self, $dist, $opts ) = @_; - my @available_versions; + my $perls = {}; my $url = $self->{all} ? "http://www.cpan.org/src/5.0/" : "http://www.cpan.org/src/README.html" ; @@ -704,28 +821,40 @@ die "\nERROR: Unable to retrieve the list of perls.\n\n"; } for ( split "\n", $html ) { + my ( $current_perl, $current_url ); if ( $self->{all} ) { - push @available_versions, $1 - if m|<a href="perl.*?\.tar\.gz">(.+?)</a>|; + ( $current_perl, $current_url ) = ( $2, $1 ) if m|<a href="(perl.*?\.tar\.gz)">(.+?)</a>|; } else { - push @available_versions, $1 - if m|<td><a href="http://www.cpan.org/src/.+?">(.+?)</a></td>|; + ( $current_perl, $current_url ) = ( $2, $1 ) if m|<td><a href="(http://www.cpan.org/src/.+?)">(.+?)</a></td>|; + } + + # if we have a $current_perl add it to the available hash of perls + if ( $current_perl ){ + $current_perl =~ s/\.tar\.gz//; + $perls->{ $current_perl } = $current_url; } } - s/\.tar\.gz// for @available_versions; - # cperl releases: https://github.com/perl11/cperl/releases - # links do downloads looks: /perl11/cperl/releases/download/cperl-5.24.0-RC3/cperl-5.24.0-RC3.tar.gz - $html = http_get("https://github.com/perl11/cperl/releases"); + # cperl releases: https://github.com/perl11/cperl/tags + my $cperl_remote = 'https://github.com'; + my $url_cperl_release_list = $cperl_remote . '/perl11/cperl/tags'; + + $html = http_get( $url_cperl_release_list ); if ($html) { - while ( $html =~ m{href="/perl11/cperl/releases/download/cperl-(.+?)/cperl-\1.tar.gz"}xg ) { - push @available_versions, "cperl-$1"; + while ( $html =~ m{href="(/perl11/cperl/archive/cperl-(5.+?)\.tar\.gz)"}xg ) { + $perls->{ "cperl-$2" } = $cperl_remote . $1; } } else { - warn "\nWARN: Unable to retrieve the list of cperl releases.\n\n"; + if ($self->{verbose}) { + warn "\nWARN: Unable to retrieve the list of cperl releases.\n\n"; + } } - return @available_versions; + + + + + return $perls; } sub perl_release { @@ -856,6 +985,11 @@ "cperl-5.22.3" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.3/cperl-5.22.3.tar.gz", "cperl-5.22.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.22.2/cperl-5.22.2.tar.gz", "cperl-5.24.0-RC1" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.0-RC1/cperl-5.24.0-RC1.tar.gz", + "cperl-5.24.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.2/cperl-5.24.2.tar.gz", + "cperl-5.25.2" => "https://github.com/perl11/cperl/releases/download/cperl-5.24.2/cperl-5.25.2.tar.gz", + "cperl-5.26.0" => "https://github.com/perl11/cperl/archive/cperl-5.26.0.tar.gz", + "cperl-5.26.0-RC1" => "https://github.com/perl11/cperl/archive/cperl-5.26.0-RC1.tar.gz", + "cperl-5.27.0" => "https://github.com/perl11/cperl/archive/cperl-5.27.0.tar.gz", ); my $error = 1; @@ -870,14 +1004,23 @@ sub release_detail_cperl_remote { my ($self, $dist, $rd) = @_; $rd ||= {}; - my $expect_href = "/perl11/cperl/releases/download/${dist}/${dist}.tar.gz"; - my $expect_url = "https://github.com/perl11/cperl/releases/download/${dist}/${dist}.tar.gz"; - my $html = http_get('https://github.com/perl11/cperl/releases'); + my $expect_href = "/perl11/cperl/archive/${dist}.tar.gz"; + my $expect_url = "https://github.com/perl11/cperl/archive/${dist}.tar.gz"; + my $html = http_get('https://github.com/perl11/cperl/tags'); my $error = 1; - if ($html =~ m{ <a \s+ href="$expect_href" }xsi) { - $rd->{tarball_name} = "${dist}.tar.gz"; - $rd->{tarball_url} = $expect_url; - $error = 0; + my $pages = 0; + while ($error && $pages++ < 25) { + if ($html =~ m{ <a \s+ href="$expect_href" }xsi) { + $rd->{tarball_name} = "${dist}.tar.gz"; + $rd->{tarball_url} = $expect_url; + $error = 0; + } else { + if ($html =~ m{ <a \s+ href="(https://github.com/perl11/cperl/tags\?after=[^"]+?)" }xsi) { + $html = http_get($1); + } else { + last; + } + } } return ($error, $rd); } @@ -896,6 +1039,7 @@ tarball_name => undef, }; + # dynamic methods: release_detail_perl_local, release_detail_cperl_local, release_detail_perl_remote, release_detail_cperl_remote my $m_local = "release_detail_${dist_type}_local"; my $m_remote = "release_detail_${dist_type}_remote"; @@ -914,7 +1058,7 @@ my @args = @_; if (@args && $args[0] eq '-') { - if ($self->current_shell =~ /(ba|z)?sh/) { + if ($self->current_shell_is_bashish) { $self->run_command_init_in_bash; } exit 0; @@ -952,51 +1096,65 @@ } } - my ( $shrc, $yourshrc ); - if ( $self->current_shell =~ m/(t?csh)/ ) { - $shrc = 'cshrc'; - $yourshrc = $1 . "rc"; - } - elsif ($self->current_shell =~ m/zsh\d?$/) { - $shrc = "bashrc"; - $yourshrc = 'zshenv'; - } - elsif( $self->current_shell eq 'fish' ) { - $shrc = "perlbrew.fish"; - $yourshrc = 'config/fish/config.fish'; - } - else { - $shrc = "bashrc"; - $yourshrc = "bash_profile"; - } - my $root_dir = $self->path_with_tilde($self->root); - my $pb_home_dir = $self->path_with_tilde($self->home); - - my $code = qq( source $root_dir/etc/${shrc}); - if ($self->home ne joinpath($self->env('HOME'), ".perlbrew")) { - $code = " export PERLBREW_HOME=$pb_home_dir\n" . $code; - } + # Skip this if we are running in a shell that already 'source's perlbrew. + # This is true during a self-install/self-init. + # Ref. https://github.com/gugod/App-perlbrew/issues/525 + if ( $ENV{PERLBREW_SHELLRC_VERSION} ) { + print("\nperlbrew root ($root_dir) is initialized.\n"); + } else { + my $shell = $self->current_shell; + my ( $code, $yourshrc ); + if ( $shell =~ m/(t?csh)/ ) { + $code = "source $root_dir/etc/cshrc"; + $yourshrc = $1 . "rc"; + } + elsif ( $shell =~ m/zsh\d?$/ ) { + $code = "source $root_dir/etc/bashrc"; + $yourshrc = $self->_firstrcfile(qw( + zshenv + .bash_profile + .bash_login + .profile + )) || "zshenv"; + } + elsif( $shell =~ m/fish/ ) { + $code = ". $root_dir/etc/perlbrew.fish"; + $yourshrc = 'config/fish/config.fish'; + } + else { + $code = "source $root_dir/etc/bashrc"; + $yourshrc = $self->_firstrcfile(qw( + .bash_profile + .bash_login + .profile + )) || ".bash_profile"; + } - if ( $self->env('SHELL') =~ m/fish/ ) { - $code =~ s/source/./; - $code =~ s/export (\S+)=(\S+)/set -x $1 $2/; - } + if ($self->home ne joinpath($self->env('HOME'), ".perlbrew")) { + my $pb_home_dir = $self->path_with_tilde($self->home); + if ( $shell =~ m/fish/ ) { + $code = "set -x PERLBREW_HOME $pb_home_dir\n $code"; + } else { + $code = "export PERLBREW_HOME=$pb_home_dir\n $code"; + } + } - print <<INSTRUCTION; + print <<INSTRUCTION; perlbrew root ($root_dir) is initialized. -Append the following piece of code to the end of your ~/.${yourshrc} and start a +Append the following piece of code to the end of your ~/${yourshrc} and start a new shell, perlbrew should be up and fully functional from there: -$code + $code Simply run `perlbrew` for usage details. Happy brewing! INSTRUCTION + } } @@ -1098,71 +1256,102 @@ # Assuming the dir extracted from the tarball is named after the tarball. my $dist_tarball_basename = $dist_tarball; - $dist_tarball_basename =~ s{.*/([^/]+)\.tar\.(?:gz|bz2)$}{$1}; + $dist_tarball_basename =~ s{.*/([^/]+)\.tar\.(?:gz|bz2|xz)$}{$1}; # Note that this is incorrect for blead. - my $extracted_dir = "@{[ $self->root ]}/build/$dist_tarball_basename"; - - # cperl tarball contains a dir name like: cperl-cperl-5.22.1 - if ($dist_tarball_basename =~ /^cperl-/) { - $extracted_dir = "@{[ $self->root ]}/build/${dist_tarball_basename}"; - } + my $workdir = joinpath($self->root, "build", $dist_tarball_basename); + rmpath($workdir) if -d $workdir; + mkpath($workdir); + my $extracted_dir; # Was broken on Solaris, where GNU tar is probably # installed as 'gtar' - RT #61042 my $tarx = - ($^O eq 'solaris' ? 'gtar ' : 'tar ') . - ( $dist_tarball =~ m/bz2$/ ? 'xjf' : 'xzf' ); + ($^O =~ /solaris|aix/ ? 'gtar ' : 'tar ') . + ( $dist_tarball =~ m/xz$/ ? 'xJf' : + $dist_tarball =~ m/bz2$/ ? 'xjf' : 'xzf' ); - if (-d $extracted_dir) { - rmpath($extracted_dir); + my $extract_command = "cd $workdir; $tarx $dist_tarball"; + die "Failed to extract $dist_tarball" if system($extract_command); + + my @things = <$workdir/*>; + if (@things == 1) { + $extracted_dir = $things[0]; + } + + unless (defined($extracted_dir) && -d $extracted_dir) { + die "Failed to find the extracted directory under $workdir"; } - my $extract_command = "cd @{[ $self->root ]}/build; $tarx $dist_tarball"; - die "Failed to extract $dist_tarball" if system($extract_command); return $extracted_dir; } -sub do_install_blead { - my $self = shift; - my $dist = shift; +sub search_blead_dir { + my ($build_dir, $contents_ref) = @_; + local *DIRH; + opendir DIRH, $build_dir or die "Couldn't open ${build_dir}: $!"; + @{$contents_ref} = grep {!/^\./ && -d joinpath($build_dir, $_)} readdir DIRH; + closedir DIRH or warn "Couldn't close ${build_dir}: $!"; + my @candidates = grep { m/^perl-blead-[0-9a-f]{4,40}$/ } @{$contents_ref}; + # Use a Schwartzian Transform in case there are lots of dirs that + # look like "perl-$SHA1", which is what's inside blead.tar.gz, + # so we stat each one only once. + @candidates = map { $_->[0] } + sort { $b->[1] <=> $a->[1] } # descending + map { [ $_, (stat( joinpath($build_dir, $_) ))[9] ] } @candidates; + if (scalar(@candidates) > 0) { + # take the newest one + return $candidates[0]; + } else { + return; + } +} +sub do_install_blead { + my ($self, $dist) = @_; my $dist_name = 'perl'; my $dist_git_describe = 'blead'; my $dist_version = 'blead'; - + # We always blindly overwrite anything that's already there, # because blead is a moving target. my $dist_tarball = 'blead.tar.gz'; my $dist_tarball_path = joinpath($self->root, "dists", $dist_tarball); print "Fetching $dist_git_describe as $dist_tarball_path\n"; - + my $error = http_download("http://perl5.git.perl.org/perl.git/snapshot/$dist_tarball", $dist_tarball_path); - + if ($error) { die "\nERROR: Failed to download perl-blead tarball.\n\n"; } - + # Returns the wrong extracted dir for blead $self->do_extract_tarball($dist_tarball_path); - + my $build_dir = joinpath($self->root, "build"); - local *DIRH; - opendir DIRH, $build_dir or die "Couldn't open ${build_dir}: $!"; - my @contents = readdir DIRH; - closedir DIRH or warn "Couldn't close ${build_dir}: $!"; - my @candidates = grep { m/^perl-blead-[0-9a-f]{4,40}$/ } @contents; - # Use a Schwartzian Transform in case there are lots of dirs that - # look like "perl-$SHA1", which is what's inside blead.tar.gz, - # so we stat each one only once. - @candidates = map { $_->[0] } - sort { $b->[1] <=> $a->[1] } # descending - map { [ $_, (stat( joinpath($build_dir, $_) ))[9] ] } @candidates; - my $dist_extracted_dir = joinpath($self->root, "build", $candidates[0]); # take the newest one + my @contents; + my $dist_extracted_subdir = search_blead_dir($build_dir, \@contents); + + # there might be an additional level on $build_dir + unless (defined($dist_extracted_subdir)) { + warn "No candidate found at $build_dir, trying a level deeper"; + for my $item (@contents) { + my $another_sub = joinpath($build_dir, $item); + $dist_extracted_subdir = search_blead_dir($another_sub); + if (defined($dist_extracted_subdir)) { + $build_dir = $another_sub; + last; + } + } + } + + die "Could not identify where is the source code to build under $build_dir, aborting..." unless (defined($dist_extracted_subdir)); + my $dist_extracted_dir = joinpath($build_dir, $dist_extracted_subdir); $self->do_install_this($dist_extracted_dir, $dist_version, "$dist_name-$dist_version"); return; } + sub resolve_stable_version { my ($self) = @_; @@ -1442,14 +1631,14 @@ my $dist_version; my $installation_name; - if (File::Basename::basename($dist_tarball_path) =~ m{(c?perl)-?(5.+)\.tar\.(gz|bz2)\Z}) { + if (File::Basename::basename($dist_tarball_path) =~ m{(c?perl)-?(5.+)\.tar\.(gz|bz2|xz)\Z}) { my $perl_variant = $1; $dist_version = $2; $installation_name = "${perl_variant}-${dist_version}"; } unless ($dist_version && $installation_name) { - die "Unable to determine perl version from archive filename.\n\nThe archive name should look like perl-5.x.y.tar.gz or perl-5.x.y.tar.bz2\n"; + die "Unable to determine perl version from archive filename.\n\nThe archive name should look like perl-5.x.y.tar.gz or perl-5.x.y.tar.bz2 or perl-5.x.y.tar.xz\n"; } my $dist_extracted_path = $self->do_extract_tarball($dist_tarball_path); @@ -1503,8 +1692,8 @@ push @d_options, "usecperl" if $looks_like_we_are_installing_cperl; - my $version = perl_version_to_integer($dist_version); - if (defined $version and $version < perl_version_to_integer( '5.6.0' ) ) { + my $version = $self->comparable_perl_version( $dist_version ); + if (defined $version and $version < $self->comparable_perl_version( '5.6.0' ) ) { # ancient perls do not support -A for Configure @a_options = (); } else { @@ -1536,7 +1725,7 @@ ( map { qq{'-U$_'} } @u_options ), ( map { qq{'-A$_'} } @a_options ), ), - (defined $version and $version < perl_version_to_integer( '5.8.9' )) + (defined $version and $version < $self->comparable_perl_version( '5.8.9' )) ? ("$^X -i -nle 'print unless /command-line/' makefile x2p/makefile") : () ); @@ -1703,9 +1892,10 @@ my $root = $self->root; for my $installation_dir (<$root/perls/*>) { - my ($name) = $installation_dir =~ m/\/([^\/]+$)/; - my $executable = joinpath($installation_dir, 'bin', 'perl'); + my ($name) = $installation_dir =~ m/\/([^\/]+$)/; + my $executable = joinpath($installation_dir, 'bin', 'perl'); my $version_file = joinpath($installation_dir,'.version'); + my $ctime = localtime( ( stat $executable )[ 10 ] ); # localtime in scalar context! my $orig_version; if ( -e $version_file ){ open my $fh, '<', $version_file; @@ -1729,10 +1919,14 @@ libs => [ $self->local_libs($name) ], executable => $executable, dir => $installation_dir, + comparable_version => $self->comparable_perl_version( $orig_version ), + ctime => $ctime, }; } - return sort { $a->{orig_version} <=> $b->{orig_version} or $a->{name} cmp $b->{name} } @result; + return sort { ( $self->{reverse} + ? ( $a->{comparable_version} <=> $b->{comparable_version} or $b->{name} cmp $a->{name} ) + : ( $b->{comparable_version} <=> $a->{comparable_version} or $a->{name} cmp $b->{name} ) ) } @result; } sub local_libs { @@ -1855,10 +2049,12 @@ my $self = shift; for my $i ( $self->installed_perls ) { - print $i->{is_current} ? '* ': ' ', + print sprintf "%2s %-20s %-20s (installed on %s)\n", + $i->{is_current} ? '*' : '', $i->{name}, (index($i->{name}, $i->{version}) < 0) ? " ($i->{version})" : "", - "\n"; + $i->{ctime}; + for my $lib (@{$i->{libs}}) { print $lib->{is_current} ? "* " : " ", @@ -1964,7 +2160,7 @@ die "${dist} is not installed\n" unless -d joinpath($self->root, "perls", $dist); - if ($self->env("PERLBREW_BASHRC_VERSION")) { + if ($self->env("PERLBREW_SHELLRC_VERSION") && $self->current_shell_is_bashish) { local $ENV{PERLBREW_PERL} = $dist; my $HOME = $self->env('HOME'); my $pb_home = $self->home; @@ -2454,18 +2650,43 @@ $self->do_install_release($dist, $dist_version); } +# Executes the list-modules command. +# This routine launches a new perl instance that, thru +# ExtUtils::Installed prints out all the modules +# in the system. If an argument is passed to the +# subroutine it is managed as a filename +# to which prints the list of modules. sub run_command_list_modules { - my ($self) = @_; + my ($self, $output_filename) = @_; my $class = ref($self) || __PACKAGE__; + + # avoid something that does not seem as a filename to print + # output to... + undef $output_filename if ( ! scalar( $output_filename ) ); + + my $name = $self->current_env; + if (-l (my $path = joinpath($self->root, 'perls', $name))) { + require File::Basename; + $name = File::Basename::basename(readlink $path); + } + + my $app = $class->new( qw(--quiet exec --with), - $self->current_env, - 'perl', '-MExtUtils::Installed', '-le', - 'BEGIN{@INC=grep {$_ ne q!.!} @INC}; print for ExtUtils::Installed->new->modules;' - ); + $name, + 'perl', + '-MExtUtils::Installed', + '-le', + sprintf( 'BEGIN{@INC=grep {$_ ne q!.!} @INC}; %s print {%s} $_ for ExtUtils::Installed->new->modules;', + $output_filename ? sprintf( 'open my $output_fh, \'>\', "%s"; ', $output_filename ) : '', + $output_filename ? '$output_fh' : 'STDOUT' ) + ); + $app->run; } + + sub resolve_installation_name { my ($self, $name) = @_; die "App::perlbrew->resolve_installation_name requires one argument." unless $name; @@ -2486,6 +2707,79 @@ return wantarray ? ($perl_name, $lib_name) : $perl_name; } + +# Implementation of the 'clone-modules' command. +# +# This method accepts a destination and source installation +# of Perl to clone modules from and into. +# For instance calling +# $app->run_command_clone_modules( $perl_a, $perl_b ); +# installs all modules that have been installed on Perl A +# to the instance of Perl B. +# +# Of course, both Perl installation must exist on this +# perlbrew enviroment. +# +# The method performs a list-modules command on the +# source Perl installation, save the list on a temporary file +# and then read back the list to execute a 'cpanm' shell +# with the argument list. +sub run_command_clone_modules { + my ( $self, $dst_perl, $src_perl, @args ) = @_; + + # if no source perl installation has been specified, use the + # current one as default + $src_perl = $self->current_perl if ( ! $src_perl || ! $self->resolve_installation_name( $src_perl ) ); + + + # check for the destination Perl to be installed + undef $dst_perl if ( ! $self->resolve_installation_name( $dst_perl ) ); + + # check that the user has provided a dest installation + # to which copy all the modules + unless ( $dst_perl ){ + $self->run_command_help( 'clone_modules' ); + exit( -1 ); + } + + + # I need to run the list-modules command on myself + # and get the result back so to handle it and pass + # to the exec subroutine. The solution I found so far + # is to store the result in a temp file (the list_modules + # uses a sub-perl process, so there is no way to pass a + # filehandle or something similar). + + require File::Temp; + use File::Temp; + my $modules_fh = File::Temp->new; + $self->run_command_list_modules( $modules_fh->filename ); + + # here I should have the list of modules into the + # temporary file name, so I can ask the destination + # perl instance to install such list + $modules_fh->close; + open $modules_fh, '<', $modules_fh->filename; + chomp( my @modules_to_install = <$modules_fh> ); + $modules_fh->close; + die "\nNo modules installed on $src_perl !\n" if ( ! @modules_to_install ); + print "\nInstalling $#modules_to_install modules from $src_perl to $dst_perl ...\n"; + + # create a new application to 'exec' the 'cpanm' + # with the specified module list + my $class = ref( $self ); + my $app = $class->new( + qw(--quiet exec --with), + $dst_perl, + 'cpanm', + @modules_to_install + ); + + $app->run; + +} + + sub format_info_output { my ($self, $module) = @_; @@ -2527,7 +2821,7 @@ } sub BASHRC_CONTENT() { - return "export PERLBREW_BASHRC_VERSION=$VERSION\n" . + return "export PERLBREW_SHELLRC_VERSION=$VERSION\n" . (exists $ENV{PERLBREW_ROOT} ? "export PERLBREW_ROOT=$PERLBREW_ROOT\n" : "") . "\n" . <<'RC'; __perlbrew_reinit() { @@ -2675,7 +2969,7 @@ } sub PERLBREW_FISH_CONTENT { - return "set -x PERLBREW_FISH_VERSION $VERSION\n" . <<'END'; + return "set -x PERLBREW_SHELLRC_VERSION $VERSION\n" . <<'END'; function __perlbrew_reinit if not test -d "$PERLBREW_HOME" @@ -2950,7 +3244,7 @@ } sub CSHRC_CONTENT { - return "setenv PERLBREW_CSHRC_VERSION $VERSION\n\n" . <<'CSHRC'; + return "setenv PERLBREW_SHELLRC_VERSION $VERSION\n\n" . <<'CSHRC'; if ( $?PERLBREW_HOME == 0 ) then setenv PERLBREW_HOME "$HOME/.perlbrew" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/03.test_get_available_versions.t new/App-perlbrew-0.82/t/03.test_get_available_versions.t --- old/App-perlbrew-0.78/t/03.test_get_available_versions.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/03.test_get_available_versions.t 2017-12-04 14:59:30.000000000 +0100 @@ -20,8 +20,8 @@ plan tests => 9; my $app = App::perlbrew->new(); - -is scalar $app->available_perls(), 8, "Correct number of releases found"; +my @vers = $app->available_perls(); +is scalar( @vers ), 8, "Correct number of releases found"; my @known_perl_versions = ( 'perl-5.13.11', 'perl-5.12.3', 'perl-5.10.1', 'perl-5.8.9', @@ -38,20 +38,20 @@ <head> <title>Perl Source - www.cpan.org</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="author" href="mailto:cpan+linkrelaut...@perl.org" /> - <link rel="canonical" href="http://www.cpan.org/src/index.html" /> - <link type="text/css" rel="stylesheet" href="../misc/css/cpan.css" /> - + <link rel="canonical" href="http://www.cpan.org/src/index.html" /> + <link type="text/css" rel="stylesheet" href="../misc/css/cpan.css" /> + </head> <body class="section_source"> <table id="wrapper" border="0" width="95%" cellspacing="0" cellpadding="2" align="center"> <tr> <td id="header"> - + <div id="header_left"> <a href="../index.html"><img src="../misc/images/cpan.png" id="logo" alt="CPAN" /></a> </div> - + <div id="header_right"> <h1>Comprehensive Perl Archive Network</h1> <p id="strapline">Stop reinventing wheels, start building space rockets @@ -61,7 +61,7 @@ </div> </td> </tr> - <tr> + <tr> <td id="menubar_holder"> <ul class="menubar"> @@ -72,7 +72,7 @@ <li><a href="../misc/cpan-faq.html">FAQ</a></li> <li><a href="../SITES.html">Mirrors</a></li> </ul> - + <div id="searchbar"> <form method="get" action="http://search.cpan.org/search" name="f" class="searchbox menubar" id="f"> <input type="hidden" name="mode" value="all" /> @@ -86,8 +86,8 @@ <tr> <td> <div id="content"> - - + + <h1>Perl Source</h1> @@ -114,7 +114,7 @@ make install </pre> <p> - Read both INSTALL and README.<strong>yoursystem</strong> in + Read both INSTALL and README.<strong>yoursystem</strong> in the <code>perl-5.12.3</code> directory for more detailed information. </p> @@ -462,18 +462,18 @@ <td id="footer"> <div id="footer_copyright"> <p>Yours Eclectically, The Self-Appointed Master Librarians (<i>OOK!</i>) of the CPAN.<br/> - © 1995-2010 Jarkko Hietaniemi. - © 2011 <a href="http://www.perl.org">Perl.org</a>. - All rights reserved. + © 1995-2010 Jarkko Hietaniemi. + © 2011 <a href="http://www.perl.org">Perl.org</a>. + All rights reserved. <a href="../disclaimer.html">Disclaimer</a>. </p> </div> - + <div id="footer_mirror"> <p>Master mirror hosted by <a href="http://www.yellowbot.com/"><img alt="YellowBot" src="../misc/images/yellowbot.png" /></a></p> </div> - + </td> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/14.perl_version_parsing.t new/App-perlbrew-0.82/t/14.perl_version_parsing.t --- old/App-perlbrew-0.78/t/14.perl_version_parsing.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/14.perl_version_parsing.t 2017-12-09 07:24:55.000000000 +0100 @@ -120,9 +120,22 @@ use Test::More; -plan tests => 0+@versions; +subtest "perl_version_to_integer" => sub { + plan tests => (@versions - 1); -my @versions_i = sort { $a->[0] <=> $b->[0] } map { [App::perlbrew::perl_version_to_integer($_), $_] } @versions; -for my $i (0..$#versions) { - is $versions[$i], $versions_i[$i]->[1]; -} + my @versions_i = map { App::perlbrew::perl_version_to_integer($_) } @versions; + for my $i (0 .. $#versions_i-1) { + ok( $versions_i[$i] < $versions_i[$i+1], "$versions[$i] < $versions[$i+1]"); + } +}; + +subtest "comparable_perl_version" => sub { + plan tests => 0+@versions; + + for my $v (@versions) { + my $n = App::perlbrew->comparable_perl_version($v); + like($n, qr/\-? [0-9]+/x, "can build comparable version from: $v"); + } +}; + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/15.no-reuse-build-dir.t new/App-perlbrew-0.82/t/15.no-reuse-build-dir.t --- old/App-perlbrew-0.78/t/15.no-reuse-build-dir.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/15.no-reuse-build-dir.t 2017-12-09 07:24:55.000000000 +0100 @@ -22,6 +22,9 @@ ok -e $test_file, 'Test file 3 created'; my $extracted_dir = $pb->do_extract_tarball( File::Spec->catfile($FindBin::Bin, 'test.tar.gz') ); +diag $extracted_dir; + is basename( $extracted_dir ) => 'test', 'Test tarball extracted as expected'; + ok !-e $test_file, 'Test file 3 was unlinked by tar'; -ok -e File::Spec->catfile( $test_dir, $_ ), "Test file $_ exists" for 1..2; +ok -e File::Spec->catfile( $extracted_dir, $_ ), "Test file $_ exists" for 1..2; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/17.release-detail-cperl-remote.t new/App-perlbrew-0.82/t/17.release-detail-cperl-remote.t --- old/App-perlbrew-0.78/t/17.release-detail-cperl-remote.t 2016-11-12 07:20:54.000000000 +0100 +++ new/App-perlbrew-0.82/t/17.release-detail-cperl-remote.t 2017-12-09 07:24:55.000000000 +0100 @@ -14,13 +14,13 @@ my $app = App::perlbrew->new(); -my $rd = { type => "cperl", "version" => "5.24.0" }; -$app->release_detail_cperl_remote("cperl-5.24.0", $rd); +my $rd = { type => "cperl", "version" => "5.27.1" }; +$app->release_detail_cperl_remote("cperl-5.27.1", $rd); ok defined( $rd->{tarball_url} ); ok defined( $rd->{tarball_name} ); -is $rd->{tarball_url}, "https://github.com/perl11/cperl/releases/download/cperl-5.24.0/cperl-5.24.0.tar.gz"; -is $rd->{tarball_name}, "cperl-5.24.0.tar.gz"; +is $rd->{tarball_url}, "https://github.com/perl11/cperl/archive/cperl-5.27.1.tar.gz"; +is $rd->{tarball_name}, "cperl-5.27.1.tar.gz"; done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/command-available.t new/App-perlbrew-0.82/t/command-available.t --- old/App-perlbrew-0.78/t/command-available.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/command-available.t 2017-12-09 07:24:55.000000000 +0100 @@ -11,21 +11,35 @@ $App::perlbrew::PERLBREW_ROOT = my $perlbrew_root = tempdir( CLEANUP => 1 ); $App::perlbrew::PERLBREW_HOME = my $perlbrew_home = tempdir( CLEANUP => 1 ); +# +# This is an example of availables perls on fluca1978 machine 2017-10-05. +# +my %available_perls = ( + 'perl-5.27.4' => 'http://www.cpan.org/src/5.0/perl-5.27.4.tar.gz', + 'perl-5.26.1' => 'http://www.cpan.org/src/5.0/perl-5.26.1.tar.gz', + 'perl-5.24.3' => 'http://www.cpan.org/src/5.0/perl-5.24.3.tar.gz', + 'perl-5.22.4' => 'http://www.cpan.org/src/5.0/perl-5.22.4.tar.gz', + 'perl-5.20.3' => 'http://www.cpan.org/src/5.0/perl-5.20.3.tar.gz', + 'perl-5.18.4' => 'http://www.cpan.org/src/5.0/perl-5.18.4.tar.gz', + 'perl-5.16.3' => 'http://www.cpan.org/src/5.0/perl-5.16.3.tar.gz', + 'perl-5.14.4' => 'http://www.cpan.org/src/5.0/perl-5.14.4.tar.gz', + 'perl-5.12.5' => 'http://www.cpan.org/src/5.0/perl-5.12.5.tar.gz', + 'perl-5.10.1' => 'http://www.cpan.org/src/5.0/perl-5.10.1.tar.gz', + 'perl-5.8.9' => 'http://www.cpan.org/src/5.0/perl-5.8.9.tar.gz', + 'perl-5.6.2' => 'http://www.cpan.org/src/5.0/perl-5.6.2.tar.gz', + 'perl5.005_04' => 'http://www.cpan.org/src/5.0/perl5.005_04.tar.gz', + 'perl5.004_05' => 'http://www.cpan.org/src/5.0/perl5.004_05.tar.gz', + 'cperl-5.26.1' => 'https://github.com/perl11/cperl/archive/cperl-5.26.1.tar.gz', + 'cperl-5.27.1' => 'https://github.com/perl11/cperl/archive/cperl-5.27.1.tar.gz', + ); + + describe "available command output, when nothing installed locally," => sub { it "should display a list of perl versions" => sub { my $app = App::perlbrew->new("available"); + $app->expects( 'available_perls_with_urls' )->returns( \%available_perls ); - my @available_perls = qw(perl-5.14.1 perl-5.14.2 perl-5.12.4); - - $app->expects("available_perls")->returns(@available_perls); - - stdout_is sub { - $app->run(); - }, <<OUT - perl-5.14.1 - perl-5.14.2 - perl-5.12.4 -OUT + stdout_like sub { $app->run(); }, qr/^\s{3,}c?perl-?\d\.\d{1,3}[_.]\d{1,2}\s+(available from)\s+<https?:\/\/.+>/, 'Cannot find Perl in output' }; }; @@ -33,22 +47,15 @@ it "should display a list of perl versions, with markers on installed versions" => sub { my $app = App::perlbrew->new("available"); - my @available_perls = qw(perl-5.14.1 perl-5.14.2 perl-5.12.4); + my @installed_perls = ( - { name => "perl-5.14.1" }, - { name => "perl-5.14.2" } + { name => "perl-5.24.0" }, + { name => "perl-5.20.3" } ); - $app->expects("available_perls")->returns(@available_perls); - $app->expects("installed_perls")->returns(@installed_perls); - - stdout_is sub { - $app->run(); - }, <<OUT -i perl-5.14.1 -i perl-5.14.2 - perl-5.12.4 -OUT + $app->expects( 'available_perls_with_urls' )->returns( \%available_perls ); + $app->expects("installed_perls")->returns(@installed_perls); + stdout_like sub { $app->run(); }, qr/^i?\s{2,}c?perl-?\d\.\d{1,3}[_.]\d{1,2}\s+(INSTALLED on .* via|available from)\s+<https?:\/\/.+>/, 'Cannot find Perl in output' }; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/command-list.t new/App-perlbrew-0.82/t/command-list.t --- old/App-perlbrew-0.78/t/command-list.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/command-list.t 2017-12-09 07:24:55.000000000 +0100 @@ -17,7 +17,7 @@ use File::Temp qw( tempdir ); use File::Spec::Functions qw( catdir ); use Test::Spec; -use Test::Output qw(stdout_is stdout_from); +use Test::Output qw(stdout_is stdout_from stdout_like); mock_perlbrew_install("perl-5.12.3"); mock_perlbrew_install("perl-5.12.4"); @@ -33,19 +33,7 @@ describe "when there no libs under PERLBREW_HOME,", sub { it "displays a list of perl installation names", sub { my $app = App::perlbrew->new("list"); - - my $out = stdout_from { $app->run; }; - - ## Remove paths to system perl from the list - $out =~ s/^[* ] \/.+$//mg; - $out =~ s/\n\n+/\n/; - - is $out, <<"EOF"; -* perl-5.12.3 - perl-5.12.4 - perl-5.14.1 - perl-5.14.2 -EOF + stdout_like sub { $app->run(); }, qr/^(\s\*)?\s{1,3}c?perl-?\d\.\d{1,3}[_.]\d{1,2}\s+/, 'Cannot find Perl in output' }; }; @@ -61,42 +49,16 @@ it "displays lib names" => sub { my $app = App::perlbrew->new("list"); - my $out = stdout_from { $app->run }; - - ## Remove paths to system perl from the list - $out =~ s/^[* ] \/.+$//mg; - $out =~ s/\n\n+/\n/; - - is $out, <<'OUT'; -* perl-5.12.3 - perl-5.12.3@nobita - perl-5.12.3@shizuka - perl-5.12.4 - perl-5.14.1 - perl-5.14.2 -OUT + stdout_like sub { $app->run(); }, qr/^(\s\*)?\s{1,3}c?perl-?\d\.\d{1,3}[_.]\d{1,2}(@\w+)?/, 'Cannot find Perl with libraries in output' }; it "marks currently activated lib", sub { $ENV{PERLBREW_LIB} = "nobita"; my $app = App::perlbrew->new("list"); - my $out = stdout_from { $app->run }; - ## Remove paths to system perl from the list - $out =~ s/^[* ] \/.+$//mg; - $out =~ s/\n\n+/\n/; - - is $out, <<'OUT'; - perl-5.12.3 -* perl-5.12.3@nobita - perl-5.12.3@shizuka - perl-5.12.4 - perl-5.14.1 - perl-5.14.2 -OUT + stdout_like sub { $app->run(); }, qr/^(\s\*)?\s{1,3}c?perl-?\d\.\d{1,3}[_.]\d{1,2}(\@nobita)?/, 'Cannot find Perl with libraries in output' }; }; }; runtests unless caller; - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/fake-bin/curl new/App-perlbrew-0.82/t/fake-bin/curl --- old/App-perlbrew-0.78/t/fake-bin/curl 1970-01-01 01:00:00.000000000 +0100 +++ new/App-perlbrew-0.82/t/fake-bin/curl 2017-12-04 14:59:30.000000000 +0100 @@ -0,0 +1,7 @@ +#!/bin/sh +exit 127 + +# This fake curl script is created to avoid +# App::perlbrew::http_user_agent_program() from selecting "curl" as +# the http ua program. + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/http-program-control.t new/App-perlbrew-0.82/t/http-program-control.t --- old/App-perlbrew-0.78/t/http-program-control.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/http-program-control.t 2017-12-04 14:59:30.000000000 +0100 @@ -10,9 +10,9 @@ use Test::More; use Test::Exception; -for (qw(curl wget fetch)) { - $App::perlbrew::HTTP_USER_AGENT_PROGRAM = "curl"; - is App::perlbrew::http_user_agent_program(), "curl"; +for my $prog (qw(curl wget fetch)) { + $App::perlbrew::HTTP_USER_AGENT_PROGRAM = $prog; + is App::perlbrew::http_user_agent_program(), $prog, "UA Program can be set to: $prog"; } $App::perlbrew::HTTP_USER_AGENT_PROGRAM = "something-that-is-not-recognized"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/http-ua-detect-non-curl.t new/App-perlbrew-0.82/t/http-ua-detect-non-curl.t --- old/App-perlbrew-0.78/t/http-ua-detect-non-curl.t 1970-01-01 01:00:00.000000000 +0100 +++ new/App-perlbrew-0.82/t/http-ua-detect-non-curl.t 2017-12-04 14:59:30.000000000 +0100 @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use FindBin qw($Bin); +BEGIN { + $ENV{PATH} = "$Bin/fake-bin:" . $ENV{PATH}; +} + +use File::Which qw(which); +use App::perlbrew; +use Test::More; + +diag "PATH=$ENV{PATH}"; + +my $curl_path = which("curl"); +diag "curl = $curl_path"; +is $curl_path, "$Bin/fake-bin/curl"; + +my $expected_ua; +if (which("wget")) { + $expected_ua = "wget"; +} +elsif (which("fetch")) { + $expected_ua = "fetch"; +} + +my $detected_ua = App::perlbrew::http_user_agent_program(); +is $detected_ua, $expected_ua, "UA: $detected_ua"; + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/http-ua-detect.t new/App-perlbrew-0.82/t/http-ua-detect.t --- old/App-perlbrew-0.78/t/http-ua-detect.t 1970-01-01 01:00:00.000000000 +0100 +++ new/App-perlbrew-0.82/t/http-ua-detect.t 2017-12-04 14:59:30.000000000 +0100 @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use File::Which qw(which); +use App::perlbrew; +use Test::More; + +my $expected_ua; +if (which("curl")) { + $expected_ua = "curl"; +} +elsif (which("wget")) { + $expected_ua = "wget"; +} +elsif (which("fetch")) { + $expected_ua = "fetch"; +} + +my $detected_ua = App::perlbrew::http_user_agent_program(); +is $detected_ua, $expected_ua, "UA: $detected_ua"; + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/App-perlbrew-0.78/t/installation-perlbrew.t new/App-perlbrew-0.82/t/installation-perlbrew.t --- old/App-perlbrew-0.78/t/installation-perlbrew.t 2016-09-22 08:27:38.000000000 +0200 +++ new/App-perlbrew-0.82/t/installation-perlbrew.t 2017-12-09 07:24:55.000000000 +0100 @@ -9,6 +9,7 @@ use Path::Class; use Test::More; +use Capture::Tiny qw( capture_stdout ); note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}"; @@ -30,4 +31,64 @@ ok -f file($ENV{PERLBREW_ROOT}, "etc", "csh_wrapper"); }; +subtest "Works with bash", sub { + if ($ENV{PERLBREW_SHELLRC_VERSION}) { + plan skip_all => "PERLBREW_SHELLRC_VERSION is defined, thus this subtest makes little sense."; + return; + } + + my $out = capture_stdout { + my $app = App::perlbrew->new('self-install'); + $app->current_shell("bash"); + $app->run; + }; + like($out, qr| export PERLBREW_HOME=\S+|); + like($out, qr| source \S+/etc/bashrc|); +}; + +subtest "Works with fish", sub { + if ($ENV{PERLBREW_SHELLRC_VERSION}) { + plan skip_all => "PERLBREW_SHELLRC_VERSION is defined, thus this subtest makes little sense."; + return; + } + + my $out = capture_stdout { + my $app = App::perlbrew->new('self-install'); + $app->current_shell("fish"); + $app->run; + }; + like($out, qr| set -x PERLBREW_HOME \S+|); + like($out, qr| . \S+/etc/perlbrew.fish|); +}; + +subtest "Works with zsh", sub { + if ($ENV{PERLBREW_SHELLRC_VERSION}) { + plan skip_all => "PERLBREW_SHELLRC_VERSION is defined, thus this subtest makes little sense."; + return; + } + my $out = capture_stdout { + my $app = App::perlbrew->new('self-install'); + $app->current_shell("zsh4"); + $app->run; + }; + like($out, qr| export PERLBREW_HOME=\S+|); + like($out, qr| source \S+/etc/bashrc|); +}; + +subtest "Exports PERLBREW_HOME when needed", sub { + if ($ENV{PERLBREW_SHELLRC_VERSION}) { + plan skip_all => "PERLBREW_SHELLRC_VERSION is defined, thus this subtest makes little sense."; + return; + } + my $out = capture_stdout { + local $App::perlbrew::PERLBREW_HOME = App::perlbrew::joinpath($ENV{HOME}, ".perlbrew"); + my $app = App::perlbrew->new('self-install'); + $app->current_shell("bash"); + $app->run; + }; + unlike($out, qr|PERLBREW_HOME=\S+|); + like($out, qr| source \S+/etc/bashrc|); +}; + + done_testing; ++++++ cpanspec.yml ++++++ --- /var/tmp/diff_new_pack.m9O70Z/_old 2018-03-06 10:45:33.260041800 +0100 +++ /var/tmp/diff_new_pack.m9O70Z/_new 2018-03-06 10:45:33.264041656 +0100 @@ -8,14 +8,6 @@ # foo.patch: -p1 # bar.patch: preamble: |- - BuildRequires: groff - BuildRequires: wget -#post_prep: |- -# hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'` -# sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL -#post_install: |- -# sed on %{name}.files -#license: SUSE-NonFree -#skip_noarch: 1 -#custom_build: - -#./Build build flags=%{?_smp_mflags} --myflag + BuildRequires: wget curl groff +post_prep: |- + chmod a+x t/fake-bin/curl