You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Randy Kobes <ra...@theoryx5.uwinnipeg.ca> on 2003/11/06 03:09:52 UTC

[mp2] including a Win32 apxs?

Hi,
  I was wondering how it would be felt to include an offer
in mp2 to get a Win32 version of apxs, if this was not
detected. There's a tar.gz archive on perl.apache.org that
contains this (plus apr-config and apu-config), so it would
be a matter of fetching and extracting this, then running
the included configure script to install. If this seems OK,
it'd be nice to detect the absence of apxs early on in the
build process so as the rest of the build can use the
installed scripts - the following diff does this for the
top-level Makefile.PL, but perhaps a better place is in
Apache::Build? Thanks.

========================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.129
diff -u -r1.129 Makefile.PL
--- Makefile.PL	5 Nov 2003 09:52:18 -0000	1.129
+++ Makefile.PL	6 Nov 2003 01:57:50 -0000
@@ -44,6 +44,8 @@
 my $build = Apache::Build->new(init => 1);
 my $code  = ModPerl::Code->new;

+fetch_apxs() if WIN32;
+
 configure();
 perl_version_check($build);

@@ -418,6 +420,58 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX};
+    return if -e catfile($prefix, 'bin', 'apxs.bat');
+    print << 'END';
+
+I could not find an apxs utility on your system, which will
+be used in certain parts of the build, if available. This
+utility (and the apr-config and apu-config utilities) have not
+yet been ported to Apache2 on Win32, but a development port
+is available, which I can install for you, if you like.
+
+END
+
+    my $ans = $build->prompt('Install apxs?', 'yes');
+    return unless $ans =~ /^y/i;
+    require Archive::Tar; require Compress::Zlib;
+    require LWP::Simple; import LWP::Simple qw(is_success getstore);
+    require File::Path; import File::Path qw(rmtree);
+    my $file = 'apxs_win32.tar.gz';
+    my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+    print "Fetching $remote ... ";
+    unless (is_success(getstore($remote, $file))) {
+        warn "Download of $remote failed";
+        return;
+    }
+    print " done!\n";
+
+    my $arc = Archive::Tar->new($file, 1);
+    $arc->extract($arc->list_files());
+    my $dir = 'apxs';
+    unless (-d $dir) {
+        warn "Unpacking $file failed";
+        return;
+    }
+    print "chdir $dir\n";
+    chdir $dir or do {
+        warn "chdir to $dir failed: $!";
+        return;
+    };
+    my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+    print "@args\n";
+    system(@args) == 0 or do {
+        warn "system @args failed: $?";
+        return;
+    };
+    chdir '..';
+    rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+    print "unlink $file\n\n";
+    unlink $file or warn "unlink of $file failed: $!";
+    return 1;
 }

 package MY;
===============================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> On Thu, 6 Nov 2003, Stas Bekman wrote:
> 
> 
>>Randy Kobes wrote:
>>very neat! A few more comments:
>>
>>
>>>=========================================================
>>>Index: Makefile.PL
>>>===================================================================
>>
>>[...]
>>
>>>+sub fetch_apxs {
>>>+    my $prefix = $build->{MP_AP_PREFIX} || '';
>>>+    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
>>>+    my @args = ($^X, $script, "--with-apache2=$prefix");
>>>+    system(@args) == 0 or die "system @args failed: $?";
>>> }
>>
>>can you please call it win32_fetch_apxs, or fetch_apxs_win32, or similar and
>>probably add a short comment before it explaining why is it needed.
> 
> 
> Sure - that's done below.

Heh, I meant the subroutine, so it won't mislead in Makefile.PL (but the 
script is a good idea as well)

> +sub fetch_apxs {
> +    my $prefix = $build->{MP_AP_PREFIX} || '';
> +    my $script = catfile($build->{cwd}, 'build', 'win32_fetch_apxs');
> +    my @args = ($^X, $script, "--with-apache2=$prefix");
> +    system(@args) == 0 or die "system @args failed: $?";
>  }

