Default.pm 3.5 KB

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