[MERGE] Port from Module::Install to ExtUtils::MakeMaker+Distar
Dagfinn Ilmari Mannsåker [Fri, 23 Feb 2018 14:45:37 +0000 (14:45 +0000)]
.gitignore
Changes
MANIFEST.SKIP [deleted file]
Makefile.PL
maint/Makefile.PL.include [new file with mode: 0644]
maint/travis-ci_scripts/30_before_script.bash
maint/travis-ci_scripts/common.bash
xt/optdep-pod.t [new file with mode: 0644]

index 234effd..64502ef 100644 (file)
@@ -4,10 +4,11 @@
 /*.old
 /blib
 /*gz
-/inc
+/Distar
 /pm_to_blib
 /Makefile
 /MANIFEST
+/MANIFEST.SKIP
 /META.*
 /MYMETA.*
 /README
diff --git a/Changes b/Changes
index d743e7d..a879ca1 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,7 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - Convert from Module::Install to ExtUtils::MakeMaker + Distar (GH#17)
+
 0.07048  2018-01-20
         - Fix for PostgreSQL enums not in the schema search path (RT#123234)
         - Fix 'default now()' test for PostgreSQL v10
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
deleted file mode 100644 (file)
index ca9d1db..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-# copied over from DBIx::Class
-#
-# Avoid version control files.
-\bRCS\b
-\bCVS\b
-,v$
-\B\.svn\b
-\B\.git(ignore)?\b
-
-# Avoid Makemaker generated and utility files.
-\bMakefile$
-\bblib
-\bMakeMaker-\d
-\bpm_to_blib$
-\bblibdirs$
-^MANIFEST\.SKIP$
-^MYMETA\.
-
-# Avoid Module::Build generated and utility files.
-\bBuild$
-\b_build
-
-# Avoid temp and backup files.
-~$
-\.tmp$
-\.old$
-\.bak$
-\.swp$
-\#$
-\b\.#
-
-# avoid OS X finder files
-\.DS_Store$
-
-# Don't ship the test junk
-^t/var
-^t/_dump
-^t/_common_dump
-^t/dbictest.db
-^t/dbictest.db-journal
-^t/sqlite.test
-^t/sqlite.test-journal
-
-# Don't ship the last dist we built :)
-\.tar\.gz$
-
-# Skip dotfiles
-^\.
-
-# Skip maint stuff
-^maint/
-
-# Skip coverage output
-^cover_db/
-
-# Don't publish the TODO file
-TODO
-
-# Don't try to add dist dirs to MANIFEST
-^DBIx-Class-Schema-Loader
-
-# Build.PL for maint only
-Build.PL
index 095fb0b..a3735bc 100644 (file)
@@ -2,67 +2,101 @@ use warnings;
 use strict;
 
 use 5.008001;
-BEGIN { unshift @INC, '.' unless $INC[-1] eq '.'; }
-use inc::Module::Install 1.00;
-
-use Getopt::Long();
-
-my $getopt = Getopt::Long::Parser->new(
-    config => [qw/gnu_getopt bundling_override no_ignore_case pass_through/]
+use ExtUtils::MakeMaker;
+my ($dev_requires) = (do './maint/Makefile.PL.include' or die $@)
+    unless -f 'META.yml';
+
+my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
+my %eumm_args = (
+    NAME => 'DBIx::Class::Schema::Loader',
+    VERSION_FROM => 'lib/DBIx/Class/Schema/Loader.pm',
+    LICENSE => 'perl',
+    MIN_PERL_VERSION => '5.008001',
+    CONFIGURE_REQUIRES => {
+        'ExtUtils::MakeMaker' => '0',
+    },
+    TEST_REQUIRES => {
+        'DBD::SQLite'     => '1.29',
+        'Test::Exception' => '0.31',
+        'Test::More'      => '0.94',
+        'Test::Warn'      => '0.21',
+        'Test::Deep'      => '0.107',
+        'Test::Differences' => '0.60',
+        # temporary, needs to be thrown out
+        'DBIx::Class::IntrospectableM2M' => 0,
+        # core, but specific versions not available on older perls
+        'File::Temp'      => '0.16',
+        'File::Path'      => '2.07',
+    },
+    test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'},
+    PREREQ_PM => {
+        'Carp::Clan'                  => 0,
+        'Class::Accessor::Grouped'    => '0.10008',
+        'Class::C3::Componentised'    => '1.0008',
+        'Class::Inspector'            => '1.27',
+        'Class::Unload'               => '0.07',
+        'curry'                       => '1.000000',
+        'Data::Dump'                  => '1.06',
+        'DBIx::Class'                 => '0.08127',
+        'Hash::Merge'                 => '0.12',
+        'Lingua::EN::Inflect::Number' => '1.1',
+        'Lingua::EN::Tagger'          => '0.23',
+        'Lingua::EN::Inflect::Phrase' => '0.15',
+        'List::Util'                  => '1.33',
+        'MRO::Compat'                 => '0.09',
+        'namespace::clean'            => '0.23',
+        'Scope::Guard'                => '0.20',
+        'String::ToIdentifier::EN'    => '0.05',
+        'String::CamelCase'           => '0.02',
+        'Sub::Util'                   => '1.40',
+        'Try::Tiny'                   => 0,
+        # core, but specific versions not available on older perls
+        'Digest::MD5'                 => '2.36',
+        'Exporter'                    => '5.63',
+    },
+    realclean => {
+        FILES => 'lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pod'
+    },
+    EXE_FILES => [ qw(script/dbicdump) ],
+    META_MERGE => {
+        "meta-spec" => { version => 2 },
+        dynamic_config => 0,
+        resources => {
+            repository => {
+                type => 'git',
+                url => 'git@github.com/dbsrgits/dbix-class-schema-loader.git',
+                web => 'https://github.com/dbsrgits/dbix-class-schema-loader',
+            },
+            x_IRC => 'irc://irc.perl.org/#dbix-class',
+            license => [ 'http://dev.perl.org/licenses/' ],
+            x_MailingList => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class',
+        },
+        no_index => {
+            directory => [qw(maint xt)],
+        },
+        prereqs => {
+            develop => { requires => $dev_requires || +{} },
+        },
+    },
 );
-my $args = {
-    skip_author_deps => undef,
-};
-$getopt->getoptions($args, 'skip_author_deps');
-if (@ARGV) {
-    warn "\nIgnoring unrecognized option(s): @ARGV\n\n";
-}
-
-use FindBin;
-use lib "$FindBin::Bin/lib";
-
-perl_version '5.008001';
-name           'DBIx-Class-Schema-Loader';
-all_from       'lib/DBIx/Class/Schema/Loader.pm';
-
-# temporary, needs to be thrown out
-test_requires 'DBIx::Class::IntrospectableM2M' => 0;
 
-# core, but specific versions not available on older perls
-test_requires 'File::Temp'      => '0.16';
-test_requires 'File::Path'      => '2.07';
-
-test_requires 'DBD::SQLite'     => '1.29';
-test_requires 'Test::Exception' => '0.31';
-test_requires 'Test::More'      => '0.94';
-test_requires 'Test::Warn'      => '0.21';
-test_requires 'Test::Deep'      => '0.107';
-test_requires 'Test::Differences' => '0.60';
-
-requires 'Carp::Clan'                  => 0;
-requires 'Class::Accessor::Grouped'    => '0.10008';
-requires 'Class::C3::Componentised'    => '1.0008';
-requires 'Class::Inspector'            => '1.27';
-requires 'Class::Unload'               => '0.07';
-requires 'curry'                       => '1.000000',
-requires 'Data::Dump'                  => '1.06';
-requires 'DBIx::Class'                 => '0.08127';
-requires 'Hash::Merge'                 => '0.12';
-requires 'Lingua::EN::Inflect::Number' => '1.1';
-requires 'Lingua::EN::Tagger'          => '0.23';
-requires 'Lingua::EN::Inflect::Phrase' => '0.15';
-requires 'List::Util'                  => '1.33';
-requires 'MRO::Compat'                 => '0.09';
-requires 'namespace::clean'            => '0.23';
-requires 'Scope::Guard'                => '0.20';
-requires 'String::ToIdentifier::EN'    => '0.05';
-requires 'String::CamelCase'           => '0.02';
-requires 'Sub::Util'                   => '1.40';
-requires 'Try::Tiny'                   => 0;
-
-# core, but specific versions not available on older perls
-requires 'Digest::MD5'                 => '2.36';
-requires 'Exporter'                    => '5.63';
+sub _move_to {
+  my ($hash, $fromkey, $tokey) = @_;
+  $hash->{$tokey} = {
+    %{ $hash->{$tokey} || {} },
+    %{ delete($hash->{$fromkey}) || {} },
+  };
+}
+delete $eumm_args{META_MERGE} if $eumm_version < 6.45_01;
+delete $eumm_args{CONFIGURE_REQUIRES}
+  if $eumm_version < 6.51_03; # too late to use so just delete
+_move_to(\%eumm_args, 'TEST_REQUIRES', 'BUILD_REQUIRES')
+  if $eumm_version < 6.63_03;
+_move_to(\%eumm_args, 'BUILD_REQUIRES', 'PREREQ_PM')
+  if $eumm_version < 6.55_01;
+$eumm_args{NO_MYMETA} = 1
+  if $eumm_version >= 6.57_02 and $eumm_version < 6.57_07;
+WriteMakefile(%eumm_args);
 
 print <<"EOF";
 ******************* DBIx::Class::Schema::Loader WARNING ***********************
@@ -85,55 +119,4 @@ See also the "Changes" file for the last few revisions.
 *******************************************************************************
 EOF
 
-if ($Module::Install::AUTHOR && ! $args->{skip_author_deps}) {
-    my @missing_plugins;
-    for my $plugin (qw(ReadmeFromPod AuthorTests)) {
-        eval "require Module::Install::$plugin" and next;
-        push @missing_plugins, "Module::Install::$plugin";
-        chomp(my $err = $@);
-        $missing_plugins[-1] .= " ($err)"
-            unless $err =~ m{^Can't locate Module/Install/$plugin.pm in \@INC};
-    }
-    die "\nYou need to install the following modules to run this Makefile.PL in author mode:\n\n", join("\n", @missing_plugins), "\n\n"
-        if @missing_plugins;
-
-    warn "\n*** AUTHOR MODE: some optional dependencies converted to hard requires.\n\n";
-
-    require DBIx::Class::Schema::Loader::Optional::Dependencies;
-
-    test_requires %{DBIx::Class::Schema::Loader::Optional::Dependencies
-        ->modreq_list_for([
-            grep { !/rdbms/ }
-            keys %{ DBIx::Class::Schema::Loader::Optional::Dependencies
-                ->req_group_list
-            }
-        ])};
-
-    DBIx::Class::Schema::Loader::Optional::Dependencies->_gen_pod(undef, 'lib');
-
-    author_tests( 'xt' );
-    readme_from( 'lib/DBIx/Class/Schema/Loader.pm' );
-    realclean_files( qw[README MANIFEST lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pod] );
-    postamble <<EOP;
-create_distdir: author_stop_distdir_creation
-author_stop_distdir_creation:
-\t\$(NOECHO) \$(ECHO) Creation of dist with author mode deps not allowed
-\t\$(NOECHO) \$(ECHO) Please re-run Makefile.PL with --skip_author_deps
-\t\$(NOECHO) \$(FALSE)
-EOP
-
-}
-
-tests_recursive;
-
-install_script 'script/dbicdump';
-
-resources 'IRC'         => 'irc://irc.perl.org/#dbix-class';
-resources 'license'     => 'http://dev.perl.org/licenses/';
-resources 'repository'  => 'https://github.com/dbsrgits/dbix-class-schema-loader';
-resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class';
-
-auto_install;
-WriteAll;
-
 # vim:et sts=4 sw=4 tw=0:
diff --git a/maint/Makefile.PL.include b/maint/Makefile.PL.include
new file mode 100644 (file)
index 0000000..bc0411c
--- /dev/null
@@ -0,0 +1,28 @@
+BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") }
+use lib 'Distar/lib';
+use Distar 0.001;
+
+author 'Caelum: Rafael Kitover <rkitover@cpan.org>';
+
+manifest_include 't/backcompat/0.04006/lib' => qr/.*\.pm$/;
+manifest_include 't/bin' => qr/\w+/;
+manifest_include 'script' => qr/\w+/;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+require DBIx::Class::Schema::Loader::Optional::Dependencies;
+my $optdeps = 'DBIx::Class::Schema::Loader::Optional::Dependencies';
+my @req_groups = keys %{ $optdeps->req_group_list };
+my @other_groups = grep { !/rdbms/ } @req_groups;
+my %dev_requires = %{ $optdeps->modreq_list_for(\@other_groups) };
+
+eval {
+    # eval as blows up if not all deps installed
+    # should probably be part of "build" stage instead
+    $optdeps->_gen_pod(undef, 'lib');
+};
+
+# vim: ft=perl et sts=4 sw=4 tw=0:
+
+# list in case more added - returned to caller
+(\%dev_requires);
index 4483e35..c6b5261 100755 (executable)
@@ -58,18 +58,6 @@ if [[ "$POISON_ENV" = "true" ]] ; then
 fi
 
 if [[ "$CLEANTEST" = "true" ]]; then
-  # get the last inc/ off cpan - we will get rid of MI
-  # soon enough, but till then this will do
-  # the point is to have a *really* clean perl (the ones
-  # we build are guaranteed to be clean, without side
-  # effects from travis preinstalls)
-
-  # trick cpanm into executing true as shell - we just need the find+unpack
-  [[ -d ~/.cpanm/latest-build/DBIx-Class-*/inc ]] || run_or_err "Downloading latest stable DBIC inc/ from CPAN" \
-    "SHELL=/bin/true cpanm --look DBIx::Class::Schema::Loader"
-
-  mv ~/.cpanm/latest-build/DBIx-Class-Schema-Loader-*/inc .
-
   # The first CPAN which is somewhat sane is around 1.94_56 (perl 5.12)
   # The problem is that the first sane version also brings a *lot* of
   # deps with it, notably things like YAML and HTTP::Tiny