Other than that go ahead and commit ;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Thu, 6 Nov 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> very neat! A few more comments:
>
> > =========================================================
> > Index: Makefile.PL
> > ===================================================================
> [...]
> > +sub fetch_apxs {
> > +    my $prefix = $build->{MP_AP_PREFIX} || '';
> > +    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
> > +    my @args = ($^X, $script, "--with-apache2=$prefix");
> > +    system(@args) == 0 or die "system @args failed: $?";
> >  }
>
> can you please call it win32_fetch_apxs, or fetch_apxs_win32, or similar and
> probably add a short comment before it explaining why is it needed.

Sure - that's done below.

> > +my $dir = 'apxs';
> > +my $arc = Archive::Tar->new($file, 1);
> > +$arc->extract($arc->list_files());
> > +die "Unpacking $file failed" unless (-d $dir);
> > +
> > +print "chdir $dir\n";
> > +chdir $dir or die "chdir to $dir failed: $!";
> > +
> > +my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
> > +print "@args\n";
> > +system(@args) == 0 or die "system @args failed: $?";
> > +
> > +chdir '..';
>
> just to avoid problems in the future it's the best to
> store cwd before chdir and at the end to chdir back to
> that stored $cwd, instead of hardcoding '..', so if later
> you decide to change 'apxs' with 'whatever/apxs' it'll
> still work just fine.

Good idea - thanks! Here's a reworked version:

==============================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.130
diff -u -r1.130 Makefile.PL
--- Makefile.PL	7 Nov 2003 00:56:31 -0000	1.130
+++ Makefile.PL	7 Nov 2003 05:20:50 -0000
@@ -44,6 +44,8 @@
 my $build = Apache::Build->new(init => 1);
 my $code  = ModPerl::Code->new;

+fetch_apxs() if WIN32;
+
 configure();
 perl_version_check($build);

@@ -418,6 +420,13 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX} || '';
+    my $script = catfile($build->{cwd}, 'build', 'win32_fetch_apxs');
+    my @args = ($^X, $script, "--with-apache2=$prefix");
+    system(@args) == 0 or die "system @args failed: $?";
 }

 package MY;
Index: build/win32_fetch_apxs
===================================================================
RCS file: build/win32_fetch_apxs
diff -N build/win32_fetch_apxs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/win32_fetch_apxs	7 Nov 2003 05:20:51 -0000
@@ -0,0 +1,89 @@
+#!C:/Perl/bin/perl
+###################################################################
+# apxs, apr-config, and apu-config are Apache utilities used      #
+# to both get certain configuration information and also to       #
+# assist in building Apache modules. These utilities have not     #
+# yet been officially ported to Win32. The following will fetch   #
+# and install a development version of these scripts which can    #
+# be used in both mod_perl 2 and Apache C modules.                #
+#                                                                 #
+# Please report problems in installing or using these utilties to #
+# Randy Kobes <ra...@theoryx5.uwinnipeg.ca>                       #
+###################################################################
+use strict;
+use warnings;
+use Getopt::Long;
+use File::Spec::Functions;
+use Archive::Tar;
+use File::Path;
+use LWP::Simple;
+use ExtUtils::MakeMaker qw(prompt);
+use Cwd;
+
+die "This is intended for Win32" unless ($^O =~ /Win32/i);
+
+my $prefix;
+GetOptions( 'with-apache2=s' => \$prefix);
+unless ($prefix and -d $prefix) {
+    die << 'END';
+
+I could not determine a valid Apache2 directory. Please
+run this script specifying the option
+   --with-apache2=/Path/to/Apache2
+where /Path/to/Apache2 is the location of your installed
+Apache2 top-level directory.
+
+END
+}
+
+exit 0 if (-e catfile($prefix, 'bin', 'apxs.bat'));
+
+print << 'END';
+
+----------------------------------------------------------------------
+I could not find an apxs utility, which will be used in certain parts
+of the build, if present. This utility (and the apr-config and
+apu-config utilities) have not yet been ported to Apache2 on Win32,
+but a development port is available. You can either
+
+- ignore installing apxs by answering "no" at the prompt below
+  (mod_perl will still build),
+- install apxs by answering "yes" at the prompt below,
+- quit now, run the "fetch_win32_apxs.pl" script in the build/ directory
+  to fetch and install the utilities, and then rebuild mod_perl,
+- quit now, and from http://perl.apache.org/dist/win32-bin/ grab
+  apxs_win32.tar.gz; when unpacked, this contains a README explaining
+  how to install the utilities. Afterwards, rebuild mod_perl.
+----------------------------------------------------------------------
+
+END
+
+my $ans = prompt('Install apxs now?', 'yes');
+exit 0 unless $ans =~ /^y/i;
+
+my $file = 'apxs_win32.tar.gz';
+unless (-e $file) {
+    my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+    print "Fetching $remote ... ";
+    die "Download of $remote failed"
+        unless (is_success(getstore($remote, $file)));
+    print " done!\n";
+}
+
+my $cwd = getcwd;
+my $dir = 'apxs';
+my $arc = Archive::Tar->new($file, 1);
+$arc->extract($arc->list_files());
+die "Unpacking $file failed" unless (-d $dir);
+
+print "chdir $dir\n";
+chdir $dir or die "chdir to $dir failed: $!";
+
+my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+print "@args\n";
+system(@args) == 0 or die "system @args failed: $?";
+
+chdir $cwd;
+#rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+#print "unlink $file\n\n";
+#unlink $file or warn "unlink of $file failed: $!";

