ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Canary-Stability/Stability.pm
(Generate patch)

Comparing Canary-Stability/Stability.pm (file contents):
Revision 1.1 by root, Wed Jun 3 20:29:47 2015 UTC vs.
Revision 1.7 by root, Mon Jun 29 00:02:01 2015 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines