[Bps-public-commit] r12518 - in Shipwright/trunk: lib/Shipwright/Script

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun May 18 11:18:11 EDT 2008


Author: sunnavy
Date: Sun May 18 11:18:10 2008
New Revision: 12518

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Script/Update.pm

Log:
 r12553 at sunnavys-mb:  sunnavy | 2008-05-18 22:54:05 +0800
 added --builder and --utility arg for update cmd for updating bin/shipwright-builder bin/shipwright-utlity


Modified: Shipwright/trunk/lib/Shipwright/Script/Update.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Script/Update.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Script/Update.pm	Sun May 18 11:18:10 2008
@@ -5,7 +5,8 @@
 use Carp;
 
 use base qw/App::CLI::Command Class::Accessor::Fast Shipwright::Script/;
-__PACKAGE__->mk_accessors(qw/repository log_level name all follow log_file/);
+__PACKAGE__->mk_accessors(
+    qw/repository log_level name all follow log_file builder utility/);
 
 use Shipwright;
 use File::Spec;
@@ -25,6 +26,8 @@
         'name=s'         => 'name',
         'a|all'          => 'all',
         'follow'         => 'follow',
+        'builder'        => 'builder',
+        'utility'        => 'utility',
     );
 }
 
@@ -34,54 +37,67 @@
     my $self = shift;
     my $name = shift;
 
-    $self->name($name) if $name && !$self->name;
-
-    die 'need name arg' unless $self->name || $self->all;
-
     $shipwright = Shipwright->new(
         repository => $self->repository,
         log_level  => $self->log_level,
         log_file   => $self->log_file,
     );
 
-    $map    = $shipwright->backend->map    || {};
-    $source = $shipwright->backend->source || {};
+    if ( $self->builder ) {
+        $shipwright->backend->update(
+            path => File::Spec->catfile( 'bin', 'shipwright-builder' ) );
+    }
+    elsif ( $self->utility ) {
+        $shipwright->backend->update(
+            path => File::Spec->catfile( 'bin', 'shipwright-utility' ) );
 
-    if ( $self->all ) {
-        my $dists = $shipwright->backend->order || [];
-        for (@$dists) {
-            $self->_update($_);
-        }
     }
     else {
-        if ( !$source->{ $self->name } && $map->{ $self->name } ) {
 
-            # in case the name is module name
-            $self->name( $map->{ $self->name } );
+        $self->name($name) if $name && !$self->name;
+
+        die 'need name arg' unless $self->name || $self->all;
+
+        $map    = $shipwright->backend->map    || {};
+        $source = $shipwright->backend->source || {};
+
+        if ( $self->all ) {
+            my $dists = $shipwright->backend->order || [];
+            for (@$dists) {
+                $self->_update($_);
+            }
         }
+        else {
+            if ( !$source->{ $self->name } && $map->{ $self->name } ) {
 
-        my @dists;
-        if ( $self->follow ) {
-            my (%checked);
-            my $find_deps;
-            $find_deps = sub {
-                my $name = shift;
-
-                return if $checked{$name}++;    # we've checked this $name
-
-                my ($require) = $shipwright->backend->requires( name => $name );
-                for my $type (qw/requires build_requires recommends/) {
-                    for ( keys %{ $require->{$type} } ) {
-                        $find_deps->($_);
+                # in case the name is module name
+                $self->name( $map->{ $self->name } );
+            }
+
+            my @dists;
+            if ( $self->follow ) {
+                my (%checked);
+                my $find_deps;
+                $find_deps = sub {
+                    my $name = shift;
+
+                    return if $checked{$name}++;    # we've checked this $name
+
+                    my ($require) =
+                      $shipwright->backend->requires( name => $name );
+                    for my $type (qw/requires build_requires recommends/) {
+                        for ( keys %{ $require->{$type} } ) {
+                            $find_deps->($_);
+                        }
                     }
-                }
-            };
+                };
 
-            $find_deps->( $self->name );
-            @dists = keys %checked;
-        }
-        for ( @dists, $self->name ) {
-            $self->_update($_);
+                $find_deps->( $self->name );
+                @dists = keys %checked;
+            }
+            for ( @dists, $self->name ) {
+                $self->_update($_);
+            }
         }
     }
 
@@ -158,4 +174,6 @@
    --name             specify the source name( only alphanumeric characters and - )
    --all              update all the dists
    --follow           update one dist with all its deps(recursively)
+   --builder          update bin/shipwright-builder
+   --utility          update bin/shipwright-utility
 



More information about the Bps-public-commit mailing list