[Bps-public-commit] r10500 - in bpsbuilder/Shipwright/lib/Shipwright: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Jan 25 15:13:04 EST 2008
Author: sunnavy
Date: Fri Jan 25 15:12:45 2008
New Revision: 10500
Modified:
bpsbuilder/Shipwright/lib/Shipwright/Backend.pm
bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm
bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm
Log:
added perl-wrapper for perl scripts
Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend.pm (original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend.pm Fri Jan 25 15:12:45 2008
@@ -45,23 +45,39 @@
BASE_DIR=` (cd "$BASE_DIR"; pwd) `
FILENAME=`basename "$BASE"`
WRAPPED_DIR=`basename "$BASE_DIR"`
- ISPERL=`head -n 1 ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/${FILENAME} | grep '\bperl\b'`
- if [ "$ISPERL" ]; then
- PERL5LIB=${BASE_DIR}/../lib/perl5/site_perl:${BASE_DIR}/../lib/perl5:${PERL5LIB}\
- LD_LIBRARY_PATH=${BASE_DIR}/../lib:${LD_LIBRARY_PATH}\
- DYLD_LIBRARY_PATH=${BASE_DIR}/../lib:${DYLD_LIBRARY_PATH}\
- exec ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/perl ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/${FILENAME} "$@"
- else
- PERL5LIB=${BASE_DIR}/../lib/perl5/site_perl:${BASE_DIR}/../lib/perl5:${PERL5LIB}\
+ PERL5LIB=${BASE_DIR}/../lib/perl5/site_perl:${BASE_DIR}/../lib/perl5:${PERL5LIB}\
LD_LIBRARY_PATH=${BASE_DIR}/../lib:${LD_LIBRARY_PATH}\
DYLD_LIBRARY_PATH=${BASE_DIR}/../lib:${DYLD_LIBRARY_PATH}\
exec ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/${FILENAME} "$@"
- fi
else
exec $LINK "$@"
fi
EOF
,
+perl_wrapper => <<'EOF'
+#!/bin/sh
+if [ -z `which readlink` ]; then
+ # if we don't have readlink, we're on some pitiful platform like solaris
+ test -h $0 && LINK=`ls -l $0 | awk -F\> '{print $NF}'`
+else
+ LINK=`readlink $0`
+fi
+
+if [ $LINK = '../etc/shipwright-perl-wrapper' ]; then
+ BASE=$0
+ BASE_DIR=`dirname "$BASE"`
+ BASE_DIR=` (cd "$BASE_DIR"; pwd) `
+ FILENAME=`basename "$BASE"`
+ WRAPPED_DIR=`basename "$BASE_DIR"`
+ PERL5LIB=${BASE_DIR}/../lib/perl5/site_perl:${BASE_DIR}/../lib/perl5:${PERL5LIB}\
+ LD_LIBRARY_PATH=${BASE_DIR}/../lib:${LD_LIBRARY_PATH}\
+ DYLD_LIBRARY_PATH=${BASE_DIR}/../lib:${DYLD_LIBRARY_PATH}\
+ exec ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/perl ${BASE_DIR}/../${WRAPPED_DIR}-wrapped/${FILENAME} "$@"
+else
+ exec $LINK "$@"
+fi
+EOF
+ ,
utility => <<'EOF'
#!/usr/bin/env perl
use strict;
@@ -153,7 +169,10 @@
my $build_base = getcwd;
# we don't want any prereqs any more!
-$CPAN::Config->{prerequisites_policy} = 'ignore';
+{
+ no warnings 'once';
+ $CPAN::Config->{prerequisites_policy} = 'ignore';
+}
my %args;
GetOptions( \%args, 'install-base=s', 'perl=s', 'skip=s', 'skip-test',
@@ -210,14 +229,15 @@
mkdir File::Spec->catfile( $args{'install-base'}, 'etc' )
unless -e File::Spec->catfile( $args{'install-base'}, 'etc' );
- copy(
- File::Spec->catfile( 'etc', 'shipwright-script-wrapper' ),
- File::Spec->catfile(
- $args{'install-base'}, 'etc', 'shipwright-script-wrapper'
- )
- );
-
-
+ for ( 'shipwright-script-wrapper', 'shipwright-perl-wrapper' ) {
+ copy(
+ File::Spec->catfile( 'etc', $_ ),
+ File::Spec->catfile(
+ $args{'install-base'}, 'etc', $_
+ )
+ );
+ }
+
for my $dist (@$order) {
unless ( grep { $dist eq $_ } @{ $args{skip} } ) {
install($dist);
@@ -298,12 +318,38 @@
mkdir File::Spec->catfile( $args{'install-base'}, "$dir-wrapped" )
unless -d File::Spec->catfile( $args{'install-base'},
"$dir-wrapped" );
+
+ my $type;
+ if ( -T $file ) {
+ open my $fh, '<', $file or die "can't open $file: $!";
+ my $shebang = <$fh>;
+ if ( $shebang =~
+ m{$args{'install-base'}(?:/|\\)(?:s?bin|libexec)(?:/|\\)(\w+)} )
+ {
+ $type = $1;
+ }
+ }
+
move( $file =>
File::Spec->catfile( $args{'install-base'}, "$dir-wrapped" ) )
or die $!;
- symlink File::Spec->catfile( '..', '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 } @$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 $!;
+ }
chmod 0755, $file;
};
Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm (original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend/SVK.pm Fri Jan 25 15:12:45 2008
@@ -45,6 +45,8 @@
my %map = (
File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) =>
'wrapper',
+ File::Spec->catfile( $dir, 'etc', 'shipwright-perl-wrapper' ) =>
+ 'perl_wrapper',
File::Spec->catfile( $dir, 'bin', 'shipwright-builder' ) => 'builder',
File::Spec->catfile( $dir, 'bin', 'shipwright-utility' ) => 'utility',
File::Spec->catfile( $dir, 't', 'test' ) => 'null',
@@ -65,8 +67,9 @@
comment => 'created project',
);
for (
- 'bin/shipwright-builder', 'bin/shipwright-utility',
- 'etc/shipwright-script-wrapper', 't/test'
+ 'bin/shipwright-builder', 'bin/shipwright-utility',
+ 'etc/shipwright-perl-wrapper', 'etc/shipwright-script-wrapper',
+ 't/test'
)
{
$self->propset(
Modified: bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm
==============================================================================
--- bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm (original)
+++ bpsbuilder/Shipwright/lib/Shipwright/Backend/SVN.pm Fri Jan 25 15:12:45 2008
@@ -45,6 +45,8 @@
my %map = (
File::Spec->catfile( $dir, 'etc', 'shipwright-script-wrapper' ) =>
'wrapper',
+ File::Spec->catfile( $dir, 'etc', 'shipwright-perl-wrapper' ) =>
+ 'perl_wrapper',
File::Spec->catfile( $dir, 'bin', 'shipwright-builder' ) => 'builder',
File::Spec->catfile( $dir, 'bin', 'shipwright-utility' ) => 'utility',
File::Spec->catfile( $dir, 't', 'test' ) => 'null',
@@ -66,8 +68,9 @@
);
for (
- 'bin/shipwright-builder', 'bin/shipwright-utility',
- 'etc/shipwright-script-wrapper', 't/test'
+ 'bin/shipwright-builder', 'bin/shipwright-utility',
+ 'etc/shipwright-perl-wrapper', 'etc/shipwright-script-wrapper',
+ 't/test'
)
{
$self->propset(
More information about the Bps-public-commit
mailing list