[Bps-public-commit] r10280 - in bpsbuilder/BPB/lib/BPB: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jan 10 14:15:25 EST 2008


Author: sunnavy
Date: Thu Jan 10 14:15:22 2008
New Revision: 10280

Modified:
   bpsbuilder/BPB/lib/BPB/Backend.pm
   bpsbuilder/BPB/lib/BPB/Build.pm
   bpsbuilder/BPB/lib/BPB/Script/Import.pm

Log:
build now has type ahead of each line; added --skip-test arg for build script

Modified: bpsbuilder/BPB/lib/BPB/Backend.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Backend.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Backend.pm	Thu Jan 10 14:15:22 2008
@@ -20,7 +20,7 @@
     my $module = delete $args{module};
 
     croak "need a backend module, please check your config" unless $module;
-    croak "need name option" unless $args{name};
+    croak "need name option"                                unless $args{name};
 
     $module = 'BPB::Backend::' . $module unless $module =~ /^BPB::Backend/;
 
@@ -50,7 +50,7 @@
     DYLD_LIBRARY_PATH=${BASE_DIR}/../lib:${DYLD_LIBRARY_PATH}\
     exec ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/${FILENAME}  "$@"
 EOF
-;
+  ;
 
 our $BUILDER = <<'EOF'
 #!perl
@@ -68,7 +68,7 @@
 my $build_base = getcwd;
 
 my %args;
-GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s' );
+GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s', 'skip-test' );
 
 unless ( $args{'install-base'} ) {
     die 'need install-base option';
@@ -135,9 +135,35 @@
     }
     else {
         substitute('__build');
-        chmod 0755, '__build';
-        if ( system('./__build') ) {
-            print $fh "build $dir with failure $?: $!\n";
+        my (@cmds, $error);
+
+        {
+            open my $fh, '<', '__build' or die "can't open __build: $!";
+            @cmds = <$fh>;
+            chomp @cmds;
+        }
+
+        for (@cmds) {
+            my ( $type, $cmd );
+            if (/^(\S+):\s*(.*)/) {
+                $type = $1;
+                $cmd  = $2;
+            }
+            else {
+                $type = '';
+                $cmd  = $_;
+            }
+
+            next if $args{'skip-test'} && $type eq 'test';
+
+            if ( system($cmd) ) {
+                print $fh "build $dir with failure when run $type: $!\n";
+                $error = 1;
+            }
+        }
+
+        if ($error) {
+            print $fh "build $dir with failure!\n";
         }
         else {
             print $fh "build $dir with success!\n";
@@ -168,7 +194,7 @@
 
     my @dirs =
       grep { -d $_ }
-      map { File::Spec->catfile( $args{install_base}, $_ ) }
+      map { File::Spec->catfile( $args{'install-base'}, $_ ) }
       qw/bin sbin libexec/;
     find( $sub, @dirs ) if @dirs;
 
@@ -208,7 +234,7 @@
 }
 
 EOF
-;
+  ;
 1;
 
 __END__

Modified: bpsbuilder/BPB/lib/BPB/Build.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Build.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Build.pm	Thu Jan 10 14:15:22 2008
@@ -79,7 +79,39 @@
     $self->_substitute('__build');
 
     chmod 0755, '__build';
-    system('./__build');
+    my ( @cmds, $error );
+
+    {
+        open my $fh, '<', '__build' or die "can't open __build: $!";
+        @cmds = <$fh>;
+        chomp @cmds;
+    }
+
+    for (@cmds) {
+        my ( $type, $cmd );
+        if (/^(\S+):\s*(.*)/) {
+            $type = $1;
+            $cmd  = $2;
+        }
+        else {
+            $type = '';
+            $cmd  = $_;
+        }
+
+        next if $self->skip_test && $type eq 'test';
+
+        if ( system($cmd) ) {
+            $self->log->error("build $dir with failure when run $type: $!");
+            $error = 1;
+        }
+    }
+
+    if ($error) {
+        $self->log->error("build $dir with failure!");
+    }
+    else {
+        $self->log->info("build $dir with success!");
+    }
 }
 
 sub _wrapper {

Modified: bpsbuilder/BPB/lib/BPB/Script/Import.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Script/Import.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Script/Import.pm	Thu Jan 10 14:15:22 2008
@@ -148,31 +148,31 @@
 
     my @commands;
     if ( -f 'configure' ) {
-        @commands =
-          ( './configure --prefix=%%INSTALL_BASE%%', 'make', 'make install' );
+        @commands = (
+            'configure: ./configure --prefix=%%INSTALL_BASE%%',
+            'make: make', 'install: make install',
+        );
     }
     elsif ( -f 'Build.PL' ) {
         push @commands,
-          $bpb->build->perl
+          'configure: '
+          . $bpb->build->perl
           . ' -I%%INSTALL_BASE%%/lib/perl5'
           . " -I%%INSTALL_BASE%%/lib/perl5/$Config{archname}"
           . ' Build.PL --install_base=%%INSTALL_BASE%%';
-        unless ( $bpb->build->skip_test ) {
-            push @commands, "./Build test";
-        }
-        push @commands, "./Build install";
+        push @commands, "test: ./Build test";
+        push @commands, "install: ./Build install";
     }
     elsif ( -f 'Makefile.PL' ) {
         push @commands,
-          $bpb->build->perl
+          'configure: '
+          . $bpb->build->perl
           . ' -I%%INSTALL_BASE%%/lib/perl5'
           . " -I%%INSTALL_BASE%%/lib/perl5/$Config{archname} "
           . ' Makefile.PL INSTALL_BASE=%%INSTALL_BASE%%';
-        unless ( $bpb->build->skip_test ) {
-            push @commands, 'make test';
-        }
+        push @commands, 'test: make test';
 
-        push @commands, "make install";
+        push @commands, "install: make install";
     }
     else {
         warn "I have no idea how to build this distribution";



More information about the Bps-public-commit mailing list