[Bps-public-commit] r14727 - in Shipwright/trunk: lib/Shipwright/Backend

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Aug 3 02:58:07 EDT 2008


Author: sunnavy
Date: Sun Aug  3 02:58:06 2008
New Revision: 14727

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/lib/Shipwright/Backend/Base.pm

Log:
 r15228 at sunnavys-mb:  sunnavy | 2008-08-03 11:31:08 +0800
 implement update_refs


Modified: Shipwright/trunk/lib/Shipwright/Backend/Base.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Backend/Base.pm	(original)
+++ Shipwright/trunk/lib/Shipwright/Backend/Base.pm	Sun Aug  3 02:58:06 2008
@@ -126,6 +126,8 @@
                 $version->{$name} = $args{version};
                 $self->version($version);
 
+                $self->update_refs;
+
                 Shipwright::Util->run(
                     $self->_cmd( import => %args, name => $name ) );
             }
@@ -355,6 +357,20 @@
     return $self->_yml( $path, $ktf );
 }
 
+=item refs
+
+Get or set refs
+
+=cut
+
+sub refs {
+    my $self = shift;
+    my $refs  = shift;
+    my $path = '/shipwright/refs.yml';
+
+    return $self->_yml( $path, $refs );
+}
+
 =item delete
 
 
@@ -568,8 +584,53 @@
     $self->source($source);
     $self->flags($flags);
     $self->order($order);
+    $self->update_refs;
 }
 
+=item update_refs
+
+update refs.
+
+we need update this after import and trim
+
+=cut
+
+sub update_refs {
+    my $self = shift;
+    my $order = $self->order;
+    my $refs = {};
+
+    for my $name (@$order) {
+        # initialize here, in case we don't have $name entry in $refs
+        $refs->{$name} ||= 0;
+
+        my $out = Shipwright::Util->run(
+            $self->_cmd( 'cat', path => "/scripts/$name/require.yml" ), 1 );
+
+        my $req = Shipwright::Util::Load($out) || {};
+
+        my @deps;
+        if ( $req->{requires} ) {
+            @deps = ( keys %{ $req->{requires} }, keys %{ $req->{recommends} },
+              keys %{ $req->{build_requires} } );
+        }
+        else {
+
+            #for back compatbility
+            @deps = keys %$req;
+        }
+
+        @deps = uniq @deps;
+
+        for (@deps) {
+            $refs->{$_}++;
+        }
+    }
+
+    $self->refs( $refs );
+}
+
+
 *_cmd = *_update_file = *_subclass_method;
 
 



More information about the Bps-public-commit mailing list