[Bps-public-commit] Shipwright branch, master, updated. c5da759633458cc41f977f12208b1940bcfb9018
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Jul 30 21:54:56 EDT 2009
The branch, master has been updated
via c5da759633458cc41f977f12208b1940bcfb9018 (commit)
via 67043896fbd009e78b6e04e5868965c038f8d862 (commit)
from 96a6ed0d91f1bed8c33f6f3c4abf57e8e60c3e79 (commit)
Summary of changes:
lib/Shipwright/Backend/Base.pm | 11 ++++++
lib/Shipwright/Source/Base.pm | 8 ++--
lib/Shipwright/Source/Directory.pm | 3 +-
share/bin/shipwright-builder | 71 ++++++++++++++++++++++--------------
4 files changed, 61 insertions(+), 32 deletions(-)
- Log -----------------------------------------------------------------
commit 67043896fbd009e78b6e04e5868965c038f8d862
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jul 31 09:17:00 2009 +0800
go on replacing cms like cp and rm
diff --git a/lib/Shipwright/Backend/Base.pm b/lib/Shipwright/Backend/Base.pm
index 1011564..51c9975 100644
--- a/lib/Shipwright/Backend/Base.pm
+++ b/lib/Shipwright/Backend/Base.pm
@@ -67,6 +67,7 @@ sub initialize {
$self->_install_clean_inc($dir);
$self->_install_module_build($dir);
$self->_install_file_compare($dir);
+ $self->_install_file_copy_recursive($dir);
# set proper permissions for yml under /shipwright/
my $sw_dir = catdir( $dir, 'shipwright' );
@@ -130,6 +131,16 @@ sub _install_file_compare {
or confess "copy File/Compare.pm failed: $!";
}
+sub _install_file_copy_recursive {
+ my $self = shift;
+ my $dir = shift;
+
+ my $path = catdir( $dir, 'inc', 'File', 'Copy' );
+ mkpath $path;
+ rcopy( Module::Info->new_from_module('File::Copy::Recursive')->file, $path )
+ or confess "copy File/Copy/Recursive.pm failed: $!";
+}
+
=item import
import a dist.
diff --git a/lib/Shipwright/Source/Base.pm b/lib/Shipwright/Source/Base.pm
index f9479c2..d8e2d6b 100644
--- a/lib/Shipwright/Source/Base.pm
+++ b/lib/Shipwright/Source/Base.pm
@@ -337,8 +337,7 @@ EOF
or confess "can't read prereqs: $!";
eval $prereqs or confess "eval error: $@"; ## no critic
- Shipwright::Util->run( [ 'rm', 'shipwright_makefile.pl' ] );
- Shipwright::Util->run( [ 'rm', 'shipwright_prereqs' ] );
+ unlink 'shipwright_makefile.pl', 'shipwright_prereqs';
}
else {
@@ -366,8 +365,9 @@ EOF
}
}
- Shipwright::Util->run( [ 'make', 'clean' ] );
- Shipwright::Util->run( [ 'rm', 'Makefile.old' ] );
+ Shipwright::Util->run(
+ [ ( $^O =~ /MSWin/ ? 'dmake' : 'make' ), 'clean' ] );
+ unlink 'Makefile.old';
}
for my $type ( @types ) {
diff --git a/lib/Shipwright/Source/Directory.pm b/lib/Shipwright/Source/Directory.pm
index bbe8799..d56d4c9 100644
--- a/lib/Shipwright/Source/Directory.pm
+++ b/lib/Shipwright/Source/Directory.pm
@@ -4,6 +4,7 @@ use warnings;
use Carp;
use File::Spec::Functions qw/catdir/;
use File::Basename;
+use File::Copy::Recursive qw/rcopy/;
use base qw/Shipwright::Source::Base/;
@@ -70,7 +71,7 @@ sub _cmd {
$self->name || $self->just_name( $self->path ) );
return if -e $to;
- return [ 'cp', '-r', $self->source, $to ];
+ return sub { rcopy( $self->source, $to ) };
}
1;
diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index 6502764..1f8ec76 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -6,7 +6,7 @@ use strict;
use lib 'inc';
use File::Spec::Functions qw/catfile catdir splitdir rel2abs/;
use File::Temp qw/tempdir/;
-use File::Copy qw/move copy/;
+use File::Copy::Recursive qw/rmove rcopy/;
use File::Find qw/find/;
use File::Path;
use Config;
@@ -126,13 +126,14 @@ $args{flags} = {
$args{with} = { map { split /=/ } split /\s*,\s*/, $args{with} || '' };
$args{branches} = { map { split /=/ } split /\s*,\s*/, $args{branches} || '' };
$args{make} ||= 'make';
-my $uname_cmd = 'uname';
-if ( $^O !~ /MSWin/ ) {
- $uname_cmd .= ' 2>/dev/null';
+if ( $^O =~ /MSWin/ ) {
+ $args{as} ||= 'MSWin';
+}
+else {
+ my $uname = `uname 2>/dev/null`;
+ chomp $uname;
+ $args{as} ||= $uname || 'default';
}
-my $uname = `$uname_cmd`;
-chomp $uname;
-$args{as} ||= $uname || 'default';
if ( $args{only} ) {
$args{only} = { map { $_ => 1 } split /\s*,\s*/, $args{only} };
@@ -356,14 +357,14 @@ sub install {
unless -e catdir( $args{'install-base'}, 'tools' );
for ( 'shipwright-script-wrapper', 'shipwright-perl-wrapper' ) {
- copy( catfile( 'etc', $_ ),
+ rcopy( catfile( 'etc', $_ ),
catfile( $args{'install-base'}, 'etc', $_ ) );
}
for ( 'shipwright-utility', 'shipwright-source-bash',
'shipwright-source-tcsh' )
{
- copy( catfile( 'etc', $_ ),
+ rcopy( catfile( 'etc', $_ ),
catfile( $args{'install-base'}, 'tools', $_ ) );
}
@@ -383,7 +384,7 @@ sub install {
{
my $dir = catdir( $args{'install-base'}, $r );
next unless -e $dir;
- `rm -rf $dir`;
+ remove_tree( $dir );
}
}
@@ -399,7 +400,7 @@ sub install {
# in case wrappers are overwritten by accident
for ( 'shipwright-script-wrapper', 'shipwright-perl-wrapper' ) {
- copy( catfile( 'etc', $_ ),
+ rcopy( catfile( 'etc', $_ ),
catfile( $args{'install-base'}, 'etc', $_ ) );
}
@@ -418,7 +419,7 @@ sub install {
for my $r ( 'lib', 'bin', 'sbin' ) {
next unless -e $r;
my $dir = catdir( $as_dir, $r );
- system("mv $r $as_dir");
+ rmove( $r, catdir( $as_dir, $r ) );
if ( $r !~ /bin/ ) {
symlink $dir, $r;
@@ -430,7 +431,7 @@ sub install {
mkdir $usr_dir;
for my $r ( 'bin', 'sbin' ) {
next unless -e catdir( 'usr', $r );
- system( "mv " . catdir( 'usr', $r ) . ' ' . $usr_dir );
+ rmove( catdir( 'usr', $r ), catdir( $usr_dir, $r ) );
}
chdir $cwd;
@@ -459,10 +460,9 @@ sub _install {
if ( !$branch && -d catdir( 'sources', $dir, 'vendor' ) ) {
$branch = 'vendor';
}
- system( "cp -r "
- . catdir( 'sources', $dir, split /\//, $branch ) . ' '
- . catdir( 'dists', $dir ) )
- && confess "cp sources/$dir/$branch to dists/$dir failed";
+ rcopy( catdir( 'sources', $dir, split /\//, $branch ),
+ catdir( 'dists', $dir ) )
+ or confess "copy sources/$dir/$branch to dists/$dir failed: $!";
}
chdir catdir( 'dists', $dir );
}
@@ -725,11 +725,11 @@ sub cmds {
sub clean {
open my $log, '>', 'clean.log' or confess $!;
- system('rm -rf tmp_dists') && confess "rm tmp_dists failed\n";
+ remove_tree( 'tmp_dists');
print $log "removed tmp_dists\n";
if ($branches) {
- system('rm -rf dists') && confess "rm dists failed\n";
+ remove_tree('dists');
print $log "removed dists\n";
}
else {
@@ -809,7 +809,10 @@ sub process_tmp_dists {
for my $name ( keys %{ $args{with} } ) {
my $cmd = cmd( $name, $args{with}{$name} );
- if ($cmd) {
+ if ( ref $cmd eq 'CODE' ) {
+ $cmd->run();
+ }
+ else {
system($cmd) && confess "$cmd failed";
}
}
@@ -823,7 +826,7 @@ sub cmd {
my ( $name, $source ) = @_;
if ( $source =~ s/^dir(ectory)?://i ) {
- return "cp -r $source tmp_dists/$name";
+ return sub { rcopy( $source, catdir( 'tmp_dists', $name ) ); };
}
elsif ( $source =~ /^svn:/i ) {
$source =~ s{^svn:(?!//)}{}i;
commit c5da759633458cc41f977f12208b1940bcfb9018
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jul 31 09:53:28 2009 +0800
abstract if on windows
diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index 1f8ec76..f5b4b5f 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -125,8 +125,18 @@ $args{flags} = {
$args{with} = { map { split /=/ } split /\s*,\s*/, $args{with} || '' };
$args{branches} = { map { split /=/ } split /\s*,\s*/, $args{branches} || '' };
-$args{make} ||= 'make';
-if ( $^O =~ /MSWin/ ) {
+
+unless ( $args{make} ) {
+ if ( is_on_windows() ) {
+ $args{make} ||= 'dmake'; # strawberry perl distribution has dmake.exe
+ }
+ else {
+ $args{make} ||= 'make';
+ }
+}
+
+
+if ( is_on_windows() ) {
$args{as} ||= 'MSWin';
}
else {
@@ -236,7 +246,7 @@ else {
my $log;
my $build_log_file = rel2abs('build.log');
my $system_cmd_pipe = '';
-if ( $^O !~ /MSWin/ && !$args{'verbose'} ) {
+unless ( is_on_windows() || $args{'verbose'} ) {
$system_cmd_pipe = " >>$build_log_file 2>&1";
}
@@ -304,7 +314,7 @@ sub install {
{
my $arch_command = $args{perl} || $^X;
- if ( $^O =~ /MSWin/ ) {
+ if ( is_on_windows() ) {
$arch_command .= q{ -MConfig -e "print $Config{archname}"};
}
else {
@@ -415,7 +425,7 @@ sub install {
my $as_dir = catdir( 'as', $args{as} );
mkdir $as_dir;
- if ( $^O !~ /MSWin/ ) {
+ unless( is_on_windows() ) {
for my $r ( 'lib', 'bin', 'sbin' ) {
next unless -e $r;
my $dir = catdir( $as_dir, $r );
@@ -643,7 +653,7 @@ sub substitute {
}
my $perl_archname;
- if ( $^O =~ /MSWin/ ) {
+ if ( is_on_windows() ) {
$perl_archname = `$perl -MConfig -e "print \$Config{archname}"`;
}
else {
@@ -655,7 +665,7 @@ sub substitute {
$text =~ s/%%MODULE_BUILD_EXTRA%%//g;
$text =~ s/%%MAKE%%/$args{make}/g;
- if ( $^O =~ /MSWin/ ) {
+ if ( is_on_windows() ) {
`$perl -I$inc_lib -MShipwright::Util::CleanINC -e"eval { require Pod::Man}; if (\$@) { exit 1} else { exit 0 }" `;
}
else {
@@ -846,3 +856,7 @@ sub _record {
$installed->write($installed_file);
}
+sub is_on_windows {
+ return $^O =~ /MSWin/;
+}
+
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list