releasing the trial release as stable
[rersyncrecent.git] / Makefile.PL
blobcb014bd338cefbed02164d137f35720c1081f1a8
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 = MM->parse_version($version_from);
9 if ($ARGV[0]){
10     if ($ARGV[0] eq "--setversion") {
11         die "Your perl is a bit dated[$]].\nDo not make a release with it\n" if $] < 5.008;
12         die "Your MakeMaker is a bit dated[$ExtUtils::MakeMaker::VERSION].\nDo not make a release with it\n"
13             if $ExtUtils::MakeMaker::VERSION < 6.48;
14         local $ENV{LANG} = "C";
15         my $dirty = `git status --porcelain --untracked-files=no`;
16         die "Not everything checked in or out?\n====\n$dirty====\n" if $dirty;
17         use lib "./lib";
18         my ($namespace) = $version_from;
19         $namespace =~ s|^lib/(.+)\.pm$|$1|;
20         $namespace =~ s|/|::|g;
21         eval qq{  require $namespace; }; die $@ if $@;
22         my $makefile = "Makefile";
23         unless (-f $makefile) {
24             $makefile = "Makefile.old";
25         }
26         unless (-f $makefile) {
27             die "no Makefile and no Makefile.old found";
28         }
29         open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
30         local $/;
31         my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
32         close $fh or die "Could not close: $!";
33         eval qq{ if (\$$namespace\::VERSION != \$version) {
34         warn "Not equal: $namespace\\::VERSION[\$$namespace\::VERSION] MM generated version[\$version]";
35         \$version_diff = 1;
36     }};
37     } elsif ($ARGV[0] eq "--trial") {
38         die "FIXME: --trial does not seem to work";
39         $version .= "-TRIAL";
40     }
42 my $trial = 0;
43 if ($trial) {
44     $version .= "-TRIAL";
45     if ($trial > 1) {
46         $version .= $trial;
47     }
50 my $provides = {
51                 "File::Rsync::Mirror::Recent" =>
52                 {
53                  version => $version,
54                  file => $version_from,
55                 }
56                };
57 for my $m (qw(Recentfile Recentfile::Done Recentfile::FakeBigFloat )) {
58     my $fullm = "File::Rsync::Mirror::$m";
59     my $file = $fullm;
60     $file =~ s/::/\//g;
61     $file = "lib/$file.pm";
62     my $v = MM->parse_version($file);
63     $provides->{$fullm} = {
64                            version => $v,
65                            file => $file,
66                           };
69 my $preferzip = "bzip2"; # bzip2 | gzip
70 WriteMakefile
71     (
72      NAME                => 'File::Rsync::Mirror::Recent',
73      VERSION             => $version,
74      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
75      PL_FILES            => {},
76      PREREQ_PM =>
77      {
78       # 'Data::Serializer' => 0.46, # restricted to YAML without it
79       'Data::Float'      => 0,
80       'Data::Serializer' => 0,
81       'ExtUtils::MakeMaker' => 6.48,
82       'File::Basename'   => 0,
83       'File::Find::Rule' => 0,
84       'File::Path'       => 0,
85       'File::Rsync'      => 0,
86       'File::Spec'       => 0,
87       'File::Temp'       => '0.21', # removes bogus test on parent directory
88       'FindBin'          => 0,
89       'Hash::Util'       => 0,
90       'JSON'             => '2',
91       'List::MoreUtils'  => 0,
92       'List::Pairwise'   => 0,
93       'Pod::Usage'       => '1.61', # 1.16 from perl-5.8.1 failed, 1.61 is
94                                     # the oldest working on CPAN now
95       'Scalar::Util'     => 0,
96       'Test::More'       => 0,
97       'Time::HiRes'      => 0,
98       'YAML::Syck'       => 0,
99       'accessors'        => 0,
100       'version'          => 0,
101      },
102      EXE_FILES    => [
103                       grep { !/~/ } glob("bin/rrr bin/rrr-*")
104                      ],
105      dist => {
106               DIST_DEFAULT => join(" ", # note: order matters!
107                                    "verify-changes-date",
108                                    "verify-changes-version",
109                                    "Makefile",
110                                    "META.yml",
111                                    "setversion",
112                                    "all",
113                                    "tardist",
114                                    "memo-howto-release",
115                                   ),
116               $preferzip eq "bzip2" ?
117               (COMPRESS => 'bzip2 -9f',
118                SUFFIX => ".bz2") :
119               (COMPRESS => 'gzip -9f',
120                SUFFIX => ".gz"),
121              },
122      META_MERGE => {
123                     # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
124                     resources => {
125                                   repository => "git://repo.or.cz/rersyncrecent.git",
126                                  },
127                     provides => $provides,
128                    },
129      MIN_PERL_VERSION => '5.006',
130      @sign,
131      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
132     );
134 if ($version_diff){
135   die "
136 ==> I had to update some \$VERSIONs <==
137 ==> Your Makefile has been rebuilt. <==
138 ==> Please rerun the make command.  <==
142 package MY;
143 sub distsignature {
144     my($self) = shift;
145     my $ret = $self->SUPER::distsignature_target(@_);
146     $ret =~ s|cpansign|\$(PERL) \`dirname \$(PERL)\`/cpansign|g;
147     return $ret;
149 sub postamble {
150   my @m;
151   push @m, q{
152 Makefile: }.$version_from.q{
154 META.yml: metafile
155         $(CP) $(DISTVNAME)/META.yml  ./META.yml
157 setversion:
158         $(PERL) Makefile.PL --setversion
160 reversion:
161         $(NOECHO) $(ECHO) AGAINST_TAG=$(AGAINST_TAG)
162         $(PERL) dagolden-reversion-gist.pl $(AGAINST_TAG)
164 verify-changes-date:
165         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
166                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
168 verify-changes-version:
169         @$(PERL) -ne '$$ok++,exit if /\b$(VERSION)\b/; END{die "Alert: did not find <$(VERSION)> in Changes file" unless $$ok}' Changes
171 verify-no-subdir:
172         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
173                 -e 'die"unexpected dir:$$s"if$$s'
175 the-release-name :
176         $(NOECHO) $(ECHO) 'version ' $(VERSION)
177         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
179 memo-howto-release:
180         $(NOECHO) $(ECHO) 'after successful make dist and upload do not forget to'
181         $(NOECHO) $(ECHO) ' make tag'
182         $(NOECHO) $(ECHO) ' git push --tags'
183         $(NOECHO) $(ECHO) 'before writing Changes do not forget to'
184         $(NOECHO) $(ECHO) ' git --no-pager log --no-merges --pretty=format:" %x20%x20 - %s (%an)" | less'
186 tag ::
187         git tag -m 'This is $(VERSION)' "$(VERSION)"
189 sign:
190         $(PERL) `dirname $(PERL)`/cpansign -s
192 test-server-run:
193         $(PERL) bin/rrr-init --force t/testserver
194         $(PERL) bin/rrr-server t/testserver/RECENT-1h.yaml &
195         $(PERL) bin/rrr-init --force t/testserver
197   join "", @m;
200 sub dist_test {
201   return q{
202 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
203 # Makefile breaks our intent to NOT remake dist
204 disttest :
205         rm -rf $(DISTVNAME)
206         tar xvjf $(DISTVNAME).tar$(SUFFIX)
207         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
208         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
209         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
211 distdir ::
212         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
213         $(CP) $(DISTVNAME)/META.yml  ./META.yml
214         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
219 sub distdir {
220   my $self = shift;
221   my $out = $self->SUPER::distdir;
222   $out =~ s/distdir :/distdir ::/g;
223   return $out;
226 # dist_dir was the name in very old MakeMaker as of 5.005_04
227 sub dist_dir {
228   my $self = shift;
229   my $out = $self->SUPER::dist_dir;
230   $out =~ s/distdir :/distdir ::/g;
231   return $out;