[Bps-public-commit] r9941 - bpsbuilder/BPB/lib/BPB

sunnavy at bestpractical.com sunnavy at bestpractical.com
Fri Dec 14 02:28:20 EST 2007


Author: sunnavy
Date: Fri Dec 14 02:28:19 2007
New Revision: 9941

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

Log:
added wrapper stuff to build

Modified: bpsbuilder/BPB/lib/BPB/Build.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Build.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Build.pm	Fri Dec 14 02:28:19 2007
@@ -10,6 +10,9 @@
 
 use File::Spec;
 use File::Temp qw/tempdir/;
+use File::Copy::Recursive qw/dircopy/;
+use File::Copy qw/move/;
+use File::Find qw/find/;
 
 sub new {
     my $class = shift;
@@ -31,6 +34,8 @@
 
     chdir $self->build_directory;
 
+    dircopy( 'etc', File::Spec->catfile( $self->install_directory, 'etc' ) );
+
     my $order =
       BPB::Config::LoadFile( File::Spec->catfile( 'bpb', 'order.yml' ) );
 
@@ -40,6 +45,8 @@
         chdir $self->build_directory;
     }
 
+    $self->_wrapper();
+
 }
 
 sub _install {
@@ -78,6 +85,34 @@
     system($cmd);
 }
 
+sub _wrapper {
+    my $self = shift;
+
+    my %seen;
+
+    my $sub = sub {
+        my $file = $_;
+        return unless $file and -f $file;
+        return if $seen{$File::Find::name}++;
+        my $dir = ( File::Spec->splitdir($File::Find::dir) )[-1];
+        mkdir File::Spec->catfile( $self->install_directory, "$dir-wrapped" )
+          or die $!;
+        move( $file =>
+              File::Spec->catfile( $self->install_directory, "$dir-wrapped" ) )
+          or die $!;
+        link File::Spec->catfile( $self->install_directory, 'etc',
+            'bpb-script-wrapper' ) => $file
+          or die $!;
+    };
+
+    for my $dir (qw(bin sbin libexec)) {
+        find( $sub,
+            grep { -d $_ }
+              map { File::Spec->catfile( $self->install_directory, $_ ) }
+              qw/bin sbin libexec/ );
+    }
+}
+
 1;
 
 __END__



More information about the Bps-public-commit mailing list