From: Jos I. Boumans Date: Fri, 9 Nov 2007 15:52:06 +0000 (+0100) Subject: CPANPLUS::Dist::Build 0.06_02 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8431a0ba74b23eebad48fe3311612a7e61c68fcb;p=p5sagit%2Fp5-mst-13.2.git CPANPLUS::Dist::Build 0.06_02 From: "Jos I. Boumans" Message-Id: <6A306E21-F59B-4FAA-A753-A11540539087@dwim.org> p4raw-id: //depot/perl@32253 --- diff --git a/lib/CPANPLUS/Dist/Build.pm b/lib/CPANPLUS/Dist/Build.pm index bd08e39..a23b4f8 100644 --- a/lib/CPANPLUS/Dist/Build.pm +++ b/lib/CPANPLUS/Dist/Build.pm @@ -29,7 +29,7 @@ use Locale::Maketext::Simple Class => 'CPANPLUS', Style => 'gettext'; local $Params::Check::VERBOSE = 1; -$VERSION = '0.06_01'; +$VERSION = '0.06_02'; =pod @@ -640,7 +640,9 @@ sub install { ### don't worry about loading the right version of M::B anymore ### the 'new_from_context' already added the 'right' path to ### M::B at the top of the build.pl - my $cmd = [$perl, BUILD->($dir), 'install', $buildflags]; + ### On VMS, flags need to be quoted + my $flag = ON_VMS ? '"install"' : 'install'; + my $cmd = [$perl, BUILD->($dir), $flag, $buildflags]; my $sudo = $conf->get_program('sudo'); unshift @$cmd, $sudo if $sudo; diff --git a/lib/CPANPLUS/Dist/Build/Constants.pm b/lib/CPANPLUS/Dist/Build/Constants.pm index 1a089ff..47986f9 100644 --- a/lib/CPANPLUS/Dist/Build/Constants.pm +++ b/lib/CPANPLUS/Dist/Build/Constants.pm @@ -18,9 +18,15 @@ use constant BUILD_DIR => sub { return @_ ? File::Spec->catdir($_[0], '_build') : '_build'; }; -use constant BUILD => sub { return @_ +use constant BUILD => sub { my $file = @_ ? File::Spec->catfile($_[0], 'Build') : 'Build'; + + ### on VMS, '.com' is appended when + ### creating the Build file + $file .= '.com' if $^O eq 'VMS'; + + return $file; }; 1; diff --git a/lib/CPANPLUS/Dist/Build/t/02_CPANPLUS-Dist-Build.t b/lib/CPANPLUS/Dist/Build/t/02_CPANPLUS-Dist-Build.t index de0b460..2c64905 100644 --- a/lib/CPANPLUS/Dist/Build/t/02_CPANPLUS-Dist-Build.t +++ b/lib/CPANPLUS/Dist/Build/t/02_CPANPLUS-Dist-Build.t @@ -102,7 +102,7 @@ while( my($path,$need_cc) = each %Map ) { ### set the fetch location -- it's local { my $where = File::Spec->rel2abs( - File::Spec->catdir( $Src, $path, $mod->package ) + File::Spec->catfile( $Src, $path, $mod->package ) ); $mod->status->fetch( $where ); @@ -164,7 +164,13 @@ while( my($path,$need_cc) = each %Map ) { # The installation directory actually needs to be in @INC # in order to test uninstallation - 'lib'->import( File::Spec->catdir($Lib, 'lib', 'perl5') ); + { my $libdir = File::Spec->catdir($Lib, 'lib', 'perl5'); + + # lib.pm is documented to require unix-style paths + $libdir = VMS::Filespec::unixify($libdir) if $^O eq 'VMS'; + + 'lib'->import( $libdir ); + } # EU::Installed and CP+::M are only capable of searching # for modules in the core directories. We need to fake @@ -236,13 +242,19 @@ sub find_module { my $file = File::Spec->catfile( split m/::/, $module ); my $candidate; foreach (@INC) { - if (-e ($candidate = File::Spec->catdir($_, $file)) + if (-e ($candidate = File::Spec->catfile($_, $file)) + or + -e ($candidate = File::Spec->catfile($_, "$file.pm")) + or + -e ($candidate = File::Spec->catfile($_, 'auto', $file)) or - -e ($candidate = File::Spec->catdir($_, "$file.pm")) + -e ($candidate = File::Spec->catfile($_, 'auto', "$file.pm")) or - -e ($candidate = File::Spec->catdir($_, 'auto', $file)) + -e ($candidate = File::Spec->catfile($_, $Config{archname}, + 'auto', $file)) or - -e ($candidate = File::Spec->catdir($_, 'auto', "$file.pm"))) { + -e ($candidate = File::Spec->catfile($_, $Config{archname}, + 'auto', "$file.pm"))) { return $candidate; } } diff --git a/lib/CPANPLUS/Dist/Build/t/inc/conf.pl b/lib/CPANPLUS/Dist/Build/t/inc/conf.pl index ff77c61..f7179e0 100644 --- a/lib/CPANPLUS/Dist/Build/t/inc/conf.pl +++ b/lib/CPANPLUS/Dist/Build/t/inc/conf.pl @@ -1,4 +1,6 @@ -### XXX copied from cpanplus's t/inc/conf.pl +### On VMS, the ENV is not reset after the program terminates. +### So reset it here explicitly +my ($old_env_path, $old_env_perl5lib); BEGIN { use FindBin; use File::Spec; @@ -21,13 +23,15 @@ BEGIN { use Config; ### and add them to the environment, so shellouts get them - $ENV{'PERL5LIB'} = join ':', + $old_env_perl5lib = $ENV{'PERL5LIB'}; + $ENV{'PERL5LIB'} = join $Config{'path_sep'}, grep { defined } $ENV{'PERL5LIB'}, @paths, @rel2abs; ### add our own path to the front of $ENV{PATH}, so that cpanp-run-perl ### and friends get picked up - $ENV{'PATH'} = join $Config{'path_sep'}, - grep { defined } "$FindBin::Bin/../../../bin", $ENV{'PATH'}; + $old_env_path = $ENV{PATH}; + $ENV{'PATH'} = join $Config{'path_sep'}, + grep { defined } "$FindBin::Bin/../bin", $ENV{'PATH'}; ### Fix up the path to perl, as we're about to chdir ### but only under perlcore, or if the path contains delimiters, @@ -50,8 +54,27 @@ BEGIN { $IPC::Cmd::USE_IPC_RUN = 0 if $^O eq 'MSWin32'; } +### Use a $^O comparison, as depending on module at this time +### may cause weird errors/warnings +END { + if ($^O eq 'VMS') { + ### VMS environment variables modified by this test need to be put back + ### path is "magic" on VMS, we can not tell if it really existed before + ### this was run, because VMS will magically pretend that a PATH + ### environment variable exists set to the current working directory + $ENV{PATH} = $old_path; + + if (defined $old_perl5lib) { + $ENV{PERL5LIB} = $old_perl5lib; + } else { + delete $ENV{PERL5LIB}; + } + } +} + use strict; use CPANPLUS::Configure; +use CPANPLUS::Error (); use File::Path qw[rmtree]; use FileHandle; @@ -82,7 +105,7 @@ sub _clean_test_dir { for my $dir ( @$dirs ) { - ### if it's not there, don't bother + ### no point if it doesn't exist; next unless -d $dir; my $dh; @@ -92,152 +115,32 @@ sub _clean_test_dir { my $path = File::Spec->catfile( $dir, $file ); - ### directory, rmtree it - if( -d $path ) { - print "Deleting directory '$path'\n" if $verbose; - eval { rmtree( $path ) }; - warn "Could not delete '$path' while cleaning up '$dir'" if $@; - - ### regular file - } else { - print "Deleting file '$path'\n" if $verbose; - 1 while unlink $path; - } - } - - close $dh; - } - - return 1; -} - -1; - -__END__ - -# prereq has to be in our package file && core! -use constant TEST_CONF_PREREQ => 'Cwd'; -use constant TEST_CONF_MODULE => 'Foo::Bar::EU::NOXS'; -use constant TEST_CONF_INST_MODULE => 'Foo::Bar'; -use constant TEST_CONF_INVALID_MODULE => 'fnurk'; -use constant TEST_CONF_MIRROR_DIR => 'dummy-localmirror'; - -### we might need this Some Day when we're installing into -### our own sandbox. see t/20.t for details -# use constant TEST_INSTALL_DIR => do { -# my $dir = File::Spec->rel2abs( 'dummy-perl' ); -# -# ### clean up paths if we are on win32 -# ### dirs with spaces will be.. bad :( -# $^O eq 'MSWin32' -# ? Win32::GetShortPathName( $dir ) -# : $dir; -# }; - -# use constant TEST_INSTALL_DIR_LIB -# => File::Spec->catdir( TEST_INSTALL_DIR, 'lib' ); -# use constant TEST_INSTALL_DIR_BIN -# => File::Spec->catdir( TEST_INSTALL_DIR, 'bin' ); -# use constant TEST_INSTALL_DIR_MAN1 -# => File::Spec->catdir( TEST_INSTALL_DIR, 'man', 'man1' ); -# use constant TEST_INSTALL_DIR_MAN3 -# => File::Spec->catdir( TEST_INSTALL_DIR, 'man', 'man3' ); -# use constant TEST_INSTALL_DIR_ARCH -# => File::Spec->catdir( TEST_INSTALL_DIR, 'arch' ); -# -# use constant TEST_INSTALL_EU_MM_FLAGS => -# ' INSTALLDIRS=site' . -# ' INSTALLSITELIB=' . TEST_INSTALL_DIR_LIB . -# ' INSTALLSITEARCH=' . TEST_INSTALL_DIR_ARCH . # .packlist -# ' INSTALLARCHLIB=' . TEST_INSTALL_DIR_ARCH . # perllocal.pod -# ' INSTALLSITEBIN=' . TEST_INSTALL_DIR_BIN . -# ' INSTALLSCRIPT=' . TEST_INSTALL_DIR_BIN . -# ' INSTALLSITEMAN1DIR=' . TEST_INSTALL_DIR_MAN1 . -# ' INSTALLSITEMAN3DIR=' . TEST_INSTALL_DIR_MAN3; - - -sub gimme_conf { - my $conf = CPANPLUS::Configure->new(); - $conf->set_conf( hosts => [ { - path => 'dummy-CPAN', - scheme => 'file', - } ], - ); - $conf->set_conf( base => 'dummy-cpanplus' ); - $conf->set_conf( dist_type => '' ); - $conf->set_conf( signature => 0 ); - - _clean_test_dir( [ - $conf->get_conf('base'), - TEST_CONF_MIRROR_DIR, -# TEST_INSTALL_DIR_LIB, -# TEST_INSTALL_DIR_BIN, -# TEST_INSTALL_DIR_MAN1, -# TEST_INSTALL_DIR_MAN3, - ], 1 ); - - return $conf; -}; - -{ - my $fh; - my $file = ".".basename($0).".output"; - sub output_handle { - return $fh if $fh; - - $fh = FileHandle->new(">$file") - or warn "Could not open output file '$file': $!"; - - $fh->autoflush(1); - return $fh; - } - - sub output_file { return $file } -} - - -### clean these files if we're under perl core -END { - if ( $ENV{PERL_CORE} ) { - close output_handle(); 1 while unlink output_file(); - - _clean_test_dir( [ - gimme_conf->get_conf('base'), - TEST_CONF_MIRROR_DIR, - # TEST_INSTALL_DIR_LIB, - # TEST_INSTALL_DIR_BIN, - # TEST_INSTALL_DIR_MAN1, - # TEST_INSTALL_DIR_MAN3, - ], 1 ); - } -} - - - -### whenever we start a new script, we want to clean out our -### old files from the test '.cpanplus' dir.. -sub _clean_test_dir { - my $dirs = shift || []; - my $verbose = shift || 0; - - for my $dir ( @$dirs ) { - - my $dh; - opendir $dh, $dir or die "Could not open basedir '$dir': $!"; - while( my $file = readdir $dh ) { - next if $file =~ /^\./; # skip dot files + ### John Malmberg reports yet another VMS issue: + ### A directory name on VMS in VMS format ends with .dir + ### when it is referenced as a file. + ### In UNIX format traditionally PERL on VMS does not remove the + ### '.dir', however the VMS C library conversion routines do remove + ### the '.dir' and the VMS C library routines can not handle the + ### '.dir' being present on UNIX format filenames. + ### So code doing the fixup has on VMS has to be able to handle both + ### UNIX format names and VMS format names. + ### XXX See http://www.xray.mpe.mpg.de/ + ### mailing-lists/perl5-porters/2007-10/msg00064.html + ### for details -- the below regex could use some touchups + ### according to John. M. + $file =~ s/\.dir//i if $^O eq 'VMS'; - my $path = File::Spec->catfile( $dir, $file ); + my $dirpath = File::Spec->catdir( $dir, $file ); ### directory, rmtree it if( -d $path ) { - print "Deleting directory '$path'\n" if $verbose; + print "# Deleting directory '$path'\n" if $verbose; eval { rmtree( $path ) }; warn "Could not delete '$path' while cleaning up '$dir'" if $@; ### regular file } else { - print "Deleting file '$path'\n" if $verbose; + print "# Deleting file '$path'\n" if $verbose; 1 while unlink $path; } } @@ -247,4 +150,5 @@ sub _clean_test_dir { return 1; } + 1; diff --git a/lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz.packed b/lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz.packed index d88c88e..26020e9 100644 --- a/lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz.packed +++ b/lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz.packed @@ -10,7 +10,7 @@ To recreate it use the following command: uupacktool.pl -p lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz lib/CPANPLUS/Dist/Build/t/src/noxs/Foo-Bar-0.01.tar.gz.packed -Created at Mon May 28 14:55:52 2007 +Created at Fri Nov 9 13:38:49 2007 ######################################################################### __UU__ M'XL("-