Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make life easier for packagers with BUILDING_AS_PACKAGE

Also README.packaging and bundled/README.
  • Loading branch information...
commit 78f8c8b71eacffbc3f8ef10ab8dea73a59b61c7c 1 parent ae3e30d
@schwern schwern authored
View
6 Changes
@@ -7,6 +7,12 @@
* my::bundle::copy_bundles() will only load File::Copy::Recursive if
it needs it, allowing vendors packaging MakeMaker to just delete
bundled/*
+ * Bundling can be overridden by setting the BUILDING_AS_PACKAGE
+ environment variable. This makes life easier for vendor packagers.
+
+ Docs
+ * README.packaging explains how to package MakeMaker
+ * bundled/README explains what the bundled directory is about.
6.63_01 Sun Oct 23 16:57:24 PDT 2011
View
33 Makefile.PL
@@ -18,6 +18,8 @@ use lib qw(lib); # build ourself with ourself
use File::Spec;
use ExtUtils::MakeMaker 6.50;
+my $BUILDING_AS_PACKAGE = $ENV{BUILDING_AS_PACKAGE};
+
BEGIN {
die "You have File::Spec version $File::Spec::VERSION\n" . "ExtUtils::MakeMaker requires File::Spec >= 0.8 to build at all.\n"
if $File::Spec::VERSION < 0.8;
@@ -46,19 +48,42 @@ CHANGE_WARN
# Test::Harnesses prior to 2.00 shoved all of @INC onto the command line
# when a test had -T. This made it too long. So we need a Test::Harness
# > 2.00 on VMS for t/testlib.t
-my %prereq = ();
-$prereq{'Test::Harness'} = 2.00 if $^O eq 'VMS';
+my %Extra_Prereqs = ();
+$Extra_Prereqs{'Test::Harness'} = 2.00 if $^O eq 'VMS';
check_environment();
-my::bundles::copy_bundles("bundled", "inc");
+# Special case for MakeMaker being built as a vendor package
+if( $BUILDING_AS_PACKAGE ) {
+ # Some of these are lower than what we bundle. That's ok, we
+ # bundle the latest because we might as well, but we don't want to
+ # burden vendors with having to update everything.
+ %Extra_Prereqs = (
+ 'CPAN::Meta' => '2.112580',
+ 'CPAN::Meta::YAML' => '0.002',
+ 'ExtUtils::Command' => '1.16',
+ 'ExtUtils::Install' => '1.52',
+ 'ExtUtils::Manifest' => '1.58',
+ 'File::Temp' => '0.22',
+ 'JSON::PP' => '2.27103',
+ 'Parse::CPAN::Meta' => '1.4400',
+ 'Scalar::Util' => '1.13',
+ 'version' => '0.82',
+ 'Version::Requirements' => '0.101020',
+ );
+
+ $Extra_Prereqs{'JSON::PP::Compat5006'} = '1.09' if $] < 5.008;
+}
+else {
+ my::bundles::copy_bundles("bundled", "inc");
+}
my $MM = WriteMakefile(
NAME => $PACKAGE,
VERSION_FROM => "lib/$PACKAGE_FILE.pm", # finds $VERSION
PREREQ_PM => {
- %prereq,
+ %Extra_Prereqs,
'File::Spec' => 0.8, # splitpath(), rel2abs()
'Pod::Man' => 0, # manifypods needs Pod::Man
'File::Basename' => 0,
View
23 README.packaging
@@ -0,0 +1,23 @@
+If you wish to package MakeMaker in a binary package, here's some tips.
+
+tl;dr version:
+
+1a) Set the BUILDING_AS_PACKAGE environment variable to a true value.
+OR
+1b) Set the $BUILDING_AS_PACKAGE variable in the Makefile.PL to true.
+2) Package normally, but watch out for dependency loops.
+
+MakeMaker cannot have any dependencies, everything depends on it and
+that would be a dependency loop. It instead bundles pre-built copies
+of all its non-core dependencies in the bundled/ directory. It adds
+them to itself if they're not already installed.
+
+This can confuse packagers, it makes it look like MakeMaker contains a
+lot more modules than it really does and causes conflicts.
+
+You can tell MakeMaker not to use it's bundles and instead declare the
+dependencies normally. This is done either by setting the
+BUILDING_AS_PACKAGE environment variable to true or by patching the
+Makefile.PL and setting $BUILDING_AS_PACKAGE to true. On the down
+side, there will be dependency loops which your packaging system will
+have to resolve.
View
5 bundled/README
@@ -0,0 +1,5 @@
+This directory contains CPAN modules which ExtUtils-MakeMaker depends on.
+They are bundled with ExtUtils-MakeMaker to avoid dependency loops.
+
+Vendor packages will want to disable this bundling. See README.packaging in the top
+level directory for details.
View
14 my/bundles.pm
@@ -3,6 +3,8 @@ package my::bundles;
use strict;
use warnings;
+use File::Path;
+
=head1 NAME
@@ -28,11 +30,8 @@ inc/ as a flattened module directory that MakeMaker can install.
=cut
-require lib;
my $bundle_dir = "bundled";
-use File::Path;
-
my %special_dist = (
"Scalar-List-Utils" => sub {
# Special case for Scalar::Util, never override the XS version with a
@@ -47,16 +46,23 @@ my %special_dist = (
);
-sub import {
+sub add_bundles_to_inc {
opendir my $dh, $bundle_dir or die "Can't open bundles directory: $!";
my @bundles = map { "$bundle_dir/$_" } grep !/^\./, readdir $dh;
+
+ require lib;
lib->import(@bundles);
+
+ return;
}
sub copy_bundles {
my($src, $dest) = @_;
+ # So we can use them to copy them.
+ add_bundles_to_inc();
+
rmtree $dest;
mkpath $dest;
Please sign in to comment.
Something went wrong with that request. Please try again.