1 |
root |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
root |
1.4 |
Canary::Stability - canary to check perl compatibility for schmorp's modules |
4 |
root |
1.1 |
|
5 |
|
|
=head1 SYNOPSIS |
6 |
|
|
|
7 |
root |
1.4 |
# in Makefile.PL |
8 |
|
|
use Canary::Stability DISTNAME => 2001, MINIMUM_PERL_VERSION; |
9 |
root |
1.1 |
|
10 |
|
|
=head1 DESCRIPTION |
11 |
|
|
|
12 |
root |
1.4 |
This module is used by Schmorp's modules during configuration stage to |
13 |
|
|
test the installed perl for compatibility with his modules. |
14 |
|
|
|
15 |
|
|
It's not, at this stage, meant as a tool for other module authors, |
16 |
|
|
although in principle nothing prevents them from subscribing to the same |
17 |
|
|
ideas. |
18 |
|
|
|
19 |
|
|
See the F<Makefile.PL> in L<Coro> or L<AnyEvent> for usage examples. |
20 |
root |
1.1 |
|
21 |
|
|
=cut |
22 |
|
|
|
23 |
|
|
package Canary::Stability; |
24 |
|
|
|
25 |
|
|
BEGIN { |
26 |
root |
1.10 |
$VERSION = 2013; |
27 |
root |
1.2 |
} |
28 |
|
|
|
29 |
|
|
sub sgr { |
30 |
|
|
# we just assume ANSI almost everywhere |
31 |
|
|
# red 31, yellow 33, green 32 |
32 |
root |
1.7 |
local $| = 1; |
33 |
root |
1.2 |
|
34 |
|
|
$ENV{PERL_CANARY_STABILITY_COLOUR} ne 0 |
35 |
|
|
and ((-t STDOUT and length $ENV{TERM}) or $ENV{PERL_CANARY_STABILITY_COLOUR}) |
36 |
|
|
and print "\e[$_[0]m"; |
37 |
root |
1.1 |
} |
38 |
|
|
|
39 |
|
|
sub import { |
40 |
root |
1.2 |
my (undef, $distname, $minvers, $minperl) = @_; |
41 |
|
|
|
42 |
|
|
$ENV{PERL_CANARY_STABILITY_DISABLE} |
43 |
|
|
and return; |
44 |
|
|
|
45 |
|
|
$minperl ||= 5.008002; |
46 |
|
|
|
47 |
root |
1.8 |
print <<EOF; |
48 |
|
|
|
49 |
|
|
*** |
50 |
|
|
*** Canary::Stability COMPATIBILITY AND SUPPORT CHECK |
51 |
|
|
*** ================================================= |
52 |
|
|
*** |
53 |
|
|
*** Hi! |
54 |
|
|
*** |
55 |
|
|
*** I do my best to provide predictable and reliable software. |
56 |
|
|
*** |
57 |
|
|
*** However, in recent releases, P5P (who maintain perl) have been |
58 |
|
|
*** introducing regressions that are sometimes subtle and at other times |
59 |
|
|
*** catastrophic, often for personal preferences with little or no concern |
60 |
|
|
*** for existing code, most notably CPAN. |
61 |
|
|
*** |
62 |
|
|
*** For this reason, it has become very hard for me to maintain the level |
63 |
|
|
*** of reliability and support I have committed myself to in the past, at |
64 |
|
|
*** least with some perl versions: I simply can't keep up working around new |
65 |
|
|
*** bugs or gratituous incompatibilities, and in turn you might suffer from |
66 |
|
|
*** unanticipated problems. |
67 |
|
|
*** |
68 |
|
|
*** Therefore I have introduced a support and compatibility check, the results |
69 |
|
|
*** of which follow below, together with a FAQ and some recommendations. |
70 |
|
|
*** |
71 |
|
|
*** This check is just to let you know that there might be a risk, so you can |
72 |
|
|
*** make judgement calls on how to proceed - it will not keep the module from |
73 |
|
|
*** installing or working. |
74 |
|
|
*** |
75 |
|
|
EOF |
76 |
|
|
|
77 |
root |
1.2 |
if ($minvers > $VERSION) { |
78 |
|
|
sgr 33; |
79 |
|
|
print <<EOF; |
80 |
root |
1.3 |
*** The stability canary says: (nothing, it died of old age). |
81 |
root |
1.2 |
*** |
82 |
|
|
*** Your Canary::Stability module (used by $distname) is too old. |
83 |
|
|
*** This is not a fatal problem - while you might want to upgrade to version |
84 |
|
|
*** $minvers (currently installed version: $VERSION) to get better support |
85 |
|
|
*** status testing, you might also not want to care at all, and all will |
86 |
|
|
*** be well as long $distname works well enough for you, as the stability |
87 |
|
|
*** canary is only used when installing the distribution. |
88 |
root |
1.10 |
*** |
89 |
root |
1.2 |
EOF |
90 |
|
|
} elsif ($] < $minperl) { |
91 |
|
|
|
92 |
|
|
sgr 33; |
93 |
|
|
print <<EOF; |
94 |
root |
1.3 |
*** The stability canary says: chirp (it seems concerned about something). |
95 |
root |
1.2 |
*** |
96 |
|
|
*** Your perl version ($]) is older than the $distname distribution |
97 |
|
|
*** likes ($minperl). This is not a fatal problem - the module might work |
98 |
|
|
*** well with your version of perl, but it does mean the author likely |
99 |
root |
1.3 |
*** won't do anything to make it work if it breaks. |
100 |
root |
1.10 |
*** |
101 |
|
|
EOF |
102 |
|
|
|
103 |
|
|
if ($ENV{AUTOMATED_TESTING}) { |
104 |
|
|
print <<EOF; |
105 |
|
|
*** Since this is an AUTOMATED_TESTING environment, the stability canary |
106 |
|
|
*** decided to fail cleanly here, rather than to generate a false test |
107 |
|
|
*** result. |
108 |
|
|
*** |
109 |
root |
1.2 |
EOF |
110 |
root |
1.10 |
exit 0; |
111 |
|
|
} |
112 |
|
|
|
113 |
root |
1.2 |
} elsif (defined $Internals::StabilityBranchVersion) { |
114 |
|
|
# note to people studying this modules sources: |
115 |
|
|
# the above test is not considered a clean or stable way to |
116 |
|
|
# test for the stability branch. |
117 |
|
|
|
118 |
|
|
sgr 32; |
119 |
|
|
print <<EOF; |
120 |
|
|
*** The stability canary says: chirp! chirp! (it seems to be quite excited) |
121 |
|
|
*** |
122 |
|
|
*** It seems you are running schmorp's stability branch of perl. |
123 |
|
|
*** All should be well, and if it isn't, you should report this as a bug |
124 |
|
|
*** to the $distname author. |
125 |
root |
1.10 |
*** |
126 |
root |
1.2 |
EOF |
127 |
root |
1.6 |
} elsif ($] < 5.021) { |
128 |
root |
1.3 |
#sgr 32; |
129 |
root |
1.2 |
print <<EOF; |
130 |
|
|
*** The stability canary says: chirp! chirp! (it seems to be quite happy) |
131 |
|
|
*** |
132 |
|
|
*** Your version of perl ($]) is quite supported by $distname, nothing |
133 |
|
|
*** else to be said, hope it comes in handy. |
134 |
root |
1.10 |
*** |
135 |
root |
1.2 |
EOF |
136 |
|
|
} else { |
137 |
|
|
sgr 31; |
138 |
|
|
print <<EOF; |
139 |
|
|
*** The stability canary says: (nothing, it was driven away by harsh weather) |
140 |
|
|
*** |
141 |
|
|
*** It seems you are running perl version $], likely the "official" or |
142 |
|
|
*** "standard" version. While there is nothing wrong with doing that, |
143 |
|
|
*** standard perl versions 5.022 and up are not supported by $distname. |
144 |
|
|
*** While this might be fatal, it might also be all right - if you run into |
145 |
|
|
*** problems, you might want to downgrade your perl or switch to the |
146 |
|
|
*** stability branch. |
147 |
|
|
*** |
148 |
|
|
*** If everything works fine, you can ignore this message. |
149 |
root |
1.10 |
*** |
150 |
root |
1.2 |
EOF |
151 |
|
|
sgr 0; |
152 |
|
|
print <<EOF; |
153 |
root |
1.8 |
*** |
154 |
root |
1.2 |
*** Stability canary mini-FAQ: |
155 |
|
|
*** |
156 |
|
|
*** Do I need to do anything? |
157 |
|
|
*** With luck, no. While some distributions are known to fail |
158 |
|
|
*** already, most should probably work. This message is here |
159 |
|
|
*** to alert you that your perl is not supported by $distname, |
160 |
|
|
*** and if things go wrong, you either need to downgrade, or |
161 |
|
|
*** sidegrade to the stability variant of your perl version, |
162 |
|
|
*** or simply live with the consequences. |
163 |
|
|
*** |
164 |
|
|
*** What is this canary thing? |
165 |
|
|
*** It's purpose is to check support status of $distname with |
166 |
|
|
*** respect to your perl version. |
167 |
|
|
*** |
168 |
|
|
*** What is this "stability branch"? |
169 |
|
|
*** It's a branch or fork of the official perl, by schmorp, to |
170 |
|
|
*** improve stability and compatibility with existing modules. |
171 |
|
|
*** |
172 |
|
|
*** How can I skip this prompt on automated installs? |
173 |
|
|
*** Set PERL_CANARY_STABILITY_NOPROMPT=1 in your environment. |
174 |
|
|
*** More info is in the Canary::Stability manpage. |
175 |
|
|
*** |
176 |
root |
1.5 |
*** Long version of this FAQ: http://stableperl.schmorp.de/faq.html |
177 |
|
|
*** Stability Branch homepage: http://stableperl.schmorp.de/ |
178 |
root |
1.2 |
*** |
179 |
|
|
|
180 |
|
|
EOF |
181 |
|
|
|
182 |
|
|
unless ($ENV{PERL_CANARY_STABILITY_NOPROMPT}) { |
183 |
|
|
require ExtUtils::MakeMaker; |
184 |
|
|
|
185 |
|
|
ExtUtils::MakeMaker::prompt ("Continue anyways? ", "y") =~ /^y/i |
186 |
|
|
or die "FATAL: User aborted configuration of $distname.\n"; |
187 |
|
|
} |
188 |
|
|
} |
189 |
|
|
|
190 |
|
|
sgr 0; |
191 |
root |
1.1 |
} |
192 |
|
|
|
193 |
root |
1.2 |
=head1 ENVIRONMENT VARIABLES |
194 |
|
|
|
195 |
|
|
=over 4 |
196 |
|
|
|
197 |
|
|
=item C<PERL_CANARY_STABILITY_NOPROMPT=1> |
198 |
|
|
|
199 |
|
|
Do not prompt the user on alert messages. |
200 |
|
|
|
201 |
|
|
=item C<PERL_CANARY_STABILITY_COLOUR=0> |
202 |
|
|
|
203 |
|
|
Disable use of colour. |
204 |
|
|
|
205 |
|
|
=item C<PERL_CANARY_STABILITY_COLOUR=1> |
206 |
|
|
|
207 |
|
|
Force use of colour. |
208 |
|
|
|
209 |
|
|
=item C<PERL_CANARY_STABILITY_DISABLE=1> |
210 |
|
|
|
211 |
|
|
Disable this modules functionality completely. |
212 |
|
|
|
213 |
root |
1.10 |
=item C<AUTOMATED_TESTING=1> |
214 |
|
|
|
215 |
|
|
When this variable is set to a true value and the perl minimum version |
216 |
|
|
requirement is not met, the module will exit, which should skip testing |
217 |
|
|
under automated testing environments. |
218 |
|
|
|
219 |
|
|
This is done to avoid false failure or success reports when the chances of |
220 |
|
|
success are already quite low and the failures are not supported by the |
221 |
|
|
author. |
222 |
|
|
|
223 |
root |
1.2 |
=back |
224 |
|
|
|
225 |
root |
1.1 |
=head1 AUTHOR |
226 |
|
|
|
227 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
228 |
root |
1.6 |
http://software.schmorp.de/pkg/Canary-Stability.html |
229 |
root |
1.1 |
|
230 |
|
|
=cut |
231 |
|
|
|
232 |
|
|
1 |
233 |
|
|
|