Default.pm 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 Dpkg::Vendor::Default;
  19. #our @ISA = qw(Dpkg::Vendor::Default);
  20. =head1 NAME
  21. Dpkg::Vendor::Default - default vendor object
  22. =head1 DESCRIPTION
  23. A vendor object is used to provide vendor specific behaviour
  24. in various places. This is the default object used in case
  25. there's none for the current vendor or in case the vendor could
  26. not be identified (see Dpkg::Vendor documentation).
  27. It provides some hooks that are called by various dpkg-* tools.
  28. If you need a new hook, please file a bug against dpkg-dev and explain
  29. your need. Note that the hook API has no guaranty to be stable over an
  30. extended period. If you run an important distribution that makes use
  31. of vendor hooks, you'd better submit them for integration so that
  32. we avoid breaking your code.
  33. =head1 FUNCTIONS
  34. =over 4
  35. =item $vendor_obj = Dpkg::Vendor::Default->new()
  36. Creates the default vendor object. Can be inherited by all vendor objects
  37. if they don't need any specific initialization at object creation time.
  38. =cut
  39. sub new {
  40. my ($this) = @_;
  41. my $class = ref($this) || $this;
  42. my $self = {};
  43. bless $self, $class;
  44. return $self;
  45. }
  46. =item $vendor_obj->run_hook($id, @params)
  47. Run the corresponding hook. The parameters are hook-specific. The
  48. supported hooks are:
  49. =over 8
  50. =item before-source-build ($srcpkg)
  51. The first parameter is a Dpkg::Source::Package object. The hook is called
  52. just before the execution of $srcpkg->build().
  53. =item before-changes-creation ($fields)
  54. The hook is called just before the content of .changes file is output
  55. by dpkg-genchanges. The first parameter is a Dpkg::Fields::Object
  56. representing all the fields that are going to be output.
  57. =back
  58. =cut
  59. sub run_hook {
  60. my ($self, $hook, @params) = @_;
  61. if ($hook eq "before-source-build") {
  62. my $srcpkg = shift @params;
  63. } elsif ($hook eq "before-changes-creation") {
  64. my $fields = shift @params;
  65. }
  66. }
  67. =back
  68. =cut
  69. 1;