[Bps-public-commit] Shipwright branch, master, updated. 4a485f0a579a59f76ab36c3f0e2bf02426072991
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Jul 16 07:25:43 EDT 2009
The branch, master has been updated
via 4a485f0a579a59f76ab36c3f0e2bf02426072991 (commit)
via a5ff166c38d5f4c18e213befb66cd95235204b3d (commit)
from 1f7c96ab21ca56c76cec97be43773d1fbe6f029c (commit)
Summary of changes:
share/bin/shipwright-builder | 79 ++++++++++++++++++++++++------------------
share/etc/shipwright-utility | 25 ++++++++++++-
2 files changed, 68 insertions(+), 36 deletions(-)
- Log -----------------------------------------------------------------
commit a5ff166c38d5f4c18e213befb66cd95235204b3d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jul 16 19:14:56 2009 +0800
move s?bin and usr/s?bin to as too
diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index cd4e7ba..88f9829 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -156,7 +156,7 @@ my $installed_hash = {};
my $installed_file = catfile( $args{'install-base'}, "$args{as}_installed.yml" );
if ( -e $installed_file ) {
$installed = YAML::Tiny->read(
- catfile( $args{'install-base'}, '$args{as}_installed.yml' ) );
+ catfile( $args{'install-base'}, "$args{as}_installed.yml" ) );
$installed_hash = { map { $_ => 1 } @{ $installed->[0] } };
}
else {
@@ -349,11 +349,12 @@ sub install {
chmod oct 755,
catfile( $args{'install-base'}, 'tools', 'shipwright-utility' );
- my $lib_dir = catfile( $args{'install-base'}, 'lib' );
-
if ( $args{as} ) {
- # remove lib/ if it's symbolic link
- unlink $lib_dir if -l $lib_dir;
+ # remove bin-wrapped, sbin-wrapped and lib if it's symbolic link
+ for my $r ( qw/bin-wrapped sbin-wrapped lib/ ) {
+ my $dir = catfile( $args{'install-base'}, $r );
+ unlink $dir if -l $dir;
+ }
}
mkdir 'dists' unless -e 'dists';
@@ -372,24 +373,40 @@ sub install {
catfile( $args{'install-base'}, 'etc', $_ ) );
}
- wrap_bin($log) unless $^O =~ /MSWin/;
-
if ( $args{as} ) {
my $cwd = getcwd;
chdir $args{'install-base'};
mkdir 'as';
my $as_dir = catdir( 'as', $args{as} );
- if ( -e $as_dir ) {
- warn "$as_dir already exists, won't overwrite";
+ mkdir $as_dir;
+
+ for my $r ( 'lib', 'bin', 'sbin' ) {
+ next unless -e $r;
+ my $dir = catdir( $as_dir, $r );
+ system( "mv $r $as_dir" );
+
+ if ( $r =~ /bin/ ) {
+ symlink $dir, "$r-wrapped";
+ }
+ else {
+ symlink $dir, $r;
+ }
}
- else {
- my $cwd = getcwd;
- system("mv lib $as_dir");
- symlink $as_dir, 'lib';
+
+ # in usr dir
+ my $usr_dir = catdir( $as_dir, 'usr' );
+ mkdir $usr_dir;
+ for my $r ( 'bin', 'sbin' ) {
+ next unless -e catdir( 'usr', $r );
+ system( "mv " . catdir( 'usr', $r ) . ' ' . $usr_dir );
+ my $dir = catdir( '..', $as_dir, 'usr', $r );
+ symlink $dir, catdir( 'usr', "$r-wrapped" );
}
chdir $cwd;
}
+ wrap_bin($log) unless $^O =~ /MSWin/;
+
print "install finished, the dists are at $args{'install-base'}\n";
print $log "install finished, the dists are at $args{'install-base'}\n";
}
@@ -509,25 +526,22 @@ sub wrap_bin {
return unless -f $file;
- # return if it's been wrapped already
- if ( -l $file ) {
- print $log "seems $file has been already wrapped, skipping\n";
- return;
- }
+ my $wrap_dir = $File::Find::dir;
+ $wrap_dir =~ s/-wrapped$//;
- my $wrapped_dir = "$File::Find::dir-wrapped";
- my $wrapped_file = catfile( $wrapped_dir, $file );
+ my $wrap_file = catfile( $wrap_dir, $file );
my $tmp = $File::Find::dir;
$tmp =~ s/$args{'install-base'}//g;
my $wrapped_depth =
scalar( splitdir($File::Find::dir) ) -
scalar( splitdir( $args{'install-base'} ) );
- mkdir $wrapped_dir unless -d $wrapped_dir;
+ mkdir $wrap_dir unless -d $wrap_dir;
- if ( -e $wrapped_file ) {
- print $log 'found old ' . $wrapped_file . ', deleting' . "\n";
- unlink $wrapped_file;
+ # return if it's been wrapped already
+ if ( -l $wrap_file ) {
+ print $log "seems $file has been already wrapped, skipping\n";
+ return;
}
my $type;
@@ -545,9 +559,6 @@ sub wrap_bin {
}
}
- chmod oct 755, $file;
- move( $file => $wrapped_dir ) or confess $!;
-
# if we have this $type(e.g. perl) installed and have that specific wrapper,
# then link to it, else link to the normal one
if (
@@ -559,23 +570,23 @@ sub wrap_bin {
)
{
symlink catfile( ('..') x $wrapped_depth,
- 'etc', "shipwright-$type-wrapper" ) => $file
+ 'etc', "shipwright-$type-wrapper" ) => $wrap_file
or confess $!;
}
else {
symlink catfile( ('..') x $wrapped_depth,
- 'etc', 'shipwright-script-wrapper' ) => $file
+ 'etc', 'shipwright-script-wrapper' ) => $wrap_file
or confess $!;
}
- chmod oct 755, $file;
+ chmod oct 755, $wrap_file;
};
my @dirs =
- grep { -d $_ }
- map { catdir( $args{'install-base'}, $_ ) } 'bin', 'sbin',
- catdir( 'usr', 'bin' ), catdir( 'usr', 'sbin' );
- find( $sub, @dirs ) if @dirs;
+ grep { -e $_ }
+ map { catdir( $args{'install-base'}, $_ ) } 'bin-wrapped', 'sbin-wrapped',
+ catdir( 'usr', 'bin-wrapped' ), catdir( 'usr', 'sbin-wrapped' );
+ find( { wanted => $sub, follow => 1 }, @dirs ) if @dirs;
}
commit 4a485f0a579a59f76ab36c3f0e2bf02426072991
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Jul 16 19:24:14 2009 +0800
update etc/shipwright-utility since we move bin stuff to as/ too
diff --git a/share/etc/shipwright-utility b/share/etc/shipwright-utility
index d08914a..f6c84fb 100755
--- a/share/etc/shipwright-utility
+++ b/share/etc/shipwright-utility
@@ -53,9 +53,30 @@ elsif ( $args{'switch'} ) {
my $name = $args{'switch'};
my $as_dir = catdir( 'as', $name );
if ( -e $as_dir ) {
- unlink 'lib';
- symlink $as_dir, 'lib';
+ for my $r ( qw/bin sbin lib/ ) {
+ my $dir = catdir( $as_dir, $r );
+ next unless -e $dir;
+
+ if ( $r =~ /bin/ ) {
+ unlink "$r-wrapped";
+ symlink $dir, "$r-wrapped";
+ }
+ else {
+ unlink $r;
+ symlink $dir, $r;
+ }
+ }
+
+ # in usr dir
+ for my $r ( qw/bin sbin/ ) {
+ my $dir = catdir( $as_dir, 'usr', $r );
+ next unless -e $dir;
+ unlink catfile( 'usr', "$r-wrapped" );
+ symlink catdir( '..', $dir ), catfile( 'usr', "$r-wrapped" );
+ }
+
print "switched to $name with success.\n";
+
}
else {
print "no switch name $name exists\n";
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list