@@ -139,14 +127,14 @@ else
 
 fi
 
-# generate the makefile which will have different deps depending on
+# generate the MYMETA which will have different deps depending on
 # the runmode and envvars set above
 run_or_err "Configure on current branch" "perl Makefile.PL"
 
 # install (remaining) dependencies, sometimes with a gentle push
 if [[ "$CLEANTEST" = "true" ]]; then
   # we may need to prepend some stuff to that list
-  HARD_DEPS="$(echo $(make listdeps))"
+  HARD_DEPS="$(extract_prereqs .)"
 
 ##### TEMPORARY WORKAROUNDS needed in case we will be using CPAN.pm
   if [[ "$DEVREL_DEPS" != "true" ]] && ! CPAN_is_sane ; then
@@ -227,7 +215,7 @@ else
   # listalldeps is deliberate - will upgrade everything it can find
   # we exclude DBIC specifically, since we do not want to pull
   # in 0.089xx on bleadcpan runs
-  deplist="$(make listalldeps | grep -vP '^(DBIx::Class)$')"
+  deplist="$(listalldeps | grep -vP '^(DBIx::Class)$')"
 
   # assume MDV on POISON_ENV, do not touch DBI/SQLite
   if [[ "$POISON_ENV" = "true" ]] ; then
@@ -242,12 +230,12 @@ echo_err "$(tstamp) Dependency installation finished"
 perl Makefile.PL
 
 # make sure we got everything we need
