summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-10-27 11:54:37 -0500
committerJesse Luehrs <doy@tozt.net>2010-10-27 11:54:37 -0500
commit354ce5a6b1b89271e4173f8efa18fd63468274f1 (patch)
tree8edf84595c442b931285d0da7b81d9479805e954
parent1f3bc924f93799222d8efc3ad8314eba58fb9f09 (diff)
downloadpackage-stash-354ce5a6b1b89271e4173f8efa18fd63468274f1.tar.gz
package-stash-354ce5a6b1b89271e4173f8efa18fd63468274f1.zip
add conflict checking to the generated Makefile.PL0.09
-rw-r--r--.gitignore1
-rw-r--r--dist.ini1
-rw-r--r--inc/MMPackageStash.pm59
3 files changed, 60 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index a2bd8da..478a475 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,6 @@ cover_db
META.yml
Makefile
blib
-inc
pm_to_blib
MANIFEST
Makefile.old
diff --git a/dist.ini b/dist.ini
index ab24035..35c87e7 100644
--- a/dist.ini
+++ b/dist.ini
@@ -5,6 +5,7 @@ copyright_holder = Jesse Luehrs
[@DOY]
dist = Package-Stash
+awesome = =inc::MMPackageStash
[Prereq]
Scalar::Util = 0
diff --git a/inc/MMPackageStash.pm b/inc/MMPackageStash.pm
new file mode 100644
index 0000000..a067fc7
--- /dev/null
+++ b/inc/MMPackageStash.pm
@@ -0,0 +1,59 @@
+package inc::MMPackageStash;
+use Moose;
+
+extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';
+
+# XXX: this is pretty gross, it should be possible to clean this up later
+around _build_MakeFile_PL_template => sub {
+ my $orig = shift;
+ my $self = shift;
+ my $template = $self->$orig(@_);
+
+ $template =~ s/(use ExtUtils::MakeMaker.*)/$1\n\ncheck_conflicts();/;
+
+ $template .= <<'CHECK_CONFLICTS';
+sub check_conflicts {
+ my %conflicts = (
+ 'Class::MOP' => '1.09',
+ );
+ my $found = 0;
+ for my $mod ( sort keys %conflicts ) {
+ eval "require $mod";
+ next if $@;
+
+ my $installed = $mod->VERSION();
+ if ( $installed le $conflicts{$mod} ) {
+
+ print <<"EOF";
+
+***
+ This version of Package::Stash conflicts with the version of
+ $mod ($installed) you have installed.
+
+ You will need to upgrade $mod after installing
+ this version of Package::Stash.
+***
+
+EOF
+
+ $found = 1;
+ }
+ }
+
+ return unless $found;
+
+ # More or less copied from Module::Build
+ return if $ENV{PERL_MM_USE_DEFAULT};
+ return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT));
+
+ sleep 4;
+}
+CHECK_CONFLICTS
+
+ return $template;
+};
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;