Change the repository URL to https, bump version, ready to release
[cpan-testers-parsereport.git] / Makefile.PL
blobed0506ae194e05b0ffd65319cf7acb4de4d0db3b
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4 $ExtUtils::MakeMaker::VERSION =~ s/_//g;
5 my @sign = (MM->can("signature_target") ? (SIGN => 1) : ());
6 my $version_diff = 0; # we'll have to die if this becomes true
7 $::version_from = './lib/CPAN/Testers/ParseReport.pm';
8 my $mmgenereatedversionfrom = MM->parse_version($::version_from);
9 if ($ARGV[0] && $ARGV[0] eq "--setversion") {
10     die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
11     warn "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nYou should get a new one\n"
12         if $ExtUtils::MakeMaker::VERSION < 6.48;
13     eval {  require $::version_from; }; die $@ if $@;
14     my $makefile = "Makefile";
15     unless (-f $makefile) {
16         $makefile = "Makefile.old";
17     }
18     unless (-f $makefile) {
19         die "no Makefile and no Makefile.old found";
20     }
21     my $dirty = `git status --porcelain --untracked-files=no`;
22     die "Not everything checked in or out?\n====\n$dirty====\n" if $dirty;
23     open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
24     local $/;
25     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
26     close $fh or die "Could not close: $!";
27     my ($namespace) = $::version_from;
28     $namespace =~ s|^lib/(.+)\.pm$|$1|;
29     $namespace =~ s|/|::|g;
30     eval qq{ if (\$$namespace\::VERSION != \$have_version) {
31         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] Makefile version[\$have_version]";
32         \$version_diff = 1;
33     }};
34     eval qq{ if (\$$namespace\::VERSION != \$mmgenereatedversionfrom) {
35         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] MM generated version[\$mmgenereatedversionfrom]";
36         \$version_diff = 1;
37     }};
40 my %indirect_dependencies =
41     (
42      'Class::ISA' => 0,
43      'DateTime'   => 0,
44      'CPAN::Meta::Converter' => '2.110440',
45     );
46 my %interesting_modules;
47 for my $m (qw(
48     CPAN::Meta::YAML
49     File::Spec
50     IO::Prompt
51     JSON::PP
52     Parse::CPAN::Meta
53     version
54     )){
55     if (eval "require $m; 1") {
56         $interesting_modules{$m} = $m->VERSION;
57     }
60 my $prereq_pm =
61     {
62      'Compress::Zlib'              => 0,
63      'DateTime::Format::Strptime'  => 0,
64      'ExtUtils::MakeMaker'         => 6.48,
65      'File::Path'                  => '1.08',
66      'Getopt::Long'                => 0,
67      'HTML::Entities'              => 0,
68      'Hash::Util'                  => 0,
69      # 'IO::Prompt'                  => 0,
70      'JSON::XS'                    => 0,
71      'LWP::UserAgent'              => 0,
72      'List::AllUtils'              => 0,
73      'MIME::QuotedPrint'           => '3.07',
74      'Pod::Usage'                  => '1.33',
75      'Statistics::Regression'      => 0,
76      'Test::More'                  => 0,
77      'Test::Pod'                   => 0,
78      'Time::Local'                 => '1.11',
79     };
81 # intentionally avoiding any size comparisons, trying to catch
82 # interesting cases that happen during WriteMakefile, like
83 # http://www.cpantesters.org/cpan/report/e1942da8-5fcc-11e0-994f-224f8e2a057c
84 while (my($k,$v) = each %interesting_modules) {
85     $prereq_pm->{$k} ||= $v;
87 while (my($k,$v) = each %indirect_dependencies) {
88     $prereq_pm->{$k} ||= $v;
91 eval { WriteMakefile
92     (
93      'NAME' => 'CPAN::Testers::ParseReport',
94      'VERSION_FROM' => $::version_from,
95      'PREREQ_PM' => $prereq_pm,
96      'INSTALLDIRS' => 'site',
97      'EXE_FILES' => [
98                      'bin/ctgetreports',
99                     ],
100      LICENSE => "perl",
101      ABSTRACT => "parse reports to www.cpantesters.org from various sources",
102      'PL_FILES' => {},
103      dist => {
104               DIST_DEFAULT => join(" ", # note: order matters!
105                                    "verify-changes-date",
106                                    "Makefile",
107                                    "META.yml",
108                                    "setversion",
109                                    "all",
110                                    "tardist",
111                                   ),
112               COMPRESS => 'bzip2 -9f',
113               SUFFIX => ".bz2",
114              },
115      META_MERGE => {
116                     # write: git push git+ssh://repo.or.cz/srv/git/cpan-testers-parsereport.git master
117                     resources => { repository => "https://repo.or.cz/cpan-testers-parsereport.git" },
118                     provides => { "CPAN::Testers::ParseReport" => { version => $mmgenereatedversionfrom, file => $::version_from }},
119                    },
120      MIN_PERL_VERSION => '5.008', # Rule: _pragma_utf8
121      @sign,
122     );
123    };
124 if (my $err = $@) {
125     while (my($k,$v) = each %interesting_modules) {
126         warn "Found $k version $v\n";
127     }
128     die $err;
131 if ($version_diff){
132   die "
133 ==> I had to update some \$VERSIONs <==
134 ==> Your Makefile has been rebuilt. <==
135 ==> Please rerun the make command.  <==
139 package MY;
140 sub distsignature {
141     my($self) = shift;
142     my $ret = $self->SUPER::distsignature_target(@_);
143     $ret =~ s|cpansign|\$(PERL) \`dirname \$(PERL)\`/cpansign|g;
144     return $ret;
146 sub postamble {
147   my @m;
148   push @m, q{
149 # the subdirs on MY OWN BOX are allowed here (only used for make dist!)
150 OKDIRS=DIST|bin|blib|cover_db\
151        |lib|t
153 Makefile: }.$::version_from.q{
155 META.yml: metafile
156         $(CP) $(DISTVNAME)/META.yml  ./META.yml
158 setversion:
159         $(PERL) Makefile.PL --setversion
161 verify-changes-date:
162         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
163                 -e '$$ok++,exit if /^[\d\.]+\s+$$t\s/ && $$.<12; END{die "Alert: did not find <$$t> in the first 12 lines of the Changes file" unless $$ok}' Changes
165 verify-no-subdir:
166         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
167                 -e 'die"unexpected dir:$$s"if$$s'
169 the-release-name :
170         $(NOECHO) $(ECHO) 'version ' $(VERSION)
171         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
173 release :: disttest
174         git tag -m 'This is $(VERSION)' $(VERSION)
175         ls -l $(DISTVNAME).tar$(SUFFIX)
176         rm -rf $(DISTVNAME)
178 sign:
179         $(PERL) `dirname $(PERL)`/cpansign -s
181   join "", @m;
184 sub dist_test {
185   return q{
186 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
187 # Makefile breaks our intent to NOT remake dist
188 disttest :
189         rm -rf $(DISTVNAME)
190         tar xvjf $(DISTVNAME).tar$(SUFFIX)
191         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
192         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
193         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
195 distdir ::
196         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
197         $(CP) $(DISTVNAME)/META.yml  ./META.yml
198         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
203 sub distdir {
204   my $self = shift;
205   my $out = $self->SUPER::distdir;
206   $out =~ s/distdir :/distdir ::/g;
207   return $out;
210 # dist_dir was the name in very old MakeMaker as of 5.005_04
211 sub dist_dir {
212   my $self = shift;
213   my $out = $self->SUPER::dist_dir;
214   $out =~ s/distdir :/distdir ::/g;
215   return $out;