[Bps-public-commit] Shipwright branch, master, updated. d69ccfc9c24ce55d0dc6eedb432af49b2efe7a29

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Jul 27 06:44:34 EDT 2009


The branch, master has been updated
       via  d69ccfc9c24ce55d0dc6eedb432af49b2efe7a29 (commit)
       via  e819eac87e11874add29a791ae8f0bdce0bd4448 (commit)
       via  ce1e7adf12ed078886257917d345503f2bab2476 (commit)
      from  3d341cf228b652b961b76e1ec2ec16497f941b81 (commit)

Summary of changes:
 Changes                         |    4 +
 META.yml                        |    2 +-
 README                          |    8 +-
 lib/Shipwright.pm               |    2 +-
 lib/Shipwright/Backend.pm       |    4 +-
 lib/Shipwright/Backend/Base.pm  |    5 +-
 lib/Shipwright/Backend/FS.pm    |   58 ++++++-----
 lib/Shipwright/Script/Import.pm |    2 +-
 lib/Shipwright/Script/Update.pm |    1 -
 lib/Shipwright/Source/Base.pm   |    4 +-
 lib/Shipwright/Util.pm          |   11 ++-
 share/bin/shipwright-builder    |  223 ++++++++++++++++++++++----------------
 t/05.util.t                     |    2 +-
 t/71.script_cmds.t              |   54 ++++++----
 t/hello/fs.t                    |    5 +-
 t/hello/scripts/build           |    2 +-
 16 files changed, 223 insertions(+), 164 deletions(-)

- Log -----------------------------------------------------------------
commit ce1e7adf12ed078886257917d345503f2bab2476
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jul 27 18:33:48 2009 +0800

    improvements to make shipwright happoer on windows

diff --git a/lib/Shipwright/Backend.pm b/lib/Shipwright/Backend.pm
index 4a06465..b98c7eb 100644
--- a/lib/Shipwright/Backend.pm
+++ b/lib/Shipwright/Backend.pm
@@ -4,7 +4,7 @@ use warnings;
 use strict;
 use Carp;
 use UNIVERSAL::require;
