Thread: [Module-build-checkins] Module-Build/lib/Module/Build Authoring.pod,1.20,1.21 Base.pm,1.519,1.520
Status: Beta
Brought to you by:
kwilliams
From: Randy W. S. <si...@us...> - 2005-11-15 09:49:56
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27267/lib/Module/Build Modified Files: Authoring.pod Base.pm Log Message: Remove action specific prereqs. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.519 retrieving revision 1.520 diff -u -d -r1.519 -r1.520 --- Base.pm 15 Nov 2005 05:43:27 -0000 1.519 +++ Base.pm 15 Nov 2005 09:49:48 -0000 1.520 @@ -30,9 +30,11 @@ $self->dist_name; $self->dist_version; + $self->check_manifest; $self->check_prereq; $self->check_autofeatures; + $self->_set_install_paths; $self->_find_nested_builds; @@ -156,7 +158,7 @@ $self->add_to_cleanup( @{delete $p->{add_to_cleanup}} ) if $p->{add_to_cleanup}; - + return $self; } @@ -175,6 +177,7 @@ } } + sub _set_install_paths { my $self = shift; my $c = $self->{config}; @@ -574,6 +577,14 @@ __PACKAGE__->add_property(metafile => 'META.yml'); __PACKAGE__->add_property(use_rcfile => 1); +{ + my @prereq_action_types = qw(requires build_requires conflicts recommends); + foreach my $type (@prereq_action_types) { + __PACKAGE__->add_property($type => {}); + } + __PACKAGE__->add_property(prereq_action_types => \@prereq_action_types); +} + __PACKAGE__->add_property($_) for qw( base_dir dist_name @@ -611,28 +622,9 @@ libdoc_dirs get_options quiet - ignore_prereq_conflicts - ignore_prereq_requires - ignore_prereqs prefix ); -{ - my @prereq_actions = ( 'Build_PL', __PACKAGE__->known_actions ); - my @prereq_types = qw( requires recommends conflicts ); - __PACKAGE__->add_property(prereq_actions => \@prereq_actions); - __PACKAGE__->add_property(prereq_types => \@prereq_types); - my @prereq_action_types; - foreach my $action ( @prereq_actions ) { - foreach my $type ( @prereq_types ) { - my $req = $action eq 'Build_PL' ? '' : $action . '_'; - $req .= $type; - __PACKAGE__->add_property( $req => {} ); - push( @prereq_action_types, $req ); - } - } - __PACKAGE__->add_property(prereq_action_types => \@prereq_action_types); -} sub mb_parents { # Code borrowed from Class::ISA. @@ -870,7 +862,7 @@ my $log_text; foreach my $type ( grep $failures->{$_}, @{$self->prereq_action_types} ) { while (my ($module, $status) = each %{$failures->{$type}}) { - my $prefix = ($type =~ /recommends$/) ? '*' : '-'; + my $prefix = ($type =~ /^(?:\w+_)?recommends$/) ? '*' : '-'; $log_text .= " $prefix $status->{message}\n"; } } @@ -885,8 +877,8 @@ sub prereq_failures { my ($self, $info) = @_; - my @types = @{ $self->prereq_action_types }; + my @types = @{ $self->prereq_action_types }; $info ||= {map {$_, $self->$_()} @types}; my $out; @@ -895,13 +887,13 @@ my $prereqs = $info->{$type}; while ( my ($modname, $spec) = each %$prereqs ) { my $status = $self->check_installed_status($modname, $spec); - - if ($type =~ /conflicts$/) { + + if ($type =~ /^(?:\w+_)?conflicts$/) { next if !$status->{ok}; $status->{conflicts} = delete $status->{need}; $status->{message} = "$modname ($status->{have}) conflicts with this distribution"; - } elsif ($type =~ /recommends$/) { + } elsif ($type =~ /^(?:\w+_)?recommends$/) { next if $status->{ok}; $status->{message} = ($status->{have} eq '<none>' ? "Optional prerequisite $modname is not installed" @@ -917,6 +909,19 @@ return $out; } +# returns a hash of defined prerequisites; i.e. only prereq types with values +sub _enum_prereqs { + my $self = shift; + my %prereqs; + foreach my $type ( @{ $self->prereq_action_types } ) { + if ( $self->can( $type ) ) { + my $prereq = $self->$type || {}; + $prereqs{$type} = $prereq if %$prereq; + } + } + return \%prereqs; +} + sub check_prereq { my $self = shift; @@ -928,20 +933,18 @@ } # Check to see if there are any prereqs to check - my $has_prereqs = grep { keys %{$self->$_()} } - @{ $self->prereq_action_types }; - return 1 unless $has_prereqs; + my $prereqs = $self->_enum_prereqs; + return 1 unless $prereqs; $self->log_info("Checking prerequisites...\n"); - my $failures = $self->prereq_failures; + my $failures = $self->prereq_failures($prereqs); if ( $failures ) { - foreach my $type ( @{$self->prereq_action_types} ) { - next unless $failures->{$type}; - while (my ($module, $status) = each %{$failures->{$type}}) { - my $prefix = ($type =~ /recommends$/) ? '*' : '- ERROR:'; + foreach my $fail ( sort keys( %$failures ) ) { + while (my ($module, $status) = each %{$failures->{$fail}}) { + my $prefix = ($fail =~ /^(?:\w+_)?recommends$/) ? '*' : '- ERROR:'; $self->log_warn(" $prefix $status->{message}\n"); } } @@ -1232,8 +1235,6 @@ sub _call_action { my ($self, $action) = @_; - $self->validate_action_prereqs( $action ); - return if $self->{_completed_actions}{$action}++; local $self->{action} = $action; @@ -1242,45 +1243,6 @@ return $self->$method(); } -sub validate_action_prereqs { - my $self = shift; - my $action = shift; - - return if $self->ignore_prereqs; - - my $failures = $self->prereq_failures; - my $fail_msg; - if ( !$self->ignore_prereq_requires && $failures->{"${action}_requires"} ) { - $fail_msg .= "Missing prerequisite module versions for action '$action':\n"; - foreach my $module ( keys( %{$failures->{"${action}_requires"}} ) ) { - my $fail_info = $failures->{"${action}_requires"}{$module}; - $fail_msg .= sprintf( " Requested module '%s %s%s' but found %s\n", - $module, - $fail_info->{need} !~ /^\s*[!=<>]/ ? '> ' : '', - $fail_info->{need}, - $fail_info->{have} ); - } - if ( $action eq 'build' ) { # Backwards compatability - $self->log_warn( "$fail_msg\n" . - "Ignoring for backwards compatability.\n" . - "This will be a fatal error in future versions of Module::Build.\n\n" ); - $fail_msg = undef; - } - } - if ( !$self->ignore_prereq_conflicts && $failures->{"${action}_conflicts"} ) { - $fail_msg .= "Found conflicting module requirements for action '$action':\n"; - foreach my $module ( keys( %{$failures->{"${action}_conflicts"}} ) ) { - my $fail_info = $failures->{"${action}_conflicts"}{$module}; - $fail_msg .= sprintf( " Requested module '%s %s%s' conflicts with installed version %s\n", - $module, - $fail_info->{conflicts} !~ /^\s*[!=<>]/ ? '> ' : '', - $fail_info->{conflicts}, - $fail_info->{have} ); - } - } - die "Aborting '$action' action.\n$fail_msg" if $fail_msg; -} - sub cull_options { my $self = shift; my $specs = $self->get_options or return ({}, @_); @@ -1346,9 +1308,6 @@ create_readme extra_compiler_flags extra_linker_flags - ignore_prereq_conflicts - ignore_prereq_requires - ignore_prereqs use_rcfile ); # normalize only selected option names @@ -1380,9 +1339,6 @@ create_readme pollute quiet - ignore_prereq_conflicts - ignore_prereq_requires - ignore_prereqs use_rcfile uninst ); Index: Authoring.pod =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Authoring.pod,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- Authoring.pod 13 Nov 2005 03:26:51 -0000 1.20 +++ Authoring.pod 15 Nov 2005 09:49:48 -0000 1.21 @@ -178,7 +178,7 @@ the body of installed modules, and facilitates correct dependency checking on binary/packaged distributions of the module. -See the documentation for L<requires> for the details of how +See the documentation for L<PREREQUISITES> for the details of how requirements can be specified. =item c_source @@ -196,7 +196,7 @@ refuse to install the given module if the given module/version is also installed. -See the documentation for L<requires> for the details of how +See the documentation for L<PREREQUISITES> for the details of how requirements can be specified. =item create_makefile_pl @@ -579,34 +579,13 @@ modules aren't installed, and it should offer to install them if it wants to be helpful. -See the documentation for L<requires> for the details of how +See the documentation for L<PREREQUISITES> for the details of how requirements can be specified. =item requires -An optional C<requires> argument specifies any module prerequisites that -the current module depends on. The prerequisites are given in a hash -reference, where the keys are the module names and the values are -version specifiers: - - requires => {Foo::Module => '2.4', - Bar::Module => 0, - Ken::Module => '>= 1.2, != 1.5, < 2.0', - perl => '5.6.0'}, - -These four version specifiers have different effects. The value -C<'2.4'> means that B<at least> version 2.4 of C<Foo::Module> must be -installed. The value C<0> means that B<any> version of C<Bar::Module> -is acceptable, even if C<Bar::Module> doesn't define a version. The -more verbose value C<'E<gt>= 1.2, != 1.5, E<lt> 2.0'> means that -C<Ken::Module>'s version must be B<at least> 1.2, B<less than> 2.0, -and B<not equal to> 1.5. The list of criteria is separated by commas, -and all criteria must be satisfied. - -A special C<perl> entry lets you specify the versions of the Perl -interpreter that are supported by your module. The same version -dependency-checking semantics are available, except that we also -understand perl's new double-dotted version numbers. +An optional C<requires> argument specifies any module prerequisites +that the current module depends on. One note: currently C<Module::Build> doesn't actually I<require> the user to have dependencies installed, it just strongly urges. In the @@ -623,6 +602,9 @@ preferred, but the C<prereq> term will remain valid in future distributions. +See the documentation for L<PREREQUISITES> for the details of how +requirements can be specified. + =item script_files An optional parameter specifying a set of files that should be @@ -1267,6 +1249,48 @@ =back +=head1 PREREQUISITES + +There are three basic types of prerequisites that can be defined: 1) +"requires" - are versions of modules that are required for certain +functionality to be available; 2) "recommends" - are versions of +modules that are recommended to provide enhanced functionality; and 3) +"conflicts" - are versions of modules that conflict with, and that can +cause problems with the distribution. + +Each of the three types of prerequisites listed above can be applied +to different aspects of the Build process. For the module distribution +itself you simply define "requires", "recommends", or "conflicts". The +types can also apply to other aspects of the Build process. Currently, +only "build_requires" is defined which is used for modules which are +required during the Build process. + + +=head2 Format of prerequisites + +The prerequisites are given in a hash reference, where the keys are +the module names and the values are version specifiers: + + requires => {Foo::Module => '2.4', + Bar::Module => 0, + Ken::Module => '>= 1.2, != 1.5, < 2.0', + perl => '5.6.0'}, + +These four version specifiers have different effects. The value +C<'2.4'> means that B<at least> version 2.4 of C<Foo::Module> must be +installed. The value C<0> means that B<any> version of C<Bar::Module> +is acceptable, even if C<Bar::Module> doesn't define a version. The +more verbose value C<'E<gt>= 1.2, != 1.5, E<lt> 2.0'> means that +C<Ken::Module>'s version must be B<at least> 1.2, B<less than> 2.0, +and B<not equal to> 1.5. The list of criteria is separated by commas, +and all criteria must be satisfied. + +A special C<perl> entry lets you specify the versions of the Perl +interpreter that are supported by your module. The same version +dependency-checking semantics are available, except that we also +understand perl's new double-dotted version numbers. + + =head1 SAVING CONFIGURATION INFORMATION Module::Build provides a very convenient way to save configuration @@ -1392,6 +1416,7 @@ See also the documentation for the C<subclass()> method. + =head1 STARTING MODULE DEVELOPMENT When starting development on a new module, it's rarely worth your time |