Default.pm 6.0 KB

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