oops, we made first the release, then the checkin; sorry about that
[rersyncrecent.git] / Makefile.PL
blobeea7a3a2fb096260b2711d59d6015b3eb3340a9c
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].\nYou should get a new one\n"
13             if $ExtUtils::MakeMaker::VERSION < 6.4502;
14         use lib "lib";
15         eval {  require $version_from; }; die $@ if $@;
16         my $makefile = "Makefile";
17         unless (-f $makefile) {
18             $makefile = "Makefile.old";
19         }
20         unless (-f $makefile) {
21             die "no Makefile and no Makefile.old found";
22         }
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 != \$version) {
31         warn "Not equal: $namespace\\::VERSION[\$$namespace\::VERSION] MM generated version[\$version]";
32         \$version_diff = 1;
33     }};
34     } elsif ($ARGV[0] eq "--trial") {
35         die "FIXME: --trial does not seem to work";
36         $version .= "-TRIAL";
37     }
39 # $version .= "-TRIAL";
41 my $provides = {
42                 "File::Rsync::Mirror::Recent" =>
43                 {
44                  version => $version,
45                  file => $version_from,
46                 }
47                };
48 for my $m (qw(Recentfile Recentfile::Done Recentfile::FakeBigFloat )) {
49     my $fullm = "File::Rsync::Mirror::$m";
50     my $file = $fullm;
51     $file =~ s/::/\//g;
52     $file = "lib/$file.pm";
53     my $v = MM->parse_version($file);
54     $provides->{$fullm} = {
55                            version => $v,
56                            file => $file,
57                           };
60 my $preferzip = "bzip2"; # bzip2 | gzip
61 WriteMakefile
62     (
63      NAME                => 'File::Rsync::Mirror::Recent',
64      VERSION             => $version,
65      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
66      PL_FILES            => {},
67      PREREQ_PM =>
68      {
69       # 'Data::Serializer' => 0.46, # restricted to YAML without it
70       'accessors'        => 0,
71       'Data::Float'      => 0,
72       'File::Rsync'      => 0,
73       'Test::More'       => 0,
74       'File::Basename'   => 0,
75       'File::Find::Rule' => 0,
76       'File::Path'       => 0,
77       'File::Spec'       => 0,
78       'File::Temp'       => 0.21, # removes bogus test on parent directory
79       'List::MoreUtils'  => 0,
80       'List::Pairwise'   => 0,
81       'Scalar::Util'     => 0,
82       'Data::Serializer' => 0,
83       'Time::HiRes'      => 0,
84       'YAML::Syck'       => 0,
85       'JSON'             => 2,
86       'version'          => 0,
87      },
88      EXE_FILES    => [
89                       grep { !/~/ } glob("bin/rrr bin/rrr-*")
90                      ],
91      dist => {
92               DIST_DEFAULT => join(" ", # note: order matters!
93                                    "verify-changes-date",
94                                    "Makefile",
95                                    "META.yml",
96                                    "setversion",
97                                    "all",
98                                    "tardist",
99                                    "memo-howto-release",
100                                   ),
101               $preferzip eq "bzip2" ?
102               (COMPRESS => 'bzip2 -9f',
103                SUFFIX => ".bz2") :
104               (COMPRESS => 'gzip -9f',
105                SUFFIX => ".gz"),
106              },
107      ($ExtUtils::MakeMaker::VERSION >= 6.4502 ?
108       (META_MERGE => {
109                       # write: git push git+ssh://repo.or.cz/srv/git/rersyncrecent.git master
110                       resources => {
111                                     repository => "git://repo.or.cz/rersyncrecent.git",
112                                    },
113                       provides => $provides,
114                      }) : ()),
115      @sign,
116      clean               => { FILES => 'File-Rsync-Mirror-Recent-*' },
117     );
119 if ($version_diff){
120   die "
121 ==> I had to update some \$VERSIONs <==
122 ==> Your Makefile has been rebuilt. <==
123 ==> Please rerun the make command.  <==
127 package MY;
128 sub distsignature {
129     my($self) = shift;
130     my $ret = $self->SUPER::distsignature_target(@_);
131     $ret =~ s|cpansign|\$(PERL) \`dirname \$(PERL)\`/cpansign|g;
132     return $ret;
134 sub postamble {
135   my @m;
136   push @m, q{
137 Makefile: }.$version_from.q{
139 META.yml: metafile
140         $(CP) $(DISTVNAME)/META.yml  ./META.yml
142 setversion:
143         $(PERL) Makefile.PL --setversion
145 verify-changes-date:
146         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
147                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
149 verify-no-subdir:
150         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
151                 -e 'die"unexpected dir:$$s"if$$s'
153 the-release-name :
154         $(NOECHO) $(ECHO) 'version ' $(VERSION)
155         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
157 memo-howto-release:
158         $(NOECHO) $(ECHO) 'after successful make dist and upload do not forget to'
159         $(NOECHO) $(ECHO) ' make tag'
160         $(NOECHO) $(ECHO) ' git push --tags'
161         $(NOECHO) $(ECHO) 'before writing Changes do not forget to'
162         $(NOECHO) $(ECHO) ' git --no-pager log --no-merges --pretty=format:" %x20%x20 - %s (%an)" | less'
164 tag ::
165         git tag -m 'This is $(VERSION)' "$(VERSION)"
167 sign:
168         $(PERL) `dirname $(PERL)`/cpansign -s
170 test-server-run:
171         $(PERL) bin/rrr-init --force t/testserver
172         $(PERL) bin/rrr-server t/testserver/RECENT-1h.yaml &
173         $(PERL) bin/rrr-init --force t/testserver
175   join "", @m;
178 sub dist_test {
179   return q{
180 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
181 # Makefile breaks our intent to NOT remake dist
182 disttest :
183         rm -rf $(DISTVNAME)
184         tar xvjf $(DISTVNAME).tar$(SUFFIX)
185         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
186         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
187         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
189 distdir ::
190         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
191         $(CP) $(DISTVNAME)/META.yml  ./META.yml
192         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
197 sub distdir {
198   my $self = shift;
199   my $out = $self->SUPER::distdir;
200   $out =~ s/distdir :/distdir ::/g;
201   return $out;
204 # dist_dir was the name in very old MakeMaker as of 5.005_04
205 sub dist_dir {
206   my $self = shift;
207   my $out = $self->SUPER::dist_dir;
208   $out =~ s/distdir :/distdir ::/g;
209   return $out;