From 8c8f3aa28bb001c19a43960568ecdfd6936d3fc6 Mon Sep 17 00:00:00 2001 From: Raphaƫl Hertzog Date: Sun, 20 Sep 2009 12:01:31 +0200 Subject: Dpkg::Vendor::*: better handle unknown hooks Implement vendor objects in a way that the return value for unknown hooks is better defined: empty list in list context or undef in scalar context. --- scripts/Dpkg/Vendor/Debian.pm | 8 +++----- scripts/Dpkg/Vendor/Default.pm | 3 +++ scripts/Dpkg/Vendor/Ubuntu.pm | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 5e4001104..e234b7be9 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -36,11 +36,7 @@ for Debian specific actions. sub run_hook { my ($self, $hook, @params) = @_; - if ($hook eq "before-source-build") { - my $srcpkg = shift @params; - } elsif ($hook eq "before-changes-creation") { - my $fields = shift @params; - } elsif ($hook eq "keyrings") { + if ($hook eq "keyrings") { return ('/usr/share/keyrings/debian-keyring.gpg', '/usr/share/keyrings/debian-maintainers.gpg'); } elsif ($hook eq "register-custom-fields") { @@ -50,6 +46,8 @@ sub run_hook { [ "insert_after", CTRL_APT_SRC, "Uploaders", "Dm-Upload-Allowed" ], [ "insert_after", CTRL_PKG_SRC, "Uploaders", "Dm-Upload-Allowed" ], ); + } else { + return $self->SUPER::run_hook($hook, @params); } } diff --git a/scripts/Dpkg/Vendor/Default.pm b/scripts/Dpkg/Vendor/Default.pm index 518cd4751..72b9af654 100644 --- a/scripts/Dpkg/Vendor/Default.pm +++ b/scripts/Dpkg/Vendor/Default.pm @@ -120,6 +120,9 @@ sub run_hook { my $fields = shift @params; } + # Default return value for unknown/unimplemented hooks + return () if wantarray; + return undef; } =back diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index 545b02ebd..5f46664b0 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -61,9 +61,6 @@ sub run_hook { } } - } elsif ($hook eq "before-changes-creation") { - my $fields = shift @params; - } elsif ($hook eq "keyrings") { my @keyrings = $self->SUPER::run_hook($hook); @@ -87,6 +84,9 @@ sub run_hook { if (scalar(@$bugs)) { $fields->{"Launchpad-Bugs-Fixed"} = join(" ", @$bugs); } + + } else { + return $self->SUPER::run_hook($hook, @params); } } -- cgit v1.2.3