-if [[ -n "$(make listdeps)" ]] ; then
+if [[ -n "$(extract_prereqs .)" ]] ; then
   echo_err "$(tstamp) Not all deps installed - something went wrong :("
   sleep 1 # without this the echo below confuses the console listener >.<
   CPAN_is_sane || echo_err -e "Outdated CPAN.pm used - full installdep log follows\n$INSTALLDEPS_OUT\n\nSearch for 'NOT OK' in the text above\n\nDeps still missing:"
   sleep 3 # without this the above echo confuses the console listener >.<
-  make listdeps
+  extract_prereqs .
   exit 1
 fi
 
index 4c6c10a..e633705 100755 (executable)
@@ -115,7 +115,10 @@ extract_prereqs() {
     s/^\!.*//;
     s/^[^a-z]+//i;
     s/\-[^\-]+$/ /; # strip version part
-    s/\-/::/g
+    s/\-/::/g;
+    s/^\s*Snowball::Swedish\s*$/ Lingua::Stem::Snowball::Se /m; # distro->module
+    s/^\s*Snowball::Norwegian\s*$/ Lingua::Stem::Snowball::No /m;
+    s/^\s*Scalar::List::Utils\s*$/ List::Util /m;
   ' <<< "$OUT")
 
   # throw away what was in $@
@@ -127,6 +130,16 @@ extract_prereqs() {
   echo "$PQ"
 }
 
+listalldeps() {
+  # relies on sorted YAML
+  perl -lne '
+    next unless /^((?:build_)?requires:)/..($_ ne $1 and /^[^ ]/);
+    next if /^[^ ]/ or /^ *perl:/; # drop requires headers, or perl
+    s/^ *([^ ]*): .*/$1/;
+    print;
+  ' MYMETA.yml
+}
+
 parallel_installdeps_notest() {
   if [[ -z "$@" ]] ; then return; fi
 
diff --git a/xt/optdep-pod.t b/xt/optdep-pod.t
new file mode 100644 (file)
index 0000000..ea329da
--- /dev/null
@@ -0,0 +1,13 @@
+use warnings;
+use strict;
+
+use Test::More;
+
+ok -f 'lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pod', 'optdep pod present';
+cmp_ok
+ -M 'lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pod' || 2 ** 15,
+ '<',
+ -M 'lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pm',
+ 'optdep pod newer than pm';
+
+done_testing;