introduce heuristics to parse MIME right even if the MIME header is missing
[cpan-testers-parsereport.git] / Makefile.PL
blob414aaec42fea53df1fc17c4041b2de03f7cd274c
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.4502;
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 = ! system "git status -a > /dev/null";
22     if ($dirty){
23         system "git status -a";
24         die "Not everything checked in?";
25     }
26     open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
27     local $/;
28     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
29     close $fh or die "Could not close: $!";
30     my ($namespace) = $::version_from;
31     $namespace =~ s|^lib/(.+)\.pm$|$1|;
32     $namespace =~ s|/|::|g;
33     eval qq{ if (\$$namespace\::VERSION != \$have_version) {
34         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] Makefile version[\$have_version]";
35         \$version_diff = 1;
36     }};
37     eval qq{ if (\$$namespace\::VERSION != \$mmgenereatedversionfrom) {
38         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] MM generated version[\$mmgenereatedversionfrom]";
39         \$version_diff = 1;
40     }};
43 WriteMakefile
44     (
45      'NAME' => 'CPAN::Testers::ParseReport',
46      'VERSION_FROM' => $::version_from,
47      'PREREQ_PM' => {
48                      'Config::Perl::V'             => 0,
49                      'DateTime::Format::Strptime'  => 0,
50                      'DateTime::Format::DateParse' => 0,
51                      'File::Path'                  => 0,
52                      'Getopt::Long'                => 0,
53                      'HTML::Entities'              => 0,
54                      'IO::Prompt'                  => 0,
55                      'LWP::UserAgent'              => 0,
56                      'List::Util'                  => 0,
57                      'MIME::QuotedPrint'           => 0,
58                      'Net::NNTP'                   => 0,
59                      'Pod::Usage'                  => 0,
60                      'Statistics::Regression'      => 0,
61                      'Test::More'                  => 0,
62                      'Test::Pod'                   => 0,
63                      'Time::Local'                 => 0,
64                      'XML::LibXML'                 => 0,
65                      'XML::LibXML::XPathContext'   => 0,
66                      'YAML::Syck'                  => 0,
67                     },
68      'INSTALLDIRS' => 'site',
69      'EXE_FILES' => [
70                      'bin/ctgetreports',
71                     ],
72      LICENSE => "perl",
73      ABSTRACT => "parse reports to www.cpantesters.org from various sources",
74      'PL_FILES' => {},
75      dist => {
76               DIST_DEFAULT => join(" ", # note: order matters!
77                                    "verify-changes-date",
78                                    "Makefile",
79                                    "META.yml",
80                                    "setversion",
81                                    "all",
82                                    "tardist",
83                                   ),
84               COMPRESS => 'bzip2 -9f',
85               SUFFIX => ".bz2",
86              },
87      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
88       (META_ADD => {
89                     # write: git push git+ssh://repo.or.cz/srv/git/cpan-testers-parsereport.git master
90                     repository => "git://repo.or.cz/cpan-testers-parsereport.git",
91                     provides => { "CPAN::Testers::ParseReport" => { version => $mmgenereatedversionfrom, file => $::version_from }},
92                    }) : ()),
93      @sign,
94     );
96 if ($version_diff){
97   die "
98 ==> I had to update some \$VERSIONs <==
99 ==> Your Makefile has been rebuilt. <==
100 ==> Please rerun the make command.  <==
104 package MY;
105 sub postamble {
106   my @m;
107   push @m, q{
108 # the subdirs on MY OWN BOX are allowed here (only used for make dist!)
109 OKDIRS=DIST|bin|blib|cover_db\
110        |lib|t
112 Makefile: }.$::version_from.q{
114 META.yml: metafile
115         $(CP) $(DISTVNAME)/META.yml  ./META.yml
117 setversion:
118         $(PERL) Makefile.PL --setversion
120 verify-changes-date:
121         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
122                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
124 verify-no-subdir:
125         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
126                 -e 'die"unexpected dir:$$s"if$$s'
128 the-release-name :
129         $(NOECHO) $(ECHO) 'version ' $(VERSION)
130         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
132 release :: disttest
133         git tag -m 'This is $(VERSION)' $(VERSION)
134         ls -l $(DISTVNAME).tar$(SUFFIX)
135         rm -rf $(DISTVNAME)
137 sign:
138         cpansign -s
140   join "", @m;
143 sub dist_test {
144   return q{
145 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
146 # Makefile breaks our intent to NOT remake dist
147 disttest :
148         rm -rf $(DISTVNAME)
149         tar xvjf $(DISTVNAME).tar$(SUFFIX)
150         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
151         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
152         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
154 distdir ::
155         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
156         $(CP) $(DISTVNAME)/META.yml  ./META.yml
157         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
162 sub distdir {
163   my $self = shift;
164   my $out = $self->SUPER::distdir;
165   $out =~ s/distdir :/distdir ::/g;
166   return $out;
169 # dist_dir was the name in very old MakeMaker as of 5.005_04
170 sub dist_dir {
171   my $self = shift;
172   my $out = $self->SUPER::dist_dir;
173   $out =~ s/distdir :/distdir ::/g;
174   return $out;