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.6 by root, Sat Jun 27 17:00:20 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
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";
21} 36}
22 37
23sub import { 38sub import {
39 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*** The stability canary says: (nothing, it died of old age).
52***
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
61EOF
62 } elsif ($] < $minperl) {
63
64 sgr 33;
65 print <<EOF;
66
67***
68*** The stability canary says: chirp (it seems concerned about something).
69***
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*** won't do anything to make it work if it breaks.
74***
75
76EOF
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
93EOF
94 } elsif ($] < 5.021) {
95 #sgr 32;
96 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
105EOF
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***
122EOF
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*** Long version of this FAQ: http://stableperl.schmorp.de/faq.html
148*** Stability Branch homepage: http://stableperl.schmorp.de/
149***
150
151EOF
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 }
24 # 159 }
160
161 sgr 0;
25} 162}
163
164=head1 ENVIRONMENT VARIABLES
165
166=over 4
167
168=item C<PERL_CANARY_STABILITY_NOPROMPT=1>
169
170Do not prompt the user on alert messages.
171
172=item C<PERL_CANARY_STABILITY_COLOUR=0>
173
174Disable use of colour.
175
176=item C<PERL_CANARY_STABILITY_COLOUR=1>
177
178Force use of colour.
179
180=item C<PERL_CANARY_STABILITY_DISABLE=1>
181
182Disable this modules functionality completely.
183
184=back
26 185
27=head1 AUTHOR 186=head1 AUTHOR
28 187
29 Marc Lehmann <schmorp@schmorp.de> 188 Marc Lehmann <schmorp@schmorp.de>
30 http://home.schmorp.de/ 189 http://software.schmorp.de/pkg/Canary-Stability.html
31 190
32=cut 191=cut
33 192
341 1931
35 194

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines