WIP at update with dirty epoch
[rersyncrecent.git] / Makefile.PL
blobdb6f40f4ecddf2a69df8f4734b812222f5025315
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 my $version_from = 'lib/File/Rsync/Mirror/Recent.pm';
8 my $version;
10     open my $fh, "<", $version_from or die "Could not open $version_from: $!";
11     my @version = grep /VERSION\s*=\s*qv/, <$fh>;
12     our $VERSION;
13     eval $version[0];
14     $version = $VERSION;
16 if ($ARGV[0] && $ARGV[0] eq "--setversion") {
17     die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
18     warn "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nYou should get a new one\n"
19         if $ExtUtils::MakeMaker::VERSION < 6.4502;
20     eval {  require $version_from; }; die $@ if $@;
21     my $makefile = "Makefile";
22     unless (-f $makefile) {
23         $makefile = "Makefile.old";
24     }
25     unless (-f $makefile) {
26         die "no Makefile and no Makefile.old found";
27     }
28     open my $fh, "make the-release-name|" or die "Could not fork: $!";
29     local $/;
30     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
31     close $fh or die "Could not close: $!";
32     my ($namespace) = $version_from;
33     $namespace =~ s|^lib/(.+)\.pm$|$1|;
34     $namespace =~ s|/|::|g;
35     eval qq{ if (\$$namespace\::VERSION != \$have_version) {
36         warn "Not equal: CPAN::Testers::ParseReport::VERSION[\$$namespace\::VERSION] Makefile version[\$have_version]";
37         \$version_diff = 1;
38     }};
41 WriteMakefile
42     (
43      NAME                => 'File::Rsync::Mirror::Recent',
44      VERSION             => $version,
45      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
46      PL_FILES            => {},
47      PREREQ_PM =>
48      {
49       # 'Data::Serializer' => 0.46, # restricted to YAML without it
50       'Data::Float'      => 0,
51       'File::Rsync'      => 0,
52       'Test::More'       => 0,
53       'File::Basename'   => 0,
54       'File::Path'       => 0,
55       'File::Temp'       => 0,
56       'List::Pairwise'   => 0,
57       'Scalar::Util'     => 0,
58       'Time::HiRes'      => 0,
59       'YAML::Syck'       => 0,
60      },
61      EXE_FILES    => [qw(bin/rrr-aggregate bin/rrr-news)],
62      dist => {
63               DIST_DEFAULT => join(" ", # note: order matters!
64                                    "Makefile",
65                                    "META.yml",
66                                    "setversion",
67                                    "all",
68                                    "tardist",
69                                   ),
70               COMPRESS => 'gzip -9',
71              },
72      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
73       (META_ADD => {
74                     # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
75                     repository => "git://repo.or.cz/rersyncrecent.git",
76                     provides => {
77                                  "File::Rsync::Mirror::Recent" =>
78                                  {
79                                   version => $version,
80                                   file => $version_from,
81                                  }
82                                 },
83                    }) : ()),
84      @sign,
85      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
86     );
88 if ($version_diff){
89   die "
90 ==> I had to update some \$VERSIONs <==
91 ==> Your Makefile has been rebuilt. <==
92 ==> Please rerun the make command.  <==
96 package MY;
97 sub postamble {
98   my @m;
99   push @m, q{
100 Makefile: MANIFEST
102 META.yml: metafile
103         $(CP) $(DISTVNAME)/META.yml  ./META.yml
105 setversion:
106         $(PERL) Makefile.PL --setversion
108 the-release-name :
109         $(NOECHO) $(ECHO) 'version ' $(VERSION)
110         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
112 release ::
113         /usr/bin/perl -I../CPAN/GIT/trunk/release-lib -S release $(DISTVNAME).tar$(SUFFIX)
114         rm -rf $(DISTVNAME)
116 sign:
117         cpansign -s
119   join "", @m;
122 sub dist_test {
123   return q{
124 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
125 # Makefile breaks our intent to NOT remake dist
126 disttest :
127         rm -rf $(DISTVNAME)
128         tar xvzf $(DISTVNAME).tar$(SUFFIX)
129         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
130         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
131         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
133 distdir ::
134         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
135         $(CP) $(DISTVNAME)/META.yml  ./META.yml
136         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
141 sub distdir {
142   my $self = shift;
143   my $out = $self->SUPER::distdir;
144   $out =~ s/distdir :/distdir ::/g;
145   return $out;
148 # dist_dir was the name in very old MakeMaker as of 5.005_04
149 sub dist_dir {
150   my $self = shift;
151   my $out = $self->SUPER::dist_dir;
152   $out =~ s/distdir :/distdir ::/g;
153   return $out;