Dpkg/Vendor/Default.pm

filter: Statementstmt 40.0% 12 / 30 Branchbran 26.6% 8 / 30 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 3 / 5 Podpod 100% 4 / 4 totaltotal 37.8% 28 / 74 CC 17 SCAR 45.5
CC
17
Cov
33%
run_hook
124.0
new
2.1
set_build_features
2.0
CRAP 94.9
« Dpkg/Deps.pm ↑ Summary Dpkg/Source/Package/V2.pm »
1 # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15  
16 =encoding utf8
17  
18 =head1 NAME
19  
20 Dpkg::Vendor::Default - default vendor class
21  
22 =head1 DESCRIPTION
23  
24 A vendor class is used to provide vendor specific behaviour
25 in various places. This is the default class used in case
26 there's none for the current vendor or in case the vendor could
27 not be identified (see L<Dpkg::Vendor> documentation).
28  
29 It provides some hooks that are called by various dpkg-* tools.
30 If you need a new hook, please file a bug against dpkg-dev and explain
31 your need. Note that the hook API has no guarantee to be stable over an
32 extended period of time. If you run an important distribution that makes
33 use of vendor hooks, you'd better submit them for integration so that
34 we avoid breaking your code.
35  
36 B<Note>: This is a private module, its API can change at any time.
37  
38 =cut
39  
40 package Dpkg::Vendor::Default 0.01;
41  
42 14 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 # If you use this file as template to create a new vendor class,
45 # uncomment the following lines:
46 #use parent qw(Dpkg::Vendor::Default);
47  
48 =head1 METHODS
49  
50 =over 4
51  
52 =item $vendor = Dpkg::Vendor::Default->new()
53  
54 Creates the default vendor object. Can be inherited by all vendor objects
55 if they don't need any specific initialization at object creation time.
56  
57 =cut
58  
59 16 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
60 16 my $this = shift;
61 16 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0160
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
62 16 my $self = {};
63 16 bless $self, $class;
64 16 return $self;
65 }
66  
67 =item $vendor->run_hook($id, @params)
68  
69 Run the corresponding hook. The parameters are hook-specific. The
70 supported hooks are:
71  
72 =over 8
73  
74 =item before-source-build ($srcpkg)
75  
76 The first parameter is a L<Dpkg::Source::Package> object. The hook is called
77 just before the execution of $srcpkg->build().
78  
79 =item package-keyrings ()
80  
81 The hook is called when dpkg-source is checking a signature on a source
82 package (since dpkg 1.18.11). It takes no parameters, but returns a
83 (possibly empty) list of vendor-specific keyrings.
84  
85 =item archive-keyrings ()
86  
87 The hook is called when there is a need to check signatures on artifacts
88 from repositories, for example by a download method (since dpkg 1.18.11).
89 It takes no parameters, but returns a (possibly empty) list of
90 vendor-specific keyrings.
91  
92 =item archive-keyrings-historic ()
93  
94 The hook is called when there is a need to check signatures on artifacts
95 from historic repositories, for example by a download method
96 (since dpkg 1.18.11). It takes no parameters, but returns a (possibly empty)
97 list of vendor-specific keyrings.
98  
99 =item builtin-build-depends ()
100  
101 The hook is called when dpkg-checkbuilddeps is initializing the source
102 package build dependencies (since dpkg 1.18.2). It takes no parameters,
103 but returns a (possibly empty) list of vendor-specific B<Build-Depends>.
104  
105 =item builtin-build-conflicts ()
106  
107 The hook is called when dpkg-checkbuilddeps is initializing the source
108 package build conflicts (since dpkg 1.18.2). It takes no parameters,
109 but returns a (possibly empty) list of vendor-specific B<Build-Conflicts>.
110  
111 =item register-custom-fields ()
112  
113 The hook is called in L<Dpkg::Control::Fields> to register custom fields.
114 You should return a list of arrays. Each array is an operation to perform.
115 The first item is the name of the operation and corresponds
116 to a field_* function provided by L<Dpkg::Control::Fields>. The remaining
117 fields are the parameters that are passed unchanged to the corresponding
118 function.
119  
120 Known operations are "register", "insert_after" and "insert_before".
121  
122 =item post-process-changelog-entry ($fields)
123  
124 The hook is called in L<Dpkg::Changelog> to post-process a
125 L<Dpkg::Changelog::Entry> after it has been created and filled with the
126 appropriate values.
127  
128 =item update-buildflags ($flags)
129  
130 The hook is called in L<Dpkg::BuildFlags> to allow the vendor to override
131 the default values set for the various build flags. $flags is a
132 L<Dpkg::BuildFlags> object.
133  
134 =item builtin-system-build-paths ()
135  
136 The hook is called by dpkg-genbuildinfo to determine if the current path
137 should be recorded in the B<Build-Path> field (since dpkg 1.18.11). It takes
138 no parameters, but returns a (possibly empty) list of root paths considered
139 acceptable. As an example, if the list contains "/build/", a Build-Path
140 field will be created if the current directory is "/build/dpkg-1.18.0". If
141 the list contains "/", the path will always be recorded. If the list is
142 empty, the current path will never be recorded.
143  
144 =item build-tainted-by ()
145  
146 The hook is called by dpkg-genbuildinfo to determine if the current system
147 has been tainted in some way that could affect the resulting build, which
148 will be recorded in the B<Build-Tainted-By> field (since dpkg 1.19.5). It
149 takes no parameters, but returns a (possibly empty) list of tainted reason
150 tags (formed by alphanumeric and dash characters).
151  
152 =item sanitize-environment ()
153  
154 The hook is called by dpkg-buildpackage to sanitize its build environment
155 (since dpkg 1.20.0).
156  
157 =item backport-version-regex ()
158  
159 The hook is called by dpkg-genchanges and dpkg-mergechangelog to determine
160 the backport version string that should be specially handled as not an earlier
161 than version or remapped so that it does not get considered as a pre-release
162 (since dpkg 1.21.3).
163 The returned string is a regex with one capture group for the backport
164 delimiter string, or undef if there is no regex.
165  
166 =item has-fuzzy-native-source ()
167  
168 The hook is called by dpkg-source when trying to determine whether native
169 source packages should be handled as proper native ones, or as incoherent
170 and confused native ones, where the source format does not match the source
171 version (since dpkg 1.23.0).
172  
173 =back
174  
175 =cut
176  
177 250 ▶sub run_hook {
Subroutine run_hook: called CC=16 SCAR=48.2
Pod documented
178 250 my ($self, $hook, @params) = @_;
179  
180 250 ▶ if ($hook eq 'before-source-build') {
Branch: 15 branches
BranchTrueFalseTotal
if ($hook eq 'before-source-build') { } 0 250 250
elsif ($hook eq 'package-keyrings') { } 0 250 250
elsif ($hook eq 'archive-keyrings') { } 0 250 250
elsif ($hook eq 'archive-keyrings-historic') { } 0 250 250
elsif ($hook eq 'register-custom-fields') { } 0 250 250
elsif ($hook eq 'builtin-build-depends') { } 0 250 250
elsif ($hook eq 'builtin-build-conflicts') { } 0 250 250
elsif ($hook eq 'post-process-changelog-entry') { } 250 0 250
elsif ($hook eq 'extend-patch-header') { } 0 0 0
elsif ($hook eq 'update-buildflags') { } 0 0 0
elsif ($hook eq 'builtin-system-build-paths') { } 0 0 0
elsif ($hook eq 'build-tainted-by') { } 0 0 0
elsif ($hook eq 'sanitize-environment') { } 0 0 0
elsif ($hook eq 'backport-version-regex') { } 0 0 0
elsif ($hook eq 'has-fuzzy-native-source') { } 0 0 0
181 0 my $srcpkg = shift @params;
182 } elsif ($hook eq 'package-keyrings') {
183 0 return ();
184 } elsif ($hook eq 'archive-keyrings') {
185 0 return ();
186 } elsif ($hook eq 'archive-keyrings-historic') {
187 0 return ();
188 } elsif ($hook eq 'register-custom-fields') {
189 0 return ();
190 } elsif ($hook eq 'builtin-build-depends') {
191 0 return ();
192 } elsif ($hook eq 'builtin-build-conflicts') {
193 0 return ();
194 } elsif ($hook eq 'post-process-changelog-entry') {
195 250 my $fields = shift @params;
196 } elsif ($hook eq 'extend-patch-header') {
197 0 my ($textref, $ch_info) = @params;
198 } elsif ($hook eq 'update-buildflags') {
199 0 my $flags = shift @params;
200 } elsif ($hook eq 'builtin-system-build-paths') {
201 0 return ();
202 } elsif ($hook eq 'build-tainted-by') {
203 0 return ();
204 } elsif ($hook eq 'sanitize-environment') {
205 0 return;
206 } elsif ($hook eq 'backport-version-regex') {
207 0 return;
208 } elsif ($hook eq 'has-fuzzy-native-source') {
209 0 return 0;
210 }
211  
212 # Default return value for unknown/unimplemented hooks.
213 250 return;
214 }
215  
216 =item $vendor->set_build_features($flags)
217  
218 Sets the vendor build features, which will then be used to initialize the
219 build flags.
220  
221 =cut
222  
223 0 ▶sub set_build_features {
Subroutine set_build_features: not called CC=1 SCAR=6.9
Pod documented
224 0 my ($self, $flags) = @_;
225  
226 0 return;
227 }
228  
229 =item $vendor->add_build_flags($flags)
230  
231 Adds the vendor build flags to the compiler flag variables based on the
232 vendor defaults and previously set build features.
233  
234 =cut
235  
236 0 ▶sub add_build_flags {
Subroutine add_build_flags: not called CC=1 SCAR=6.9
Pod documented
237 0 my ($self, $flags) = @_;
238  
239 0 return;
240 }
241  
242 =back
243  
244 =head1 CHANGES
245  
246 =head2 Version 0.xx
247  
248 This is a private module.
249  
250 =cut
251  
252 14 1;
« Dpkg/Deps.pm ↑ Summary Dpkg/Source/Package/V2.pm »