diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Dpkg/Control/Fields.pm | 15 | ||||
-rw-r--r-- | scripts/Dpkg/Vendor.pm | 4 | ||||
-rw-r--r-- | scripts/Dpkg/Vendor/Default.pm | 13 |
3 files changed, 30 insertions, 2 deletions
diff --git a/scripts/Dpkg/Control/Fields.pm b/scripts/Dpkg/Control/Fields.pm index a58632098..7223a425c 100644 --- a/scripts/Dpkg/Control/Fields.pm +++ b/scripts/Dpkg/Control/Fields.pm @@ -24,6 +24,7 @@ use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::Control::Types; use Dpkg::Checksums qw(@check_supported %check_supported); +use Dpkg::Vendor qw(run_vendor_hook); our @EXPORT = qw(field_capitalize field_is_official field_is_allowed_in field_transfer_single field_transfer_all @@ -313,6 +314,20 @@ $FIELD_ORDER{CTRL_APT_SRC()} = [ @{$FIELD_ORDER{CTRL_PKG_SRC()}} ]; @{$FIELD_ORDER{CTRL_PKG_SRC()}}; &field_insert_before(CTRL_APT_SRC, "Checksums-Md5", "Directory"); +# Register vendor specifics fields +foreach my $op (run_vendor_hook("register-custom-fields")) { + my $func = shift @$op; + if ($func eq "register") { + &field_register(@$op); + } elsif ($func eq "insert_before") { + &field_insert_before(@$op); + } elsif ($func eq "insert_after") { + &field_insert_after(@$op); + } else { + error("vendor hook register-custom-fields sent bad data: @$op"); + } +} + =head1 NAME Dpkg::Control::Fields - manage (list of official) control fields diff --git a/scripts/Dpkg/Vendor.pm b/scripts/Dpkg/Vendor.pm index fa967f509..bacb32b2e 100644 --- a/scripts/Dpkg/Vendor.pm +++ b/scripts/Dpkg/Vendor.pm @@ -21,7 +21,7 @@ use warnings; use Dpkg::ErrorHandling; use Dpkg::Gettext; -use Dpkg::Control; +use Dpkg::Control::Hash; use base qw(Exporter); our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file @@ -62,7 +62,7 @@ sub get_vendor_info(;$) { my $file = get_vendor_file($vendor); return undef unless $file; open(my $fh, "<", $file) || syserr(_g("cannot read %s"), $file); - my $fields = Dpkg::Control->new(type => CTRL_FILE_VENDOR); + my $fields = Dpkg::Control::Hash->new(); $fields->parse_fh($fh, $file) || error(_g("%s is empty"), $file); close($fh); return $fields; diff --git a/scripts/Dpkg/Vendor/Default.pm b/scripts/Dpkg/Vendor/Default.pm index a33b32f97..d940839bd 100644 --- a/scripts/Dpkg/Vendor/Default.pm +++ b/scripts/Dpkg/Vendor/Default.pm @@ -85,6 +85,17 @@ The hook is called when dpkg-source is checking a signature on a source package. It takes no parameters, but returns a (possibly empty) list of vendor-specific keyrings. +=item register-custom-fields () + +The hook is called in Dpkg::Control::Fields to register custom fields. +You should return a list of arrays. Each array is an operation to perform. +The first item is the name of the operation and corresponds +to a field_* function provided by Dpkg::Control::Fields. The remaining +fields are the parameters that are passed unchanged to the corresponding +function. + +Known operations are "register", "insert_after" and "insert_before". + =back =cut @@ -98,6 +109,8 @@ sub run_hook { my $fields = shift @params; } elsif ($hook eq "keyrings") { return (); + } elsif ($hook eq "register-custom-fields") { + return (); } } |