==================================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
very neat! A few more comments:

> =========================================================
> Index: Makefile.PL
> ===================================================================
[...]
> +sub fetch_apxs {
> +    my $prefix = $build->{MP_AP_PREFIX} || '';
> +    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
> +    my @args = ($^X, $script, "--with-apache2=$prefix");
> +    system(@args) == 0 or die "system @args failed: $?";
>  }

can you please call it win32_fetch_apxs, or fetch_apxs_win32, or similar and 
probably add a short comment before it explaining why is it needed.

> +my $dir = 'apxs';
> +my $arc = Archive::Tar->new($file, 1);
> +$arc->extract($arc->list_files());
> +die "Unpacking $file failed" unless (-d $dir);
> +
> +print "chdir $dir\n";
> +chdir $dir or die "chdir to $dir failed: $!";
> +
> +my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
> +print "@args\n";
> +system(@args) == 0 or die "system @args failed: $?";
> +
> +chdir '..';

just to avoid problems in the future it's the best to store cwd before chdir 
and at the end to chdir back to that stored $cwd, instead of hardcoding '..', 
so if later you decide to change 'apxs' with 'whatever/apxs' it'll still work 
just fine.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Thu, 6 Nov 2003, Stas Bekman wrote:

[...]
> > +sub fetch_apxs {
> > +    my $prefix = $build->{MP_AP_PREFIX};
>
> are you sure it's always set to a sensible value?

That's a good point - the diff below will check that.
Thanks.

> > +    return if -e catfile($prefix, 'bin', 'apxs.bat1');
>
> I sure don't know what I'm talking about but why 'bat1'?
> Shouldn't that be 'bat'?

Sorry about that - that was a remnant of testing things. It
should be '.bat'.

> the problem with the suggested build/fetch_win32_apxs.pl
> is that if the user wants to abort the install and start
> again it's going to be fetched again. I think
> fetch_win32_apxs.pl should just fetch and fetch_apxs()
> should return if it finds the files already. May be
> s/fetch_apxs/run_win32_apxs/ which will fetch the files if
> they weren't fetched already?

That's another good point - in the diff below, the .tar.gz
file won't be fetched again if it's already present. Also
below, I moved the messages formerly in Makefile.PL to the
fetch_win32_apxs.pl script.

=========================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.129
diff -u -r1.129 Makefile.PL
--- Makefile.PL	5 Nov 2003 09:52:18 -0000	1.129
+++ Makefile.PL	6 Nov 2003 15:26:32 -0000
@@ -44,6 +44,8 @@
 my $build = Apache::Build->new(init => 1);
 my $code  = ModPerl::Code->new;

+fetch_apxs() if WIN32;
+
 configure();
 perl_version_check($build);

@@ -418,6 +420,13 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX} || '';
+    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
+    my @args = ($^X, $script, "--with-apache2=$prefix");
+    system(@args) == 0 or die "system @args failed: $?";
 }

 package MY;
