[Bps-public-commit] r12962 - in Shipwright/trunk: share/bin

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jun 6 10:10:41 EDT 2008


Author: sunnavy
Date: Fri Jun  6 10:10:38 2008
New Revision: 12962

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/share/bin/shipwright-builder

Log:
 r13054 at sunnavys-mb:  sunnavy | 2008-06-06 21:45:02 +0800
 added only arg for shpwright-builder


Modified: Shipwright/trunk/share/bin/shipwright-builder
==============================================================================
--- Shipwright/trunk/share/bin/shipwright-builder	(original)
+++ Shipwright/trunk/share/bin/shipwright-builder	Fri Jun  6 10:10:38 2008
@@ -16,9 +16,15 @@
 my %args;
 
 die "unknown option"
-  unless GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s', 'flags=s',
-    'skip-test', 'skip-test-except-final', 'only-test', 'force', 'clean',
-    'name=s', 'help', 'noclean' );
+  unless GetOptions(
+    \%args,                   'install-base=s',
+    'perl=s',                 'skip=s',
+    'flags=s',                'skip-test',
+    'skip-test-except-final', 'only-test',
+    'force',                  'clean',
+    'name=s',                 'help',
+    'noclean',                'only=s'
+  );
 
 my $USAGE = <<'END'
 run: ./bin/shipwright-builder
@@ -43,6 +49,9 @@
 skip: dists we don't want to install, comma-separated
     e.g. --skip perl,Module-Build
 
+only:  dists we want to install only, comma-separated
+    e.g. --only perl,Module-Build
+
 flags: set flags we need, comma-separated
     e.g.  --flags mysql,standalone
 
@@ -74,6 +83,10 @@
     map { $_ => 1 } split /\s*,\s*/, $args{flags} || ''
 };
 
+if ( $args{only} ) {
+    $args{only} = { map { $_ => 1 } split /\s*,\s*/, $args{only} };
+}
+
 if ( $args{'install-base'} ) {
     $args{'install-base'} = abs_path( $args{'install-base'} );
 }
@@ -101,8 +114,11 @@
         next
           if $flags->{$dist} && !grep { $args{flags}{$_} } @{ $flags->{$dist} };
 
-        unless ( $args{skip}{$dist} ) {
-            clean($dist);
+        if ( $args{only} ) {
+            clean($dist) if $args{only}{$dist};
+        }
+        else {
+            clean($dist) unless $args{skip}{$dist};
         }
         chdir $build_base;
     }
@@ -114,10 +130,17 @@
     # for install
     open $log, '>', 'build.log' or die $!;
 
-    if ( -e '__need_clean' && ! $args{noclean} ) {
+    if ( -e '__need_clean' && !$args{noclean} ) {
         print "seems it has been built before, need to clean first\n";
         print $log "seems it has been built before, need to clean first\n";
-        system("$0 --clean") && die 'clean failed.';
+        system(
+            "$0 --clean "
+              . (
+                $args{only}
+                ? '--only ' . join( ',', keys %{ $args{only} } )
+                : '--skip ' . ( join( ',', keys %{ $args{skip} } || q{''} ) )
+              )
+        ) && die 'clean failed.';
     }
 
     # set clean flag again
@@ -163,8 +186,13 @@
         my $perl = File::Spec->catfile( $args{'install-base'}, 'bin', 'perl' );
 
         # -e $perl makes sense when we install on to another vessel
-        if ( ( ( grep { $_ eq 'perl' } @$order ) && !$args{skip}{perl} )
-            || -e $perl )
+        if (
+            (
+                ( grep { $_ eq 'perl' } @$order )
+                && $args{only} ? $args{only}{perl} : !$args{skip}{perl}
+            )
+            || -e $perl
+          )
         {
             $args{perl} = $perl;
         }
@@ -220,8 +248,11 @@
         next
           if $flags->{$dist} && !grep { $args{flags}{$_} } @{ $flags->{$dist} };
 
-        unless ( $args{skip}{$dist} ) {
-            install($dist);
+        if ( $args{only} ) {
+            install($dist) if $args{only}{$dist};
+        }
+        else {
+            install($dist) unless $args{skip}{$dist};
         }
         chdir $build_base;
     }
@@ -343,7 +374,7 @@
     # then link to it, else link to the normal one
         if (   $type
             && grep( { $_ eq $type } @$order )
-            && !$args{skip}{$type}
+            && $args{only} ? $args{only}{$type} : !$args{skip}{$type}
             && -e File::Spec->catfile( '..', 'etc', "shipwright-$type-wrapper" )
           )
         {



More information about the Bps-public-commit mailing list