1package Magus::OutcomeRules;
2#
3# Copyright (c) 2007,2008 Chris Reinhardt. All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9# 1. Redistributions of source code must retain the above copyright notice
10#    this list of conditions and the following disclaimer.
11#
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
17# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26#
27
28#
29# MAINTAINER=   ctriv@MidnightBSD.org
30#
31
32sub missing_license_warning {
33  m/LICENSE not set/i
34    || m/has not defined LICENSE/i
35    || m/no licenses present in LICENSE/i
36    and return "LICENSE is not set.";
37}
38
39sub empty_license_warning {
40  m/empty license/i && return "LICENSE is empty.";
41}
42
43sub invalid_license_warning {
44  m/Invalid LICENSE: (\S+)/ && return "Invalid license set: $1";
45}
46
47sub fake_qa_warning {
48  return unless m/^====>\s+Running Q\/A tests \(fake-qa\)$/m;
49
50  my @messages = m/^(?:Error|Warning):\s*(.+)$/mg;
51  return unless @messages;
52
53  return "fake-qa reported: " . join("; ", @messages);
54}
55
56=head1 fetch rules
57
58=cut
59
60package Magus::OutcomeRules::fetch;
61
62use base qw(Magus::OutcomeRules::Base);
63
64sub NoLicense :warning {
65  Magus::OutcomeRules::missing_license_warning();
66}
67
68sub EmptyLicense :warning {
69  Magus::OutcomeRules::empty_license_warning();
70}
71
72sub InvalidLicense :warning {
73  Magus::OutcomeRules::invalid_license_warning();
74}
75
76sub FetchFailed :error {
77  m/Couldn't fetch it/ && return "Fetch failed.";
78}
79
80
81=head1 extract rules
82
83=cut
84
85package Magus::OutcomeRules::extract;
86
87use base qw(Magus::OutcomeRules::Base);
88
89
90
91=head1 patch rules
92
93=cut
94
95package Magus::OutcomeRules::patch;
96
97use base qw(Magus::OutcomeRules::Base);
98
99sub NoLicense :warning {
100  Magus::OutcomeRules::missing_license_warning();
101}
102
103sub EmptyLicense :warning {
104  Magus::OutcomeRules::empty_license_warning();
105}
106
107sub InvalidLicense :warning {
108  Magus::OutcomeRules::invalid_license_warning();
109}
110
111=head1 configure rules
112
113=cut
114
115package Magus::OutcomeRules::configure;
116
117use base qw(Magus::OutcomeRules::Base);
118
119
120
121=head1 build rules
122
123=cut
124
125package Magus::OutcomeRules::build;
126
127use base qw(Magus::OutcomeRules::Base);
128
129
130=head1 fake rules
131
132=cut
133
134package Magus::OutcomeRules::fake;
135
136use base qw(Magus::OutcomeRules::Base);
137
138sub IncompleteInstall :error {
139  m/^\s+.* not installed.$/m
140    && return "A file in the plist wasn't installed in the fake dir or the final dir.";
141}
142
143sub FakeDestdirInFile :error {
144  m/contains the fake destdir./s
145    && return "A file contained the fake destdir.";
146}
147
148sub FakedOutsideDestdir :error {
149  m:^    .* installed in /:m
150    && return "A file was installed in the final dir instead of the fake dir.";
151}
152
153sub FakeQA :warning {
154  Magus::OutcomeRules::fake_qa_warning();
155}
156
157
158
159=head1 package rules
160
161=cut
162
163package Magus::OutcomeRules::package;
164
165use base qw(Magus::OutcomeRules::Base);
166
167
168
169=head1 install rules
170
171=cut
172
173package Magus::OutcomeRules::install;
174
175use base qw(Magus::OutcomeRules::Base);
176
177sub AlreadyInstalled :error {
178  m:package .*? or its older version already installed: &&
179    return "The package was already installed.  This is an error in magus, not the port.";
180}
181
182=head1 deinstall rules
183
184=cut
185
186package Magus::OutcomeRules::deinstall;
187
188use base qw(Magus::OutcomeRules::Base);
189
190
191
192=head1 reinstall rules
193
194=cut
195
196package Magus::OutcomeRules::reinstall;
197
198use base qw(Magus::OutcomeRules::Base);
199
200
201=head1 test rules
202
203=cut
204
205package Magus::OutcomeRules::test;
206
207use base qw(Magus::OutcomeRules::Base);
208
209
2101;
211__END__
212