Re: [Module-build-general] A better passthrough Makefile.PL
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2002-11-02 01:32:03
|
On Thursday, October 31, 2002, at 09:33 PM, Ken Williams wrote:
> Actually, I just had an idea - would the following small change work
> (note the 'touch' line, "open $0")?
>
> unless (eval "use Module::Build::Compat 0.02; 1" ) {
> # Workaround with old CPAN.pm and CPANPLUS.pm
> require ExtUtils::MakeMaker;
> ExtUtils::MakeMaker::WriteMakefile(
> PREREQ_PM => { 'Module::Build::Compat' => 0.02 }
> );
> warn "Warning: prerequisite Module::Build::Compat is not found.\n";
> sleep 2; # Wait a couple seconds after writing Makefile
> open my($fh), ">> $0" # Change modification date
> or warn "You may have to run 'perl Makefile.PL' again.";
> exit(0);
> }
> Module::Build::Compat->run_build_pl(args => \@ARGV);
> Module::Build::Compat->write_makefile();
>
> The idea is that it changes the modification time for Makefile.PL to be
> after the Makefile's, so that Makefile.PL gets re-run.
I got this working, but only sort of. I had to change the open() stuff
to utime() (duh) to get an effective touch. But the problem is that
even though the Makefile is rebuilt, CPAN.pm doesn't notice. See below.
> This is kind of tough to test out - Dave, how did you test this before?
I figured out a really kludgey way to test it.
To get CPAN to build from local tarballs, I did this:
1) Disconnect from the network so CPAN can't reload its metafiles.
2) Replace the Makefile.PL for Params::Validate with a pass-through
Makefile.PL like the one above, and create a Build.PL for it.
3) Make a tarball of Params::Validate and put it in
~/.cpan/sources/authors/id/D/DR/DROLSKY/.
4) Uninstall Module::Build and Module::Build::Compat from my system.
5) Make a tarball of Module::Build and put it in
~/.cpan/sources/authors/id/K/KW/KWILLIAMS/.
6) Delete the checksums for Module::Build and Params::Validate from the
CHECKSUMS files in ~/.cpan/sources/authors/id/... since they're no
longer valid.
Then in the cpan shell I did 'install Params::Validate' to see what
would happen. CPAN successfully notices that Module::Build is a
prerequisite and installs it. Then when it goes back to install
Params::Validate, 'make' notices that the Makefile is out of date and
rebuilds it, returning an error status. But then for some reason CPAN
extracts the tarball *again*, and rebuilds the blib/ or something, and
everything goes to hell (where it can stay, as far as I'm concerned).
This means that in order to install Params::Validate, I had to do
'install Params::Validate', 'clean Params::Validate', 'install
Params::Validate'. Ish.
I think it also didn't get the prerequisites right - CPAN probably only
registered a prereq of Module::Build, and not Attribute::Handlers.
So I think we'll indeed have to invoke CPAN->install if we want it to be
all in one step. I'll try that next.
-Ken
|