Dpkg/BuildFlags.pm

filter: Statementstmt 59.7% 101 / 169 Branchbran 27.7% 20 / 72 Conditioncond 28.5% 2 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 80.0% 28 / 35 Podpod 100% 28 / 28 totaltotal 56.8% 179 / 315 CC 42 SCAR 35.2
CC
42
Cov
50%
update_from_conffile
156.0
load_environment_config
42.0
load_maintainer_config
42.0
CRAP 33.8
« Dpkg/Vendor/Ubuntu.pm ↑ Summary Dpkg/Source/Package/V3/Quilt.pm »
1 # Copyright © 2010-2011 Raphaël Hertzog <hertzog@debian.org>
2 # Copyright © 2012-2022 Guillem Jover <guillem@debian.org>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16  
17 =encoding utf8
18  
19 =head1 NAME
20  
21 Dpkg::BuildFlags - query build flags
22  
23 =head1 DESCRIPTION
24  
25 This class is used by dpkg-buildflags and can be used
26 to query the same information.
27  
28 =cut
29  
30 package Dpkg::BuildFlags 1.06;
31  
32 2 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 2 ▶use Dpkg ();
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use Dpkg::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 2 ▶use Dpkg::BuildEnv;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use Dpkg::ErrorHandling;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use Dpkg::Vendor qw(run_vendor_hook);
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 =head1 METHODS
41  
42 =over 4
43  
44 =item $bf = Dpkg::BuildFlags->new(%opts)
45  
46 Create a new Dpkg::BuildFlags object. It will be initialized based
47 on the value of several configuration files and environment variables.
48  
49 Options:
50  
51 =over
52  
53 =item B<vendor_defaults>
54  
55 If set to false, then no vendor defaults are initialized
56 (it defaults to true).
57  
58 =back
59  
60 =cut
61  
62 26 ▶sub new {
Subroutine new: called CC=4 SCAR=15.0
Pod documented
63 26 my ($this, %opts) = @_;
64 26 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0260
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
65  
66 26 my $self = {
67 };
68 26 bless $self, $class;
69  
70 26 ▶ $opts{vendor_defaults} //= 1;
Condition50%1/2
$opts{"vendor_defaults"} //= 1
l!l
026
MC/DC0%0/1
$opts{"vendor_defaults"} //= 1
$opts{"vendor_defaults"}
Truth table50%1/2
A
A= $opts{"vendor_defaults"}
Aresult
11
00
71  
72 26 ▶ if ($opts{vendor_defaults}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{'vendor_defaults'}) { } 26 0 26
73 26 $self->load_vendor_defaults();
74 } else {
75 0 $self->_init_vendor_defaults();
76 }
77 26 return $self;
78 }
79  
80 26 ▶sub _init_vendor_defaults {
Subroutine _init_vendor_defaults: called CC=1 SCAR=0.0
81 26 my $self = shift;
82  
83 26 my @flags = qw(
84 ASFLAGS
85 ASFLAGS_FOR_BUILD
86 CPPFLAGS
87 CPPFLAGS_FOR_BUILD
88 CFLAGS
89 CFLAGS_FOR_BUILD
90 CXXFLAGS
91 CXXFLAGS_FOR_BUILD
92 OBJCFLAGS
93 OBJCFLAGS_FOR_BUILD
94 OBJCXXFLAGS
95 OBJCXXFLAGS_FOR_BUILD
96 DFLAGS
97 DFLAGS_FOR_BUILD
98 FFLAGS
99 FFLAGS_FOR_BUILD
100 FCFLAGS
101 FCFLAGS_FOR_BUILD
102 LDFLAGS
103 LDFLAGS_FOR_BUILD
104 );
105  
106 26 $self->{features} = {};
107 26 $self->{builtins} = {};
108 26 $self->{optvals} = {};
109 26 $self->{flags} = { map { $_ => '' } @flags };
110 26 $self->{origin} = { map { $_ => 'vendor' } @flags };
111 26 $self->{maintainer} = { map { $_ => 0 } @flags };
112 }
113  
114 =item $bf->load_vendor_defaults()
115  
116 Reset the flags stored to the default set provided by the vendor.
117  
118 =cut
119  
120 26 ▶sub load_vendor_defaults {
Subroutine load_vendor_defaults: called CC=1 SCAR=0.0
Pod documented
121 26 my $self = shift;
122  
123 26 $self->_init_vendor_defaults();
124  
125 # The vendor hook will add the feature areas build flags.
126 26 run_vendor_hook('update-buildflags', $self);
127 }
128  
129 =item $bf->load_system_config()
130  
131 Update flags from the system configuration.
132  
133 =cut
134  
135 0 ▶sub load_system_config {
Subroutine load_system_config: not called CC=1 SCAR=6.9
Pod documented
136 0 my $self = shift;
137  
138 0 $self->update_from_conffile("$Dpkg::CONFDIR/buildflags.conf", 'system');
139 }
140  
141 =item $bf->load_user_config()
142  
143 Update flags from the user configuration.
144  
145 =cut
146  
147 0 ▶sub load_user_config {
Subroutine load_user_config: not called CC=4 SCAR=30.0
Pod documented
148 0 my $self = shift;
149  
150 0 my $confdir = $ENV{XDG_CONFIG_HOME};
151 0 ▶ $confdir ||= $ENV{HOME} . '/.config' if length $ENV{HOME};
Branch: 1 branch
BranchTrueFalseTotal
if length $ENV{"HOME"} 0 0 0
Condition0%0/2
$confdir ||= $ENV{"HOME"} . '/.config'
l!l
00
MC/DC0%0/1
$confdir ||= $ENV{"HOME"} . '/.config'
$confdir
Truth table0%0/2
A
A= $confdir
Aresult
11
00
152 0 ▶ if (length $confdir) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $confdir) 0 0 0
153 0 $self->update_from_conffile("$confdir/dpkg/buildflags.conf", 'user');
154 }
155 }
156  
157 =item $bf->load_environment_config()
158  
159 Update flags based on user directives stored in the environment. See
160 L<dpkg-buildflags(1)> for details.
161  
162 =cut
163  
164 0 ▶sub load_environment_config {
Subroutine load_environment_config: not called CC=6 SCAR=37.4
Pod documented
165 0 my $self = shift;
166  
167 0 foreach my $flag (keys %{$self->{flags}}) {
168 0 my $envvar = 'DEB_' . $flag . '_SET';
169 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
170 0 $self->set($flag, Dpkg::BuildEnv::get($envvar), 'env');
171 }
172 0 $envvar = 'DEB_' . $flag . '_STRIP';
173 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
174 0 $self->strip($flag, Dpkg::BuildEnv::get($envvar), 'env');
175 }
176 0 $envvar = 'DEB_' . $flag . '_APPEND';
177 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
178 0 $self->append($flag, Dpkg::BuildEnv::get($envvar), 'env');
179 }
180 0 $envvar = 'DEB_' . $flag . '_PREPEND';
181 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
182 0 $self->prepend($flag, Dpkg::BuildEnv::get($envvar), 'env');
183 }
184 }
185 }
186  
187 =item $bf->load_maintainer_config()
188  
189 Update flags based on maintainer directives stored in the environment. See
190 L<dpkg-buildflags(1)> for details.
191  
192 =cut
193  
194 0 ▶sub load_maintainer_config {
Subroutine load_maintainer_config: not called CC=6 SCAR=37.4
Pod documented
195 0 my $self = shift;
196  
197 0 foreach my $flag (keys %{$self->{flags}}) {
198 0 my $envvar = 'DEB_' . $flag . '_MAINT_SET';
199 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
200 0 $self->set($flag, Dpkg::BuildEnv::get($envvar), undef, 1);
201 }
202 0 $envvar = 'DEB_' . $flag . '_MAINT_STRIP';
203 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
204 0 $self->strip($flag, Dpkg::BuildEnv::get($envvar), undef, 1);
205 }
206 0 $envvar = 'DEB_' . $flag . '_MAINT_APPEND';
207 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
208 0 $self->append($flag, Dpkg::BuildEnv::get($envvar), undef, 1);
209 }
210 0 $envvar = 'DEB_' . $flag . '_MAINT_PREPEND';
211 0 ▶ if (Dpkg::BuildEnv::has($envvar)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Dpkg::BuildEnv::has($envvar)) 0 0 0
212 0 $self->prepend($flag, Dpkg::BuildEnv::get($envvar), undef, 1);
213 }
214 }
215 }
216  
217  
218 =item $bf->load_config()
219  
220 Call successively load_system_config(), load_user_config(),
221 load_environment_config() and load_maintainer_config() to update the
222 default build flags defined by the vendor.
223  
224 =cut
225  
226 0 ▶sub load_config {
Subroutine load_config: not called CC=1 SCAR=6.9
Pod documented
227 0 my $self = shift;
228  
229 0 $self->load_system_config();
230 0 $self->load_user_config();
231 0 $self->load_environment_config();
232 0 $self->load_maintainer_config();
233 }
234  
235 =item $bf->unset($flag)
236  
237 Unset the build flag $flag, so that it will not be known anymore.
238  
239 =cut
240  
241 0 ▶sub unset {
Subroutine unset: not called CC=1 SCAR=6.9
Pod documented
242 0 my ($self, $flag) = @_;
243  
244 0 delete $self->{flags}->{$flag};
245 0 delete $self->{origin}->{$flag};
246 0 delete $self->{maintainer}->{$flag};
247 }
248  
249 =item $bf->set($flag, $value, $source, $maint)
250  
251 Update the build flag $flag with value $value and record its origin as
252 $source (if defined). Record it as maintainer modified if $maint is
253 defined and true.
254  
255 =cut
256  
257 7 ▶sub set {
Subroutine set: called CC=3 SCAR=11.4
Pod documented
258 7 my ($self, $flag, $value, $src, $maint) = @_;
259 7 $self->{flags}->{$flag} = $value;
260 7 ▶ $self->{origin}->{$flag} = $src if defined $src;
Branch: 1 branch
BranchTrueFalseTotal
if defined $src 7 0 7
261 7 ▶ $self->{maintainer}->{$flag} = $maint if $maint;
Branch: 1 branch
BranchTrueFalseTotal
if $maint 0 7 7
262 }
263  
264 =item $bf->set_feature($area, $feature, $enabled)
265  
266 Update the boolean state of whether a specific feature within a known
267 feature area has been enabled. The only currently known feature areas
268 are "future", "qa", "sanitize", "optimize", "hardening" and "reproducible".
269  
270 =cut
271  
272 598 ▶sub set_feature {
Subroutine set_feature: called CC=1 SCAR=0.0
Pod documented
273 598 my ($self, $area, $feature, $enabled) = @_;
274 598 $self->{features}{$area}{$feature} = $enabled;
275 }
276  
277 =item $value = $bf->get_feature($area, $feature)
278  
279 Returns the value for the given feature within a known feature area.
280 This is relevant for builtin features where the feature has a ternary
281 state of true, false and undef, and where the latter cannot be retrieved
282 with use_feature().
283  
284 =cut
285  
286 26 ▶sub get_feature {
Subroutine get_feature: called CC=2 SCAR=7.1
Pod documented
287 26 my ($self, $area, $feature) = @_;
288  
289 26 ▶ return if ! $self->has_features($area);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_features($area) 0 26 26
290 26 return $self->{features}{$area}{$feature};
291 }
292  
293 =item $bool = $bf->use_feature($area, $feature)
294  
295 Returns true if the given feature within a known feature areas has been
296 enabled, and false otherwise.
297 The only currently recognized feature areas are "future", "qa", "sanitize",
298 "optimize", "hardening" and "reproducible".
299  
300 =cut
301  
302 588 ▶sub use_feature {
Subroutine use_feature: called CC=3 SCAR=11.0
Pod documented
303 588 my ($self, $area, $feature) = @_;
304  
305 588 ▶ return 0 if ! $self->has_features($area);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_features($area) 0 588 588
306 588 ▶ return 0 if ! $self->{features}{$area}{$feature};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"features"}{$area}{$feature} 302 286 588
307 286 return 1;
308 }
309  
310 =item $bf->set_builtin($area, $feature, $enabled)
311  
312 Update the boolean state of whether a specific feature within a known
313 feature area is handled (even if only in some architectures) as a builtin
314 default by the compiler.
315  
316 =cut
317  
318 78 ▶sub set_builtin {
Subroutine set_builtin: called CC=1 SCAR=0.0
Pod documented
319 78 my ($self, $area, $feature, $enabled) = @_;
320 78 $self->{builtins}{$area}{$feature} = $enabled;
321 }
322  
323 =item %builtins = $bf->get_builtins($area)
324  
325 Return, for the given area, a hash with keys as feature names, and values
326 as booleans indicating whether the feature is handled as a builtin default
327 by the compiler or not. Only features that might be handled as builtins on
328 some architectures are returned as part of the hash. Missing features mean
329 they are currently never handled as builtins by the compiler.
330  
331 =cut
332  
333 52 ▶sub get_builtins {
Subroutine get_builtins: called CC=2 SCAR=7.0
Pod documented
334 52 my ($self, $area) = @_;
335 52 ▶ return if ! exists $self->{builtins}{$area};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"builtins"}{$area} 0 52 52
336 52 return %{$self->{builtins}{$area}};
337 }
338  
339 =item $bf->set_option_value($option, $value)
340  
341 B<Private> method to set the value of a build option.
342 Do not use outside of the dpkg project.
343  
344 =cut
345  
346 136 ▶sub set_option_value {
Subroutine set_option_value: called CC=1 SCAR=0.0
Pod documented
347 136 my ($self, $option, $value) = @_;
348  
349 136 $self->{optvals}{$option} = $value;
350 }
351  
352 =item $value = $bf->get_option_value($option)
353  
354 B<Private> method to get the value of a build option.
355 Do not use outside of the dpkg project.
356  
357 =cut
358  
359 144 ▶sub get_option_value {
Subroutine get_option_value: called CC=1 SCAR=0.0
Pod documented
360 144 my ($self, $option) = @_;
361  
362 144 return $self->{optvals}{$option};
363 }
364  
365 =item $bf->strip($flag, $value, $source, $maint)
366  
367 Update the build flag $flag by stripping the flags listed in $value and
368 record its origin as $source (if defined). Record it as maintainer modified
369 if $maint is defined and true.
370  
371 =cut
372  
373 7 ▶sub strip {
Subroutine strip: called CC=3 SCAR=11.2
Pod documented
374 7 my ($self, $flag, $value, $src, $maint) = @_;
375  
376 7 my %strip = map { $_ => 1 } split /\s+/, $value;
377  
378 $self->{flags}->{$flag} = join q{ }, grep {
379 22 ! exists $strip{$_}
380 7 } split q{ }, $self->{flags}{$flag};
381 7 ▶ $self->{origin}->{$flag} = $src if defined $src;
Branch: 1 branch
BranchTrueFalseTotal
if defined $src 7 0 7
382 7 ▶ $self->{maintainer}->{$flag} = $maint if $maint;
Branch: 1 branch
BranchTrueFalseTotal
if $maint 0 7 7
383 }
384  
385 =item $bf->append($flag, $value, $source, $maint)
386  
387 Append the options listed in $value to the current value of the flag $flag.
388 Record its origin as $source (if defined). Record it as maintainer modified
389 if $maint is defined and true.
390  
391 =cut
392  
393 1154 ▶sub append {
Subroutine append: called CC=4 SCAR=13.9
Pod documented
394 1154 my ($self, $flag, $value, $src, $maint) = @_;
395 1154 ▶ if (length($self->{flags}->{$flag})) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'flags'}{$flag}) { } 669 485 1154
396 669 $self->{flags}->{$flag} .= " $value";
397 } else {
398 485 $self->{flags}->{$flag} = $value;
399 }
400 1154 ▶ $self->{origin}->{$flag} = $src if defined $src;
Branch: 1 branch
BranchTrueFalseTotal
if defined $src 1 1153 1154
401 1154 ▶ $self->{maintainer}->{$flag} = $maint if $maint;
Branch: 1 branch
BranchTrueFalseTotal
if $maint 0 1154 1154
402 }
403  
404 =item $bf->prepend($flag, $value, $source, $maint)
405  
406 Prepend the options listed in $value to the current value of the flag $flag.
407 Record its origin as $source (if defined). Record it as maintainer modified
408 if $maint is defined and true.
409  
410 =cut
411  
412 6 ▶sub prepend {
Subroutine prepend: called CC=4 SCAR=14.0
Pod documented
413 6 my ($self, $flag, $value, $src, $maint) = @_;
414 6 ▶ if (length($self->{flags}->{$flag})) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{'flags'}{$flag}) { } 6 0 6
415 6 $self->{flags}->{$flag} = "$value " . $self->{flags}->{$flag};
416 } else {
417 0 $self->{flags}->{$flag} = $value;
418 }
419 6 ▶ $self->{origin}->{$flag} = $src if defined $src;
Branch: 1 branch
BranchTrueFalseTotal
if defined $src 1 5 6
420 6 ▶ $self->{maintainer}->{$flag} = $maint if $maint;
Branch: 1 branch
BranchTrueFalseTotal
if $maint 1 5 6
421 }
422  
423  
424 =item $bf->update_from_conffile($file, $source)
425  
426 Update the current build flags based on the configuration directives
427 contained in $file. See L<dpkg-buildflags(1)> for the format of the directives.
428  
429 $source is the origin recorded for any build flag set or modified.
430  
431 =cut
432  
433 0 ▶sub update_from_conffile {
Subroutine update_from_conffile: not called CC=12 SCAR=50.5
Pod documented
434 0 my ($self, $file, $src) = @_;
435 0 local $_;
436  
437 0 ▶ return unless -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 0 0
438 0 ▶ open(my $conf_fh, '<', $file) or syserr(g_('cannot read %s'), $file);
Branch: 1 branch
BranchTrueFalseTotal
open my $conf_fh, "<", $file or syserr(g_("cannot read %s"), $file) 0 0 0
439 0 ▶ while (<$conf_fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $conf_fh)) 0 0 0
440 0 chomp;
441 # Skip comments.
442 0 ▶ next if /^\s*#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*#/u 0 0 0
443 # Skip empty lines.
444 0 ▶ next if /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*$/u 0 0 0
445 0 ▶ if (/^(append|prepend|set|strip)\s+(\S+)\s+(\S.*\S)\s*$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(append|prepend|set|strip)\s+(\S+)\s+(\S.*\S)\s*$/iu) { } 0 0 0
446 0 my ($op, $flag, $value) = ($1, $2, $3);
447 0 ▶ unless (exists $self->{flags}->{$flag}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"flags"}{$flag}) 0 0 0
448 0 warning(g_('line %d of %s mentions unknown flag %s'), $., $file, $flag);
449 0 $self->{flags}->{$flag} = '';
450 }
451 0 ▶ if (lc($op) eq 'set') {
Branch: 4 branches
BranchTrueFalseTotal
if (lc $op eq 'set') { } 0 0 0
elsif (lc $op eq 'strip') { } 0 0 0
elsif (lc $op eq 'append') { } 0 0 0
elsif (lc $op eq 'prepend') { } 0 0 0
452 0 $self->set($flag, $value, $src);
453 } elsif (lc($op) eq 'strip') {
454 0 $self->strip($flag, $value, $src);
455 } elsif (lc($op) eq 'append') {
456 0 $self->append($flag, $value, $src);
457 } elsif (lc($op) eq 'prepend') {
458 0 $self->prepend($flag, $value, $src);
459 }
460 } else {
461 0 warning(g_('line %d of %s is invalid, it has been ignored'), $., $file);
462 }
463 }
464 0 close($conf_fh);
465 }
466  
467 =item $value = $bf->get($flag)
468  
469 Return the value associated to the flag. It might be undef if the
470 flag doesn't exist.
471  
472 =cut
473  
474 340 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod documented
475 340 my ($self, $key) = @_;
476 340 return $self->{flags}{$key};
477 }
478  
479 =item @areas = $bf->get_feature_areas()
480  
481 Return the feature areas (i.e. the area values has_features will return
482 true for).
483  
484 =cut
485  
486 1 ▶sub get_feature_areas {
Subroutine get_feature_areas: called CC=1 SCAR=0.0
Pod documented
487 1 my $self = shift;
488  
489 1 return keys %{$self->{features}};
490 }
491  
492 =item %features = $bf->get_features($area)
493  
494 Return, for the given area, a hash with keys as feature names, and values
495 as booleans indicating whether the feature is enabled or not.
496  
497 =cut
498  
499 7 ▶sub get_features {
Subroutine get_features: called CC=1 SCAR=0.0
Pod documented
500 7 my ($self, $area) = @_;
501 7 return %{$self->{features}{$area}};
502 }
503  
504 =item $origin = $bf->get_origin($flag)
505  
506 Return the origin associated to the flag. It might be undef if the
507 flag doesn't exist.
508  
509 =cut
510  
511 5 ▶sub get_origin {
Subroutine get_origin: called CC=1 SCAR=0.0
Pod documented
512 5 my ($self, $key) = @_;
513 5 return $self->{origin}{$key};
514 }
515  
516 =item $bool = $bf->is_maintainer_modified($flag)
517  
518 Return true if the flag is modified by the maintainer.
519  
520 =cut
521  
522 4 ▶sub is_maintainer_modified {
Subroutine is_maintainer_modified: called CC=1 SCAR=0.0
Pod documented
523 4 my ($self, $key) = @_;
524 4 return $self->{maintainer}{$key};
525 }
526  
527 =item $bool = $bf->has_features($area)
528  
529 Returns true if the given area of features is known, and false otherwise.
530 The only currently recognized feature areas are "future", "qa", "sanitize",
531 "optimize", "hardening" and "reproducible".
532  
533 =cut
534  
535 621 ▶sub has_features {
Subroutine has_features: called CC=1 SCAR=0.0
Pod documented
536 621 my ($self, $area) = @_;
537 621 return exists $self->{features}{$area};
538 }
539  
540 =item $bool = $bf->has($option)
541  
542 Returns a boolean indicating whether the flags exists in the object.
543  
544 =cut
545  
546 1 ▶sub has {
Subroutine has: called CC=1 SCAR=0.0
Pod documented
547 1 my ($self, $key) = @_;
548 1 return exists $self->{flags}{$key};
549 }
550  
551 =item @flags = $bf->list()
552  
553 Returns the list of flags stored in the object.
554  
555 =cut
556  
557 23 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
558 23 my $self = shift;
559 23 my @list = sort keys %{$self->{flags}};
560 23 return @list;
561 }
562  
563 =back
564  
565 =head1 CHANGES
566  
567 =head2 Version 1.06 (dpkg 1.21.15)
568  
569 New method: $bf->get_feature().
570  
571 =head2 Version 1.05 (dpkg 1.21.14)
572  
573 New option: 'vendor_defaults' in new().
574  
575 New methods: $bf->load_vendor_defaults(), $bf->use_feature(),
576 $bf->set_builtin(), $bf->get_builtins().
577  
578 =head2 Version 1.04 (dpkg 1.20.0)
579  
580 New method: $bf->unset().
581  
582 =head2 Version 1.03 (dpkg 1.16.5)
583  
584 New method: $bf->get_feature_areas() to list possible values for
585 $bf->get_features.
586  
587 New method $bf->is_maintainer_modified() and new optional parameter to
588 $bf->set(), $bf->append(), $bf->prepend(), $bf->strip().
589  
590 =head2 Version 1.02 (dpkg 1.16.2)
591  
592 New methods: $bf->get_features(), $bf->has_features(), $bf->set_feature().
593  
594 =head2 Version 1.01 (dpkg 1.16.1)
595  
596 New method: $bf->prepend() very similar to append(). Implement support of
597 the prepend operation everywhere.
598  
599 New method: $bf->load_maintainer_config() that update the build flags
600 based on the package maintainer directives.
601  
602 =head2 Version 1.00 (dpkg 1.15.7)
603  
604 Mark the module as public.
605  
606 =cut
607  
608 2 1;
« Dpkg/Vendor/Ubuntu.pm ↑ Summary Dpkg/Source/Package/V3/Quilt.pm »