-use Cwd qw/abs_path/;
+use File::Spec::Functions qw/rel2abs/;
 use Shipwright::Util;
 
 sub new {
@@ -26,7 +26,7 @@ sub new {
     elsif ( $args{repository} =~ m{^\s*fs:} ) {
         $args{repository} =~ s{^\s*fs:}{};
         $args{repository} =~ s/^~/Shipwright::Util->user_home/e;
-        my $abs_path = abs_path($args{repository});
+        my $abs_path = rel2abs($args{repository});
         $args{repository} = $abs_path if $abs_path;
         $module = 'Shipwright::Backend::FS';
     }
diff --git a/lib/Shipwright/Backend/Base.pm b/lib/Shipwright/Backend/Base.pm
index 4711225..ea9aad8 100644
--- a/lib/Shipwright/Backend/Base.pm
+++ b/lib/Shipwright/Backend/Base.pm
@@ -3,7 +3,7 @@ package Shipwright::Backend::Base;
 use warnings;
 use strict;
 use Carp;
-use File::Spec::Functions qw/catfile catdir/;
+use File::Spec::Functions qw/catfile catdir splitpath/;
 use Shipwright::Util;
 use File::Temp qw/tempdir/;
 use File::Copy qw/copy/;
@@ -152,8 +152,7 @@ sub import {
     my $self = shift;
     return unless ref $self; # get rid of class->import
     my %args = @_;
-    my $name = $args{source};
-    $name =~ s{.*/}{};
+    my $name = ( splitpath( $args{source} ) )[-1];
 
     if ( $self->has_branch_support ) {
         if ( $args{branches} ) {
diff --git a/lib/Shipwright/Backend/FS.pm b/lib/Shipwright/Backend/FS.pm
index ff317ec..1d64666 100644
--- a/lib/Shipwright/Backend/FS.pm
+++ b/lib/Shipwright/Backend/FS.pm
@@ -3,7 +3,7 @@ package Shipwright::Backend::FS;
 use warnings;
 use strict;
 use Carp;
-use File::Spec::Functions qw/catfile splitdir/;
+use File::Spec::Functions qw/catfile splitdir catdir/;
 use Shipwright::Util;
 use File::Copy qw/copy/;
 use File::Copy::Recursive qw/dircopy/;
@@ -37,7 +37,8 @@ sub initialize {
 
     $self->delete;    # clean repository in case it exists
 
-    dircopy( $dir, $self->repository ) or confess "can't copy $dir to " .  $self->repository . ": $!";
+    dircopy( $dir, $self->repository )
+      or confess "can't copy $dir to " . $self->repository . ": $!";
 }
 
 # a cmd generating factory
@@ -58,51 +59,54 @@ sub _cmd {
     }
     elsif ( $type eq 'import' ) {
         if ( $args{_extra_tests} ) {
-            @cmd =
-              [ 'cp', '-r', $args{source}, $self->repository . '/t/extra' ];
+            @cmd = [
+                'cp', '-r',
+                $args{source}, catdir( $self->repository, 't', 'extra' )
+            ];
         }
         else {
             if ( my $script_dir = $args{build_script} ) {
                 push @cmd,
                   [
-                    'cp', '-r', "$script_dir/",
-                    $self->repository . "/scripts/$args{name}",
+                    'cp', '-r', catdir($script_dir),
+                    catdir( $self->repository, 'scripts', $args{name} )
                   ];
             }
             else {
                 if ( $self->has_branch_support ) {
                     my @dirs = splitdir( $args{as} );
                     unless (
-                          -e $self->repository
-                        . "/sources/$args{name}/"
-                        . join '/',
-                        @dirs[ 0 .. $#dirs - 1 ]
+                        -e catdir(
+                            $self->repository, 'sources',
+                            $args{name},       @dirs[ 0 .. $#dirs - 1 ]
+                        )
                       )
                     {
                         push @cmd,
                           [
-                            'mkdir',
-                            '-p',
-                            $self->repository
-                              . "/sources/$args{name}/"
-                              . join '/',
-                            @dirs[ 0 .. $#dirs - 1 ]
+                            'mkdir', '-p',
+                            catdir(
+                                $self->repository, 'sources',
+                                $args{name},       @dirs[ 0 .. $#dirs - 1 ]
+                            )
                           ];
                     }
 
                     push @cmd,
                       [
-                        'cp', '-r', "$args{source}/",
-                        $self->repository . "/sources/$args{name}/$args{as}",
+                        'cp', '-r',
+                        catdir( $args{source} ),
+                        catdir(
+                            $self->repository, 'sources',
+                            $args{name},       $args{as}
+                        )
                       ];
                 }
                 else {
-                    push @cmd,
-                      [
-                        'cp', '-r', "$args{source}/",
-                        $self->repository . "/dists/$args{name}",
-                      ];
-
+                    push @cmd, [
+                        'cp', '-r', catdir( $args{source} ),
+                        catdir( $self->repository, 'dists', $args{name} )
+                    ];
                 }
             }
         }
@@ -166,7 +170,7 @@ sub info {
         return $info, $err;
     }
     else {
-        return if $info =~ /no such file or directory/;
+        return if $info =~ /no such file or directory/i;
         return $info;
     }
 }
@@ -188,7 +192,7 @@ sub _update_file {
     my $latest = shift;
 
     my $file = catfile( $self->repository, $path );
-
+    unlink $file;
     copy( $latest, $file ) or confess "can't copy $latest to $file: $!";
 }
 
@@ -207,7 +211,7 @@ sub _update_dir {
 
 sub import {
     my $self = shift;
-    return unless ref $self; # get rid of class->import
+    return unless ref $self;    # get rid of class->import
     return $self->SUPER::import( @_, delete => 1 );
 }
 
diff --git a/lib/Shipwright/Script/Import.pm b/lib/Shipwright/Script/Import.pm
index 313a41c..5ffb945 100644
--- a/lib/Shipwright/Script/Import.pm
+++ b/lib/Shipwright/Script/Import.pm
@@ -161,7 +161,7 @@ sub run {
 
             $version =
               Shipwright::Util::LoadFile( $shipwright->source->version_path );
-            my ($name) = $source =~ m{.*/(.*)$};
+            my $name = ( splitdir( $source ) )[-1];
 
             my $base = $self->_parent_dir($source);
 
diff --git a/lib/Shipwright/Script/Update.pm b/lib/Shipwright/Script/Update.pm
index c6c5cb9..57e1d66 100644
--- a/lib/Shipwright/Script/Update.pm
+++ b/lib/Shipwright/Script/Update.pm
@@ -207,7 +207,6 @@ sub run {
             }
         }
     }
-
     $self->log->fatal( 'updated with success' );
 }
 
diff --git a/lib/Shipwright/Source/Base.pm b/lib/Shipwright/Source/Base.pm
index 3ab61d1..ed250f0 100644
--- a/lib/Shipwright/Source/Base.pm
+++ b/lib/Shipwright/Source/Base.pm
@@ -162,7 +162,7 @@ sub _follow {
               or confess "can't read Build.PL: $!";
 
             Shipwright::Util->run(
-                [ './Build', 'realclean', '--allow_mb_mismatch', 1 ] );
+                [ $^X, 'Build', 'realclean', '--allow_mb_mismatch', 1 ] );
         }
         elsif ( -e 'Makefile.PL' ) {
             my $makefile = read_file('Makefile.PL')
@@ -656,7 +656,7 @@ return true if the source is compressed file, i.e. tar.gz(tgz) and tar.bz2
 
 sub is_compressed {
     my $self = shift;
-    return 1 if $self->source =~ m{.*/.+\.(tar.(gz|bz2)|tgz)$};
+    return 1 if $self->source =~ m{\.(tar.(gz|bz2)|tgz)$};
     return;
 }
 
diff --git a/lib/Shipwright/Util.pm b/lib/Shipwright/Util.pm
index e03f0bb..3dbcb6d 100644
--- a/lib/Shipwright/Util.pm
+++ b/lib/Shipwright/Util.pm
@@ -4,7 +4,7 @@ use warnings;
 use strict;
 use Carp;
 use IPC::Run3;
-use File::Spec::Functions qw/catfile catdir splitpath splitdir tmpdir/;
+use File::Spec::Functions qw/catfile catdir splitpath splitdir tmpdir rel2abs/;
 use File::Temp qw/tempfile/;
 use Cwd qw/abs_path/;
 
@@ -60,7 +60,7 @@ sub run {
     my ( $out, $err );
     $log->info( "run cmd: " . join ' ', @$cmd );
     Shipwright::Util->select('null');
-    run3( $cmd, \*STDIN, \$out, \$err );
+    run3( $cmd, undef, \$out, \$err );
     Shipwright::Util->select('stdout');
 
     $log->debug("run output:\n$out") if $out;
@@ -94,7 +94,7 @@ sub shipwright_root {
 
     unless ($SHIPWRIGHT_ROOT) {
         my $dir = ( splitpath( $INC{"Shipwright.pm"} ) )[1];
-        $SHIPWRIGHT_ROOT = abs_path($dir);
+        $SHIPWRIGHT_ROOT = rel2abs($dir);
     }
 
     return ($SHIPWRIGHT_ROOT);
@@ -113,7 +113,10 @@ sub share_root {
     unless ($SHARE_ROOT) {
         my @root = splitdir( $self->shipwright_root );
 
-        if ( $root[-2] ne 'blib' && $root[-1] eq 'lib' ) {
+        if (   $root[-2] ne 'blib'
+            && $root[-1] eq 'lib'
+            && ( $^O !~ /MSWin/ || $root[-2] ne 'site' ) )
+        {
 
             # so it's -Ilib in the Shipwright's source dir
             $root[-1] = 'share';
diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index ce4ffb3..6502764 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -4,20 +4,20 @@ use warnings;
 use strict;
 
 use lib 'inc';
-use File::Spec::Functions qw/catfile catdir splitdir/;
+use File::Spec::Functions qw/catfile catdir splitdir rel2abs/;
 use File::Temp qw/tempdir/;
 use File::Copy qw/move copy/;
 use File::Find qw/find/;
 use File::Path;
 use Config;
 use Getopt::Long;
-use Cwd qw/getcwd abs_path/;
+use Cwd qw/getcwd/;
 use YAML::Tiny;
 use Shipwright::Util::CleanINC;
 use Carp qw/confess/;
 
 my $build_base = getcwd;
-my $inc_lib = catdir( $build_base, 'inc' );
+my $inc_lib = join '/', splitdir($build_base), 'inc';
 
 @ARGV = get_default_builder_options() unless @ARGV;
 
@@ -25,7 +25,7 @@ my %args;
 
 use Getopt::Long;
 confess "unknown option"
-unless GetOptions(
+  unless GetOptions(
     \%args,                   'install-base=s',
     'perl=s',                 'skip=s',
     'flags=s',                'skip-test',
@@ -37,7 +37,7 @@ unless GetOptions(
     'with=s',                 'noclean-after-install',
     'make=s',                 'branches=s',
     'verbose',                'as=s',
-);
+  );
 
 my $USAGE = <<'END';
 run: ./bin/shipwright-builder
@@ -106,14 +106,15 @@ if ( $args{'help'} ) {
     exit 0;
 }
 
-if ($args{'advanced-help'}) {
-        print $ADVANCED_USAGE;
-        exit 0;
+if ( $args{'advanced-help'} ) {
+    print $ADVANCED_USAGE;
+    exit 0;
 }
 
-unless (-d 'shipwright') {
-        print "$0 expects to be run in a directory with a 'shipwright' subdirectory\n";
-        exit -1;
+unless ( -d 'shipwright' ) {
+    print
+      "$0 expects to be run in a directory with a 'shipwright' subdirectory\n";
+    exit -1;
 }
 
 $args{skip} = { map { $_ => 1 } split /\s*,\s*/, $args{skip} || '' };
@@ -122,10 +123,14 @@ $args{flags} = {
     map { $_ => 1 } split /\s*,\s*/, $args{flags} || ''
 };
 
-$args{with} = { map { split /=/ } split /\s*,\s*/, $args{with} || '' };
+$args{with}     = { map { split /=/ } split /\s*,\s*/, $args{with}     || '' };
 $args{branches} = { map { split /=/ } split /\s*,\s*/, $args{branches} || '' };
 $args{make} ||= 'make';
-my $uname = `uname 2>/dev/null`;
+my $uname_cmd = 'uname';
+if ( $^O !~ /MSWin/ ) {
+    $uname_cmd .= ' 2>/dev/null';
+}
+my $uname = `$uname_cmd`;
 chomp $uname;
 $args{as} ||= $uname || 'default';
 
@@ -137,8 +142,9 @@ $args{'install-base'} = get_install_base() unless $args{'install-base'};
 
 # replace prefix ~ with real home dir
 $args{'install-base'} =~ s/^~/(getpwuid $<)[7]/e;
+
 # remove last / or \
-$args{'install-base'} =~ s![/\\]$!!;
+$args{'install-base'} =~ s{[/\\]$}{};
 
 unless ( $args{name} ) {
     if ( $build_base =~ m{([-.\w]+)[\\/]([.\d]+)$} ) {
@@ -157,7 +163,8 @@ unless ( $args{'install-base'} ) {
 
 my $installed;
 my $installed_hash = {};
-my $installed_file = catfile( $args{'install-base'}, "$args{as}_installed.yml" );
+my $installed_file =
+  catfile( $args{'install-base'}, "$args{as}_installed.yml" );
 if ( -e $installed_file ) {
     $installed = YAML::Tiny->read(
         catfile( $args{'install-base'}, "$args{as}_installed.yml" ) );
@@ -167,7 +174,7 @@ else {
     $installed = YAML::Tiny->new;
 }
 
-$args{'install-base'} = abs_path( $args{'install-base'} );
+$args{'install-base'} = rel2abs( $args{'install-base'} );
 
 # YAML::Tiny objects are array based.
 my $order = ( YAML::Tiny->read( catfile( 'shipwright', 'order.yml' ) ) )->[0];
@@ -226,12 +233,9 @@ else {
 @$order = grep { !$installed_hash->{$_} } @$order;
 
 my $log;
-my $build_log_file = abs_path( 'build.log' );
-my $system_cmd_pipe;
-if ( $args{'verbose'} ) {
-    $system_cmd_pipe = '';
-}
-else {
+my $build_log_file  = rel2abs('build.log');
+my $system_cmd_pipe = '';
+if ( $^O !~ /MSWin/ && !$args{'verbose'} ) {
     $system_cmd_pipe = " >>$build_log_file 2>&1";
 }
 
@@ -248,7 +252,7 @@ else {
         print "seems it has been built before, need to clean first\n";
         clean();
     }
-    if ( @$order ) {
+    if (@$order) {
         install();
     }
     else {
@@ -298,14 +302,21 @@ sub install {
 
     {
 
-                my $arch_command = ($args{perl} || $^X)." -MConfig -e 'print \$Config{archname}'";
-                my $arch = `$arch_command`;
+        my $arch_command = $args{perl} || $^X;
+        if ( $^O =~ /MSWin/ ) {
+            $arch_command .= q{ -MConfig -e "print $Config{archname}"};
+        }
+        else {
+            $arch_command .= q{ -MConfig -e 'print $Config{archname}'};
+        }
+        my $arch = `$arch_command`;
 
         no warnings 'uninitialized';
-        # this dirty hack means that ExtUtils::AutoInstall won't try to recurse and run cpan
-        $ENV{'PERL5_CPANPLUS_IS_RUNNING'}= 1;
-        $ENV{'AUTOMATED_TESTING'} =1; # Term::ReadLine::Perl and others
-                                      # use this to not prompt
+
+# this dirty hack means that ExtUtils::AutoInstall won't try to recurse and run cpan
+        $ENV{'PERL5_CPANPLUS_IS_RUNNING'} = 1;
+        $ENV{'AUTOMATED_TESTING'}         = 1; # Term::ReadLine::Perl and others
+                                               # use this to not prompt
         $ENV{DYLD_LIBRARY_PATH} =
           catdir( $args{'install-base'}, 'lib' ) . ':'
           . $ENV{DYLD_LIBRARY_PATH};
@@ -313,11 +324,12 @@ sub install {
           catdir( $args{'install-base'}, 'lib' ) . ':' . $ENV{LD_LIBRARY_PATH};
         $ENV{PERL5LIB} = join(
             ':',
-            catdir( 'blib','lib'),
-            catdir('blib','arch'),
-            $inc_lib, #BLIB COMES FIRST TO PLEASE MODULE::BUILD
-            catdir( $args{'install-base'}, 'lib', 'perl5',  $arch
-            
+            catdir( 'blib', 'lib' ),
+            catdir( 'blib', 'arch' ),
+            $inc_lib,    #BLIB COMES FIRST TO PLEASE MODULE::BUILD
+            catdir(
+                $args{'install-base'}, 'lib', 'perl5', $arch
+
             ),
             catdir( $args{'install-base'}, 'lib', 'perl5', 'site_perl' ),
             catdir( $args{'install-base'}, 'lib', 'perl5' ),
@@ -330,17 +342,17 @@ sub install {
           . catdir( $args{'install-base'}, 'usr', 'bin' ) . ':'
           . $ENV{PATH};
         $ENV{PERL_MM_USE_DEFAULT} = 1;
-        $ENV{PERL_MM_OPT} = '';
-        $ENV{MODULEBUILDRC} = '';
+        $ENV{PERL_MM_OPT}         = '';
+        $ENV{MODULEBUILDRC}       = '';
         $ENV{LDFLAGS} .= ' -L' . catdir( $args{'install-base'}, 'lib' );
         $ENV{CFLAGS}  .= ' -I' . catdir( $args{'install-base'}, 'include' );
     }
 
     mkpath $args{'install-base'} unless -e $args{'install-base'};
 
-    mkdir catdir( $args{'install-base'},       'etc' )
+    mkdir catdir( $args{'install-base'}, 'etc' )
       unless -e catdir( $args{'install-base'}, 'etc' );
-    mkdir catdir( $args{'install-base'},       'tools' )
+    mkdir catdir( $args{'install-base'}, 'tools' )
       unless -e catdir( $args{'install-base'}, 'tools' );
 
     for ( 'shipwright-script-wrapper', 'shipwright-perl-wrapper' ) {
@@ -359,7 +371,7 @@ sub install {
       catfile( $args{'install-base'}, 'tools', 'shipwright-utility' );
 
     # remove lib it's symbolic link
-    for my $r ( 'lib' ) {
+    for my $r ('lib') {
         my $dir = catdir( $args{'install-base'}, $r );
         unlink $dir if -l $dir;
     }
@@ -371,11 +383,10 @@ sub install {
         {
             my $dir = catdir( $args{'install-base'}, $r );
             next unless -e $dir;
-            system("rm -rf $dir");
+            `rm -rf $dir`;
         }
     }
 
-
     mkdir 'dists' unless -e 'dists';
     for my $dist (@$order) {
         _install( $dist, $log );
@@ -403,26 +414,28 @@ sub install {
     my $as_dir = catdir( 'as', $args{as} );
     mkdir $as_dir;
 
-    for my $r ( 'lib', 'bin', 'sbin' ) {
-        next unless -e $r;
-        my $dir = catdir( $as_dir, $r );
-        system("mv $r $as_dir");
+    if ( $^O !~ /MSWin/ ) {
+        for my $r ( 'lib', 'bin', 'sbin' ) {
+            next unless -e $r;
+            my $dir = catdir( $as_dir, $r );
+            system("mv $r $as_dir");
 
-        if ( $r !~ /bin/ ) {
-            symlink $dir, $r;
+            if ( $r !~ /bin/ ) {
+                symlink $dir, $r;
+            }
         }
-    }
 
-    # in usr dir
-    my $usr_dir = catdir( $as_dir, 'usr' );
-    mkdir $usr_dir;
-    for my $r ( 'bin', 'sbin' ) {
-        next unless -e catdir( 'usr', $r );
-        system( "mv " . catdir( 'usr', $r ) . ' ' . $usr_dir );
-    }
-    chdir $cwd;
+        # in usr dir
+        my $usr_dir = catdir( $as_dir, 'usr' );
+        mkdir $usr_dir;
+        for my $r ( 'bin', 'sbin' ) {
+            next unless -e catdir( 'usr', $r );
+            system( "mv " . catdir( 'usr', $r ) . ' ' . $usr_dir );
+        }
+        chdir $cwd;
 
-    wrap_bin($log) unless $^O =~ /MSWin/;
+        wrap_bin($log);
+    }
 
     print "install finished, the dists are at $args{'install-base'}\n";
     print $log "install finished, the dists are at $args{'install-base'}\n";
@@ -438,19 +451,18 @@ sub _install {
     else {
         if ($branches) {
             my $branch = $args{branches}{$dir} || $branches->{$dir}[0];
-            # If no branch is specified but the vendor dir is there, 
-            # assume we should use it 
-            # XXX TODO - this will fail on old shipwright sources 
+
+            # If no branch is specified but the vendor dir is there,
+            # assume we should use it
+            # XXX TODO - this will fail on old shipwright sources
             # which have a vendor directory inside the dist.
-            if (!$branch  &&     -d  catdir( 'sources', $dir,  'vendor' )) {
-                        $branch = 'vendor';
-            }  
-           system( "cp -r "
-                  . catdir( 'sources', $dir, split /\//, $branch )
-                  . ' '
+            if ( !$branch && -d catdir( 'sources', $dir, 'vendor' ) ) {
+                $branch = 'vendor';
+            }
+            system( "cp -r "
+                  . catdir( 'sources', $dir, split /\//, $branch ) . ' '
                   . catdir( 'dists', $dir ) )
-              && confess
-              "cp sources/$dir/$branch to dists/$dir failed";
+              && confess "cp sources/$dir/$branch to dists/$dir failed";
         }
         chdir catdir( 'dists', $dir );
     }
@@ -467,20 +479,22 @@ sub _install {
 
     if ( -e catfile( '..', '..', 'scripts', $dir, 'build.pl' ) ) {
         print $log "Found build.pl for $dir, will install $dir using that\n";
-        my $cmd = join ' ', 
-           'PERL5OPT=-MShipwright::Util::CleanINC',
-            $args{perl} || $^X,
+        my $cmd = join ' ',
+          $args{perl} || $^X,
+          '-MShipwright::Util::CleanINC',
           catfile( '..', '..', 'scripts', $dir, 'build.pl' ),
           '--install-base' => $args{'install-base'},
           '--flags'        => join( ',', keys %{ $args{flags} } ),
           $skip_test ? '--skip-test' : (), $args{'force'} ? '--force' : (),
           $args{'clean'} ? '--clean' : ();
-        if ( system($cmd . $system_cmd_pipe) ) {
-            print $log "build $dir failed" . (
+        system("$cmd $system_cmd_pipe");
+        if ( $? >> 8 ) {
+            print $log "build $dir failed"
+              . (
                 $? == -1
                 ? ": $!"
                 : ( ' with value ' . ( $? >> 8 ) )
-            ) . "\n";
+              ) . "\n";
             confess "Build $dir failed\n";
         }
     }
@@ -499,12 +513,14 @@ sub _install {
             print $log "Build $type part in $dir with cmd: $cmd\n";
 
             print $log "Running shipwright build command: $cmd\n";
-            if ( system($cmd . $system_cmd_pipe) ) {
-                print $log "build $dir $type failed" . (
+            system("$cmd $system_cmd_pipe");
+            if ( $? >> 8 ) {
+                print $log "build $dir $type failed"
+                  . (
                     $? == -1
                     ? ": $!"
                     : ( ' with value ' . ( $? >> 8 ) )
-                ) . "\n";
+                  ) . "\n";
                 if ( $type eq 'test' ) {
                     if ( $args{force} ) {
                         print $log
@@ -582,8 +598,10 @@ sub wrap_bin {
             $type
             && (   -e catfile( '..', 'bin', $type )
                 || -e catfile( ('..') x $wrapped_depth, 'bin', $type ) )
-            && -e catfile( ('..') x $wrapped_depth, 'etc',
-                "shipwright-$type-wrapper" )
+            && -e catfile(
+                ('..') x $wrapped_depth,
+                'etc', "shipwright-$type-wrapper"
+            )
           )
         {
             symlink catfile( ('..') x $wrapped_depth,
@@ -624,24 +642,39 @@ sub substitute {
         $perl = $^X;
     }
 
-    my $perl_archname = `$perl -MConfig -e 'print \$Config{archname}'`;
-    $text =~ s/%%PERL%%/PERL5OPT="-I$inc_lib -MShipwright::Util::CleanINC" $perl/g;
+    my $perl_archname;
+    if ( $^O =~ /MSWin/ ) {
+        $perl_archname = `$perl -MConfig -e "print \$Config{archname}"`;
+    }
+    else {
+        $perl_archname = `$perl -MConfig -e 'print \$Config{archname}'`;
+    }
+
+    $text =~ s/%%PERL%%/$perl -I$inc_lib -MShipwright::Util::CleanINC/g;
     $text =~ s/%%PERL_ARCHNAME%%/$perl_archname/g;
     $text =~ s/%%MODULE_BUILD_EXTRA%%//g;
-    $text =~ s/%%MAKE%%/PERL5OPT="-I$inc_lib -MShipwright::Util::CleanINC" $args{make}/g;
+    $text =~ s/%%MAKE%%/$args{make}/g;
 
-    `$perl -MShipwright::Util::CleanINC -e'eval { require Pod::Man}; if (\$@) { exit 1} else { exit 0 }' `;
-    my $no_podman = $?>>8;
-    if ($no_podman || $args{'skip-man-pages'}) {
-        $text =~ s/%%MODULE_BUILD_BEFORE_BUILD_PL%%/-MShipwright::Util::PatchModuleBuild/;
-        $text =~ s/%%MODULE_BUILD_BEFORE_BUILD%%/-MShipwright::Util::PatchModuleBuild/;
-         $text =~ s/%%MAKEMAKER_CONFIGURE_EXTRA%%/INSTALLMAN1DIR=none INSTALLMAN3DIR=none/;
-    } else {
-         $text =~ s/%%MAKEMAKER_CONFIGURE_EXTRA%%//;
-         $text =~ s/%%MODULE_BUILD_BEFORE_BUILD_PL%%//;
-         $text =~ s/%%MODULE_BUILD_BEFORE_BUILD%%//;
+    if ( $^O =~ /MSWin/ ) {
+`$perl -I$inc_lib -MShipwright::Util::CleanINC -e"eval { require Pod::Man}; if (\$@) { exit 1} else { exit 0 }" `;
+    }
+    else {
+`$perl -I$inc_lib -MShipwright::Util::CleanINC -e'eval { require Pod::Man}; if (\$@) { exit 1} else { exit 0 }' `;
+    }
+    my $no_podman = $? >> 8;
+    if ( $no_podman || $args{'skip-man-pages'} ) {
+        $text =~
+s/%%MODULE_BUILD_BEFORE_BUILD_PL%%/-MShipwright::Util::PatchModuleBuild/;
+        $text =~
+          s/%%MODULE_BUILD_BEFORE_BUILD%%/-MShipwright::Util::PatchModuleBuild/;
+        $text =~
+s/%%MAKEMAKER_CONFIGURE_EXTRA%%/INSTALLMAN1DIR=none INSTALLMAN3DIR=none/;
+    }
+    else {
+        $text =~ s/%%MAKEMAKER_CONFIGURE_EXTRA%%//;
+        $text =~ s/%%MODULE_BUILD_BEFORE_BUILD_PL%%//;
+        $text =~ s/%%MODULE_BUILD_BEFORE_BUILD%%//;
     }
-
 
     return $text;
 }
@@ -651,6 +684,7 @@ sub test {
     for (@$cmds) {
         my ( $type, $cmd ) = @$_;
         print $log "run tests $type part with cmd: $cmd\n";
+
         # the return of system is not so uselful, so omit it
         system($cmd);
     }
@@ -718,6 +752,7 @@ sub _clean {
     if ( -e catfile( '..', '..', 'scripts', $dir, 'build.pl' ) ) {
         print $log "Using build.pl to clean $dir\n";
         $cmd = join ' ', $args{perl} || $^X,
+          "-I $inc_lib",
           '-MShipwright::Util::CleanINC',
           catfile( '..', '..', 'scripts', $dir, 'build.pl' ),
           '--install-base' => $args{'install-base'},
@@ -758,7 +793,7 @@ sub get_install_base {
 sub get_default_builder_options {
     my @argv;
     if ( open my $fh, '<', '__default_builder_options' ) {
-        while( <$fh> ) {
+        while (<$fh>) {
             chomp;
             next if /^\s*#/;
             next unless /\S/;
diff --git a/t/05.util.t b/t/05.util.t
index 2b1cce5..2254271 100644
--- a/t/05.util.t
+++ b/t/05.util.t
@@ -14,7 +14,7 @@ Shipwright::Test->init;
 my $cwd = getcwd;
 my ( $shipwright_root, $share_root );
 
-if ( grep { m{blib/lib} } @INC ) {
+if ( grep { m{blib[/\\]lib} } @INC ) {
 
     # found blib/lib, so we're probably in `make test` or something like that.
     $shipwright_root = catfile( $cwd, 'blib', 'lib' );
diff --git a/t/71.script_cmds.t b/t/71.script_cmds.t
index 0e353f0..8a8ce16 100644
--- a/t/71.script_cmds.t
+++ b/t/71.script_cmds.t
@@ -1,14 +1,20 @@
 use strict;
 use warnings;
 
-use Test::More tests => 140;
+use Test::More;
+if ( $^O =~ /MSWin/ ) {
+    plan tests => 136;
+}
+else {
+    plan tests => 140;
+}
 
 use Shipwright;
 use Shipwright::Test;
 use File::Spec::Functions qw/catdir tmpdir/;
 use File::Path qw/rmtree/;
 use Cwd qw/getcwd/;
-my $sw = Shipwright::Test->shipwright_bin;
+my $sw  = Shipwright::Test->shipwright_bin;
 my $cwd = getcwd;
 
 Shipwright::Test->init;
@@ -22,13 +28,15 @@ my $build_base   = catdir( tmpdir(), 'shipwright_build_71_scripts_cmds' );
 }
 
 SKIP: {
-    skip "git: no git found or env SHIPWRIGHT_TEST_GIT not set", 34
+    skip "git: no git found or env SHIPWRIGHT_TEST_GIT not set", ( $^O =~
+        /MSWin/ ? 33 : 34 )
       if skip_git();
     start_test( 'git:' . create_git_repo() );
 }
 
 SKIP: {
-    skip "svn: no svn found or env SHIPWRIGHT_TEST_SVN not set", 36
+    skip "svn: no svn found or env SHIPWRIGHT_TEST_SVN not set", ( $^O =~
+        /MSWin/ ? 35 : 36 )
       if skip_svn();
 
     my $repo = 'svn:' . create_svn_repo() . '/hello';
@@ -52,7 +60,8 @@ SKIP: {
 }
 
 SKIP: {
-    skip "svk: no svk found or env SHIPWRIGHT_TEST_SVK not set", 36
+    skip "svk: no svk found or env SHIPWRIGHT_TEST_SVK not set", ( $^O =~
+        /MSWin/ ? 35 : 36 )
       if skip_svk();
 
     create_svk_repo();
@@ -278,15 +287,6 @@ qr/set mandatory flags with success\s+mandatory flags of man1 are build/,
             'Build.PL and Makefile.PL are run',
         ],
         [
-            [
-                'build',     '--flags',
-                'configure', '--install-base',
-                $install_base, '--verbose',
-            ],
-            qr/run, run, configure/,
-            'configure is run',
-        ],
-        [
             [ 'update', '--builder' ],
             qr/updated with success/,
             "updated builder",
@@ -296,9 +296,18 @@ qr/set mandatory flags with success\s+mandatory flags of man1 are build/,
             qr/updated with success/,
             "updated utility",
         ],
-
-        $source
-        ? (
+        $^O =~ /MSWin/
+        ? ()
+        : [
+            [
+                'build',       '--flags',
+                'configure',   '--install-base',
+                $install_base, '--verbose',
+            ],
+            qr/run, run, configure/,
+            'configure is run',
+        ],
+        $source ? (
 
             # import an svn or svk dist named foo
             [
@@ -319,13 +328,18 @@ qr/set mandatory flags with success\s+mandatory flags of man1 are build/,
         if ( ref $item->[0] eq 'ARRAY' ) {
             my $cmd = shift @{ $item->[0] };
             if ( $cmd eq 'build' ) {
-# it's not really a build cmd, we need to export first, cd to it, 
-# then run bin/shipwright-builder
+
+               # it's not really a build cmd, we need to export first, cd to it,
+               # then run bin/shipwright-builder
                 my $shipwright = Shipwright->new( repository => $repo );
                 $shipwright->backend->export( target => $build_base );
                 chdir $build_base;
                 test_cmd(
-                    [ $^X, 'bin/shipwright-builder', @{ $item->[0] } ],
+                    [
+                        $^X, 'bin/shipwright-builder',
+                        @{ $item->[0] },
+                        $^O =~ /MSWin/ ? ( '--make', 'dmake' ) : ()
+                    ],
                     @$item[ 1 .. $#$item ],
                 );
                 chdir $cwd;
diff --git a/t/hello/fs.t b/t/hello/fs.t
index 055057e..aaa8179 100644
--- a/t/hello/fs.t
+++ b/t/hello/fs.t
@@ -130,7 +130,7 @@ like(
     'original order is right'
 );
 
-system( 'cp -r ' . catfile( $tempdir, 'shipwright' ) . " $repo/" );
+system( 'cp -r ' . catdir( $tempdir, 'shipwright' ) . " $repo" );
 like(
     `cat $repo/shipwright/order.yml`,
     qr/howdy.*Foo-Bar/s,
@@ -161,7 +161,8 @@ for (
 }
 
 chdir( $build_base );
-system( "$^X bin/shipwright-builder --install-base $install_base" );
+system( "$^X bin/shipwright-builder --install-base $install_base"
+      . ( $^O =~ /MSWin/ ? ' --make dmake' : '' ) );
 for (
     catfile(
         $install_base, 'lib',
diff --git a/t/hello/scripts/build b/t/hello/scripts/build
index 2a1abbf..7b58e98 100644
--- a/t/hello/scripts/build
+++ b/t/hello/scripts/build
@@ -1,4 +1,4 @@
-configure: %%PERL%% Makefile.PL LIB=%%INSTALL_BASE%%/lib/perl5/ PREFIX=%%INSTALL_BASE%% %%MAKEMAKER_EXTRA%%
+configure: %%PERL%% Makefile.PL LIB=%%INSTALL_BASE%%/lib/perl5/ PREFIX=%%INSTALL_BASE%% %%MAKEMAKER_CONFIGURE_EXTRA%%
 make: %%MAKE%%
 test: %%MAKE%% test
 install: %%MAKE%% install

commit e819eac87e11874add29a791ae8f0bdce0bd4448
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jul 27 18:39:12 2009 +0800

    add a not for use on windows

diff --git a/README b/README
index 8d87502..5ac1a1c 100644
--- a/README
+++ b/README
@@ -10,11 +10,11 @@ To install this module, run the following commands:
     make test
     make install
 
+NOTES FOR USERS ON WINDOWS
 
-
-DEPENDENCIES
-
-None.
+Shipwright depends many UNIX shell cmds( e.g. ls, rm, mv ), so if you are
+on Windows, you need to install a UNIX Utility software that supplied those
+cmds, e.g. http://sourceforge.net/projects/unxutils/ can do this.
 
 
 COPYRIGHT AND LICENCE

commit d69ccfc9c24ce55d0dc6eedb432af49b2efe7a29
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jul 27 18:43:43 2009 +0800

    update version to 2.3.2

diff --git a/Changes b/Changes
index bd2c1a4..73a9150 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Shipwright
 
+2.3.2 Mon Jul 27 18:41:41 CST 2009
+
+* improvements version, mostly for windows
+
 2.3.1 Fri Jul 24 14:11:11 CST 2009
 
 * add --squeeze and --verbose args for shipwright-filter
diff --git a/META.yml b/META.yml
index 97730cd..de8d05c 100644
--- a/META.yml
+++ b/META.yml
@@ -52,4 +52,4 @@ requires:
   version: 0
 resources:
   license: http://dev.perl.org/licenses/
-version: 2.003001
+version: 2.003002
diff --git a/lib/Shipwright.pm b/lib/Shipwright.pm
index b0aa91b..cbf7c5f 100644
--- a/lib/Shipwright.pm
+++ b/lib/Shipwright.pm
@@ -2,7 +2,7 @@ package Shipwright;
 
 use warnings;
 use strict;
-use version; our $VERSION = qv('2.3.1');
+use version; our $VERSION = qv('2.3.2');
 
 use base qw/Class::Accessor::Fast/;
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list