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.3 |
$VERSION = 2001; |
27 |
root |
1.2 |
} |
28 |
|
|
|
29 |
|
|
sub sgr { |
30 |
|
|
# we just assume ANSI almost everywhere |
31 |
|
|
# red 31, yellow 33, green 32 |
32 |
|
|
|
33 |
|
|
$ENV{PERL_CANARY_STABILITY_COLOUR} ne 0 |
34 |
|
|
and ((-t STDOUT and length $ENV{TERM}) or $ENV{PERL_CANARY_STABILITY_COLOUR}) |
35 |
|
|
and print "\e[$_[0]m"; |
36 |
root |
1.1 |
} |
37 |
|
|
|
38 |
|
|
sub import { |
39 |
root |
1.2 |
my (undef, $distname, $minvers, $minperl) = @_; |
40 |
|
|
|
41 |
|
|
$ENV{PERL_CANARY_STABILITY_DISABLE} |
42 |
|
|
and return; |
43 |
|
|
|
44 |
|
|
$minperl ||= 5.008002; |
45 |
|
|
|
46 |
|
|
if ($minvers > $VERSION) { |
47 |
|
|
sgr 33; |
48 |
|
|
print <<EOF; |
49 |
|
|
|
50 |
|
|
*** |
51 |
root |
1.3 |
*** The stability canary says: (nothing, it died of old age). |
52 |
root |
1.2 |
*** |
53 |
|
|
*** Your Canary::Stability module (used by $distname) is too old. |
54 |
|
|
*** This is not a fatal problem - while you might want to upgrade to version |
55 |
|
|
*** $minvers (currently installed version: $VERSION) to get better support |
56 |
|
|
*** status testing, you might also not want to care at all, and all will |
57 |
|
|
*** be well as long $distname works well enough for you, as the stability |
58 |
|
|
*** canary is only used when installing the distribution. |
59 |
|
|
*** |
60 |
|
|
|
61 |
|
|
EOF |
62 |
|
|
} elsif ($] < $minperl) { |
63 |
|
|
|
64 |
|
|
sgr 33; |
65 |
|
|
print <<EOF; |
66 |
|
|
|
67 |
|
|
*** |
68 |
root |
1.3 |
*** The stability canary says: chirp (it seems concerned about something). |
69 |
root |
1.2 |
*** |
70 |
|
|
*** Your perl version ($]) is older than the $distname distribution |
71 |
|
|
*** likes ($minperl). This is not a fatal problem - the module might work |
72 |
|
|
*** well with your version of perl, but it does mean the author likely |
73 |
root |
1.3 |
*** won't do anything to make it work if it breaks. |
74 |
root |
1.2 |
*** |
75 |
|
|
|
76 |
|
|
EOF |
77 |
|
|
} elsif (defined $Internals::StabilityBranchVersion) { |
78 |
|
|
# note to people studying this modules sources: |
79 |
|
|
# the above test is not considered a clean or stable way to |
80 |
|
|
# test for the stability branch. |
81 |
|
|
|
82 |
|
|
sgr 32; |
83 |
|
|
print <<EOF; |
84 |
|
|
|
85 |
|
|
*** |
86 |
|
|
*** The stability canary says: chirp! chirp! (it seems to be quite excited) |
87 |
|
|
*** |
88 |
|
|
*** It seems you are running schmorp's stability branch of perl. |
89 |
|
|
*** All should be well, and if it isn't, you should report this as a bug |
90 |
|
|
*** to the $distname author. |
91 |
|
|
*** |
92 |
|
|
|
93 |
|
|
EOF |
94 |
root |
1.3 |
} elsif ($] <= 5.020) { |
95 |
|
|
#sgr 32; |
96 |
root |
1.2 |
print <<EOF; |
97 |
|
|
|
98 |
|
|
*** |
99 |
|
|
*** The stability canary says: chirp! chirp! (it seems to be quite happy) |
100 |
|
|
*** |
101 |
|
|
*** Your version of perl ($]) is quite supported by $distname, nothing |
102 |
|
|
*** else to be said, hope it comes in handy. |
103 |
|
|
*** |
104 |
|
|
|
105 |
|
|
EOF |
106 |
|
|
} else { |
107 |
|
|
sgr 31; |
108 |
|
|
print <<EOF; |
109 |
|
|
|
110 |
|
|
*** |
111 |
|
|
*** The stability canary says: (nothing, it was driven away by harsh weather) |
112 |
|
|
*** |
113 |
|
|
*** It seems you are running perl version $], likely the "official" or |
114 |
|
|
*** "standard" version. While there is nothing wrong with doing that, |
115 |
|
|
*** standard perl versions 5.022 and up are not supported by $distname. |
116 |
|
|
*** While this might be fatal, it might also be all right - if you run into |
117 |
|
|
*** problems, you might want to downgrade your perl or switch to the |
118 |
|
|
*** stability branch. |
119 |
|
|
*** |
120 |
|
|
*** If everything works fine, you can ignore this message. |
121 |
|
|
*** |
122 |
|
|
EOF |
123 |
|
|
sgr 0; |
124 |
|
|
print <<EOF; |
125 |
|
|
*** Stability canary mini-FAQ: |
126 |
|
|
*** |
127 |
|
|
*** Do I need to do anything? |
128 |
|
|
*** With luck, no. While some distributions are known to fail |
129 |
|
|
*** already, most should probably work. This message is here |
130 |
|
|
*** to alert you that your perl is not supported by $distname, |
131 |
|
|
*** and if things go wrong, you either need to downgrade, or |
132 |
|
|
*** sidegrade to the stability variant of your perl version, |
133 |
|
|
*** or simply live with the consequences. |
134 |
|
|
*** |
135 |
|
|
*** What is this canary thing? |
136 |
|
|
*** It's purpose is to check support status of $distname with |
137 |
|
|
*** respect to your perl version. |
138 |
|
|
*** |
139 |
|
|
*** What is this "stability branch"? |
140 |
|
|
*** It's a branch or fork of the official perl, by schmorp, to |
141 |
|
|
*** improve stability and compatibility with existing modules. |
142 |
|
|
*** |
143 |
|
|
*** How can I skip this prompt on automated installs? |
144 |
|
|
*** Set PERL_CANARY_STABILITY_NOPROMPT=1 in your environment. |
145 |
|
|
*** More info is in the Canary::Stability manpage. |
146 |
|
|
*** |
147 |
root |
1.5 |
*** Long version of this FAQ: http://stableperl.schmorp.de/faq.html |
148 |
|
|
*** Stability Branch homepage: http://stableperl.schmorp.de/ |
149 |
root |
1.2 |
*** |
150 |
|
|
|
151 |
|
|
EOF |
152 |
|
|
|
153 |
|
|
unless ($ENV{PERL_CANARY_STABILITY_NOPROMPT}) { |
154 |
|
|
require ExtUtils::MakeMaker; |
155 |
|
|
|
156 |
|
|
ExtUtils::MakeMaker::prompt ("Continue anyways? ", "y") =~ /^y/i |
157 |
|
|
or die "FATAL: User aborted configuration of $distname.\n"; |
158 |
|
|
} |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
sgr 0; |
162 |
root |
1.1 |
} |
163 |
|
|
|
164 |
root |
1.2 |
=head1 ENVIRONMENT VARIABLES |
165 |
|
|
|
166 |
|
|
=over 4 |
167 |
|
|
|
168 |
|
|
=item C<PERL_CANARY_STABILITY_NOPROMPT=1> |
169 |
|
|
|
170 |
|
|
Do not prompt the user on alert messages. |
171 |
|
|
|
172 |
|
|
=item C<PERL_CANARY_STABILITY_COLOUR=0> |
173 |
|
|
|
174 |
|
|
Disable use of colour. |
175 |
|
|
|
176 |
|
|
=item C<PERL_CANARY_STABILITY_COLOUR=1> |
177 |
|
|
|
178 |
|
|
Force use of colour. |
179 |
|
|
|
180 |
|
|
=item C<PERL_CANARY_STABILITY_DISABLE=1> |
181 |
|
|
|
182 |
|
|
Disable this modules functionality completely. |
183 |
|
|
|
184 |
|
|
=back |
185 |
|
|
|
186 |
root |
1.1 |
=head1 AUTHOR |
187 |
|
|
|
188 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
189 |
|
|
http://home.schmorp.de/ |
190 |
|
|
|
191 |
|
|
=cut |
192 |
|
|
|
193 |
|
|
1 |
194 |
|
|
|