Index: build/fetch_win32_apxs.pl
===================================================================
RCS file: build/fetch_win32_apxs.pl
diff -N build/fetch_win32_apxs.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/fetch_win32_apxs.pl	6 Nov 2003 15:26:33 -0000
@@ -0,0 +1,74 @@
+#!C:/Perl/bin/perl
+use strict;
+use warnings;
+use Getopt::Long;
+use File::Spec::Functions;
+use Archive::Tar;
+use File::Path;
+use LWP::Simple;
+use ExtUtils::MakeMaker qw(prompt);
+
+die "This is intended for Win32" unless ($^O =~ /Win32/i);
+
+my $prefix;
+GetOptions( 'with-apache2=s' => \$prefix);
+unless ($prefix and -d $prefix) {
+    die << 'END';
+
+I could not determine a valid Apache2 directory. Please
+run this script specifying the option
+   --with-apache2=/Path/to/Apache2
+where /Path/to/Apache2 is the location of your installed
+Apache2 top-level directory.
+
+END
+}
+
+exit 0 if (-e catfile($prefix, 'bin', 'apxs.bat'));
+
+print << 'END';
+
+I could not find an apxs utility, which will be used in certain parts
+of the build, if present. This utility (and the apr-config and
+apu-config utilities) have not yet been ported to Apache2 on Win32,
+but a development port is available. You can either
+
+- ignore installing apxs by answering "no" at the prompt below
+  (mod_perl will still build),
+- install apxs by answering "yes" at the prompt below,
+- quit now, run the "fetch_win32_apxs.pl" script in the build/ directory
+  to fetch and install the utilities, and then rebuild mod_perl,
+- quit now, and from http://perl.apache.org/dist/win32-bin/ grab
+  apxs_win32.tar.gz; when unpacked, this contains a README explaining
+  how to install the utilities. Afterwards, rebuild mod_perl.
+
+END
+
+my $ans = prompt('Install apxs now?', 'yes');
+exit 0 unless $ans =~ /^y/i;
+
+my $file = 'apxs_win32.tar.gz';
+unless (-e $file) {
+    my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+    print "Fetching $remote ... ";
+    die "Download of $remote failed"
+        unless (is_success(getstore($remote, $file)));
+    print " done!\n";
+}
+
+my $dir = 'apxs';
+my $arc = Archive::Tar->new($file, 1);
+$arc->extract($arc->list_files());
+die "Unpacking $file failed" unless (-d $dir);
+
+print "chdir $dir\n";
+chdir $dir or die "chdir to $dir failed: $!";
+
+my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+print "@args\n";
+system(@args) == 0 or die "system @args failed: $?";
+
+chdir '..';
+#rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+#print "unlink $file\n\n";
+#unlink $file or warn "unlink of $file failed: $!";

==============================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
[...]
>>If not, perhaps we should just bundle it
>>with mod_perl? Or would it be a bad idea? The fetch thing
>>sounds OK, but what if the there is no network available
>>during the install? Also some people won't like "random"
>>code being brought and installed without them reviewing it
>>first? May be Makefile.PL should die telling the user what
>>to do. e.g. we could include this fetch thing in a
>>build/fetch_win32_apxs and just tell the user to run it
>>first, install it and then return to the normal build?
>>Just throwing ideas...
> 
> 
> That's a good point about the external code being brought
> in, and also a potential lack of a network ... One advantage
> to running it from Makefile.PL (or equivalent) though is
> that MP_AP_PREFIX is available, which is used to install
> apxs. What about offering a choice:
> - ignore apxs (things still build)
> - install automatically
> - quit, and run a build/fetch_win32_apxs script
> - give the location where the sources are, for
>   manual installation

