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.4 by root, Fri Jun 5 00:39:05 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.
14
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.
12 20
13=over 4 21=over 4
14 22
15=cut 23=cut
16 24
17package Canary::Stability; 25package Canary::Stability;
18 26
19BEGIN { 27BEGIN {
20 $VERSION = 1996; #รค the year the ariane 5 crashed due to a software bug 28 $VERSION = 2001;
29}
30
31sub 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";
21} 38}
22 39
23sub import { 40sub import {
41 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*** The stability canary says: (nothing, it died of old age).
54***
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
63EOF
64 } elsif ($] < $minperl) {
65
66 sgr 33;
67 print <<EOF;
68
69***
70*** The stability canary says: chirp (it seems concerned about something).
71***
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*** won't do anything to make it work if it breaks.
76***
77
78EOF
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
95EOF
96 } elsif ($] <= 5.020) {
97 #sgr 32;
98 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
107EOF
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***
124EOF
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
153EOF
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 }
24 # 161 }
162
163 sgr 0;
25} 164}
165
166=head1 ENVIRONMENT VARIABLES
167
168=over 4
169
170=item C<PERL_CANARY_STABILITY_NOPROMPT=1>
171
172Do not prompt the user on alert messages.
173
174=item C<PERL_CANARY_STABILITY_COLOUR=0>
175
176Disable use of colour.
177
178=item C<PERL_CANARY_STABILITY_COLOUR=1>
179
180Force use of colour.
181
182=item C<PERL_CANARY_STABILITY_DISABLE=1>
183
184Disable this modules functionality completely.
185
186=back
26 187
27=head1 AUTHOR 188=head1 AUTHOR
28 189
29 Marc Lehmann <schmorp@schmorp.de> 190 Marc Lehmann <schmorp@schmorp.de>
30 http://home.schmorp.de/ 191 http://home.schmorp.de/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines