[Bps-public-commit] r10501 - bpsbuilder/Shipwright/lib/Shipwright

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Jan 25 15:50:41 EST 2008


Author: sunnavy
Date: Fri Jan 25 15:50:33 2008
New Revision: 10501

Modified:
   bpsbuilder/Shipwright/lib/Shipwright/Build.pm

Log:
updated Build.pm for sepcific wrapper

Modified: bpsbuilder/Shipwright/lib/Shipwright/Build.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Build.pm	(original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Build.pm	Fri Jan 25 15:50:33 2008
@@ -8,7 +8,7 @@
 
 __PACKAGE__->mk_accessors(
     qw/install_base perl build_base skip_test commands log
-      skip skip_test only_test force/
+      skip skip_test only_test force order/
 );
 
 use File::Spec;
@@ -89,10 +89,14 @@
     else {
         dircopy( 'etc', File::Spec->catfile( $self->install_base, 'etc' ) );
 
-        my $order = Shipwright::Config::LoadFile(
-            File::Spec->catfile( 'shipwright', 'order.yml' ) );
+        $self->order(
+            Shipwright::Config::LoadFile(
+                File::Spec->catfile( 'shipwright', 'order.yml' )
+            )
+        );
 
-        for my $dist (@$order) {
+
+        for my $dist (@{$self->order}) {
             unless ( grep { $dist eq $_ } @{ $self->skip || [] } ) {
                 $self->_install($dist);
             }
@@ -168,12 +172,44 @@
         my $dir = ( File::Spec->splitdir($File::Find::dir) )[-1];
         mkdir File::Spec->catfile( $self->install_base,       "$dir-wrapped" )
           unless -d File::Spec->catfile( $self->install_base, "$dir-wrapped" );
+
+        my $type;
+        if ( -T $file ) {
+            open my $fh, '<', $file or die "can't open $file: $!";
+            my $shebang = <$fh>;
+            my $base = quotemeta $self->install_base;
+            my $perl = quotemeta $self->perl;
+
+            if ( $shebang =~ m{$perl} )
+            {
+                $type = 'perl';
+            }
+            elsif ( $shebang =~ m{$base(?:/|\\)(?:s?bin|libexec)(?:/|\\)(\w+)} )
+            {
+                $type = $1;
+            }
+        }
+
         move(
             $file => File::Spec->catfile( $self->install_base, "$dir-wrapped" )
         ) or die $!;
-        link File::Spec->catfile( $self->install_base, 'etc',
-            'shipwright-script-wrapper' ) => $file
-          or die $!;
+
+    # 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 ( $type && grep( { $_ eq $type } @{$self->order} )
+            && -e File::Spec->catfile( '..', 'etc', "shipwright-$type-wrapper" )
+          )
+        {
+            symlink File::Spec->catfile( '..', 'etc',
+                "shipwright-$type-wrapper" ) => $file
+              or die $!;
+        }
+        else {
+
+            symlink File::Spec->catfile( '..', 'etc',
+                'shipwright-script-wrapper' ) => $file
+              or die $!;
+        }
     };
 
     my @dirs =



More information about the Bps-public-commit mailing list