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

? sunnavy sunnavy at bestpractical.com
Tue Jul 20 02:45:55 EDT 2010


The branch, master has been updated
       via  ed440b9c27fd9f78dde740b3f17738dd898d4cd1 (commit)
       via  bfe0b5bd88a0a348173325a5fb3386801eee502a (commit)
      from  ec1ba4fad9f70bf52dfa3da5892a30fd825a4f3f (commit)

Summary of changes:
 share/bin/shipwright-builder |   98 ++++++++++++++++++++++++++---------------
 1 files changed, 62 insertions(+), 36 deletions(-)

- Log -----------------------------------------------------------------
commit bfe0b5bd88a0a348173325a5fb3386801eee502a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 20 13:25:56 2010 +0800

    tweak shipwright-builder a bit, mostly the way to set $args{perl}

diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index d4c825d..ef44d05 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -320,14 +320,7 @@ sub install {
 
     unless ( $args{perl} && -e $args{perl} ) {
         my $perl = catfile( $args{'install-base'}, 'bin', 'perl' );
-
-        # -e $perl makes sense when we install onto another vessel
-        if ( ( grep { /^perl/ } @$order ) || -e $perl ) {
-            $args{perl} = $perl;
-        }
-        else {
-            $args{perl} = $^X;
-        }
+        $args{perl} = -e $perl ? $perl : $^X;
     }
 
     $args{perl} = $bin_quote . $args{perl} . $bin_quote
@@ -337,6 +330,11 @@ sub install {
     if ( $args{'no-install-base'} ) {
         for my $dist (@$order) {
             _install( $dist, $log );
+            if ( $dist =~ /^perl/ ) {
+                my $perl = catfile( $args{'install-base'}, 'bin', 'perl' );
+                $args{perl} = -e $perl ? $perl : $^X;
+            }
+
             chdir $build_base;
         }
         print "install finished\n";
@@ -349,15 +347,6 @@ sub install {
 
         {
 
-            my $arch_command = $args{perl};
-            if ( is_on_windows() ) {
-                $arch_command .= q{ -MConfig -e "print $Config{archname}" };
-            }
-            else {
-                $arch_command .= q{ -MConfig -e 'print $Config{archname}'};
-            }
-            my $arch = `$arch_command`;
-
             no warnings 'uninitialized';
             $ENV{DYLD_LIBRARY_PATH} =
               catdir( $args{'install-base'}, 'lib' ) . ':'
@@ -365,18 +354,7 @@ sub install {
             $ENV{LD_LIBRARY_PATH} =
               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( $args{'install-base'}, 'lib', 'perl5', 'site_perl' ),
-                catdir( $args{'install-base'}, 'lib', 'perl5' ),
-            );
+            _set_perl5lib();
 
             $ENV{PATH} =
                 catdir( $args{'install-base'}, 'sbin' ) . ':'
@@ -433,6 +411,11 @@ sub install {
         for my $dist (@$order) {
             _install( $dist, $log );
             _record( $dist, $log );
+            if ( $dist =~ /^perl/ ) {
+                my $perl = catfile( $args{'install-base'}, 'bin', 'perl' );
+                $args{perl} = -e $perl ? $perl : $^X;
+                _set_perl5lib();
+            }
             chdir $build_base;
         }
 
@@ -684,7 +667,7 @@ sub substitute {
         $text =~ s/%%INSTALL_BASE%%/$install_base/g;
     }
 
-    my $perl = $args{perl};
+    my $perl = -e $args{perl} ? $args{perl} : $^X;
 
     my $perl_archname;
     if ( is_on_windows() ) {
@@ -921,3 +904,26 @@ sub which {
 
     return $path;
 }
+
+sub _get_perl_arch {
+    my $arch_command = -e $args{perl} ? $args{perl} : $^X;
+    if ( is_on_windows() ) {
+        $arch_command .= q{ -MConfig -e "print $Config{archname}" };
+    }
+    else {
+        $arch_command .= q{ -MConfig -e 'print $Config{archname}'};
+    }
+    return `$arch_command`;
+}
+
+sub _set_perl5lib {
+    $ENV{PERL5LIB} = join(
+        ':',
+        catdir( 'blib', 'lib' ),
+        catdir( 'blib', 'arch' ),
+        $inc_lib,    #BLIB COMES FIRST TO PLEASE MODULE::BUILD
+        catdir( $args{'install-base'}, 'lib', 'perl5', _get_perl_arch() ),
+        catdir( $args{'install-base'}, 'lib', 'perl5', 'site_perl' ),
+        catdir( $args{'install-base'}, 'lib', 'perl5' ),
+    );
+}

commit ed440b9c27fd9f78dde740b3f17738dd898d4cd1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Jul 20 13:55:07 2010 +0800

    show last a few lines of build.log to screen to help debug

diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index ef44d05..aa126c1 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -501,10 +501,10 @@ sub _install {
         $skip_test = 0;
     }
 
-    print "Building $dir\n";
+    print "building $dir\n";
 
     if ( -e catfile( '..', '..', 'scripts', $dir, 'build.pl' ) ) {
-        print $log "Found build.pl for $dir, will install $dir using that\n";
+        print $log "found build.pl for $dir, will install $dir using that\n";
         my $cmd = join ' ',
           $args{perl},
           '-MShipwright::Util::CleanINC',
@@ -521,7 +521,10 @@ sub _install {
                 ? ": $!"
                 : ( ' with value ' . ( $? >> 8 ) )
               ) . "\n";
-            confess "Build $dir failed\n";
+            my $error =
+              "build $dir failed, the last output of build.log is:\n"
+              . "\t" . _get_log();
+            confess $error;
         }
     }
     else {
@@ -536,9 +539,9 @@ sub _install {
                 next;
             }
 
-            print $log "Build $type part in $dir with cmd: $cmd\n";
+            print $log "build $type part in $dir with cmd: $cmd\n";
 
-            print $log "Running shipwright build command: $cmd\n";
+            print $log "running shipwright build command: $cmd\n";
             system("$cmd $system_cmd_pipe");
             if ( $? >> 8 ) {
                 print $log "build $dir $type failed"
@@ -564,7 +567,10 @@ sub _install {
                 if ( $type ne 'clean' ) {
 
                     # clean is trivial, we'll just ignore if 'clean' fails
-                    confess "build $dir $type part failed.\n";
+                    my $error =
+"build $dir $type part failed, last output of build.log is:\n"
+                      . "\t" . _get_log();
+                    confess $error;
                 }
             }
             else {
@@ -927,3 +933,17 @@ sub _set_perl5lib {
         catdir( $args{'install-base'}, 'lib', 'perl5' ),
     );
 }
+
+sub _get_log {
+    my $number = shift || 20;
+    require Tie::File;
+    if ( tie my @array, 'Tie::File', $build_log_file, autochomp => 0 ) {
+        $number = @array if $number > @array;
+        return join "\t", grep { defined } @array[ -1*$number .. -1 ];
+    }
+    else {
+        warn "failed to open $build_log_file";
+        return;
+    }
+}
+

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



More information about the Bps-public-commit mailing list