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