Default.pm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. =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 guaranty to be stable over an
  33. extended period. If you run an important distribution that makes use
  34. of vendor hooks, you'd better submit them for integration so that
  35. we avoid breaking your code.
  36. =head1 FUNCTIONS
  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) = @_;
  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 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. =item update-buildflags ($flags)
  73. The hook is called in Dpkg::BuildFlags to allow the vendor to override
  74. the default values set for the various build flags. $flags is a
  75. Dpkg::BuildFlags object.
  76. =back
  77. =cut
  78. sub run_hook {
  79. my ($self, $hook, @params) = @_;
  80. if ($hook eq "before-source-build") {
  81. my $srcpkg = shift @params;
  82. } elsif ($hook eq "keyrings") {
  83. return ();
  84. } elsif ($hook eq "register-custom-fields") {
  85. return ();
  86. } elsif ($hook eq "post-process-changelog-entry") {
  87. my $fields = shift @params;
  88. } elsif ($hook eq "extend-patch-header") {
  89. my ($textref, $ch_info) = @params;
  90. } elsif ($hook eq "update-buildflags") {
  91. my $flags = shift @params;
  92. }
  93. # Default return value for unknown/unimplemented hooks
  94. return () if wantarray;
  95. return undef;
  96. }
  97. =back
  98. =cut
  99. 1;