ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Canary-Stability/Stability.pm
Revision: 1.4
Committed: Fri Jun 5 00:39:05 2015 UTC (8 years, 11 months ago) by root
Branch: MAIN
CVS Tags: rel-2001
Changes since 1.3: +11 -3 lines
Log Message:
2001

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