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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Dec 30 23:33:19 EST 2007


Author: sunnavy
Date: Sun Dec 30 23:33:18 2007
New Revision: 10215

Added:
   bpsbuilder/BPB/lib/BPB/Source/SVN.pm
Modified:
   bpsbuilder/BPB/TODO
   bpsbuilder/BPB/lib/BPB/Source.pm

Log:
svn source support, source beginning with 'svn::' will be treated as svn source

Modified: bpsbuilder/BPB/TODO
==============================================================================
--- bpsbuilder/BPB/TODO	(original)
+++ bpsbuilder/BPB/TODO	Sun Dec 30 23:33:18 2007
@@ -1,4 +1,3 @@
-* import from svn directly
 * svn backend
 * better log support 
 * should be possible to build a bindist that runs on macos, linux, solaris and windows using lib path tricks. (windows may need special love).

Modified: bpsbuilder/BPB/lib/BPB/Source.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source.pm	(original)
+++ bpsbuilder/BPB/lib/BPB/Source.pm	Sun Dec 30 23:33:18 2007
@@ -55,12 +55,15 @@
 "only support directory and compressed file which contains only one directory";
         }
     }
-    elsif ( $source =~ m{http://} ) {
+    elsif ( $source =~ m{^\s*http://} ) {
         return 'HTTP';
     }
-    elsif ( $source =~ m{ftp://} ) {
+    elsif ( $source =~ m{^\s*ftp://} ) {
         return 'FTP';
     }
+    elsif ( $source =~ m{^\s*svn::} ) {
+        return 'SVN';
+    }
     else {
         return 'CPAN';
     }

Added: bpsbuilder/BPB/lib/BPB/Source/SVN.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Source/SVN.pm	Sun Dec 30 23:33:18 2007
@@ -0,0 +1,118 @@
+package BPB::Source::SVN;
+
+use warnings;
+use strict;
+use Carp;
+use File::Spec;
+
+use base qw/BPB::Source::Base/;
+
+sub new {
+    my $class = shift;
+    my $self  = $class->SUPER::new(@_);
+    my $s     = $self->source;
+    $s =~ s/^\s*svn:://;
+    $self->source($s);
+    return $self;
+}
+
+=head2 run
+
+=cut
+
+sub run {
+    my $self = shift;
+    $self->_run;
+    my $s;
+    if ( $self->_is_compressed ) {
+        require BPB::Source::Compressed;
+        $s = BPB::Source::Compressed->new(%$self);
+    }
+    else {
+        require BPB::Source::Directory;
+        $s = BPB::Source::Directory->new(%$self);
+    }
+    $s->run(@_);
+}
+
+=head2 _run
+
+=cut
+
+sub _run {
+    my $self   = shift;
+    my $source = $self->source;
+    my $cmd    = join ' ', 'svn export ', $self->source,
+      File::Spec->catfile( $self->download_directory, $self->name || $self->path );
+    $self->source(
+        File::Spec->catfile(
+            $self->download_directory, $self->name || $self->path
+        )
+    );
+    system($cmd );
+}
+
+sub path {
+    my $self = shift;
+    if ( $self->source =~ m{.*/(.+)\.(tar.(gz|bz2)|tgz)$} ) {
+        return $1;
+    }
+    elsif ( $self->source =~ m{.*/(.+)/?$} ) {
+        return $1;
+    }
+    else {
+        croak "invalid source, I can't guess the path";
+    }
+}
+
+
+sub _is_compressed {
+    my $self = shift;
+    return 1 if $self->source =~ m{.*/(.+)\.(tar.(gz|bz2)|tgz)$};
+    return;
+}
+
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Source::SVN - 
+
+
+=head1 SYNOPSIS
+
+  
+=head1 DESCRIPTION
+
+
+=head1 INTERFACE 
+
+
+=head1 DEPENDENCIES
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.



More information about the Bps-public-commit mailing list