On Mon, 22 Sep 2003, Dave Rolsky wrote:
> On Sun, 21 Sep 2003, Ken Williams wrote:
>
> > > Yes, but until that time it makes sense for module authors to use the
> > > backwards compatibility layer and generate a Makefile.PL.
> >
> > Indeed. Dave, do you suppose you could revive the CGI.pm patch?
>
> I take it you mean CPAN.pm ;)
>
> Anyway, the old patch mostly applied. An updated patch for CPAN 1.76
> appears below my sig. A quick test with Acme::Lingua::Pirate::Perl
> suggests it works. However, it still passes the EU::MM args to
> Build.PL/Build, like UNINST=1.
Gah, that was a bit mailer-mangled. Here it is again.
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/
--- lib/CPAN.pm 2003-07-31 09:53:06.000000000 -0500
+++ lib/CPAN.pm.new 2003-09-22 00:18:48.000000000 -0500
@@ -3966,17 +3966,40 @@
my($mpl) = File::Spec->catfile($packagedir,"Makefile.PL");
my($mpl_exists) = -f $mpl;
- unless ($mpl_exists) {
+ my($bpl) = MM->catfile($packagedir,"Build.PL");
+ my($bpl_exists) = -f $bpl;
+ unless ($mpl_exists or $bpl_exists) {
# NFS has been reported to have racing problems after the
# renaming of a directory in some environments.
# This trick helps.
sleep 1;
- my $mpldh = DirHandle->new($packagedir)
+ my $dh = DirHandle->new($packagedir)
or Carp::croak("Couldn't opendir $packagedir: $!");
- $mpl_exists = grep /^Makefile\.PL$/, $mpldh->read;
- $mpldh->close;
+ foreach ($dh->read) {
+ $mpl_exists = /^Makefile\.PL$/;
+ $bpl_exists = /^Build\.PL$/;
+ }
+ $dh->close;
}
- unless ($mpl_exists) {
+
+ # If this is a module that uses Module::Build then we need to
+ # install Module::Build. However, Module::Build uses _itself_ to
+ # install so to avoid a recursive prereq follow of doom, we
+ # explicitly do not try to install Module::Build when already
+ # install Module::Build. - Dave Rolsky
+ if ($bpl_exists and not grep { $_ eq "Module::Build" }
$self->containsmods) {
+ my $nmo = $CPAN::META->instance("CPAN::Module","Module::Build");
+
+ unless ($nmo->inst_file and $nmo->uptodate) {
+ $CPAN::Frontend->myprint("The module you are installing requires
the Module::Build package.
+Either you do not have this module installed or you do not have the latest
version.
+It is recommended that you install the latest version now or
+else it may not be possible to install this module");
+ $self->follow_prereqs("Module::Build");
+ }
+ }
+
+ unless ($mpl_exists or $bpl_exists) {
$self->debug(sprintf("makefilepl[%s]anycwd[%s]",
$mpl,
CPAN::anycwd(),
@@ -3987,7 +4010,7 @@
$self->{'configure'} = $configure;
} elsif (-f File::Spec->catfile($packagedir,"Makefile")) {
$CPAN::Frontend->myprint(qq{
-Package comes with a Makefile and without a Makefile.PL.
+Package comes with a Makefile and without a Makefile.PL or Build.PL.
We\'ll try to build it with that Makefile then.
});
$self->{writemakefile} = "YES";
@@ -4000,9 +4023,9 @@
}
$cf =~ s|[/\\:]||g; # risk of filesystem damage
$cf = "unknown" unless length($cf);
- $CPAN::Frontend->myprint(qq{Package seems to come without
Makefile.PL.
- (The test -f "$mpl" returned false.)
- Writing one on our own (setting NAME to $cf)\a\n});
+ $CPAN::Frontend->myprint(qq{Package seems to come without
Makefile.PL or Build.PL.
+ (The tests -f "$mpl" and -f "$bpl" returned false.)
+ Writing a Makefile.PL on our own (setting NAME to $cf)\a\n});
$self->{had_no_makefile_pl}++;
sleep 3;
@@ -4013,7 +4036,7 @@
or Carp::croak("Could not open >$mpl: $!");
$fh->print(
qq{# This Makefile.PL has been autogenerated by the module CPAN.pm
-# because there was no Makefile.PL supplied.
+# because there was no Makefile.PL or Build.PL supplied.
# Autogenerated on: }.scalar localtime().qq{
use ExtUtils::MakeMaker;
@@ -4021,9 +4044,14 @@
});
$fh->close;
+
+ $mpl_exists = 1;
}
}
+ $self->{makescript} = $mpl_exists ? "Makefile.PL" : $bpl_exists ?
"Build.PL" : "";
+ $self->{maketype} = $mpl_exists ? 'make' : $bpl_exists ? "Module::Build" :
"";
+
return $self;
}
@@ -4486,7 +4514,7 @@
# $switch = "-MExtUtils::MakeMaker ".
# "-Mops=:default,:filesys_read,:filesys_open,require,chdir"
# if $] > 5.00310;
- $system = "$perl $switch Makefile.PL $CPAN::Config->{makepl_arg}";
+ $system = "$perl $switch $self->{makescript}
$CPAN::Config->{makepl_arg}";
}
unless (exists $self->{writemakefile}) {
local($SIG{ALRM}) = sub { die "inactivity_timeout reached\n" };
@@ -4523,16 +4551,17 @@
} else {
$ret = system($system);
if ($ret != 0) {
- $self->{writemakefile} = "NO Makefile.PL returned status $ret";
+ $self->{writemakefile} = "NO $self->{makescript} returned status
$ret";
return;
}
}
- if (-f "Makefile") {
+ if (($self->{maketype} eq "make" && -f "Makefile") ||
+ ($self->{maketype} eq "Module::Build" && -f "Build")) {
$self->{writemakefile} = "YES";
delete $self->{make_clean}; # if cleaned before, enable next
} else {
$self->{writemakefile} =
- qq{NO Makefile.PL refused to write a Makefile.};
+ qq{NO $self->{makescript} refused to write a Makefile/Build.PL.};
# It's probably worth it to record the reason, so let's retry
# local $/;
# my $fh = IO::File->new("$system |"); # STDERR? STDIN?
@@ -4546,7 +4575,11 @@
if (my @prereq = $self->unsat_prereq){
return 1 if $self->follow_prereqs(@prereq); # signal success to the
queuerunner
}
- $system = join " ", $CPAN::Config->{'make'}, $CPAN::Config->{make_arg};
+ if ($self->{maketype} eq 'make') {
+ $system = join " ", $CPAN::Config->{'make'}, $CPAN::Config->{make_arg};
+ } else {
+ $system = join " ", $self->perl, File::Spec->catfile(
File::Spec->curdir, "Build" ), $CPAN::Config->{make_arg};
+ }
if (system($system) == 0) {
$CPAN::Frontend->myprint(" $system -- OK\n");
$self->{'make'} = "YES";
@@ -4649,6 +4682,7 @@
# but we must have run it
my $build_dir = $self->{build_dir} or die "Panic: no build_dir?";
my $makefile = File::Spec->catfile($build_dir,"Makefile");
+ my $buildprereq = File::Spec->catfile($build_dir,"_build","prereq");
my(%p) = ();
my $fh;
if (-f $makefile
@@ -4677,6 +4711,16 @@
}
last;
}
+ } elsif (-f $buildprereq
+ and
+ $fh = FileHandle->new("<$buildprereq")) {
+ while (<$fh>) {
+ my ($mod,$ver) = split /\s*=\s*/;
+ if ( defined $p{$mod} ) {
+ warn "Warning: PREREQ_PM mentions $mod more than once, last
mention wins";
+ }
+ $p{$mod} = $ver;
+ }
}
$self->{prereq_pm_detected}++;
return $self->{prereq_pm} = \%p;
@@ -4725,7 +4769,12 @@
local $ENV{PERL5LIB} = $ENV{PERL5LIB} || "";
$CPAN::META->set_perl5lib;
- my $system = join " ", $CPAN::Config->{'make'}, "test";
+ my $system;
+ if ($self->{maketype} eq "make") {
+ $system = join " ", $CPAN::Config->{'make'}, "test";
+ } elsif ($self->{maketype} eq "Module::Build") {
+ $system = join " ", $self->perl, File::Spec->catfile(
File::Spec->curdir, "Build" ), "test";
+ }
if (system($system) == 0) {
$CPAN::Frontend->myprint(" $system -- OK\n");
$CPAN::META->is_tested($self->{'build_dir'});
@@ -4757,7 +4806,12 @@
return;
}
- my $system = join " ", $CPAN::Config->{'make'}, "clean";
+ my $system;
+ if ($self->{maketype} eq "make") {
+ $system = join " ", $CPAN::Config->{'make'}, "clean";
+ } elsif ($self->{maketype} eq "Module::Build") {
+ $system = join " ", $self->perl, File::Spec->catfile(
File::Spec->curdir, "Build" ), "clean";
+ }
if (system($system) == 0) {
$CPAN::Frontend->myprint(" $system -- OK\n");
@@ -4832,8 +4886,14 @@
return;
}
- my $system = join(" ", $CPAN::Config->{'make'},
- "install", $CPAN::Config->{make_install_arg});
+ my $system;
+ if ($self->{maketype} eq "make") {
+ $system = join(" ", $CPAN::Config->{'make'},
+ "install", $CPAN::Config->{make_install_arg});
+ } elsif ($self->{maketype} eq "Module::Build") {
+ $system = join(" ", $self->perl, File::Spec->catfile(
File::Spec->curdir, "Build" ),
+ "install", $CPAN::Config->{make_install_arg});
+ }
my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 ";
my($pipe) = FileHandle->new("$system $stderr |");
my($makeout) = "";
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
|