[Bps-public-commit] r11155 - in Shipwright/trunk: share/bin
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Mar 21 03:23:19 EDT 2008
Author: sunnavy
Date: Fri Mar 21 03:23:18 2008
New Revision: 11155
Modified:
Shipwright/trunk/lib/Shipwright/Build.pm
Shipwright/trunk/share/bin/shipwright-builder
Log:
added build.pl support
Modified: Shipwright/trunk/lib/Shipwright/Build.pm
==============================================================================
--- Shipwright/trunk/lib/Shipwright/Build.pm (original)
+++ Shipwright/trunk/lib/Shipwright/Build.pm Fri Mar 21 03:23:18 2008
@@ -32,7 +32,7 @@
$self->{build_base} =
File::Spec->catfile( tempdir( CLEANUP => 0 ), 'build' );
- $self->name( 'vessel' ) unless $self->name;
+ $self->name('vessel') unless $self->name;
unless ( $self->install_base ) {
@@ -98,7 +98,8 @@
$self->order(
Shipwright::Util::LoadFile(
File::Spec->catfile( 'shipwright', 'order.yml' )
- ) || []
+ )
+ || []
);
my $flags = {};
@@ -136,46 +137,65 @@
my $self = shift;
my $dir = shift;
- my @cmds = read_file( File::Spec->catfile( 'scripts', $dir, 'build' ) );
- chomp @cmds;
- @cmds = map { $self->_substitute($_) } @cmds;
-
- chdir File::Spec->catfile( 'dists', $dir );
+ if ( -e File::Spec->catfile( 'scripts', $dir, 'build.pl' ) ) {
+ $self->log->info(
+ "found build.pl for $dir, will install $dir using that");
+ Shipwright::Util->run(
+ [
+ $self->perl || $^X,
+ File::Spec->catfile( 'scripts', $dir, 'build.pl' ),
+ '--source' => File::Spec->catfile( 'dists', $dir ),
+ '--install-base' => $self->install_base,
+ '--flags' => join( ',', keys %{ $self->flags } ),
+ $self->skip_test ? '--skip-test' : (),
+ $self->force ? '--force' : (),
+ ]
+ );
- for (@cmds) {
- my ( $type, $cmd );
- next unless /\S/;
+ }
+ else {
- if (/^(\S+):\s*(.*)/) {
- $type = $1;
- $cmd = $2;
- }
- else {
- $type = '';
- $cmd = $_;
- }
+ my @cmds = read_file( File::Spec->catfile( 'scripts', $dir, 'build' ) );
+ chomp @cmds;
+ @cmds = map { $self->_substitute($_) } @cmds;
+
+ chdir File::Spec->catfile( 'dists', $dir );
+
+ for (@cmds) {
+ my ( $type, $cmd );
+ next unless /\S/;
+
+ if (/^(\S+):\s*(.*)/) {
+ $type = $1;
+ $cmd = $2;
+ }
+ else {
+ $type = '';
+ $cmd = $_;
+ }
- next if $type eq 'clean'; # don't need to clean when install
- if ( $self->skip_test && $type eq 'test' ) {
- $self->log->info("skip build $type part in $dir");
- next;
- }
+ next if $type eq 'clean'; # don't need to clean when install
+ if ( $self->skip_test && $type eq 'test' ) {
+ $self->log->info("skip build $type part in $dir");
+ next;
+ }
- $self->log->info("build $type part in $dir");
+ $self->log->info("build $type part in $dir");
- if ( system($cmd) ) {
- $self->log->error("build $dir with failure when run $type: $!");
- if ( $self->force && $type eq 'error' ) {
- $self->log->error(
+ if ( system($cmd) ) {
+ $self->log->error("build $dir with failure when run $type: $!");
+ if ( $self->force && $type eq 'error' ) {
+ $self->log->error(
"although tests failed, will install anyway since we have force arg\n"
- );
- }
- else {
- die "install failed";
+ );
+ }
+ else {
+ die "install failed";
+ }
}
}
- }
+ }
$self->log->info("build $dir with success!");
}
Modified: Shipwright/trunk/share/bin/shipwright-builder
==============================================================================
--- Shipwright/trunk/share/bin/shipwright-builder (original)
+++ Shipwright/trunk/share/bin/shipwright-builder Fri Mar 21 03:23:18 2008
@@ -15,9 +15,9 @@
my %args;
GetOptions(
- \%args, 'install-base=s', 'perl=s', 'skip=s',
+ \%args, 'install-base=s', 'perl=s', 'skip=s',
'flags=s', 'skip-test', 'only-test', 'force',
- 'clean', 'name=s', 'help',
+ 'clean', 'name=s', 'help',
);
my $USAGE = <<'END'
@@ -91,8 +91,7 @@
for my $dist (@$order) {
next
- if $flags->{$dist} && !grep { $args{flags}{$_} }
- @{ $flags->{$dist} };
+ if $flags->{$dist} && !grep { $args{flags}{$_} } @{ $flags->{$dist} };
unless ( $args{skip}{$dist} ) {
clean($dist);
@@ -195,8 +194,7 @@
# $flags->{$dist} is undef means 'default', will be installed
next
- if $flags->{$dist} && ! grep { $args{flags}{$_} }
- @{ $flags->{$dist} };
+ if $flags->{$dist} && !grep { $args{flags}{$_} } @{ $flags->{$dist} };
unless ( $args{skip}{$dist} ) {
install($dist);
@@ -216,35 +214,52 @@
my $dir = shift;
print "start to build and install $dir\n";
- my $cmds = cmds( File::Spec->catfile( 'scripts', $dir, 'build' ) );
- chdir File::Spec->catfile( 'dists', $dir );
+ if ( -e File::Spec->catfile( 'scripts', $dir, 'build.pl' ) ) {
+ print $log "found build.pl for $dir, will install $dir using that\n";
+ my $cmd = join ' ', $args{perl} || $^X,
+ File::Spec->catfile( 'scripts', $dir, 'build.pl' ),
+ '--source' => File::Spec->catfile( 'dists', $dir ),
+ '--install-base' => $args{'install-base'},
+ '--flags' => join( ',', keys %{ $args{flags} } ),
+ $args{'skip-test'} ? '--skip-test' : (),
+ $args{'force'} ? '--force' : (), $args{'clean'} ? '--clean' : ();
+ if ( system($cmd) ) {
+ print $log "build $dir with failure: $!\n";
+ die "build $dir with failure: $!\n";
+ }
+ }
+ else {
+ my $cmds = cmds( File::Spec->catfile( 'scripts', $dir, 'build' ) );
- for (@$cmds) {
- my ( $type, $cmd ) = @$_;
- next if $type eq 'clean';
+ chdir File::Spec->catfile( 'dists', $dir );
- if ( $args{'skip-test'} && $type eq 'test' ) {
- print $log "skip build $type part in $dir\n";
- next;
- }
+ for (@$cmds) {
+ my ( $type, $cmd ) = @$_;
+ next if $type eq 'clean';
- print $log "build $type part in $dir with cmd: $cmd\n";
+ if ( $args{'skip-test'} && $type eq 'test' ) {
+ print $log "skip build $type part in $dir\n";
+ next;
+ }
- print "we'll run the cmd: $cmd\n";
- if ( system($cmd) ) {
- print $log "build $dir $type part with failure: $!\n";
- if ( $args{force} && $type eq 'test' ) {
- print $log
+ print $log "build $type part in $dir with cmd: $cmd\n";
+
+ print "we'll run the cmd: $cmd\n";
+ if ( system($cmd) ) {
+ print $log "build $dir $type part with failure: $!\n";
+ if ( $args{force} && $type eq 'test' ) {
+ print $log
"although tests failed, will install anyway since we have force arg\n";
+ }
+ else {
+ die "build $dir $type part with failure: $!\n";
+ }
}
else {
- die "build $dir $type part with failure: $!\n";
+ print $log "build $dir $type part with success!\n";
}
}
- else {
- print $log "build $dir $type part with success!\n";
- }
}
print $log "build $dir with success!\n";
@@ -388,22 +403,36 @@
sub clean {
my $dir = shift;
- my $cmds = cmds( File::Spec->catfile( 'scripts', $dir, 'build' ) );
+ my $cmd;
- chdir File::Spec->catfile( 'dists', $dir );
+ if ( -e File::Spec->catfile( 'scripts', $dir, 'build.pl' ) ) {
+ print $log "found build.pl for $dir, will clean $dir using that\n";
+ $cmd = join ' ', $args{perl} || $^X,
+ File::Spec->catfile( 'scripts', $dir, 'build.pl' ),
+ '--source' => File::Spec->catfile( 'dists', $dir ),
+ '--clean';
+ }
+ else {
+ my $cmds = cmds( File::Spec->catfile( 'scripts', $dir, 'build' ) );
- for (@$cmds) {
- my ( $type, $cmd ) = @$_;
- next unless $type eq 'clean';
+ chdir File::Spec->catfile( 'dists', $dir );
- if ( system($cmd) ) {
- print $log "clean $dir with failure: $!\n";
- }
- else {
- print $log "clean $dir with success $!\n";
+ for (@$cmds) {
+ my ( $type, $c ) = @$_;
+ if ( $type eq 'clean' ) {
+ $cmd = $c;
+ last;
+ }
}
}
+ if ( system($cmd) ) {
+ print $log "clean $dir with failure: $!\n";
+ }
+ else {
+ print $log "clean $dir with success $!\n";
+ }
+
print '=' x 80, "\n";
}
More information about the Bps-public-commit
mailing list