[Bps-public-commit] r10188 - bpsbuilder/BPB/lib/BPB/Backend
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Dec 30 04:27:44 EST 2007
Author: sunnavy
Date: Sun Dec 30 04:27:43 2007
New Revision: 10188
Modified:
bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
Log:
refactor a little, added update_order method to uhh... update order, of cause ;)
Modified: bpsbuilder/BPB/lib/BPB/Backend/SVK.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Backend/SVK.pm (original)
+++ bpsbuilder/BPB/lib/BPB/Backend/SVK.pm Sun Dec 30 04:27:43 2007
@@ -155,33 +155,68 @@
my $self = shift;
my %args = @_;
my $name = $args{source};
- my $dir = tempdir( CLEANUP => 1 );
- my $file = File::Spec->catfile( $dir, 'order.yml' );
- $self->checkout(
- path => '/bpb/order.yml',
- target => $file,
- );
-
- my $order = BPB::Config::LoadFile($file) || [];
+ my $order = $self->order;
$name =~ s!^.*/(.+)/?$!$1.tar.gz!;
$name = CPAN::DistnameInfo->new($name)->dist;
unless ( grep { /^$name$/ } @$order ) {
push @$order, $name;
- BPB::Config::DumpFile( $file, $order );
- $self->commit( path => $file, comment => "added $name to order" );
+ $self->order($order);
+ }
+}
+
+sub update_order {
+ my $self = shift;
+ my $cmd = 'svk ls ' . $self->repository . '/scripts';
+ my @dists = `$cmd`;
+ chomp @dists;
+
+ my $require;
+
+ for (@dists) {
+ s{/$}{};
+ my $cmd = 'svk cat ' . $self->repository . "/scripts/$_/require.yml";
+ my $string = `$cmd`;
+ my $req = BPB::Config::Load($string);
+ use Data::Dumper;
+ $require->{$_} = [ keys %$req ];
}
- $self->checkout( detach => 1, target => $file );
+ require Algorithm::Dependency::Ordered;
+ require Algorithm::Dependency::Source::HoA;
+
+ my $source = Algorithm::Dependency::Source::HoA->new($require);
+ $source->load();
+ my $dep = Algorithm::Dependency::Ordered->new( source => $source, )
+ or die $@;
+ my $order = $dep->schedule_all();
+ $self->order( $order );
}
sub order {
- my $self = shift;
- my $cmd = 'svk cat ' . $self->repository . '/bpb/order.yml';
- my $string = `$cmd`;
- return BPB::Config::Load($string);
+ my $self = shift;
+ my $order = shift;
+ if ($order) {
+ my $dir = tempdir( CLEANUP => 1 );
+ my $file = File::Spec->catfile( $dir, 'order.yml' );
+
+ $self->checkout(
+ path => '/bpb/order.yml',
+ target => $file,
+ );
+
+ BPB::Config::DumpFile( $file, $order );
+ $self->commit( path => $file, comment => "set order" );
+ $self->checkout( detach => 1, target => $file );
+
+ }
+ else {
+ my $cmd = 'svk cat ' . $self->repository . '/bpb/order.yml';
+ my $string = `$cmd`;
+ return BPB::Config::Load($string);
+ }
}
sub _run {
More information about the Bps-public-commit
mailing list