[Bps-public-commit] r17788 - in Shipwright/trunk: . lib lib/Shipwright/Script share/bin

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jan 16 11:51:14 EST 2009


Author: sunnavy
Date: Fri Jan 16 11:51:14 2009
New Revision: 17788

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright.pm
   Shipwright/trunk/lib/Shipwright/Build.pm
   Shipwright/trunk/lib/Shipwright/Script/Build.pm
   Shipwright/trunk/share/bin/shipwright-builder

Log:
 r18832 at sunnavys-mb:  sunnavy | 2009-01-16 21:03:51 +0800
 added --branches arg for build


Modified: Shipwright/trunk/lib/Shipwright.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright.pm	(original)
+++ Shipwright/trunk/lib/Shipwright.pm	Fri Jan 16 11:51:14 2009
@@ -257,6 +257,7 @@
     only_test: don't install, just test, (used for previously installed dists),
                 default is false
     flags: flags for building, default is { default => 1 }
+    branches: branches build should use
 
 =head1 SEE ALSO
 

Modified: Shipwright/trunk/lib/Shipwright/Build.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Build.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Build.pm	Fri Jan 16 11:51:14 2009
@@ -8,7 +8,7 @@
 
 __PACKAGE__->mk_accessors(
     qw/install_base perl build_base skip_test commands log
-      skip only_test force order flags name only make/
+      skip only_test force order flags name only make branches/
 );
 
 use File::Spec::Functions qw/catfile catdir splitdir/;
@@ -211,13 +211,14 @@
     my $dir      = shift;
     my $ktf      = shift;
     my $branches = shift;
+    my $branch = $self->branches->{$dir} || $branches->{$dir}[0];
 
     if ($branches) {
         system( "cp -r "
-              . catdir( 'sources', $dir, split /\//, $branches->{$dir}[0] )
+              . catdir( 'sources', $dir, split /\//, $branch )
               . ' '
               . catdir( 'dists', $dir ) )
-          && confess "cp sources/$dir/$branches->{$dir}[0] to dists/$dir failed";
+          && confess "cp sources/$dir/$branch to dists/$dir failed";
     }
 
     chdir catdir( 'dists', $dir );

Modified: Shipwright/trunk/lib/Shipwright/Script/Build.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Build.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Build.pm	Fri Jan 16 11:51:14 2009
@@ -7,7 +7,7 @@
 use base qw/App::CLI::Command Class::Accessor::Fast Shipwright::Script/;
 __PACKAGE__->mk_accessors(
     qw/build_base skip skip_test only_test install_base
-      force log_file flags name perl only with make/
+      force log_file flags name perl only with make branches/
 );
 
 use Shipwright;
@@ -28,6 +28,7 @@
         'perl'           => 'perl',
         'with=s'         => 'with',
         'make=s'         => 'make',
+        'branches=s'     => 'branches',
     );
 }
 
@@ -66,6 +67,8 @@
     );
 
     $self->with( { map { split /=/ } split /\s*,\s*/, $self->with || '' } );
+    $self->branches(
+        { map { split /=/ } split /\s*,\s*/, $self->branches || '' } );
 
     my %source;
     for my $name ( keys %{ $self->with } ) {
@@ -81,19 +84,28 @@
     my $shipwright = Shipwright->new(
         map { $_ => $self->$_ }
           qw/repository log_level log_file skip skip_test
-          flags name force only_test install_base build_base perl only make/
+          flags name force only_test install_base build_base perl only make
+          branches
+          /
     );
+    my $branches = $shipwright->backend->branches() || {};
+    for my $name ( keys %{ $self->branches } ) {
+        die 'no branch name ' . $self->branches->{$name} . " for $name"
+          unless grep { $_ eq $self->branches->{$name} }
+              @{ $branches->{$name} || [] };
+    }
 
     $shipwright->backend->export( target => $shipwright->build->build_base );
 
     my $dists_dir = $shipwright->build->build_base;
-    if ( $shipwright->backend->has_branch_support ) {
-        for my $name ( keys %source ) {
-            my $dir = catdir( $dists_dir, 'dists', $name );
-            system("rm -rf $dir");
-            system("cp -r $source{$name} $dir");
-        }
+
+    mkdir 'dists' unless -e 'dists';
+    for my $name ( keys %source ) {
+        my $dir = catdir( $dists_dir, 'dists', $name );
+        system("rm -rf $dir");
+        system("cp -r $source{$name} $dir");
     }
+
     if ( $shipwright->build->run() ) {
         print "install finished. the dists are at "
           . $self->install_base . "\n";
@@ -135,4 +147,5 @@
  --make PATH                  : specify the path of make command
  --with name=source,...       : don't build the dist of the name in repo,
                                 use the one specified here instead.
+ --branches name=branch,...   : specify the branch we want to build
 

Modified: Shipwright/trunk/share/bin/shipwright-builder
==============================================================================
--- Shipwright/trunk/share/bin/shipwright-builder	(original)
+++ Shipwright/trunk/share/bin/shipwright-builder	Fri Jan 16 11:51:14 2009
@@ -27,7 +27,7 @@
     'name=s',                 'help',
     'noclean',                'only=s',
     'with=s',                 'noclean-after-install',
-    'make=s',
+    'make=s',                 'branches=s',
   );
 
 my $USAGE = <<'END'
@@ -80,6 +80,9 @@
 make: specify the path of your make command, default is 'make'.
     e.g. --make /usr/bin/make
 
+branches: specify the branch you want to build.
+    e.g. --branches Foo,trunk,Bar,2.0
+
 END
   ;
 
@@ -95,6 +98,7 @@
 };
 
 $args{with} = { map { split /=/ } split /\s*,\s*/, $args{with} || '' };
+$args{branches} = { map { split /=/ } split /\s*,\s*/, $args{branches} || '' };
 $args{make} ||= 'make';
 
 if ( $args{only} ) {
@@ -155,7 +159,13 @@
 
 if ( -e catfile( 'shipwright', 'branches.yml' ) ) {
     $branches =
-      ( YAML::Tiny->read( catfile( 'shipwright', 'branches.yml' ) ) )->[0];
+         ( YAML::Tiny->read( catfile( 'shipwright', 'branches.yml' ) ) )->[0]
+      || {};
+    for my $name ( keys %{ $args{branches} } ) {
+        die 'no branch name ' . $args{branches}->{$name} . " for $name"
+          unless grep { $_ eq $args{branches}->{$name} }
+              @{ $branches->{$name} || [] };
+    }
 }
 
 # fill not specified but mandatory flags
@@ -312,12 +322,13 @@
     }
     else {
         if ($branches) {
+            my $branch = $args{branches}{$dir} || $branches->{$dir}[0];
             system( "cp -r "
-                  . catdir( 'sources', $dir, split /\//, $branches->{$dir}[0] )
+                  . catdir( 'sources', $dir, split /\//, $branch )
                   . ' '
                   . catdir( 'dists', $dir ) )
               && confess
-              "cp sources/$dir/$branches->{$dir}[0] to dists/$dir failed";
+              "cp sources/$dir/$branch to dists/$dir failed";
         }
         chdir catdir( 'dists', $dir );
     }



More information about the Bps-public-commit mailing list