Default.pm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 <http://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 base qw(Dpkg::Vendor::Default);
  22. =head1 NAME
  23. Dpkg::Vendor::Default - default vendor object
  24. =head1 DESCRIPTION
  25. A vendor object is used to provide vendor specific behaviour
  26. in various places. This is the default object used in case
  27. there's none for the current vendor or in case the vendor could
  28. not be identified (see Dpkg::Vendor documentation).
  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 guaranty to be stable over an
  32. extended period. If you run an important distribution that makes use
  33. of vendor hooks, you'd better submit them for integration so that
  34. we avoid breaking your code.
  35. =head1 FUNCTIONS
  36. =over 4
  37. =item $vendor_obj = Dpkg::Vendor::Default->new()
  38. Creates the default vendor object. Can be inherited by all vendor objects
  39. if they don't need any specific initialization at object creation time.
  40. =cut
  41. sub new {
  42. my ($this) = @_;
  43. my $class = ref($this) || $this;
  44. my $self = {};
  45. bless $self, $class;
  46. return $self;
  47. }
  48. =item $vendor_obj->run_hook($id, @params)
  49. Run the corresponding hook. The parameters are hook-specific. The
  50. supported hooks are:
  51. =over 8
  52. =item before-source-build ($srcpkg)
  53. The first parameter is a Dpkg::Source::Package object. The hook is called
  54. just before the execution of $srcpkg->build().
  55. =item keyrings ()
  56. The hook is called when dpkg-source is checking a signature on a source
  57. package. It takes no parameters, but returns a (possibly empty) list of
  58. vendor-specific keyrings.
  59. =item register-custom-fields ()
  60. The hook is called in Dpkg::Control::Fields to register custom fields.
  61. You should return a list of arrays. Each array is an operation to perform.
  62. The first item is the name of the operation and corresponds
  63. to a field_* function provided by Dpkg::Control::Fields. The remaining
  64. fields are the parameters that are passed unchanged to the corresponding
  65. function.
  66. Known operations are "register", "insert_after" and "insert_before".
  67. =item post-process-changelog-entry ($fields)
  68. The hook is called in Dpkg::Changelog to post-process a
  69. Dpkg::Changelog::Entry after it has been created and filled with the
  70. appropriate values.
  71. =back
  72. =cut
  73. sub run_hook {
  74. my ($self, $hook, @params) = @_;
  75. if ($hook eq "before-source-build") {
  76. my $srcpkg = shift @params;
  77. } elsif ($hook eq "keyrings") {
  78. return ();
  79. } elsif ($hook eq "register-custom-fields") {
  80. return ();
  81. } elsif ($hook eq "post-process-changelog-entry") {
  82. my $fields = shift @params;
  83. } elsif ($hook eq "extend-patch-header") {
  84. my ($textref, $ch_info) = @params;
  85. }
  86. # Default return value for unknown/unimplemented hooks
  87. return () if wantarray;
  88. return undef;
  89. }
  90. =back
  91. =cut
  92. 1;