-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile.PL
181 lines (150 loc) · 5.99 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# -*- cperl -*-
use 5.010; # defined-or
use strict;
use Cwd 'realpath', 'getcwd';
use ExtUtils::MakeMaker;
my $eumm_recent_enough = $ExtUtils::MakeMaker::VERSION >= 6.54;
if (!$eumm_recent_enough) {
*MY::dist_core = sub {
<<'EOF';
dist :
$(NOECHO) $(ECHO) "Sorry, use a newer EUMM!"
EOF
};
}
WriteMakefile(NAME => 'CPAN::Testers::Matrix',
VERSION_FROM => 'cgi-bin/cpantestersmatrix.pl',
($eumm_recent_enough ?
(META_ADD => { resources => { repository => 'git://github.com/eserte/cpan-testers-matrix.git' },
}) : ()),
PREREQ_PM => {
'CGI' => 0,
'CPAN::DistnameInfo' => 0,
'CPAN::Version' => 0,
'Gravatar::URL' => 0, # optional
'HTML::Table' => 0,
'Kwalify' => 0, # only for validation of "amendment" data
'LWP' => 5.808,
'Parse::CPAN::Packages::Fast' => 0, # may work also without
'URI::Query' => 0.08, # escaping is wrong before this version
'version' => 0.76, # may work also with CPAN::Version
'JSON::XS' => 0,
'YAML::Syck' => 0, # may work also with YAML, but not recommended
},
MIN_PERL_VERSION => 5.10.0,
);
sub MY::postamble {
my $srcroot = realpath(getcwd().'/../..');
my $postamble = '';
my $fix_permissions_data_target = (
$^O eq 'freebsd' ? 'fix-permissions-data-freebsd' :
$^O eq 'linux' && getpwnam('www-data') ? 'fix-permissions-data-debian' :
'fix-permissions-data-unhandled'
);
$postamble .= "fix-permissions-data: $fix_permissions_data_target\n\n";
$postamble .= <<"EOF";
SRCROOT= $srcroot
EOF
$postamble .= <<'EOF';
validate-cpantestersmatrix-data:
pkwalify -f etc/cpantesters_amendments.kwalify data/cpantesters_amendments.yml
validate-config:
[ ! -e cgi-bin/cpantestersmatrix.yml ] || pkwalify -f etc/cpantestersmatrix_config.kwalify cgi-bin/cpantestersmatrix.yml
update: git-pull fix-permissions
git-pull:
git pull --ff-only
fix-permissions: fix-permissions-data
chmod ugo+rx cgi-bin/cpantestersmatrix.pl cgi-bin/zdjelameda.pl
chmod ugo+r data/*.yml htdocs/* images/*
fix-permissions-data-freebsd:
sudo chgrp www data
sudo chmod g+w data
fix-permissions-data-debian:
sudo chgrp www-data data
sudo chmod g+w data
BOTCHECKER= ${SRCROOT}/botchecker/Botchecker.pm
BOTCHECKER_JS= ${SRCROOT}/botchecker/Botchecker_js.pm
EOF
for my $def (
['live', 'live-matrix', '/srv/www'],
['pps', 'pps-matrix', '/root/work'],
['pps-jessie', 'pps-jessie-matrix', '/srv/www'],
) {
my($type, $host, $wwwroot) = @$def;
if ($type eq 'pps' || $type eq 'pps-jessie') {
$postamble .= <<EOF;
update-$type-from-home: rsync-$type-cpantestersmatrix
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.beta && git fetch home && git checkout home/master'
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.fast && git fetch home && git checkout home/master'
ssh -A $host 'cd $wwwroot/cpan-testers-matrix && git fetch home && git checkout home/master'
update-$type: rsync-$type-cpantestersmatrix
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.beta && git checkout master && git pull --ff-only'
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.fast && git checkout master && git pull --ff-only'
ssh -A $host 'cd $wwwroot/cpan-testers-matrix && git checkout master && git pull --ff-only'
EOF
} else {
$postamble .= <<EOF;
update-$type-beta: rsync-$type-cpantestersmatrix-beta
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.beta && git checkout master && git pull --ff-only'
update-$type-beta-from-home: rsync-$type-cpantestersmatrix-beta
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.beta && git fetch home && git checkout home/master'
update-$type-fast: rsync-$type-cpantestersmatrix-fast
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.fast && git checkout master && git pull --ff-only'
update-$type-fast-from-home: rsync-$type-cpantestersmatrix-fast
ssh -A $host 'cd $wwwroot/cpan-testers-matrix.fast && git fetch home && git checkout home/master'
update-$type-stable: rsync-$type-cpantestersmatrix
ssh -A $host 'cd $wwwroot/cpan-testers-matrix && git checkout master && git pull --ff-only'
EOF
}
$postamble .= <<EOF;
rsync-$type-cpantestersmatrix: rsync-$type-cpantestersmatrix-beta rsync-$type-cpantestersmatrix-fast rsync-$type-cpantestersmatrix-stable
rsync-$type-cpantestersmatrix-beta:
perl -c \${BOTCHECKER}
perl -c \${BOTCHECKER_JS}
rsync -av \${BOTCHECKER} \${BOTCHECKER_JS} $host:$wwwroot/cpan-testers-matrix.beta/cgi-bin/
rsync-$type-cpantestersmatrix-fast:
perl -c \${BOTCHECKER}
perl -c \${BOTCHECKER_JS}
rsync -av \${BOTCHECKER} \${BOTCHECKER_JS} $host:$wwwroot/cpan-testers-matrix.fast/cgi-bin/
rsync-$type-cpantestersmatrix-stable:
perl -c \${BOTCHECKER}
perl -c \${BOTCHECKER_JS}
rsync -av \${BOTCHECKER} \${BOTCHECKER_JS} $host:$wwwroot/cpan-testers-matrix/cgi-bin/
fix-$type-cpantestersmatrix-permissions:
ssh $host chgrp www-data $wwwroot/cpantestersmatrix
ssh $host chmod g+w $wwwroot/cpantestersmatrix
EOF
}
if (defined $ENV{USER} && $ENV{USER} eq 'eserte') {
if ($^O =~ /bsd/i) { # assume BSD make
$postamble .= <<'EOF';
GIT_TAG_DATE= $(shell date +%Y%m%d)
EOF
} else { # assume GNU make
$postamble .= <<'EOF';
GIT_TAG_DATE!= date +%Y%m%d
EOF
}
$postamble .= <<'EOF';
GIT_TAG= deployment/bbbikede/${GIT_TAG_DATE}
git-post-tasks:
git diff-index --quiet --cached HEAD
git diff-files --quiet || (\
echo "There are uncommitted changes"; \
git diff-files; \
false; \
)
test -z "$$(git ls-files --exclude-standard --others)" || (\
echo "There are untracked files"; \
git ls-files --exclude-standard --others; \
false; \
)
$(NOECHO) echo -n "This will tag version $(GIT_TAG) and push the default branch and the current tag. OK? "
$(NOECHO) read yn
git tag -a -m "* $(GIT_TAG)" $(GIT_TAG) || (echo "If setting this tag fails, then try using a suffix e.g. _2"; false)
git push
git push origin $(GIT_TAG)
EOF
}
$postamble;
}