[Bps-public-commit] r9761 - in bpsbuilder/BPB/lib/BPB: .

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Nov 29 09:36:02 EST 2007


Author: sunnavy
Date: Thu Nov 29 09:36:00 2007
New Revision: 9761

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

Log:
added .tgz extension, changed command from tar => 'tar' to compressed => 'tar', also bug fixes

Modified: bpsbuilder/BPB/lib/BPB/Source.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source.pm	Thu Nov 29 09:36:00 2007
@@ -4,8 +4,12 @@
 use strict;
 use Carp;
 use UNIVERSAL::require;
+use Hash::Merge qw/merge/;
 
-our %DEFAULT = ( directory => '/tmp', command => { tar => 'tar' } );
+Hash::Merge::set_behavior('RIGHT_PRECEDENT');
+
+our %DEFAULT =
+  ( directory => '/tmp', command => { compressed => 'tar', http => 'wget' } );
 
 =head2 new
 
@@ -13,7 +17,7 @@
 
 sub new {
     my $class = shift;
-    my %args = ( %DEFAULT, @_ );
+    my %args = %{ merge( \%DEFAULT, {@_} ) };
 
     my $type = delete $args{type} || type( $args{source} );
 
@@ -27,6 +31,10 @@
 
 }
 
+=head2 type
+
+=cut
+
 sub type {
     my $source = shift;
 
@@ -34,11 +42,12 @@
         if ( -d $source ) {
             return 'Directory';
         }
-        elsif ( -f $source && $source =~ /tar\.(gz|bz2)$/ ) {
+        elsif ( -f $source && $source =~ /\.(tgz|tar\.(gz|bz2))$/ ) {
             return 'Compressed';
         }
         else {
-            croak "only support directory and compressed file which can be decompressed to a directory";
+            croak
+"only support directory and compressed file which contains only one directory";
         }
     }
     elsif ( $source =~ m{http://} ) {
@@ -52,6 +61,18 @@
     }
 }
 
+=head2 run
+
+=cut
+
+sub run {
+    my $self = shift;
+    my $path = shift;
+
+    # do build order stuff
+
+}
+
 1;
 
 __END__

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 09:36:00 2007
@@ -36,13 +36,13 @@
 
 sub path {
     my $self     = shift;
-    my $tar      = $self->command->{tar};
+    my $tar      = $self->command->{compressed};
     my $source = $self->source;
     my @contents = `$tar -t -f $source`;
     my %path;
 
     for (@contents) {
-        $path{$1} = 1 if m{(.+)/};
+        $path{$1} = 1 if m{^(.+?)/};
     }
 
     my @paths = keys %path;
@@ -55,16 +55,16 @@
     my $self = shift;
     my $arg;
 
-    if ( $self->source =~ /tar\.gz$/ ) {
+    if ( $self->source =~ /\.(tar\.|t)gz$/ ) {
         $arg = 'xfz';
     }
-    elsif ( $self->source =~ /tar\.bz2$/ ) {
+    elsif ( $self->source =~ /\.tar\.bz2$/ ) {
         $arg = 'xfj';
     }
     else {
         croak "I've no idea what the cmd is";
     }
-    return join ' ', $self->command->{tar}, 'xfz', $self->source, '-C',
+    return join ' ', $self->command->{compressed}, 'xfz', $self->source, '-C',
       $self->directory;
 }
 



More information about the Bps-public-commit mailing list