Default.pm 3.5 KB

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