Sounds fine to me, win32 users may have more useful input.

> The following implements that; unfortunately, it still
> expands Makefile.PL - perhaps this could be moved elsewhere,
> or perhaps the number of options cut down, or perhaps I
> could be less verbose ...

Don't worry about this at the moment, we can refactor that code later.
[...]
> +sub fetch_apxs {
> +    my $prefix = $build->{MP_AP_PREFIX};

are you sure it's always set to a sensible value?

> +    return if -e catfile($prefix, 'bin', 'apxs.bat1');

I sure don't know what I'm talking about but why 'bat1'? Shouldn't that be 'bat'?

the problem with the suggested build/fetch_win32_apxs.pl is that if the user 
wants to abort the install and start again it's going to be fetched again. I 
think fetch_win32_apxs.pl should just fetch and fetch_apxs() should return if 
it finds the files already. May be s/fetch_apxs/run_win32_apxs/ which will 
fetch the files if they weren't fetched already?


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 5 Nov 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> > Hi,
> >   I was wondering how it would be felt to include an offer
> > in mp2 to get a Win32 version of apxs, if this was not
> > detected. There's a tar.gz archive on perl.apache.org that
> > contains this (plus apr-config and apu-config), so it would
> > be a matter of fetching and extracting this, then running
> > the included configure script to install. If this seems OK,
> > it'd be nice to detect the absence of apxs early on in the
> > build process so as the rest of the build can use the
> > installed scripts - the following diff does this for the
> > top-level Makefile.PL, but perhaps a better place is in
> > Apache::Build? Thanks.
>
> Ideally we should stop blowing up Makefile.PL, it's
> already too big. We should think of having most of the
> support functions moved elsewhere. But this is not urgent
> of course, just something to think of.
>
> What's the verdict from Bill? Does httpd go on including
> it in the core?

I haven't heard anything on this, but that's understandable,
as he's pretty busy ...

> If not, perhaps we should just bundle it
> with mod_perl? Or would it be a bad idea? The fetch thing
> sounds OK, but what if the there is no network available
> during the install? Also some people won't like "random"
> code being brought and installed without them reviewing it
> first? May be Makefile.PL should die telling the user what
> to do. e.g. we could include this fetch thing in a
> build/fetch_win32_apxs and just tell the user to run it
> first, install it and then return to the normal build?
> Just throwing ideas...

That's a good point about the external code being brought
in, and also a potential lack of a network ... One advantage
to running it from Makefile.PL (or equivalent) though is
that MP_AP_PREFIX is available, which is used to install
apxs. What about offering a choice:
- ignore apxs (things still build)
- install automatically
- quit, and run a build/fetch_win32_apxs script
- give the location where the sources are, for
  manual installation

The following implements that; unfortunately, it still
expands Makefile.PL - perhaps this could be moved elsewhere,
or perhaps the number of options cut down, or perhaps I
could be less verbose ...
========================================================
Index: Makefile.PL
===================================================================
RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
retrieving revision 1.129
diff -u -r1.129 Makefile.PL
--- Makefile.PL	5 Nov 2003 09:52:18 -0000	1.129
+++ Makefile.PL	6 Nov 2003 07:44:48 -0000
@@ -44,6 +44,8 @@
 my $build = Apache::Build->new(init => 1);
 my $code  = ModPerl::Code->new;

+fetch_apxs() if WIN32;
+
 configure();
 perl_version_check($build);

@@ -418,6 +420,35 @@
 EOF
         }
     }
