[Bps-public-commit] r9829 - in bpsbuilder/BPB: lib/BPB/Source
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Thu Dec 6 03:08:48 EST 2007
Author: sunnavy
Date: Thu Dec 6 03:08:47 2007
New Revision: 9829
Modified:
bpsbuilder/BPB/examples/config.yml
bpsbuilder/BPB/lib/BPB/Source/Base.pm
Log:
aotumatically generate _require.yml if not present; is min_perl_version instead of mini_perl_version
Modified: bpsbuilder/BPB/examples/config.yml
==============================================================================
--- bpsbuilder/BPB/examples/config.yml (original)
+++ bpsbuilder/BPB/examples/config.yml Thu Dec 6 03:08:47 2007
@@ -8,3 +8,4 @@
tar: '/usr/bin/tar'
directory: '/tmp'
download_directory: '/tmp/download'
+ min_perl_version: 5.008008
Modified: bpsbuilder/BPB/lib/BPB/Source/Base.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB/Source/Base.pm (original)
+++ bpsbuilder/BPB/lib/BPB/Source/Base.pm Thu Dec 6 03:08:47 2007
@@ -10,9 +10,10 @@
use base qw/Class::Accessor::Fast/;
__PACKAGE__->mk_accessors(
- qw/source directory command download_directory follow mini_perl_version/);
+ qw/source directory command download_directory follow min_perl_version/);
-our %MODULE = ( '^(LWP
+our %MODULE = (
+ '^(LWP
|File::Listing
|HTML::Form
|HTTP::Cookies
@@ -36,7 +37,8 @@
|Net::HTTPS
|WWW::RobotRules
|WWW::RobotRules::AnyDBM_File
-)' => 'libwww-perl', );
+)' => 'libwww-perl',
+);
=head2 new
@@ -67,51 +69,56 @@
}
sub _follow {
- my $self = shift;
- my $path = shift;
- $path = File::Spec->catfile( $path, '_require.yml' );
+ my $self = shift;
+ my $path = shift;
+ my $require_path = File::Spec->catfile( $path, '_require.yml' );
+
+ # if not found, we'll create one according to META.yml
+ if ( !-e $require_path ) {
+ my $meta_path = File::Spec->catfile( $path, 'META.yml' );
+ my $meta = BPB::Config::LoadFile($meta_path);
+ my $require = $meta->{requires};
+ BPB::Config::DumpFile( $require_path, $require );
+ }
- if ( -e $path ) {
- if ( my $require = BPB::Config::LoadFile($path) ) {
- while ( my ( $module, $version ) = each %$require ) {
-
- # we don't want to require perl
- if ( $module eq 'perl' ) {
- delete $require->{$module};
- next;
- }
- if ( Module::CoreList->first_release( $module, $version )
- && Module::CoreList->first_release( $module, $version )
- le $self->mini_perl_version )
- {
- delete $require->{$module};
+ if ( my $require = BPB::Config::LoadFile($require_path) ) {
+ while ( my ( $module, $version ) = each %$require ) {
+
+ # we don't want to require perl
+ if ( $module eq 'perl' ) {
+ delete $require->{$module};
+ next;
+ }
+ if ( Module::CoreList->first_release( $module, $version )
+ && Module::CoreList->first_release( $module, $version )
+ <= $self->min_perl_version )
+ {
+ delete $require->{$module};
+ }
+ else {
+ opendir my $dir, $self->directory;
+ my @sources = readdir $dir;
+ close $dir;
+ my $name;
+
+ for ( keys %MODULE ) {
+ $name = $MODULE{$_} if $module =~ /$_/x;
}
- else {
- opendir my $dir, $self->directory;
- my @sources = readdir $dir;
- close $dir;
- my $name;
-
- for ( keys %MODULE ) {
- $name = $MODULE{$_} if $module =~ /$_/x;
- }
-
- $name ||= $module;
- $name =~ s/::/-/g;
-
- unless ( grep { /^$name/ } @sources ) {
- my $cpan =
- BPB::Source->new( %$self, source => $module );
- $cpan->run();
- }
+
+ $name ||= $module;
+ $name =~ s/::/-/g;
+
+ unless ( grep { /^$name/ } @sources ) {
+ my $cpan = BPB::Source->new( %$self, source => $module );
+ $cpan->run();
}
}
-
- BPB::Config::DumpFile( $path, $require );
- }
- else {
- croak "invalid _require.yml file: $path";
}
+
+ BPB::Config::DumpFile( $require_path, $require );
+ }
+ else {
+ croak "invalid _require.yml in $path";
}
}
More information about the Bps-public-commit
mailing list