additional talk about the protocol and its relation to bittorrent
[rersyncrecent.git] / Makefile.PL
blobddc1c051c188fd8d540dfd99205921c986c021b8
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] && $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     use lib "lib";
14     eval {  require $version_from; }; die $@ if $@;
15     my $makefile = "Makefile";
16     unless (-f $makefile) {
17         $makefile = "Makefile.old";
18     }
19     unless (-f $makefile) {
20         die "no Makefile and no Makefile.old found";
21     }
22     open my $fh, "make -f $makefile the-release-name|" or die "Could not fork: $!";
23     local $/;
24     my ($have_version) = <$fh> =~ /^version\s+([\d\._]+)/m;
25     close $fh or die "Could not close: $!";
26     my ($namespace) = $version_from;
27     $namespace =~ s|^lib/(.+)\.pm$|$1|;
28     $namespace =~ s|/|::|g;
29     eval qq{ if (\$$namespace\::VERSION != \$version) {
30         warn "Not equal: $namespace\\::VERSION[\$$namespace\::VERSION] MM generated version[\$version]";
31         \$version_diff = 1;
32     }};
35 WriteMakefile
36     (
37      NAME                => 'File::Rsync::Mirror::Recent',
38      VERSION             => $version,
39      AUTHOR              => 'Andreas König <andreas.koenig.7os6VVqR@franz.ak.mind.de>',
40      PL_FILES            => {},
41      PREREQ_PM =>
42      {
43       # 'Data::Serializer' => 0.46, # restricted to YAML without it
44       'accessors'        => 0,
45       'Data::Float'      => 0,
46       'File::Rsync'      => 0,
47       'Test::More'       => 0,
48       'File::Basename'   => 0,
49       'File::Path'       => 0,
50       'File::Temp'       => 0,
51       'List::MoreUtils'  => 0,
52       'List::Pairwise'   => 0,
53       'Scalar::Util'     => 0,
54       'Data::Serializer' => 0,
55       'Time::HiRes'      => 0,
56       'YAML::Syck'       => 0,
57       'version'          => 0,
58      },
59      EXE_FILES    => [qw(bin/rrr-aggregate bin/rrr-news)],
60      dist => {
61               DIST_DEFAULT => join(" ", # note: order matters!
62                                    "verify-changes-date",
63                                    "Makefile",
64                                    "META.yml",
65                                    "setversion",
66                                    "all",
67                                    "tardist",
68                                   ),
69               COMPRESS => 'bzip2 -9f',
70               SUFFIX => ".bz2",
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: }.$version_from.q{
102 META.yml: metafile
103         $(CP) $(DISTVNAME)/META.yml  ./META.yml
105 setversion:
106         $(PERL) Makefile.PL --setversion
108 verify-changes-date:
109         @$(PERL) -ne 'BEGIN{my@t=(localtime)[5,4,3];$$t[0]+=1900;$$t[1]++;$$t=sprintf"%04d-%02d-%02d",@t}' \
110                 -e '$$ok++,exit if /^$$t\s/; END{die "Alert: did not find <$$t> in Changes file" unless $$ok}' Changes
112 verify-no-subdir:
113         @$(PERL) -e 'my$$s=join",",grep{!/^($(OKDIRS))\z/x&&-d($$_)}glob"*";' \
114                 -e 'die"unexpected dir:$$s"if$$s'
116 the-release-name :
117         $(NOECHO) $(ECHO) 'version ' $(VERSION)
118         $(NOECHO) $(ECHO) 'release-name ' $(DISTVNAME).tar$(SUFFIX)
120 tag ::
121         git tag -m 'This is $(VERSION)' "$(VERSION)"
123 sign:
124         cpansign -s
126   join "", @m;
129 sub dist_test {
130   return q{
131 # if we depend on $(DISTVNAME).tar$(SUFFIX), then the rest of the
132 # Makefile breaks our intent to NOT remake dist
133 disttest :
134         rm -rf $(DISTVNAME)
135         tar xvjf $(DISTVNAME).tar$(SUFFIX)
136         cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
137         cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
138         cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
140 distdir ::
141         touch $(DISTVNAME)/SIGNATURE && $(CP) $(DISTVNAME)/SIGNATURE ./SIGNATURE
142         $(CP) $(DISTVNAME)/META.yml  ./META.yml
143         $(CP) $(DISTVNAME)/MANIFEST  ./MANIFEST
148 sub distdir {
149   my $self = shift;
150   my $out = $self->SUPER::distdir;
151   $out =~ s/distdir :/distdir ::/g;
152   return $out;
155 # dist_dir was the name in very old MakeMaker as of 5.005_04
156 sub dist_dir {
157   my $self = shift;
158   my $out = $self->SUPER::dist_dir;
159   $out =~ s/distdir :/distdir ::/g;
160   return $out;