Default.pm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 2 of the License, or
  5. # (at your option) any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License along
  11. # with this program; if not, write to the Free Software Foundation, Inc.,
  12. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  13. package Dpkg::Vendor::Default;
  14. use strict;
  15. use warnings;
  16. # If you use this file as template to create a new vendor object, please
  17. # uncomment the following lines
  18. #use base qw(Dpkg::Vendor::Default);
  19. =head1 NAME
  20. Dpkg::Vendor::Default - default vendor object
  21. =head1 DESCRIPTION
  22. A vendor object is used to provide vendor specific behaviour
  23. in various places. This is the default object used in case
  24. there's none for the current vendor or in case the vendor could
  25. not be identified (see Dpkg::Vendor documentation).
  26. It provides some hooks that are called by various dpkg-* tools.
  27. If you need a new hook, please file a bug against dpkg-dev and explain
  28. your need. Note that the hook API has no guaranty to be stable over an
  29. extended period. If you run an important distribution that makes use
  30. of vendor hooks, you'd better submit them for integration so that
  31. we avoid breaking your code.
  32. =head1 FUNCTIONS
  33. =over 4
  34. =item $vendor_obj = Dpkg::Vendor::Default->new()
  35. Creates the default vendor object. Can be inherited by all vendor objects
  36. if they don't need any specific initialization at object creation time.
  37. =cut
  38. sub new {
  39. my ($this) = @_;
  40. my $class = ref($this) || $this;
  41. my $self = {};
  42. bless $self, $class;
  43. return $self;
  44. }
  45. =item $vendor_obj->run_hook($id, @params)
  46. Run the corresponding hook. The parameters are hook-specific. The
  47. supported hooks are:
  48. =over 8
  49. =item before-source-build ($srcpkg)
  50. The first parameter is a Dpkg::Source::Package object. The hook is called
  51. just before the execution of $srcpkg->build().
  52. =item before-changes-creation ($fields)
  53. The hook is called just before the content of .changes file is output
  54. by dpkg-genchanges. The first parameter is a Dpkg::Control object
  55. representing all the fields that are going to be output.
  56. =item keyrings ()
  57. The hook is called when dpkg-source is checking a signature on a source
  58. package. It takes no parameters, but returns a (possibly empty) list of
  59. vendor-specific keyrings.
  60. =item register-custom-fields ()
  61. The hook is called in Dpkg::Control::Fields to register custom fields.
  62. You should return a list of arrays. Each array is an operation to perform.
  63. The first item is the name of the operation and corresponds
  64. to a field_* function provided by Dpkg::Control::Fields. The remaining
  65. fields are the parameters that are passed unchanged to the corresponding
  66. function.
  67. Known operations are "register", "insert_after" and "insert_before".
  68. =item post-process-changelog-entry ($fields)
  69. The hook is called in Dpkg::Changelog to post-process a
  70. Dpkg::Changelog::Entry after it has been created and filled with the
  71. appropriate values.
  72. =back
  73. =cut
  74. sub run_hook {
  75. my ($self, $hook, @params) = @_;
  76. if ($hook eq "before-source-build") {
  77. my $srcpkg = shift @params;
  78. } elsif ($hook eq "before-changes-creation") {
  79. my $fields = shift @params;
  80. } elsif ($hook eq "keyrings") {
  81. return ();
  82. } elsif ($hook eq "register-custom-fields") {
  83. return ();
  84. } elsif ($hook eq "post-process-changelog-entry") {
  85. my $fields = shift @params;
  86. }
  87. # Default return value for unknown/unimplemented hooks
  88. return () if wantarray;
  89. return undef;
  90. }
  91. =back
  92. =cut
  93. 1;