[Bps-public-commit] Shipwright branch, master, updated. 37f06e268eccbd902880f8ceacfba054ec03eedb

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jul 22 02:36:33 EDT 2009


The branch, master has been updated
       via  37f06e268eccbd902880f8ceacfba054ec03eedb (commit)
       via  03dd4c46357c0ade4c9b8b3ba882ca215940a311 (commit)
      from  c58bcac0404abff5dca3f4e4ac9fbd1c05f75b5b (commit)

Summary of changes:
 share/bin/shipwright-builder |    4 +++-
 share/etc/shipwright-utility |   18 ++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 03dd4c46357c0ade4c9b8b3ba882ca215940a311
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jul 22 14:35:19 2009 +0800

    make as name uname, "default" if uname is unavailable

diff --git a/share/bin/shipwright-builder b/share/bin/shipwright-builder
index c82ceb2..37a5df5 100755
--- a/share/bin/shipwright-builder
+++ b/share/bin/shipwright-builder
@@ -123,7 +123,9 @@ $args{flags} = {
 $args{with} = { map { split /=/ } split /\s*,\s*/, $args{with} || '' };
 $args{branches} = { map { split /=/ } split /\s*,\s*/, $args{branches} || '' };
 $args{make} ||= 'make';
-$args{as} ||= 'default';
+my $uname = `uname 2>/dev/null`;
+chomp $uname;
+$args{as} ||= $uname || 'default';
 
 if ( $args{only} ) {
     $args{only} = { map { $_ => 1 } split /\s*,\s*/, $args{only} };

commit 37f06e268eccbd902880f8ceacfba054ec03eedb
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jul 22 14:35:57 2009 +0800

    add --auto-switch to tools/shipwright-utility

diff --git a/share/etc/shipwright-utility b/share/etc/shipwright-utility
index f8297c6..556a540 100755
--- a/share/etc/shipwright-utility
+++ b/share/etc/shipwright-utility
@@ -8,11 +8,12 @@ use Cwd;
 use Carp;
 use File::Find;
 my %args;
-GetOptions( \%args, 'install-links=s', 'switch=s', 'help' );
+GetOptions( \%args, 'install-links=s', 'switch=s', 'auto-switch', 'help' );
 
 my $USAGE = <<'END'
 run: ./tools/shipwright-utility --install-links /usr/local
 run: ./tools/shipwright-utility --switch ubuntu
+run: ./tools/shipwright-utility --auto-switch 
 
 options: 
 
@@ -24,6 +25,8 @@ install-links: link files in bin, sbin, or libexec to other places
 switch: switch to the lib below as/$name
     e.g. --switch ubuntu
 
+auto-switch: swith automatically by the uname
+
 END
   ;
 
@@ -49,8 +52,10 @@ elsif ( $args{'install-links'} ) {
         }
     }
 }
-elsif ( $args{'switch'} ) {
-    my $name = $args{'switch'};
+elsif ( $args{'switch'} || $args{'auto-switch' } ) {
+    my $name = $args{'switch'} || `uname 2>/dev/null`;
+    chomp $name;
+
     my $as_dir = catdir( 'as', $name );
     if ( -e $as_dir ) {
         for my $r ( qw/lib/ ) {
@@ -71,7 +76,7 @@ elsif ( $args{'switch'} ) {
                 system( "rm -rf $dir" );
             }
         }
-        wrap_bin();
+        wrap_bin($name);
 
         open my $fh, '>', '__as' or die $!;
         print $fh $name;
@@ -86,6 +91,7 @@ elsif ( $args{'switch'} ) {
 }
 
 sub wrap_bin {
+    my $name = shift;
     my $install_base = getcwd();
     my $sub = sub {
         my $file = $_;
@@ -93,7 +99,7 @@ sub wrap_bin {
         return unless -f $file;
 
         my $wrap_dir = $File::Find::dir;
-        $wrap_dir =~ s!as/$args{switch}/!!;
+        $wrap_dir =~ s!as/$name/!!;
 
         my $wrap_file = catfile( $wrap_dir, $file );
         my $wrapped_depth =
@@ -146,7 +152,7 @@ sub wrap_bin {
     };
 
     my @dirs =
-      grep { -e $_ } map { catdir( $install_base, 'as', $args{switch}, $_ ) } 'bin',
+      grep { -e $_ } map { catdir( $install_base, 'as', $name, $_ ) } 'bin',
       'sbin', catdir( 'usr', 'bin' ), catdir( 'usr', 'sbin' );
     find( { wanted => $sub, follow => 1 }, @dirs ) if @dirs;
 }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list