module-build-checkins Mailing List for Module::Build (Page 35)
Status: Beta
Brought to you by:
kwilliams
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(82) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(49) |
Feb
(57) |
Mar
(49) |
Apr
(49) |
May
(2) |
Jun
(147) |
Jul
(60) |
Aug
(55) |
Sep
(51) |
Oct
(68) |
Nov
(61) |
Dec
(44) |
2006 |
Jan
(27) |
Feb
(38) |
Mar
(89) |
Apr
(31) |
May
(17) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ken W. <kwi...@us...> - 2005-01-24 03:52:11
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12846 Modified Files: Tag: release-0_26_branch Changes Log Message: Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.299.2.30 retrieving revision 1.299.2.31 diff -u -d -r1.299.2.30 -r1.299.2.31 --- Changes 24 Jan 2005 03:50:16 -0000 1.299.2.30 +++ Changes 24 Jan 2005 03:52:02 -0000 1.299.2.31 @@ -18,9 +18,8 @@ - Work around some bad mojo between Fedora Core [with its very long @INC] and old versions of Test::Harness [with its propensity to compound the number of @INC entries] that produced an "argument - list too long" error during testing. The workaround is to filter - out Test::Harness' added nonsensical @INC entries before we call it - again. [assisted by Ville Skytta, David Golden, & Randy Sims] + list too long" error during testing. [assisted by Ville Skytta, + David Golden, & Randy Sims] - Killed an infinite loop that would happen in y_n() in interactive mode if the author provided no default value. [Max Maischein] |
From: Ken W. <kwi...@us...> - 2005-01-24 03:50:35
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12342 Modified Files: Tag: release-0_26_branch Changes Log Message: Use -I instead of PERL5LIB in run_perl_script() Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.299.2.29 retrieving revision 1.299.2.30 diff -u -d -r1.299.2.29 -r1.299.2.30 --- Changes 10 Jan 2005 01:03:21 -0000 1.299.2.29 +++ Changes 24 Jan 2005 03:50:16 -0000 1.299.2.30 @@ -22,6 +22,9 @@ out Test::Harness' added nonsensical @INC entries before we call it again. [assisted by Ville Skytta, David Golden, & Randy Sims] + - Killed an infinite loop that would happen in y_n() in interactive + mode if the author provided no default value. [Max Maischein] + 0.2607 (Bug fix release in 0.26 series) Sat Dec 18 14:14:09 CST 2004 - Instead of freezing @INC in the 'Build' script to the value it had |
From: Ken W. <kwi...@us...> - 2005-01-24 03:50:35
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12342/lib/Module/Build Modified Files: Tag: release-0_26_branch Base.pm Log Message: Use -I instead of PERL5LIB in run_perl_script() Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.340.2.14 retrieving revision 1.340.2.15 diff -u -d -r1.340.2.14 -r1.340.2.15 --- Base.pm 24 Jan 2005 03:40:30 -0000 1.340.2.14 +++ Base.pm 24 Jan 2005 03:50:19 -0000 1.340.2.15 @@ -957,8 +957,6 @@ sub _default_INC { my $self = shift; - local $ENV{PERL5LIB}; # this is not considered part of the default. - my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter; my @inc = `$perl -le "print for \@INC"`; @@ -2605,11 +2603,13 @@ } my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter; - # Make sure our local additions to @INC are propagated to the subprocess + # Make sure our local additions to @INC are propagated to the + # subprocess. It seems to work better on systems with very large + # @INCs to use -I instead of $ENV{PERL5LIB}. my $c = ref $self ? $self->config : \%Config::Config; - local $ENV{PERL5LIB} = join $c->{path_sep}, $self->_added_to_INC; - - return $self->do_system($perl, @$preargs, $script, @$postargs); + my @inc = map { "-I$_" } $self->_added_to_INC; + + return $self->do_system($perl, @inc, @$preargs, $script, @$postargs); } sub process_xs { |
From: Ken W. <kwi...@us...> - 2005-01-24 03:42:07
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9716/lib/Module/Build Modified Files: Base.pm Log Message: Integrate from branch Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.378 retrieving revision 1.379 diff -u -d -r1.378 -r1.379 --- Base.pm 24 Jan 2005 03:27:36 -0000 1.378 +++ Base.pm 24 Jan 2005 03:41:58 -0000 1.379 @@ -225,12 +225,14 @@ sub base_dir { shift()->{properties}{base_dir} } sub installdirs { shift()->{properties}{installdirs} } +sub _is_interactive { + return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe? +} + sub prompt { my $self = shift; my ($mess, $def) = @_; die "prompt() called without a prompt message" unless @_; - - my $INTERACTIVE = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe? ($def, my $dispdef) = defined $def ? ($def, "[$def] ") : ('', ' '); @@ -239,7 +241,7 @@ print "$mess $dispdef"; } my $ans; - if ($INTERACTIVE) { + if ($self->_is_interactive) { $ans = <STDIN>; if ( defined $ans ) { chomp $ans; @@ -259,12 +261,14 @@ sub y_n { my $self = shift; die "y_n() called without a prompt message" unless @_; - + + my $interactive = $self->_is_interactive; my $answer; while (1) { $answer = $self->prompt(@_); return 1 if $answer =~ /^y/i; return 0 if $answer =~ /^n/i; + die "No y/n answer given, no default supplied, and no user to ask again" unless $interactive; print "Please answer 'y' or 'n'.\n"; } } |
From: Ken W. <kwi...@us...> - 2005-01-24 03:40:41
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9327/lib/Module/Build Modified Files: Tag: release-0_26_branch Base.pm Log Message: Fix potential infinite loop in y_n() Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.340.2.13 retrieving revision 1.340.2.14 diff -u -d -r1.340.2.13 -r1.340.2.14 --- Base.pm 10 Jan 2005 03:04:36 -0000 1.340.2.13 +++ Base.pm 24 Jan 2005 03:40:30 -0000 1.340.2.14 @@ -200,12 +200,14 @@ sub base_dir { shift()->{properties}{base_dir} } sub installdirs { shift()->{properties}{installdirs} } +sub _is_interactive { + return -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe? +} + sub prompt { my $self = shift; my ($mess, $def) = @_; die "prompt() called without a prompt message" unless @_; - - my $INTERACTIVE = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe? ($def, my $dispdef) = defined $def ? ($def, "[$def] ") : ('', ' '); @@ -214,7 +216,7 @@ print "$mess $dispdef"; } my $ans; - if ($INTERACTIVE) { + if ($self->_is_interactive) { $ans = <STDIN>; if ( defined $ans ) { chomp $ans; @@ -234,12 +236,14 @@ sub y_n { my $self = shift; die "y_n() called without a prompt message" unless @_; - + + my $interactive = $self->_is_interactive; my $answer; while (1) { $answer = $self->prompt(@_); return 1 if $answer =~ /^y/i; return 0 if $answer =~ /^n/i; + die "No y/n answer given, no default supplied, and no user to ask again" unless $interactive; print "Please answer 'y' or 'n'.\n"; } } |
From: Ken W. <kwi...@us...> - 2005-01-24 03:37:35
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8490/t Modified Files: Tag: release-0_26_branch compat.t Log Message: Remove some debug stuff Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.17.2.4 retrieving revision 1.17.2.5 diff -u -d -r1.17.2.4 -r1.17.2.5 --- compat.t 7 Jan 2005 08:14:57 -0000 1.17.2.4 +++ compat.t 24 Jan 2005 03:37:10 -0000 1.17.2.5 @@ -9,7 +9,7 @@ my $common_pl = File::Spec->catfile('t', 'common.pl'); require $common_pl; -use Carp; $SIG{__WARN__} = \&Carp::cluck; +#use Carp; $SIG{__WARN__} = \&Carp::cluck; # Don't let our own verbosity/test_file get mixed up with our subprocess's |
From: Ken W. <kwi...@us...> - 2005-01-24 03:27:45
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6214/lib/Module/Build Modified Files: Base.pm Log Message: Add a note for a bug in install_base_relative() Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.377 retrieving revision 1.378 diff -u -d -r1.377 -r1.378 --- Base.pm 22 Jan 2005 02:00:21 -0000 1.377 +++ Base.pm 24 Jan 2005 03:27:36 -0000 1.378 @@ -2452,6 +2452,7 @@ sub install_base_relative { my ($self, $type) = @_; + # XXX - this won't handle additional build elements correctly my %map = ( lib => ['lib', 'perl5'], arch => ['lib', 'perl5', $self->{config}{archname}], |
From: Ken W. <kwi...@us...> - 2005-01-22 02:00:31
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31391/lib/Module/Build Modified Files: Authoring.pod Base.pm Log Message: Add the current_action() method Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.376 retrieving revision 1.377 diff -u -d -r1.376 -r1.377 --- Base.pm 10 Jan 2005 04:28:14 -0000 1.376 +++ Base.pm 22 Jan 2005 02:00:21 -0000 1.377 @@ -286,6 +286,7 @@ sub config_data { shift()->_general_notes('config_data', @_) } sub feature { shift()->_general_notes('features', @_) } sub runtime_params { shift->_persistent_hash_read('runtime_params', @_ ? shift : ()) } +sub current_action { shift->{action} } sub add_build_element { my $self = shift; Index: Authoring.pod =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Authoring.pod,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Authoring.pod 4 Jan 2005 05:26:38 -0000 1.4 +++ Authoring.pod 22 Jan 2005 02:00:21 -0000 1.5 @@ -647,6 +647,10 @@ =over 4 +=item current_action() + +Returns the name of the currently-running action, such as "build" or "test". + =item add_build_element($type) Adds a new type of entry to the build process. Accepts a single |
From: Ken W. <kwi...@us...> - 2005-01-22 02:00:29
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31391 Modified Files: Changes Log Message: Add the current_action() method Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.327 retrieving revision 1.328 diff -u -d -r1.327 -r1.328 --- Changes 7 Jan 2005 12:04:09 -0000 1.327 +++ Changes 22 Jan 2005 02:00:20 -0000 1.328 @@ -34,6 +34,9 @@ use 'install_path' to override specific paths or add paths for additional kinds of targets. + - Added the current_action() method, which, surprisingly, returns the + name of the currently running action. [David Wheeler] + * When using the 'install_base' option to choose a directory for installing everything, perl modules now go into lib/perl5/ instead of just lib/. It seems this is more consistent with people's |
From: Ken W. <kwi...@us...> - 2005-01-10 04:28:25
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11067 Modified Files: Base.pm Log Message: Integrate from branch Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.375 retrieving revision 1.376 diff -u -d -r1.375 -r1.376 --- Base.pm 10 Jan 2005 04:27:32 -0000 1.375 +++ Base.pm 10 Jan 2005 04:28:14 -0000 1.376 @@ -1429,6 +1429,10 @@ local @INC = (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'), @INC); + + # Filter out nonsensical @INC entries - some versions of + # Test::Harness will really explode the number of entries here + @INC = grep {ref() || -d} @INC if @INC > 100; my $tests = $self->find_test_files; |
From: Ken W. <kwi...@us...> - 2005-01-10 04:27:45
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10882 Modified Files: Base.pm Log Message: carp() is too fancy about printing stack traces, just fix up warn() to subtract 1 frame from the call stack. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.374 retrieving revision 1.375 diff -u -d -r1.374 -r1.375 --- Base.pm 10 Jan 2005 04:24:23 -0000 1.374 +++ Base.pm 10 Jan 2005 04:27:32 -0000 1.375 @@ -121,8 +121,17 @@ ################## End constructors ######################### sub log_info { print @_ unless shift()->quiet } -sub log_warn { shift; Carp::carp @_; } sub log_verbose { shift()->log_info(@_) if $_[0]->verbose } +sub log_warn { + # Try to make our call stack invisible + shift; + if (@_ and $_[-1] !~ /\n$/) { + my (undef, $file, $line) = caller(); + warn @_, " at $file line $line.\n"; + } else { + warn @_; + } +} sub _set_install_paths { my $self = shift; |
From: Ken W. <kwi...@us...> - 2005-01-10 04:24:32
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10224/lib/Module/Build Modified Files: Base.pm Log Message: Add a 'quiet' parameter that silences 'info' messages Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.373 retrieving revision 1.374 diff -u -d -r1.373 -r1.374 --- Base.pm 7 Jan 2005 11:08:57 -0000 1.373 +++ Base.pm 10 Jan 2005 04:24:23 -0000 1.374 @@ -120,7 +120,7 @@ ################## End constructors ######################### -sub log_info { shift; print @_; } +sub log_info { print @_ unless shift()->quiet } sub log_warn { shift; Carp::carp @_; } sub log_verbose { shift()->log_info(@_) if $_[0]->verbose } @@ -570,6 +570,7 @@ bindoc_dirs libdoc_dirs get_options + quiet ); sub mb_parents { |
From: Ken W. <kwi...@us...> - 2005-01-10 03:04:51
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27534/lib/Module/Build Modified Files: Tag: release-0_26_branch Base.pm Log Message: Fix a comment Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.340.2.12 retrieving revision 1.340.2.13 diff -u -d -r1.340.2.12 -r1.340.2.13 --- Base.pm 10 Jan 2005 01:03:23 -0000 1.340.2.12 +++ Base.pm 10 Jan 2005 03:04:36 -0000 1.340.2.13 @@ -1341,8 +1341,8 @@ File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'), @INC); - # Filter out duplicate and non-existent @INC entries - some versions - # of Test::Harness will really explode the number of entries here + # Filter out nonsensical @INC entries - some versions of + # Test::Harness will really explode the number of entries here @INC = grep {ref() || -d} @INC if @INC > 100; my $tests = $self->find_test_files; |
From: Ken W. <kwi...@us...> - 2005-01-10 01:03:58
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2600/lib/Module/Build Modified Files: Tag: release-0_26_branch Base.pm Log Message: Use a -d test instead of a uniqueness test for @INC Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.340.2.11 retrieving revision 1.340.2.12 diff -u -d -r1.340.2.11 -r1.340.2.12 --- Base.pm 9 Jan 2005 19:28:17 -0000 1.340.2.11 +++ Base.pm 10 Jan 2005 01:03:23 -0000 1.340.2.12 @@ -1341,11 +1341,10 @@ File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'), @INC); - # Filter out duplicate @INC entries - some versions of Test::Harness - # will really explode the number of entries here - my %seen; - @INC = grep {not $seen{$_}++} @INC; - + # Filter out duplicate and non-existent @INC entries - some versions + # of Test::Harness will really explode the number of entries here + @INC = grep {ref() || -d} @INC if @INC > 100; + my $tests = $self->find_test_files; if (@$tests) { |
From: Ken W. <kwi...@us...> - 2005-01-10 01:03:51
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2600 Modified Files: Tag: release-0_26_branch Changes Log Message: Use a -d test instead of a uniqueness test for @INC Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.299.2.28 retrieving revision 1.299.2.29 diff -u -d -r1.299.2.28 -r1.299.2.29 --- Changes 9 Jan 2005 19:28:17 -0000 1.299.2.28 +++ Changes 10 Jan 2005 01:03:21 -0000 1.299.2.29 @@ -19,7 +19,7 @@ @INC] and old versions of Test::Harness [with its propensity to compound the number of @INC entries] that produced an "argument list too long" error during testing. The workaround is to filter - out Test::Harness' duplicate @INC entries before we call it + out Test::Harness' added nonsensical @INC entries before we call it again. [assisted by Ville Skytta, David Golden, & Randy Sims] 0.2607 (Bug fix release in 0.26 series) Sat Dec 18 14:14:09 CST 2004 |
From: Ken W. <kwi...@us...> - 2005-01-09 19:28:26
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17588/lib/Module/Build Modified Files: Tag: release-0_26_branch Base.pm Log Message: Filter @INC down to its unique entries Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.340.2.10 retrieving revision 1.340.2.11 diff -u -d -r1.340.2.10 -r1.340.2.11 --- Base.pm 5 Jan 2005 04:37:32 -0000 1.340.2.10 +++ Base.pm 9 Jan 2005 19:28:17 -0000 1.340.2.11 @@ -1340,6 +1340,11 @@ local @INC = (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), File::Spec->catdir($p->{base_dir}, $self->blib, 'arch'), @INC); + + # Filter out duplicate @INC entries - some versions of Test::Harness + # will really explode the number of entries here + my %seen; + @INC = grep {not $seen{$_}++} @INC; my $tests = $self->find_test_files; |
From: Ken W. <kwi...@us...> - 2005-01-09 19:28:25
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17588 Modified Files: Tag: release-0_26_branch Changes Log Message: Filter @INC down to its unique entries Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.299.2.27 retrieving revision 1.299.2.28 diff -u -d -r1.299.2.27 -r1.299.2.28 --- Changes 7 Jan 2005 04:38:10 -0000 1.299.2.27 +++ Changes 9 Jan 2005 19:28:17 -0000 1.299.2.28 @@ -15,6 +15,13 @@ be set to something like "gzip -f --best" and it'll work correctly. [Spotted by Chris Dolan] + - Work around some bad mojo between Fedora Core [with its very long + @INC] and old versions of Test::Harness [with its propensity to + compound the number of @INC entries] that produced an "argument + list too long" error during testing. The workaround is to filter + out Test::Harness' duplicate @INC entries before we call it + again. [assisted by Ville Skytta, David Golden, & Randy Sims] + 0.2607 (Bug fix release in 0.26 series) Sat Dec 18 14:14:09 CST 2004 - Instead of freezing @INC in the 'Build' script to the value it had |
From: Randy W. S. <si...@us...> - 2005-01-07 12:04:23
|
Update of /cvsroot/module-build/Module-Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15206 Modified Files: Changes Log Message: Index: Changes =================================================================== RCS file: /cvsroot/module-build/Module-Build/Changes,v retrieving revision 1.326 retrieving revision 1.327 diff -u -d -r1.326 -r1.327 --- Changes 4 Jan 2005 05:26:38 -0000 1.326 +++ Changes 7 Jan 2005 12:04:09 -0000 1.327 @@ -3,6 +3,9 @@ 0.27_01 (Beta for 0.28) + - Refactored methods relating to parsing perl module files for package, + version, and pod data into a new class: Module::Build::ModuleInfo. + - Split documentation into two sections. The user level documentation and overview remains in 'Module/Build.pm', while a new document, 'Module/Build/Authoring.pod', has been created for module authors. |
From: Randy W. S. <si...@us...> - 2005-01-07 11:09:28
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/t Added Files: moduleinfo.t Log Message: Refactored methods relating to parsing perl module files for package, version, and pod data into a new class. --- NEW FILE: moduleinfo.t --- use strict; use Test; BEGIN { plan tests => 17 } use Module::Build::ModuleInfo; ok(1); # class method C<find_module_by_name> my $module = Module::Build::ModuleInfo->find_module_by_name( 'Module::Build::ModuleInfo' ); ok( -e $module ); my $pm_info; # fail on invalid filename $pm_info = Module::Build::ModuleInfo->new_from_file( 'Foo/Bar.pm' ); ok( !defined( $pm_info ) ); # construct from module filename $pm_info = Module::Build::ModuleInfo->new_from_file( 't/Sample/lib/Sample.pm' ); ok( defined( $pm_info ) ); # construct from script filename $pm_info = Module::Build::ModuleInfo->new_from_file( 't/Sample/bin/sample.pl' ); ok( defined( $pm_info ) ); # fail on invalid module name $pm_info = Module::Build::ModuleInfo->new_from_module( 'Foo::Bar' ); ok( !defined( $pm_info ) ); $pm_info = Module::Build::ModuleInfo->new_from_module( 'Sample', inc => [ 't/Sample/lib', @INC ] ); # finds module in 'inc' path ok( defined( $pm_info ) ); ok( $pm_info->name(), 'Sample' ); ok( $pm_info->version(), '0.01' ); # got correct version for secondary package ok( $pm_info->version( 'Sample::Ex' ), '0.02' ); my $filename = $pm_info->filename(); ok( defined( $filename ) && length( $filename ) ); my @packages = $pm_info->packages_inside(); ok( scalar( @packages ), 2 ); ok( $packages[0], 'Sample' ); # we can detect presence of pod regardless of whether we are collecting it ok( $pm_info->contains_pod() ); my @pod = $pm_info->pod_inside(); ok( "@pod", 'NAME AUTHOR OTHER' ); # no pod is collected my $name = $pm_info->pod('NAME'); ok( !defined( $name ) ); # collect_pod $pm_info = Module::Build::ModuleInfo->new_from_module( 'Sample', inc => [ 't/Sample/lib', @INC ], collect_pod => 1 ); $name = $pm_info->pod('NAME'); if ( $name ) { $name =~ s/^\s+//; $name =~ s/\s+$//; } ok( $name, 'Sample - Foo foo sample foo' ); |
From: Randy W. S. <si...@us...> - 2005-01-07 11:09:28
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/lib/Module/Build Modified Files: Base.pm Added Files: ModuleInfo.pm Log Message: Refactored methods relating to parsing perl module files for package, version, and pod data into a new class. Index: Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.372 retrieving revision 1.373 diff -u -d -r1.372 -r1.373 --- Base.pm 7 Jan 2005 00:20:43 -0000 1.372 +++ Base.pm 7 Jan 2005 11:08:57 -0000 1.373 @@ -14,6 +14,8 @@ use Text::ParseWords (); use Carp (); +require Module::Build::ModuleInfo; + #################### Constructors ########################### sub new { my $self = shift()->_construct(@_); @@ -673,7 +675,8 @@ my $version_from = File::Spec->catfile( split '/', $p->{dist_version_from} ); - return $p->{dist_version} = $self->version_from_file($version_from); + my $pm_info = Module::Build::ModuleInfo->new_from_file( $version_from ); + return $p->{dist_version} = $pm_info->version(); } sub dist_author { shift->_pod_parse('author') } @@ -694,65 +697,12 @@ return $p->{$member} = $parser->$method(); } -sub find_module_by_name { - my ($self, $mod, $dirs) = @_; - my $file = File::Spec->catfile(split '::', $mod); - foreach (@$dirs) { - my $testfile = File::Spec->catfile($_, $file); - return $testfile if -e $testfile and !-d _; # For stuff like ExtUtils::xsubpp - return "$testfile.pm" if -e "$testfile.pm"; - } - return; -} - -sub _next_code_line { - my ($self, $fh, $pat) = @_; - my $inpod = 0; - - local $_; - while (<$fh>) { - $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; - next if $inpod || /^\s*#/; - return wantarray ? ($_, /$pat/) : $_ - if $_ =~ $pat; - } - return; +sub version_from_file { # Method provided for backwards compatability + return Module::Build::ModuleInfo->new_from_file($_[1])->version(); } -sub version_from_file { - my ($self, $file) = @_; - - # Some of this code came from the ExtUtils:: hierarchy. - my $fh = IO::File->new($file) or die "Can't open '$file' for version: $!"; - - my $match = qr/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; - my ($v_line, $sigil, $var) = $self->_next_code_line($fh, $match) or return undef; - - my $eval = qq{q# Hide from _packages_inside() - #; package Module::Build::Base::_version; - no strict; - - local $sigil$var; - \$$var=undef; do { - $v_line - }; \$$var - }; - local $^W; - - # version.pm will change the ->VERSION method, so we mitigate the - # potential effects here. Unfortunately local(*UNIVERSAL::VERSION) - # will crash perl < 5.8.1. - - my $old_version = \&UNIVERSAL::VERSION; - eval {require version}; - my $result = eval $eval; - *UNIVERSAL::VERSION = $old_version; - $self->log_warn("Error evaling version line '$eval' in $file: $@\n") if $@; - - # Unbless it if it's a version.pm object - $result = "$result" if UNIVERSAL::isa( $result, 'version' ); - - return $result; +sub find_module_by_name { # Method provided for backwards compatability + return Module::Build::ModuleInfo->find_module_by_name(@_[1,2]); } sub _persistent_hash_write { @@ -986,13 +936,13 @@ # Don't try to load if it's already loaded } else { - my $file = $self->find_module_by_name($modname, \@INC); - unless ($file) { + my $pm_info = Module::Build::ModuleInfo->new_from_module( $modname ); + unless (defined( $pm_info )) { @status{ qw(have message) } = ('<none>', "Prerequisite $modname isn't installed"); return \%status; } - $status{have} = $self->version_from_file($file); + $status{have} = $pm_info->version(); if ($spec and !$status{have}) { @status{ qw(have message) } = (undef, "Couldn't find a \$VERSION in prerequisite $modname"); return \%status; @@ -1512,8 +1462,8 @@ sub ACTION_testcover { my ($self) = @_; - unless ($self->find_module_by_name('Devel::Cover', \@INC)) { - $self->log_warn("Cannot run testcover action unless Devel::Cover is installed.\n"); + unless (Module::Build::ModuleInfo->find_module_by_name('Devel::Cover')) { + warn("Cannot run testcover action unless Devel::Cover is installed.\n"); return; } @@ -2007,7 +1957,8 @@ my @parts = File::Spec->splitdir($file); @parts = @parts[@localparts .. $#parts]; # Get rid of blib/lib or similar - my $installed = $self->find_module_by_name(join('::', @parts), \@myINC); + my $installed = Module::Build::ModuleInfo->find_module_by_name( + join('::', @parts), \@myINC ); if (not $installed) { print "Only in lib: $file\n"; next; @@ -2443,9 +2394,8 @@ or die "Can't find dist packages without a MANIFEST file - run 'manifest' action first"; # Localize - my %dist_files = (map - {$self->localize_file_path($_) => $_} - keys %$manifest); + my %dist_files = map { $self->localize_file_path($_) => $_ } + keys %$manifest; my @pm_files = grep {exists $dist_files{$_}} keys %{ $self->find_pm_files }; @@ -2454,28 +2404,17 @@ next if $file =~ m{^t/}; # Skip things in t/ my $localfile = File::Spec->catfile( split m{/}, $file ); - my $version = $self->version_from_file( $localfile ); + + my $pm_info = Module::Build::ModuleInfo->new_from_file( $localfile ); - foreach my $package ($self->_packages_inside($localfile)) { + foreach my $package ($pm_info->packages_inside($localfile)) { $out{$package}{file} = $dist_files{$file}; - $out{$package}{version} = $version if defined $version; + $out{$package}{version} = $pm_info->version( $package ); } } return \%out; } -sub _packages_inside { - # XXX this SUCKS SUCKS SUCKS! Damn you perl! - my ($self, $file) = @_; - my $fh = IO::File->new($file) or die "Can't read $file: $!"; - - my (@packages, $p); - push @packages, $p while (undef, $p) = - $self->_next_code_line($fh, qr/^[\s\{;]*package\s+([\w:]+)/); - - return @packages; -} - sub make_tarball { my ($self, $dir, $file) = @_; $file ||= $dir; @@ -2684,10 +2623,10 @@ } else { # Ok, I give up. Just use backticks. - my $xsubpp = $self->find_module_by_name('ExtUtils::xsubpp', \@INC) + my $xsubpp = Module::Build::ModuleInfo->find_module_by_name('ExtUtils::xsubpp') or die "Can't find ExtUtils::xsubpp in INC (@INC)"; - my $typemap = $self->find_module_by_name('ExtUtils::typemap', \@INC); + my $typemap = Module::Build::ModuleInfo->find_module_by_name('ExtUtils::typemap', \@INC); my $cf = $self->{config}; my $perl = $self->{properties}{perl}; --- NEW FILE: ModuleInfo.pm --- package Module::Build::ModuleInfo; # This module provides routines to gather information about # perl modules (assuming this may be expanded in the distant # parrot future to look at other types of modules). use strict; use File::Spec; use IO::File; my $PKG_REGEXP = qr/^[\s\{;]*package\s+([\w:]+)/; my $VERS_REGEXP = qr/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; sub new_from_file { my $package = shift; my $filename = File::Spec->rel2abs( shift ); return undef unless defined( $filename ) && -f $filename; return __PACKAGE__->_init( undef, $filename, @_ ); } sub new_from_module { my $package = shift; my $module = shift; my %props = @_; $props{inc} ||= \@INC; my $filename = __PACKAGE__->find_module_by_name( $module, $props{inc} ); return undef unless defined( $filename ) && -f $filename; return __PACKAGE__->_init( $module, $filename, %props ); } sub _init { my $package = shift; my $module = shift; my $filename = shift; my %props = @_; my( %valid_props, @valid_props ); @valid_props = qw( collect_pod inc ); @valid_props{@valid_props} = delete( @props{@valid_props} ); warn "Unknown properties: @{[keys %props]}\n" if scalar( %props ); my %data = ( module => $module, filename => $filename, version => undef, packages => [], versions => {}, pod => {}, pod_headings => [], collect_pod => 0, %valid_props, ); my $self = bless( \%data, $package ); $self->_parse_file(); unless ( $self->{module} && length( $self->{module} ) ) { my( $v, $d, $f ) = File::Spec->splitpath( $self->{filename} ); if ( $f =~ /\.pm$/ ) { $f =~ s/\..+$//; my @candidates = grep /$f$/, @{$self->{packages}}; $self->{module} = shift( @candidates ); # punt } else { if ( grep /main/, @{$self->{packages}} ) { $self->{module} = 'main'; } else { $self->{module} = $self->{packages}[0] || ''; } } } $self->{version} = $self->{versions}{$self->{module}}; return $self; } # class method sub find_module_by_name { my $package = shift; my $module = shift || die 'find_module_by_name() requires a package name'; my $dirs = shift || \@INC; my $file = File::Spec->catfile(split( /::/, $module)); foreach my $dir ( @$dirs ) { my $testfile = File::Spec->catfile($dir, $file); return File::Spec->rel2abs( $testfile ) if -e $testfile and !-d _; # For stuff like ExtUtils::xsubpp return File::Spec->rel2abs( "$testfile.pm" ) if -e "$testfile.pm"; } return; } sub _parse_file { my $self = shift; my $filename = $self->{filename}; my $fh = IO::File->new( $filename ) or die( "Can't open '$filename': $!" ); my( $in_pod, $seen_end ) = ( 0, 0 ); my( @pkgs, %vers, %pod, @pod ); my $pkg = 'main'; my $pod_sect = ''; my $pod_data = ''; while (defined( my $line = <$fh> )) { chomp( $line ); next if $line =~ /^\s*#/; $in_pod = ($line =~ /^=(?!cut)/) ? 1 : ($line =~ /^=cut/) ? 0 : $in_pod; if ( $in_pod || $line =~ /^=cut/ ) { if ( $line =~ /^=head\d\s+(.+)\s*$/ ) { push( @pod, $1 ); if ( $self->{collect_pod} && length( $pod_data ) ) { $pod{$pod_sect} = $pod_data; $pod_data = ''; } $pod_sect = $1; } elsif ( $self->{collect_pod} ) { $pod_data .= "$line\n"; } } else { $pod_sect = ''; $pod_data = ''; if ( $line =~ $PKG_REGEXP ) { $pkg = $1; $vers{$pkg} = undef; push( @pkgs, $pkg ); } elsif ( $line =~ $VERS_REGEXP ) { unless ( defined( $vers{$pkg} ) ) { # only first VERSION my $v = $self->_evaluate_version_line( $line ); $vers{$pkg} = $v; } } elsif ( !exists($vers{main}) && $pkg eq 'main' && $line =~ /\w+/ ) { $vers{main} = ''; push( @pkgs, 'main' ); } } } if ( $self->{collect_pod} && length($pod_data) ) { $pod{$pod_sect} = $pod_data; } $self->{versions} = \%vers; $self->{packages} = \@pkgs; $self->{pod} = \%pod; $self->{pod_headings} = \@pod; } sub _evaluate_version_line { my $self = shift; my $line = shift; # Some of this code came from the ExtUtils:: hierarchy. my ($sigil, $var) = ($line =~ $VERS_REGEXP); my $eval = qq{q# Hide from _packages_inside() #; package Module::Build::ModuleInfo::_version; no strict; local $sigil$var; \$$var=undef; do { $line }; \$$var }; local $^W; # version.pm will change the ->VERSION method, so we mitigate the # potential effects here. Unfortunately local(*UNIVERSAL::VERSION) # will crash perl < 5.8.1. my $old_version = \&UNIVERSAL::VERSION; eval {require version}; my $result = eval $eval; *UNIVERSAL::VERSION = $old_version; warn "Error evaling version line '$eval' in $self->{filename}: $@\n" if $@; # Unbless it if it's a version.pm object $result = "$result" if UNIVERSAL::isa( $result, 'version' ); return $result; } ############################################################ # accessors sub name { $_[0]->{module} } sub filename { $_[0]->{filename} } sub packages_inside { @{$_[0]->{packages}} } sub pod_inside { @{$_[0]->{pod_headings}} } sub contains_pod { $#{$_[0]->{pod_headings}} } sub version { $_[0]->{versions}{ $_[1] || $_[0]->{module} } } sub pod { $_[0]->{pod}{$_[1]} } 1; __END__ =head1 NAME ModuleInfo - Gather package and POD information from a perl module files =head1 DESCRIPTION =head2 new_from_file( $filename [ , collect_pod => 1 ] ) Construct a ModuleInfo object given the path to a file. Takes an optional arguement C<collect_pod> which is a boolean that determines whether POD data is collected and stored for reference. POD data is not collected by default. POD headings are always collected. =head2 new_from_module( $module [ , collect_pod => 1, inc => \@dirs ] ) Construct a ModuleInfo object given a module or package name. In addition to accepting the C<collect_pod> argument as described above, this method accepts a C<inc> arguemnt which is a reference to an array of of directories to search for the module. If none are given, the default is @INC. =head2 name( ) Returns the name of the package represented by this module. If there are more than one packages, it makes a best guess based on the filename. If it's a script (i.e. not a *.pm) the package name is 'main'. =head2 version( [ $package ] ) Returns the version as defined by the $VERSION variable for the package as returned by the C<name> method if no arguments are given. If given the name of a package it will attempt to return the version of that package if it is specified in the file. =head2 filename( ) Returns the absolute path to the file. =head2 packages_inside( ) Returns a list of packages. =head2 pod_inside( ) Returns a list of POD sections. =head2 contains_pod( ) Returns true if there is any POD in the file. =head2 pod( $section ) Returns the POD data in the given section. =head2 find_module_by_name( $module [ , \@dirs ] ) Returns the path to a module given the module or package name. A list of directories can be passed in as an optional paramater, otherwise @INC is searched. Can be called as both an object and a class method. =cut |
From: Randy W. S. <si...@us...> - 2005-01-07 11:09:28
|
Update of /cvsroot/module-build/Module-Build/t/Sample In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/t/Sample Modified Files: META.yml Log Message: Refactored methods relating to parsing perl module files for package, version, and pod data into a new class. Index: META.yml =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/Sample/META.yml,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- META.yml 25 Sep 2004 03:35:23 -0000 1.41 +++ META.yml 7 Jan 2005 11:09:10 -0000 1.42 @@ -11,6 +11,10 @@ Sample: file: lib/Sample.pm version: 0.01 + Sample::Ex: + file: lib/Sample.pm + version: 0.02 Sample::NoPod: file: lib/Sample/NoPod.pm + version: ~ generated_by: Module::Build version 0.26 |
From: Randy W. S. <si...@us...> - 2005-01-07 11:09:28
|
Update of /cvsroot/module-build/Module-Build/t/Sample/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3413/t/Sample/lib Modified Files: Sample.pm Log Message: Refactored methods relating to parsing perl module files for package, version, and pod data into a new class. Index: Sample.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/Sample/lib/Sample.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Sample.pm 14 Jul 2003 17:09:25 -0000 1.3 +++ Sample.pm 7 Jan 2005 11:09:10 -0000 1.4 @@ -29,3 +29,10 @@ } 1; + + +package Sample::Ex; + +our $VERSION = 0.02; + +1; |
From: Randy W. S. <si...@us...> - 2005-01-07 10:16:31
|
Update of /cvsroot/module-build/Module-Build/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24585/t Modified Files: basic.t compat.t ext.t install.t runthrough.t signature.t xs.t Log Message: Integrate from branch. Index: signature.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/signature.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- signature.t 2 Sep 2003 16:33:04 -0000 1.7 +++ signature.t 7 Jan 2005 10:15:54 -0000 1.8 @@ -2,7 +2,9 @@ use strict; use Test; use File::Spec; -require File::Spec->catfile('t', 'common.pl'); + +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; use Module::Build; skip_test("Skipping unless \$ENV{TEST_SIGNATURE} is true") unless $ENV{TEST_SIGNATURE}; Index: runthrough.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/runthrough.t,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- runthrough.t 30 Nov 2004 03:10:46 -0000 1.50 +++ runthrough.t 7 Jan 2005 10:15:54 -0000 1.51 @@ -10,8 +10,8 @@ ok(1); ok $INC{'Module/Build.pm'}, '/blib/', "Make sure version from blib/ is loaded"; - -require File::Spec->catfile('t', 'common.pl'); +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; ######################### End of black magic. Index: ext.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/ext.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ext.t 13 Dec 2004 04:37:44 -0000 1.6 +++ ext.t 7 Jan 2005 10:15:53 -0000 1.7 @@ -3,7 +3,8 @@ use Test; use File::Spec; -require File::Spec->catfile('t', 'common.pl'); +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; my @unix_splits = ( Index: compat.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/compat.t,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- compat.t 28 Dec 2004 05:13:50 -0000 1.19 +++ compat.t 7 Jan 2005 10:15:53 -0000 1.20 @@ -5,7 +5,9 @@ use File::Spec; use File::Path; use Config; -require File::Spec->catfile('t', 'common.pl'); + +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; use Carp; $SIG{__WARN__} = \&Carp::cluck; @@ -144,8 +146,11 @@ ok (! -e 'Makefile.PL', 1); } -{ - # Make sure tilde-expansion works +{ # Make sure tilde-expansion works + + # C<glob> on MSWin32 uses $ENV{HOME} if defined to do tilde-expansion + local $ENV{HOME} = 'C:/' if $^O =~ /MSWin/ && !exists( $ENV{HOME} ); + Module::Build::Compat->create_makefile_pl('passthrough', $build); $build->run_perl_script('Makefile.PL', [], ['INSTALL_BASE=~/foo']); Index: install.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/install.t,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- install.t 26 Dec 2004 05:10:52 -0000 1.13 +++ install.t 7 Jan 2005 10:15:53 -0000 1.14 @@ -1,14 +1,15 @@ use strict; use Test; -BEGIN { plan tests => 31 } +BEGIN { plan tests => 30 } + use Module::Build; use File::Spec; use File::Path; use Config; -ok(1); -require File::Spec->catfile('t', 'common.pl'); +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; my $start_dir = Module::Build->cwd; Index: basic.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/basic.t,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- basic.t 4 Jan 2005 05:26:39 -0000 1.35 +++ basic.t 7 Jan 2005 10:15:53 -0000 1.36 @@ -8,7 +8,9 @@ use File::Spec; use Cwd; -require File::Spec->catfile('t', 'common.pl'); + +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; ######################### End of black magic. Index: xs.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/xs.t,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- xs.t 10 Oct 2004 04:19:29 -0000 1.15 +++ xs.t 7 Jan 2005 10:15:54 -0000 1.16 @@ -9,7 +9,8 @@ print("1..0 # Skipped: C_support not enabled\n"), exit(0) unless Module::Build->current->feature('C_support'); plan tests => 12; -require File::Spec->catfile('t', 'common.pl'); +my $common_pl = File::Spec->catfile('t', 'common.pl'); +require $common_pl; ######################### End of black magic. |
From: Randy W. S. <si...@us...> - 2005-01-07 10:16:28
|
Update of /cvsroot/module-build/Module-Build/lib/Module/Build In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24585/lib/Module/Build Modified Files: Compat.pm Log Message: Integrate from branch. Index: Compat.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Compat.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- Compat.pm 28 Dec 2004 05:16:35 -0000 1.59 +++ Compat.pm 7 Jan 2005 10:15:53 -0000 1.60 @@ -135,8 +135,8 @@ my ($key, $val) = ($arg =~ /^(\w+)=(.+)/ ? ($1, $2) : die "Malformed argument '$arg'"); - # Do tilde-expansion like MakeMaker does, more or less - $val =~ s{^~(\w*)} { (getpwnam($1 || (getpwuid $>)[0]))[7] || "~$1" }e; + # Do tilde-expansion if it looks like a tilde prefixed path + ( $val ) = glob( $val ) if $val =~ /^~/; if (exists $makefile_to_build{$key}) { my $trans = $makefile_to_build{$key}; |
From: Randy W. S. <si...@us...> - 2005-01-07 08:51:53
|
Update of /cvsroot/module-build/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6954 Modified Files: loginfo syncmail Log Message: Upgrade to version 2.1 of the syncmail script, and enable unified diffs. Index: loginfo =================================================================== RCS file: /cvsroot/module-build/CVSROOT/loginfo,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** loginfo 9 Nov 2004 15:21:01 -0000 1.6 --- loginfo 7 Jan 2005 08:51:36 -0000 1.7 *************** *** 26,28 **** #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} mod...@li... --- 26,28 ---- #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail -u %{sVv} mod...@li... Index: syncmail =================================================================== RCS file: /cvsroot/module-build/CVSROOT/syncmail,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** syncmail 9 Nov 2004 00:10:24 -0000 1.1 --- syncmail 7 Jan 2005 08:51:37 -0000 1.2 *************** *** 1,4 **** --- 1,11 ---- #! /usr/bin/python + # Copyright (c) 2002, 2003, 2004 Barry Warsaw, Fred Drake, and contributors + # All rights reserved. + # See the accompanying LICENSE file for details. + + # NOTE: SourceForge currently runs Python 2.2.3, so we need to remain + # compatible with the Python 2.2 line. + """Complicated notification for CVS checkins. *************** *** 10,18 **** set this up, create a loginfo entry that looks something like this: ! mymodule /path/to/syncmail %%s som...@yo...main ! In this example, whenever a checkin that matches `mymodule' is made, the ! syncmail script is invoked, which will generate the diff containing email, and ! send it to som...@yo...main. Note: This module used to also do repository synchronizations via --- 17,25 ---- set this up, create a loginfo entry that looks something like this: ! mymodule /path/to/this/script %%s som...@yo...main ! In this example, whenever a checkin that matches `mymodule' is made, this ! script is invoked, which will generate the diff containing email, and send it ! to som...@yo...main. Note: This module used to also do repository synchronizations via *************** *** 20,25 **** this is no longer necessary. The syncing functionality has been ripped out in the 3.0, which simplifies it considerably. Access the 2.x versions ! to refer to this functionality. Because of this, the script's name is ! misleading. It no longer makes sense to run this script from the command line. Doing so --- 27,31 ---- this is no longer necessary. The syncing functionality has been ripped out in the 3.0, which simplifies it considerably. Access the 2.x versions ! to refer to this functionality. Because of this, the script is misnamed. It no longer makes sense to run this script from the command line. Doing so *************** *** 28,34 **** Usage: ! syncmail [options] <%%S> email-addr [email-addr ...] ! Where options is: --cvsroot=<path> --- 34,40 ---- Usage: ! %(PROGRAM)s [options] <%%S> email-addr [email-addr ...] ! Where options are: --cvsroot=<path> *************** *** 36,43 **** variable must exist in the environment. ! --help ! -h Print this text. <%%S> CVS %%s loginfo expansion. When invoked by CVS, this will be a single --- 42,82 ---- variable must exist in the environment. ! --context=# ! -C # ! Include # lines of context around lines that differ (default: 2). ! ! -c ! Produce a context diff (default). ! ! -m hostname ! --mailhost hostname ! The hostname of an available SMTP server. The default is ! 'localhost'. ! ! -u ! Produce a unified diff (smaller). ! ! -S TEXT ! --subject-prefix=TEXT ! Prepend TEXT to the email subject line. ! ! -R ADDR ! --reply-to=ADDR ! Add a "Reply-To: ADDR" header to the email message. ! ! --quiet / -q ! Don't print as much status to stdout. ! ! --fromhost=hostname ! -f hostname ! The hostname that email messages appear to be coming from. The From: ! header of the outgoing message will look like user@hostname. By ! default, hostname is the machine's fully qualified domain name. ! ! --help / -h Print this text. + The rest of the command line arguments are: + <%%S> CVS %%s loginfo expansion. When invoked by CVS, this will be a single *************** *** 49,63 **** email-addrs At least one email address. - """ import os import sys - import string import time import getopt ! # Notification command ! MAILCMD = '/bin/mail -s "CVS: %(SUBJECT)s" %(PEOPLE)s 2>&1 > /dev/null' # Diff trimming stuff --- 88,109 ---- email-addrs At least one email address. """ + __version__ = '$Revision$' import os + import re + import pwd import sys import time import getopt + import socket + import smtplib ! from cStringIO import StringIO ! from email.Utils import formataddr ! ! # Which SMTP server to do we connect to? ! MAILHOST = 'localhost' ! MAILPORT = 25 # Diff trimming stuff *************** *** 66,103 **** DIFF_TRUNCATE_IF_LARGER = 1000 ! def usage(errcode, msg=''): print __doc__ % globals() ! if msg: print msg ! sys.exit(errorcode) ! def calculate_diff(filespec): ! try: ! file, oldrev, newrev = string.split(filespec, ',') ! except ValueError: ! # No diff to report ! return '***** Bogus filespec: %s' % filespec ! if oldrev == 'NONE': try: ! fp = open(file) lines = fp.readlines() fp.close() ! lines.insert(0, '--- NEW FILE ---\n') except IOError, e: ! lines = ['***** Error reading new file', ! str(e)] else: # This /has/ to happen in the background, otherwise we'll run into CVS # lock contention. What a crock. ! diffcmd = '/usr/bin/cvs -f diff -kk -u -r %s -r %s %s' % ( ! oldrev, newrev, file) fp = os.popen(diffcmd) lines = fp.readlines() - sts = fp.close() # ignore the error code, it always seems to be 1 :( ! ## if sts: ! ## return 'Error code %d occurred during diff\n' % (sts >> 8) if len(lines) > DIFF_TRUNCATE_IF_LARGER: removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES --- 112,196 ---- DIFF_TRUNCATE_IF_LARGER = 1000 + COMMASPACE = ', ' ! PROGRAM = sys.argv[0] ! ! BINARY_EXPLANATION_LINES = [ ! "(This appears to be a binary file; contents omitted.)\n" ! ] ! ! NOVERSION = "Couldn't generate diff; no version number found for file: %s" ! BACKSLASH = "Couldn't generate diff: backslash in filespec's filename: %s" ! ! ! ! def usage(code, msg=''): print __doc__ % globals() ! if msg: ! print msg ! sys.exit(code) ! def calculate_diff(entry, contextlines): ! file = entry.name ! oldrev = entry.revision ! newrev = entry.new_revision ! ! # Make sure we can find a CVS version number ! if oldrev is None and newrev is None: ! return NOVERSION % file ! ! if file.find("'") <> -1: ! # Those crazy users put single-quotes in their file names! Now we ! # have to escape everything that is meaningful inside double-quotes. ! filestr = filestr.replace('\\', '\\\\') ! filestr = filestr.replace('`', '\`') ! filestr = filestr.replace('"', '\"') ! filestr = filestr.replace('$', '\$') ! # and quote it with double-quotes. ! filestr = '"' + filestr + '"' ! else: ! # quote it with single-quotes. ! filestr = "'" + file + "'" ! if oldrev is None: ! # File is being added. try: ! if os.path.exists(file): ! fp = open(file) ! else: ! update_cmd = "cvs -fn update -r %s -p %s" % (newrev, filestr) ! fp = os.popen(update_cmd) lines = fp.readlines() fp.close() ! # Is this a binary file? Let's look at the first few ! # lines to figure it out: ! for line in lines[:5]: ! for c in line.rstrip(): ! if c.isspace(): ! continue ! if c < ' ' or c > chr(127): ! lines = BINARY_EXPLANATION_LINES[:] ! break ! lines.insert(0, '--- NEW FILE: %s ---\n' % file) except IOError, e: ! lines = ['***** Error reading new file: ', ! str(e), '\n***** file: ', file, ' cwd: ', os.getcwd()] ! elif newrev is None: ! lines = ['--- %s DELETED ---\n' % file] else: + # File has been changed. # This /has/ to happen in the background, otherwise we'll run into CVS # lock contention. What a crock. ! if contextlines > 0: ! difftype = "-C " + str(contextlines) ! else: ! difftype = "-u" ! diffcmd = "/usr/bin/cvs -f diff -kk %s --minimal -r %s -r %s %s" \ ! % (difftype, oldrev, newrev, filestr) fp = os.popen(diffcmd) lines = fp.readlines() # ignore the error code, it always seems to be 1 :( ! fp.close() if len(lines) > DIFF_TRUNCATE_IF_LARGER: removedlines = len(lines) - DIFF_HEAD_LINES - DIFF_TAIL_LINES *************** *** 105,113 **** lines.insert(DIFF_HEAD_LINES, '[...%d lines suppressed...]\n' % removedlines) ! return string.join(lines, '') ! def blast_mail(mailcmd, filestodiff): # cannot wait for child process or that will cause parent to retain cvs # lock for too long. Urg! --- 198,216 ---- lines.insert(DIFF_HEAD_LINES, '[...%d lines suppressed...]\n' % removedlines) ! return ''.join(lines) ! rfc822_specials_re = re.compile(r'[\(\)\<\>\@\,\;\:\\\"\.\[\]]') ! ! def quotename(name): ! if name and rfc822_specials_re.search(name): ! return '"%s"' % name.replace('"', '\\"') ! else: ! return name ! ! ! ! def blast_mail(subject, people, entries, contextlines, fromhost, replyto): # cannot wait for child process or that will cause parent to retain cvs # lock for too long. Urg! *************** *** 116,140 **** # give up the lock you cvs thang! time.sleep(2) ! fp = os.popen(mailcmd, 'w') ! fp.write(sys.stdin.read()) ! fp.write('\n') # append the diffs if available ! for file in filestodiff: ! fp.write(calculate_diff(file)) ! fp.write('\n') ! fp.close() ! # doesn't matter what code we return, it isn't waited on os._exit(0) # scan args for options def main(): try: ! opts, args = getopt.getopt(sys.argv[1:], 'h', ['cvsroot=', 'help']) except getopt.error, msg: usage(1, msg) # parse the options for opt, arg in opts: if opt in ('-h', '--help'): --- 219,375 ---- # give up the lock you cvs thang! time.sleep(2) ! # Create the smtp connection to the localhost ! conn = smtplib.SMTP() ! conn.connect(MAILHOST, MAILPORT) ! pwinfo = pwd.getpwuid(os.getuid()) ! user = pwinfo[0] ! name = pwinfo[4] ! domain = fromhost or socket.getfqdn() ! address = '%s@%s' % (user, domain) ! s = StringIO() ! datestamp = time.strftime('%a, %d %b %Y %H:%M:%S +0000', ! time.gmtime(time.time())) ! vars = {'author' : formataddr((name, address)), ! 'people' : COMMASPACE.join(people), ! 'subject' : subject, ! 'version' : __version__, ! 'date' : datestamp, ! } ! print >> s, '''\ ! From: %(author)s ! To: %(people)s''' % vars ! if replyto: ! print >> s, 'Reply-To: %s' % replyto ! print >>s, '''\ ! Subject: %(subject)s ! Date: %(date)s ! X-Mailer: Python syncmail %(version)s <http://sf.net/projects/cvs-syncmail> ! ''' % vars ! s.write(sys.stdin.read()) # append the diffs if available ! print >> s ! for entry in entries: ! print >> s, calculate_diff(entry, contextlines) ! resp = conn.sendmail(address, people, s.getvalue()) ! conn.close() os._exit(0) + class CVSEntry: + def __init__(self, name, revision, timestamp, conflict, options, tagdate): + self.name = name + self.revision = revision + self.timestamp = timestamp + self.conflict = conflict + self.options = options + self.tagdate = tagdate + + def get_entry(prefix, mapping, line, filename): + line = line.strip() + parts = line.split("/") + _, name, revision, timestamp, options, tagdate = parts + key = namekey(prefix, name) + try: + entry = mapping[key] + except KeyError: + if revision == "0": + revision = None + if timestamp.find("+") != -1: + timestamp, conflict = tuple(timestamp.split("+")) + else: + conflict = None + entry = CVSEntry(key, revision, timestamp, conflict, + options, tagdate) + mapping[key] = entry + return entry + + def namekey(prefix, name): + if prefix: + return os.path.join(prefix, name) + else: + return name + + def load_change_info(prefix=None): + if prefix is not None: + entries_fn = os.path.join(prefix, "CVS", "Entries") + else: + entries_fn = os.path.join("CVS", "Entries") + entries_log_fn = entries_fn + ".Log" + mapping = {} + f = open(entries_fn) + while 1: + line = f.readline() + if not line: + break + ## if line.strip() == "D": + ## continue + # we could recurse down subdirs, except the Entries.Log files + # we need haven't been written to the subdirs yet, so it + # doesn't do us any good + ## if line[0] == "D": + ## name = line.split("/")[1] + ## dirname = namekey(prefix, name) + ## if os.path.isdir(dirname): + ## m = load_change_info(dirname) + ## mapping.update(m) + if line[0] == "/": + # normal file + get_entry(prefix, mapping, line, entries_fn) + # else: bogus Entries line + f.close() + if os.path.isfile(entries_log_fn): + f = open(entries_log_fn) + while 1: + line = f.readline() + if not line: + break + if line[1:2] != ' ': + # really old version of CVS + break + entry = get_entry(prefix, mapping, line[2:], entries_log_fn) + parts = line.split("/")[1:] + if line[0] == "A": + # adding a file + entry.new_revision = parts[1] + elif line[0] == "R": + # removing a file + entry.new_revision = None + f.close() + for entry in mapping.values(): + if not hasattr(entry, "new_revision"): + print 'confused about file', entry.name, '-- ignoring' + del mapping[entry.name] + return mapping + + def load_branch_name(): + tag_fn = os.path.join("CVS", "Tag") + if os.path.isfile(tag_fn): + f = open(tag_fn) + line = f.readline().strip() + f.close() + if line[:1] == "T": + return line[1:] + return None + # scan args for options def main(): + # XXX Should really move all the options to an object, just to + # avoid threading so many positional args through everything. try: ! opts, args = getopt.getopt( ! sys.argv[1:], 'hC:cuS:R:qf:m:', ! ['fromhost=', 'context=', 'cvsroot=', 'mailhost=', ! 'subject-prefix=', 'reply-to=', ! 'help', 'quiet']) except getopt.error, msg: usage(1, msg) # parse the options + contextlines = 2 + verbose = 1 + subject_prefix = "" + replyto = None + fromhost = None for opt, arg in opts: if opt in ('-h', '--help'): *************** *** 142,145 **** --- 377,398 ---- elif opt == '--cvsroot': os.environ['CVSROOT'] = arg + elif opt in ('-C', '--context'): + contextlines = int(arg) + elif opt == '-c': + if contextlines <= 0: + contextlines = 2 + elif opt == '-u': + contextlines = 0 + elif opt in ('-S', '--subject-prefix'): + subject_prefix = arg + elif opt in ('-R', '--reply-to'): + replyto = arg + elif opt in ('-q', '--quiet'): + verbose = 0 + elif opt in ('-f', '--fromhost'): + fromhost = arg + elif opt in ('-m', '--mailhost'): + global MAILHOST + MAILHOST = arg # What follows is the specification containing the files that were *************** *** 149,154 **** if not args: usage(1, 'No CVS module specified') ! SUBJECT = args[0] ! specs = string.split(args[0]) del args[0] --- 402,407 ---- if not args: usage(1, 'No CVS module specified') ! subject = subject_prefix + args[0] ! specs = args[0].split() del args[0] *************** *** 158,175 **** # Now do the mail command ! PEOPLE = string.join(args) ! mailcmd = MAILCMD % vars() ! print 'Mailing %s...' % PEOPLE ! if specs[-3:] == ['-', 'New', 'directory']: ! del specs[-3:] ! blast_mail(mailcmd, specs[1:]) if __name__ == '__main__': - print 'Running syncmail...' main() - print '...syncmail done.' sys.exit(0) - --- 411,434 ---- # Now do the mail command ! people = args ! if specs[-3:] == ['-', 'Imported', 'sources']: ! print 'Not sending email for imported sources.' ! return ! ! branch = load_branch_name() ! changes = load_change_info() ! ! if verbose: ! print 'Mailing %s...' % COMMASPACE.join(people) ! print 'Generating notification message...' ! blast_mail(subject, people, changes.values(), ! contextlines, fromhost, replyto) ! if verbose: ! print 'Generating notification message... done.' if __name__ == '__main__': main() sys.exit(0) |