+}
+
+sub fetch_apxs {
+    my $prefix = $build->{MP_AP_PREFIX};
+    return if -e catfile($prefix, 'bin', 'apxs.bat1');
+    print << 'END';
+
+I could not find an apxs utility, which will be used in certain parts
+of the build, if present. This utility (and the apr-config and
+apu-config utilities) have not yet been ported to Apache2 on Win32,
+but a development port is available. You can either
+
+- ignore installing apxs by answering "no" at the prompt below
+  (mod_perl will still build),
+- install apxs by answering "yes" at the prompt below,
+- quit now, run the "fetch_win32_apxs.pl" script in the build/ directory
+  to fetch and install the utilities, and then re-run this Makefile.PL,
+- quit now, and from http://perl.apache.org/dist/win32-bin/ grab
+  apxs_win32.tar.gz; when unpacked, this contains a README explaining
+  how installation is done. Afterwards, re-run this Makefile.PL.
+
+END
+
+    my $ans = $build->prompt('Install apxs now?', 'yes');
+    return unless $ans =~ /^y/i;
+    my $script = catfile($build->{cwd}, 'build', 'fetch_win32_apxs.pl');
+    my @args = ($^X, $script, "--with-apache2=$prefix");
+    print "@args\n";
+    system(@args) == 0 or die "fetch of apxs failed: $?";
 }

 package MY;
Index: build/fetch_win32_apxs.pl
===================================================================
RCS file: build/fetch_win32_apxs.pl
diff -N build/fetch_win32_apxs.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ build/fetch_win32_apxs.pl	6 Nov 2003 07:44:48 -0000
@@ -0,0 +1,37 @@
+#!C:/Perl/bin/perl
+use strict;
+use warnings;
+use Getopt::Long;
+require File::Spec;
+use File::Basename;
+use Archive::Tar;
+use File::Path;
+use LWP::Simple;
+
+my $prefix;
+GetOptions( 'with-apache2=s' => \$prefix);
+die "Please specify the --with-apache2 option as the path to Apache2"
+    unless $prefix;
+
+my $file = 'apxs_win32.tar.gz';
+my $remote = 'http://perl.apache.org/dist/win32-bin/' . $file;
+print "Fetching $remote ... ";
+die "Download of $remote failed"
+    unless (is_success(getstore($remote, $file)));
+print " done!\n";
+
+my $arc = Archive::Tar->new($file, 1);
+$arc->extract($arc->list_files());
+my $dir = 'apxs';
+die "Unpacking $file failed" unless (-d $dir);
+print "chdir $dir\n";
+chdir $dir or die "chdir to $dir failed: $!";
+
+my @args = ($^X, 'Configure.pl', "--with-apache2=$prefix");
+print "@args\n";
+system(@args) == 0 or die "system @args failed: $?";
+
+chdir '..';
+rmtree($dir, 1, 1) or warn "rmtree of $dir failed: $!";
+print "unlink $file\n\n";
+unlink $file or warn "unlink of $file failed: $!";

================================================================

-- 
best regards,
randy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [mp2] including a Win32 apxs?

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> Hi,
>   I was wondering how it would be felt to include an offer
> in mp2 to get a Win32 version of apxs, if this was not
> detected. There's a tar.gz archive on perl.apache.org that
> contains this (plus apr-config and apu-config), so it would
> be a matter of fetching and extracting this, then running
> the included configure script to install. If this seems OK,
> it'd be nice to detect the absence of apxs early on in the
> build process so as the rest of the build can use the
> installed scripts - the following diff does this for the
> top-level Makefile.PL, but perhaps a better place is in
> Apache::Build? Thanks.

Ideally we should stop blowing up Makefile.PL, it's already too big. We should 
think of having most of the support functions moved elsewhere. But this is not 
urgent of course, just something to think of.

What's the verdict from Bill? Does httpd go on including it in the core? If 
not, perhaps we should just bundle it with mod_perl? Or would it be a bad 
idea? The fetch thing sounds OK, but what if the there is no network available 
during the install? Also some people won't like "random" code being brought 
and installed without them reviewing it first? May be Makefile.PL should die 
telling the user what to do. e.g. we could include this fetch thing in a 
build/fetch_win32_apxs and just tell the user to run it first, install it and 
then return to the normal build? Just throwing ideas...


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org