ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Canary-Stability/Stability.pm
Revision: 1.2
Committed: Thu Jun 4 16:18:26 2015 UTC (8 years, 11 months ago) by root
Branch: MAIN
Changes since 1.1: +157 -3 lines
Log Message:
*** empty log message ***

File Contents

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