File Coverage

blib/lib/Dpkg/Vendor/Default.pm
Criterion Covered Total %
statement 15 27 55.5
branch 8 26 30.7
condition 1 3 33.3
subroutine 4 4 100.0
pod 2 2 100.0
total 30 62 48.3


line stmt bran cond sub pod time code
1             # Copyright © 2009 Raphaël Hertzog
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 .
15              
16             package Dpkg::Vendor::Default;
17              
18 11     11   5479 use strict;
  11         25  
  11         311  
19 11     11   55 use warnings;
  11         27  
  11         3222  
20              
21             our $VERSION = '0.01';
22              
23             # If you use this file as template to create a new vendor class, please
24             # uncomment the following lines
25             #use parent qw(Dpkg::Vendor::Default);
26              
27             =encoding utf8
28              
29             =head1 NAME
30              
31             Dpkg::Vendor::Default - default vendor class
32              
33             =head1 DESCRIPTION
34              
35             A vendor class is used to provide vendor specific behaviour
36             in various places. This is the default class used in case
37             there's none for the current vendor or in case the vendor could
38             not be identified (see Dpkg::Vendor documentation).
39              
40             It provides some hooks that are called by various dpkg-* tools.
41             If you need a new hook, please file a bug against dpkg-dev and explain
42             your need. Note that the hook API has no guarantee to be stable over an
43             extended period of time. If you run an important distribution that makes
44             use of vendor hooks, you'd better submit them for integration so that
45             we avoid breaking your code.
46              
47             =head1 METHODS
48              
49             =over 4
50              
51             =item $vendor_obj = Dpkg::Vendor::Default->new()
52              
53             Creates the default vendor object. Can be inherited by all vendor objects
54             if they don't need any specific initialization at object creation time.
55              
56             =cut
57              
58             sub new {
59 12     12 1 112 my $this = shift;
60 12   33     134 my $class = ref($this) || $this;
61 12         32 my $self = {};
62 12         31 bless $self, $class;
63 12         133 return $self;
64             }
65              
66             =item $vendor_obj->run_hook($id, @params)
67              
68             Run the corresponding hook. The parameters are hook-specific. The
69             supported hooks are:
70              
71             =over 8
72              
73             =item before-source-build ($srcpkg)
74              
75             The first parameter is a Dpkg::Source::Package object. The hook is called
76             just before the execution of $srcpkg->build().
77              
78             =item package-keyrings ()
79              
80             The hook is called when dpkg-source is checking a signature on a source
81             package (since dpkg 1.18.11). It takes no parameters, but returns a
82             (possibly empty) list of vendor-specific keyrings.
83              
84             =item archive-keyrings ()
85              
86             The hook is called when there is a need to check signatures on artifacts
87             from repositories, for example by a download method (since dpkg 1.18.11).
88             It takes no parameters, but returns a (possibly empty) list of
89             vendor-specific keyrings.
90              
91             =item archive-keyrings-historic ()
92              
93             The hook is called when there is a need to check signatures on artifacts
94             from historic repositories, for example by a download method
95             (since dpkg 1.18.11). It takes no parameters, but returns a (possibly empty)
96             list of vendor-specific keyrings.
97              
98             =item builtin-build-depends ()
99              
100             The hook is called when dpkg-checkbuilddeps is initializing the source
101             package build dependencies (since dpkg 1.18.2). It takes no parameters,
102             but returns a (possibly empty) list of vendor-specific B.
103              
104             =item builtin-build-conflicts ()
105              
106             The hook is called when dpkg-checkbuilddeps is initializing the source
107             package build conflicts (since dpkg 1.18.2). It takes no parameters,
108             but returns a (possibly empty) list of vendor-specific B.
109              
110             =item register-custom-fields ()
111              
112             The hook is called in Dpkg::Control::Fields to register custom fields.
113             You should return a list of arrays. Each array is an operation to perform.
114             The first item is the name of the operation and corresponds
115             to a field_* function provided by Dpkg::Control::Fields. The remaining
116             fields are the parameters that are passed unchanged to the corresponding
117             function.
118              
119             Known operations are "register", "insert_after" and "insert_before".
120              
121             =item post-process-changelog-entry ($fields)
122              
123             The hook is called in Dpkg::Changelog to post-process a
124             Dpkg::Changelog::Entry after it has been created and filled with the
125             appropriate values.
126              
127             =item update-buildflags ($flags)
128              
129             The hook is called in Dpkg::BuildFlags to allow the vendor to override
130             the default values set for the various build flags. $flags is a
131             Dpkg::BuildFlags object.
132              
133             =item builtin-system-build-paths ()
134              
135             The hook is called by dpkg-genbuildinfo to determine if the current path
136             should be recorded in the B field (since dpkg 1.18.11). It takes
137             no parameters, but returns a (possibly empty) list of root paths considered
138             acceptable. As an example, if the list contains "/build/", a Build-Path
139             field will be created if the current directory is "/build/dpkg-1.18.0". If
140             the list contains "/", the path will always be recorded. If the list is
141             empty, the current path will never be recorded.
142              
143             =item build-tainted-by ()
144              
145             The hook is called by dpkg-genbuildinfo to determine if the current system
146             has been tainted in some way that could affect the resulting build, which
147             will be recorded in the B field (since dpkg 1.19.5). It
148             takes no parameters, but returns a (possibly empty) list of tainted reason
149             tags (formed by alphanumeric and dash characters).
150              
151             =item sanitize-environment ()
152              
153             The hook is called by dpkg-buildpackage to sanitize its build environment
154             (since dpkg 1.20.0).
155              
156             =back
157              
158             =cut
159              
160             sub run_hook {
161 250     250 1 454 my ($self, $hook, @params) = @_;
162              
163 250 50       1050 if ($hook eq 'before-source-build') {
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    0          
    0          
    0          
    0          
    0          
164 0         0 my $srcpkg = shift @params;
165             } elsif ($hook eq 'package-keyrings') {
166 0         0 return ();
167             } elsif ($hook eq 'archive-keyrings') {
168 0         0 return ();
169             } elsif ($hook eq 'archive-keyrings-historic') {
170 0         0 return ();
171             } elsif ($hook eq 'register-custom-fields') {
172 0         0 return ();
173             } elsif ($hook eq 'builtin-build-depends') {
174 0         0 return ();
175             } elsif ($hook eq 'builtin-build-conflicts') {
176 0         0 return ();
177             } elsif ($hook eq 'post-process-changelog-entry') {
178 250         400 my $fields = shift @params;
179             } elsif ($hook eq 'extend-patch-header') {
180 0         0 my ($textref, $ch_info) = @params;
181             } elsif ($hook eq 'update-buildflags') {
182 0         0 my $flags = shift @params;
183             } elsif ($hook eq 'builtin-system-build-paths') {
184 0         0 return ();
185             } elsif ($hook eq 'build-tainted-by') {
186 0         0 return ();
187             } elsif ($hook eq 'sanitize-environment') {
188 0         0 return;
189             }
190              
191             # Default return value for unknown/unimplemented hooks
192 250         589 return;
193             }
194              
195             =back
196              
197             =head1 CHANGES
198              
199             =head2 Version 0.xx
200              
201             This is a private module.
202              
203             =cut
204              
205             1;