ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Canary-Stability/Stability.pm
Revision: 1.8
Committed: Sun Mar 13 03:44:43 2016 UTC (8 years, 2 months ago) by root
Branch: MAIN
CVS Tags: rel_2011
Changes since 1.7: +33 -20 lines
Log Message:
2011

File Contents

# User Rev Content
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.8 $VERSION = 2011;
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 sgr 33;
48     print <<EOF;
49    
50     ***
51     *** Canary::Stability COMPATIBILITY AND SUPPORT CHECK
52     *** =================================================
53     ***
54     *** Hi!
55     ***
56     *** I do my best to provide predictable and reliable software.
57     ***
58     *** However, in recent releases, P5P (who maintain perl) have been
59     *** introducing regressions that are sometimes subtle and at other times
60     *** catastrophic, often for personal preferences with little or no concern
61     *** for existing code, most notably CPAN.
62     ***
63     *** For this reason, it has become very hard for me to maintain the level
64     *** of reliability and support I have committed myself to in the past, at
65     *** least with some perl versions: I simply can't keep up working around new
66     *** bugs or gratituous incompatibilities, and in turn you might suffer from
67     *** unanticipated problems.
68     ***
69     *** Therefore I have introduced a support and compatibility check, the results
70     *** of which follow below, together with a FAQ and some recommendations.
71     ***
72     *** This check is just to let you know that there might be a risk, so you can
73     *** make judgement calls on how to proceed - it will not keep the module from
74     *** installing or working.
75     ***
76     EOF
77    
78 root 1.2 if ($minvers > $VERSION) {
79     sgr 33;
80     print <<EOF;
81 root 1.3 *** The stability canary says: (nothing, it died of old age).
82 root 1.2 ***
83     *** Your Canary::Stability module (used by $distname) is too old.
84     *** This is not a fatal problem - while you might want to upgrade to version
85     *** $minvers (currently installed version: $VERSION) to get better support
86     *** status testing, you might also not want to care at all, and all will
87     *** be well as long $distname works well enough for you, as the stability
88     *** canary is only used when installing the distribution.
89     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.2 EOF
101     } elsif (defined $Internals::StabilityBranchVersion) {
102     # note to people studying this modules sources:
103     # the above test is not considered a clean or stable way to
104     # test for the stability branch.
105    
106     sgr 32;
107     print <<EOF;
108     *** The stability canary says: chirp! chirp! (it seems to be quite excited)
109     ***
110     *** It seems you are running schmorp's stability branch of perl.
111     *** All should be well, and if it isn't, you should report this as a bug
112     *** to the $distname author.
113     EOF
114 root 1.6 } elsif ($] < 5.021) {
115 root 1.3 #sgr 32;
116 root 1.2 print <<EOF;
117     *** The stability canary says: chirp! chirp! (it seems to be quite happy)
118     ***
119     *** Your version of perl ($]) is quite supported by $distname, nothing
120     *** else to be said, hope it comes in handy.
121     EOF
122     } else {
123     sgr 31;
124     print <<EOF;
125     *** The stability canary says: (nothing, it was driven away by harsh weather)
126     ***
127     *** It seems you are running perl version $], likely the "official" or
128     *** "standard" version. While there is nothing wrong with doing that,
129     *** standard perl versions 5.022 and up are not supported by $distname.
130     *** While this might be fatal, it might also be all right - if you run into
131     *** problems, you might want to downgrade your perl or switch to the
132     *** stability branch.
133     ***
134     *** If everything works fine, you can ignore this message.
135     EOF
136     sgr 0;
137     print <<EOF;
138 root 1.8 ***
139 root 1.2 *** Stability canary mini-FAQ:
140     ***
141     *** Do I need to do anything?
142     *** With luck, no. While some distributions are known to fail
143     *** already, most should probably work. This message is here
144     *** to alert you that your perl is not supported by $distname,
145     *** and if things go wrong, you either need to downgrade, or
146     *** sidegrade to the stability variant of your perl version,
147     *** or simply live with the consequences.
148     ***
149     *** What is this canary thing?
150     *** It's purpose is to check support status of $distname with
151     *** respect to your perl version.
152     ***
153     *** What is this "stability branch"?
154     *** It's a branch or fork of the official perl, by schmorp, to
155     *** improve stability and compatibility with existing modules.
156     ***
157     *** How can I skip this prompt on automated installs?
158     *** Set PERL_CANARY_STABILITY_NOPROMPT=1 in your environment.
159     *** More info is in the Canary::Stability manpage.
160     ***
161 root 1.5 *** Long version of this FAQ: http://stableperl.schmorp.de/faq.html
162     *** Stability Branch homepage: http://stableperl.schmorp.de/
163 root 1.2 ***
164    
165     EOF
166    
167     unless ($ENV{PERL_CANARY_STABILITY_NOPROMPT}) {
168     require ExtUtils::MakeMaker;
169    
170     ExtUtils::MakeMaker::prompt ("Continue anyways? ", "y") =~ /^y/i
171     or die "FATAL: User aborted configuration of $distname.\n";
172     }
173     }
174    
175     sgr 0;
176 root 1.1 }
177    
178 root 1.2 =head1 ENVIRONMENT VARIABLES
179    
180     =over 4
181    
182     =item C<PERL_CANARY_STABILITY_NOPROMPT=1>
183    
184     Do not prompt the user on alert messages.
185    
186     =item C<PERL_CANARY_STABILITY_COLOUR=0>
187    
188     Disable use of colour.
189    
190     =item C<PERL_CANARY_STABILITY_COLOUR=1>
191    
192     Force use of colour.
193    
194     =item C<PERL_CANARY_STABILITY_DISABLE=1>
195    
196     Disable this modules functionality completely.
197    
198     =back
199    
200 root 1.1 =head1 AUTHOR
201    
202     Marc Lehmann <schmorp@schmorp.de>
203 root 1.6 http://software.schmorp.de/pkg/Canary-Stability.html
204 root 1.1
205     =cut
206    
207     1
208