chiark / gitweb /
dpkg (1.18.25) stretch; urgency=medium
[dpkg] / scripts / Dpkg / Vendor / Default.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 package Dpkg::Vendor::Default;
17
18 use strict;
19 use warnings;
20
21 our $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
31 Dpkg::Vendor::Default - default vendor object
32
33 =head1 DESCRIPTION
34
35 A vendor object is used to provide vendor specific behaviour
36 in various places. This is the default object 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     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
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<Build-Depends>.
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<Build-Conflicts>.
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<Build-Path> 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 =back
144
145 =cut
146
147 sub 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
187 This is a private module.
188
189 =cut
190
191 1;