[Bps-public-commit] r9760 - bpsbuilder/BPB/lib/BPB/Source

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Nov 29 06:20:08 EST 2007


Author: sunnavy
Date: Thu Nov 29 06:20:02 2007
New Revision: 9760

Modified:
   bpsbuilder/BPB/lib/BPB/Source/Compressed.pm

Log:
added decompressed source path stuff for Compressed.pm

Modified: bpsbuilder/BPB/lib/BPB/Source/Compressed.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/Compressed.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source/Compressed.pm	Thu Nov 29 06:20:02 2007
@@ -3,6 +3,7 @@
 use warnings;
 use strict;
 use Carp;
+use File::Spec;
 
 use base qw/Class::Accessor::Fast BPB::Source/;
 __PACKAGE__->mk_accessors(qw/source directory command/);
@@ -24,6 +25,30 @@
     my $self = shift;
     my $cmd  = $self->_cmd;
     $self->_run($cmd);
+    $self->SUPER::run( $self->path );
+}
+
+=head2 path
+
+the decompressed source path
+
+=cut
+
+sub path {
+    my $self     = shift;
+    my $tar      = $self->command->{tar};
+    my $source = $self->source;
+    my @contents = `$tar -t -f $source`;
+    my %path;
+
+    for (@contents) {
+        $path{$1} = 1 if m{(.+)/};
+    }
+
+    my @paths = keys %path;
+    croak 'only support compressed file which contains only one directory'
+      unless @paths == 1;
+    return File::Spec->catfile( $self->directory, $paths[0] );
 }
 
 sub _cmd {



More information about the Bps-public-commit mailing list