1 # Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org>
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.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 Dpkg::Control::FieldsCore - manage (list of official) control fields
24 The modules contains a list of field names with associated meta-data explaining
25 in which type of control information they are allowed. The types are the
26 CTRL_* constants exported by L<Dpkg::Control>.
30 package Dpkg
::Control
::FieldsCore
1.02;
41 field_parse_binary_source
56 use Exporter
qw(import);
59 use Dpkg
::ErrorHandling
;
60 use Dpkg
::Control
::Types
;
63 ALL_PKG
=> CTRL_INFO_PKG
| CTRL_INDEX_PKG
| CTRL_PKG_DEB
| CTRL_FILE_STATUS
,
64 ALL_SRC
=> CTRL_INFO_SRC
| CTRL_INDEX_SRC
| CTRL_PKG_SRC
,
65 ALL_FILE_MANIFEST
=> CTRL_FILE_BUILDINFO
| CTRL_FILE_CHANGES
,
66 ALL_CHANGES
=> CTRL_FILE_CHANGES
| CTRL_CHANGELOG
,
67 ALL_COPYRIGHT
=> CTRL_COPYRIGHT_HEADER
| CTRL_COPYRIGHT_FILES
| CTRL_COPYRIGHT_LICENSE
,
71 FIELD_SEP_UNKNOWN
=> 0,
77 # The canonical list of fields.
79 # Note that fields used only in dpkg's available file are not listed.
80 # Deprecated fields of dpkg's status file are also not listed.
82 'acquire-by-hash' => {
83 name
=> 'Acquire-By-Hash',
84 allowed
=> CTRL_REPO_RELEASE
,
87 name
=> 'Architecture',
88 allowed
=> (ALL_PKG
| ALL_SRC
| ALL_FILE_MANIFEST
| CTRL_TESTS
) & (~CTRL_INFO_SRC
),
89 separator
=> FIELD_SEP_SPACE
,
92 name
=> 'Architectures',
93 allowed
=> CTRL_REPO_RELEASE
,
94 separator
=> FIELD_SEP_SPACE
,
96 'auto-built-package' => {
97 name
=> 'Auto-Built-Package',
98 allowed
=> ALL_PKG
& ~CTRL_INFO_PKG
,
99 separator
=> FIELD_SEP_SPACE
,
103 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| ALL_FILE_MANIFEST
,
104 # XXX: This field values are separated either by space or comma
105 # depending on the context.
106 separator
=> FIELD_SEP_SPACE
| FIELD_SEP_COMMA
,
109 name
=> 'Binary-Only',
110 allowed
=> ALL_CHANGES
,
112 'binary-only-changes' => {
113 name
=> 'Binary-Only-Changes',
114 allowed
=> CTRL_FILE_BUILDINFO
,
119 separator
=> FIELD_SEP_COMMA
,
120 dependency
=> 'union',
125 allowed
=> (ALL_PKG
| CTRL_INFO_SRC
| CTRL_FILE_VENDOR
) & (~CTRL_INFO_PKG
),
127 'build-architecture' => {
128 name
=> 'Build-Architecture',
129 allowed
=> CTRL_FILE_BUILDINFO
,
131 'build-conflicts' => {
132 name
=> 'Build-Conflicts',
134 separator
=> FIELD_SEP_COMMA
,
135 dependency
=> 'union',
138 'build-conflicts-arch' => {
139 name
=> 'Build-Conflicts-Arch',
141 separator
=> FIELD_SEP_COMMA
,
142 dependency
=> 'union',
145 'build-conflicts-indep' => {
146 name
=> 'Build-Conflicts-Indep',
148 separator
=> FIELD_SEP_COMMA
,
149 dependency
=> 'union',
153 name
=> 'Build-Date',
154 allowed
=> CTRL_FILE_BUILDINFO
,
157 name
=> 'Build-Depends',
159 separator
=> FIELD_SEP_COMMA
,
160 dependency
=> 'normal',
163 'build-depends-arch' => {
164 name
=> 'Build-Depends-Arch',
166 separator
=> FIELD_SEP_COMMA
,
167 dependency
=> 'normal',
170 'build-depends-indep' => {
171 name
=> 'Build-Depends-Indep',
173 separator
=> FIELD_SEP_COMMA
,
174 dependency
=> 'normal',
177 'build-essential' => {
178 name
=> 'Build-Essential',
181 'build-kernel-version' => {
182 name
=> 'Build-Kernel-Version',
183 allowed
=> CTRL_FILE_BUILDINFO
,
186 name
=> 'Build-Origin',
187 allowed
=> CTRL_FILE_BUILDINFO
,
190 name
=> 'Build-Path',
191 allowed
=> CTRL_FILE_BUILDINFO
,
193 'build-profiles' => {
194 name
=> 'Build-Profiles',
195 allowed
=> CTRL_INFO_PKG
,
196 separator
=> FIELD_SEP_SPACE
,
198 'build-tainted-by' => {
199 name
=> 'Build-Tainted-By',
200 allowed
=> CTRL_FILE_BUILDINFO
,
201 separator
=> FIELD_SEP_SPACE
,
203 'built-for-profiles' => {
204 name
=> 'Built-For-Profiles',
205 allowed
=> ALL_PKG
| CTRL_FILE_CHANGES
,
206 separator
=> FIELD_SEP_SPACE
,
209 name
=> 'Built-Using',
211 separator
=> FIELD_SEP_COMMA
,
212 dependency
=> 'union',
215 'butautomaticupgrades' => {
216 name
=> 'ButAutomaticUpgrades',
217 allowed
=> CTRL_REPO_RELEASE
,
220 name
=> 'Changed-By',
221 allowed
=> CTRL_FILE_CHANGES
,
224 name
=> 'Changelogs',
225 allowed
=> CTRL_REPO_RELEASE
,
229 allowed
=> ALL_CHANGES
,
232 name
=> 'Checksums-Md5',
233 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| ALL_FILE_MANIFEST
,
235 'checksums-sha1' => {
236 name
=> 'Checksums-Sha1',
237 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| ALL_FILE_MANIFEST
,
239 'checksums-sha256' => {
240 name
=> 'Checksums-Sha256',
241 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| ALL_FILE_MANIFEST
,
245 allowed
=> CTRL_TESTS
,
246 separator
=> FIELD_SEP_COMMA
,
250 allowed
=> ALL_CHANGES
,
251 separator
=> FIELD_SEP_SPACE
,
255 allowed
=> CTRL_REPO_RELEASE
,
259 allowed
=> ALL_COPYRIGHT
,
262 name
=> 'Components',
263 allowed
=> CTRL_REPO_RELEASE
,
264 separator
=> FIELD_SEP_SPACE
,
268 allowed
=> CTRL_FILE_STATUS
,
269 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
271 'config-version' => {
272 name
=> 'Config-Version',
273 allowed
=> CTRL_FILE_STATUS
,
278 separator
=> FIELD_SEP_COMMA
,
279 dependency
=> 'union',
284 allowed
=> CTRL_COPYRIGHT_HEADER
| CTRL_COPYRIGHT_FILES
,
288 allowed
=> ALL_CHANGES
| CTRL_REPO_RELEASE
,
292 allowed
=> ALL_PKG
| CTRL_TESTS
,
293 separator
=> FIELD_SEP_COMMA
,
294 dependency
=> 'normal',
298 name
=> 'Description',
299 allowed
=> ALL_SRC
| ALL_PKG
| CTRL_FILE_CHANGES
| CTRL_REPO_RELEASE
,
302 name
=> 'Disclaimer',
303 allowed
=> CTRL_COPYRIGHT_HEADER
,
307 allowed
=> CTRL_INDEX_SRC
,
310 name
=> 'Distribution',
311 allowed
=> ALL_CHANGES
,
316 separator
=> FIELD_SEP_COMMA
,
317 dependency
=> 'union',
321 name
=> 'Environment',
322 allowed
=> CTRL_FILE_BUILDINFO
,
323 separator
=> FIELD_SEP_LINE
,
331 allowed
=> CTRL_TESTS
,
332 separator
=> FIELD_SEP_SPACE
,
336 allowed
=> CTRL_INDEX_PKG
,
337 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
341 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| CTRL_FILE_CHANGES
| CTRL_COPYRIGHT_FILES
,
342 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
346 allowed
=> CTRL_PKG_SRC
| CTRL_INDEX_SRC
| ALL_FILE_MANIFEST
| CTRL_COPYRIGHT_HEADER
,
350 allowed
=> ALL_SRC
| ALL_PKG
,
352 'installed-build-depends' => {
353 name
=> 'Installed-Build-Depends',
354 allowed
=> CTRL_FILE_BUILDINFO
,
355 separator
=> FIELD_SEP_COMMA
,
356 dependency
=> 'union',
359 'installed-size' => {
360 name
=> 'Installed-Size',
361 allowed
=> ALL_PKG
& ~CTRL_INFO_PKG
,
363 'installer-menu-item' => {
364 name
=> 'Installer-Menu-Item',
367 'kernel-version' => {
368 name
=> 'Kernel-Version',
373 allowed
=> CTRL_REPO_RELEASE
,
377 allowed
=> ALL_COPYRIGHT
,
381 allowed
=> (ALL_PKG
| ALL_SRC
| CTRL_REPO_RELEASE
) & (~CTRL_INFO_PKG
),
384 name
=> 'Maintainer',
385 allowed
=> CTRL_PKG_DEB
| CTRL_INDEX_PKG
| CTRL_FILE_STATUS
| ALL_SRC
| ALL_CHANGES
,
388 # XXX: Wrong capitalization due to historical reasons.
390 allowed
=> CTRL_INDEX_PKG
| CTRL_REPO_RELEASE
,
391 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
394 name
=> 'Multi-Arch',
397 'no-support-for-architecture-all' => {
398 name
=> 'No-Support-for-Architecture-all',
399 allowed
=> CTRL_REPO_RELEASE
,
402 name
=> 'NotAutomatic',
403 allowed
=> CTRL_REPO_RELEASE
,
407 allowed
=> ALL_PKG
| CTRL_INDEX_SRC
,
410 name
=> 'Package-List',
411 allowed
=> ALL_SRC
& ~CTRL_INFO_SRC
,
412 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
415 name
=> 'Package-Type',
420 allowed
=> CTRL_FILE_VENDOR
,
423 name
=> 'Pre-Depends',
425 separator
=> FIELD_SEP_COMMA
,
426 dependency
=> 'normal',
431 allowed
=> CTRL_INFO_SRC
| CTRL_INDEX_SRC
| ALL_PKG
,
440 separator
=> FIELD_SEP_COMMA
,
441 dependency
=> 'union',
445 name
=> 'Recommends',
447 separator
=> FIELD_SEP_COMMA
,
448 dependency
=> 'normal',
454 separator
=> FIELD_SEP_COMMA
,
455 dependency
=> 'union',
459 name
=> 'Restrictions',
460 allowed
=> CTRL_TESTS
,
461 separator
=> FIELD_SEP_SPACE
,
463 'rules-requires-root' => {
464 name
=> 'Rules-Requires-Root',
465 allowed
=> CTRL_INFO_SRC
,
466 separator
=> FIELD_SEP_SPACE
,
470 allowed
=> CTRL_INFO_SRC
| CTRL_INDEX_SRC
| ALL_PKG
,
473 # XXX: Wrong capitalization due to historical reasons.
475 allowed
=> CTRL_INDEX_PKG
| CTRL_REPO_RELEASE
,
476 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
479 # XXX: Wrong capitalization due to historical reasons.
481 allowed
=> CTRL_INDEX_PKG
| CTRL_REPO_RELEASE
,
482 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
486 allowed
=> CTRL_INDEX_PKG
,
487 separator
=> FIELD_SEP_LINE
| FIELD_SEP_SPACE
,
491 allowed
=> (ALL_PKG
| ALL_SRC
| ALL_CHANGES
| CTRL_COPYRIGHT_HEADER
| CTRL_FILE_BUILDINFO
) &
492 (~(CTRL_INDEX_SRC
| CTRL_INFO_PKG
)),
494 'standards-version' => {
495 name
=> 'Standards-Version',
498 'static-built-using' => {
499 name
=> 'Static-Built-Using',
501 separator
=> FIELD_SEP_COMMA
,
502 dependency
=> 'union',
507 allowed
=> CTRL_FILE_STATUS
,
508 separator
=> FIELD_SEP_SPACE
,
510 'subarchitecture' => {
511 name
=> 'Subarchitecture',
516 allowed
=> CTRL_REPO_RELEASE
,
521 separator
=> FIELD_SEP_COMMA
,
522 dependency
=> 'normal',
528 separator
=> FIELD_SEP_COMMA
,
535 name
=> 'Test-Command',
536 allowed
=> CTRL_TESTS
,
540 allowed
=> CTRL_TESTS
,
541 separator
=> FIELD_SEP_SPACE
,
543 'tests-directory' => {
544 name
=> 'Tests-Directory',
545 allowed
=> CTRL_TESTS
,
550 separator
=> FIELD_SEP_COMMA
,
552 'testsuite-triggers' => {
553 name
=> 'Testsuite-Triggers',
555 separator
=> FIELD_SEP_COMMA
,
559 allowed
=> CTRL_CHANGELOG
,
561 'triggers-awaited' => {
562 name
=> 'Triggers-Awaited',
563 allowed
=> CTRL_FILE_STATUS
,
564 separator
=> FIELD_SEP_SPACE
,
566 'triggers-pending' => {
567 name
=> 'Triggers-Pending',
568 allowed
=> CTRL_FILE_STATUS
,
569 separator
=> FIELD_SEP_SPACE
,
574 separator
=> FIELD_SEP_COMMA
,
577 name
=> 'Upstream-Name',
578 allowed
=> CTRL_COPYRIGHT_HEADER
,
580 'upstream-contact' => {
581 name
=> 'Upstream-Contact',
582 allowed
=> CTRL_COPYRIGHT_HEADER
,
586 allowed
=> ALL_CHANGES
,
589 name
=> 'Valid-Until',
590 allowed
=> CTRL_REPO_RELEASE
,
593 name
=> 'Vcs-Browser',
630 allowed
=> CTRL_FILE_VENDOR
,
633 name
=> 'Vendor-Url',
634 allowed
=> CTRL_FILE_VENDOR
,
638 allowed
=> (ALL_PKG
| ALL_SRC
| CTRL_FILE_BUILDINFO
| ALL_CHANGES
| CTRL_REPO_RELEASE
) &
639 (~(CTRL_INFO_SRC
| CTRL_INFO_PKG
)),
643 my @src_vcs_fields = qw(
655 my @src_dep_fields = qw(
661 build-conflicts-indep
663 my @bin_dep_fields = qw(
677 my @src_test_fields = qw(
682 my @src_checksums_fields = qw(
687 my @bin_checksums_fields = qw(
761 @src_checksums_fields,
797 CTRL_INDEX_SRC
() => [
820 @src_checksums_fields,
825 CTRL_INDEX_PKG
() => [
850 @bin_checksums_fields,
861 CTRL_REPO_RELEASE
() => [
874 no-support-for-architecture-all
879 @bin_checksums_fields
881 CTRL_CHANGELOG
() => [
895 CTRL_COPYRIGHT_HEADER
() => [
907 CTRL_COPYRIGHT_FILES
() => [
915 CTRL_COPYRIGHT_LICENSE
() => [
921 CTRL_FILE_BUILDINFO
() => [
930 @src_checksums_fields,
938 installed-build-depends
942 CTRL_FILE_CHANGES
() => [
960 @src_checksums_fields,
965 CTRL_FILE_VENDOR
() => [
973 CTRL_FILE_STATUS
() => [
974 # Same as fieldinfos in lib/dpkg/parse.c
1005 # These are allowed here, but not tracked by lib/dpkg/parse.c.
1039 =item $f = field_capitalize($field_name)
1041 Returns the field name properly capitalized. All characters are lowercase,
1042 except the first of each word (words are separated by a hyphen in field names).
1046 sub field_capitalize
($) {
1047 my $field = lc(shift);
1049 # Use known fields first.
1050 return $FIELDS{$field}{name
} if exists $FIELDS{$field};
1053 return join '-', map { ucfirst } split /-/, $field;
1056 =item $bool = field_is_official($fname)
1058 Returns true if the field is official and known.
1062 sub field_is_official
($) {
1063 my $field = lc shift;
1065 return exists $FIELDS{$field};
1068 =item $bool = field_is_allowed_in($fname, @types)
1070 Returns true (1) if the field $fname is allowed in all the types listed in
1071 the list. Note that you can use type sets instead of individual types (ex:
1072 CTRL_FILE_CHANGES | CTRL_CHANGELOG).
1074 field_allowed_in(A|B, C) returns true only if the field is allowed in C
1077 Undef is returned for non-official fields.
1081 sub field_is_allowed_in
($@
) {
1082 my ($field, @types) = @_;
1085 return unless exists $FIELDS{$field};
1087 return 0 if not scalar(@types);
1088 foreach my $type (@types) {
1089 next if $type == CTRL_UNKNOWN
; # Always allowed
1090 return 0 unless $FIELDS{$field}{allowed
} & $type;
1095 =item $new_field = field_transfer_single($from, $to, $field)
1097 If appropriate, copy the value of the field named $field taken from the
1098 $from L<Dpkg::Control> object to the $to L<Dpkg::Control> object.
1100 Official fields are copied only if the field is allowed in both types of
1101 objects. Custom fields are treated in a specific manner. When the target
1102 is not among CTRL_PKG_SRC, CTRL_PKG_DEB or CTRL_FILE_CHANGES, then they
1103 are always copied as is (the X- prefix is kept). Otherwise they are not
1104 copied except if the target object matches the target destination encoded
1105 in the field name. The initial X denoting custom fields can be followed by
1106 one or more letters among "S" (Source: corresponds to CTRL_PKG_SRC), "B"
1107 (Binary: corresponds to CTRL_PKG_DEB) or "C" (Changes: corresponds to
1110 Returns undef if nothing has been copied or the name of the new field
1111 added to $to otherwise.
1115 sub field_transfer_single
($$;$) {
1116 my ($from, $to, $field) = @_;
1117 if (not defined $field) {
1118 warnings
::warnif
('deprecated',
1119 'using Dpkg::Control::Fields::field_transfer_single() with an ' .
1120 'an implicit field argument is deprecated');
1123 my ($from_type, $to_type) = ($from->get_type(), $to->get_type());
1124 $field = field_capitalize
($field);
1126 if (field_is_allowed_in
($field, $from_type, $to_type)) {
1127 $to->{$field} = $from->{$field};
1129 } elsif ($field =~ /^X([SBC]*)-/i) {
1131 if (($dest =~ /B/i and $to_type == CTRL_PKG_DEB
) or
1132 ($dest =~ /S/i and $to_type == CTRL_PKG_SRC
) or
1133 ($dest =~ /C/i and $to_type == CTRL_FILE_CHANGES
))
1136 $new =~ s/^X([SBC]*)-//i;
1137 $to->{$new} = $from->{$field};
1139 } elsif ($to_type != CTRL_PKG_DEB
and
1140 $to_type != CTRL_PKG_SRC
and
1141 $to_type != CTRL_FILE_CHANGES
)
1143 $to->{$field} = $from->{$field};
1146 } elsif (not field_is_allowed_in
($field, $from_type)) {
1147 warning
(g_
("unknown information field '%s' in input data in %s"),
1148 $field, $from->get_option('name') || g_
('control information'));
1153 =item @field_list = field_transfer_all($from, $to)
1155 Transfer all appropriate fields from $from to $to. Calls
1156 field_transfer_single() on all fields available in $from.
1158 Returns the list of fields that have been added to $to.
1162 sub field_transfer_all
($$) {
1163 my ($from, $to) = @_;
1165 foreach my $k (keys %$from) {
1166 $res = field_transfer_single
($from, $to, $k);
1167 push @res, $res if $res and defined wantarray;
1172 =item @field_list = field_ordered_list($type)
1174 Returns an ordered list of fields for a given type of control information.
1175 This list can be used to output the fields in a predictable order.
1176 The list might be empty for types where the order does not matter much.
1180 sub field_ordered_list
($) {
1183 if (exists $FIELD_ORDER{$type}) {
1184 return map { $FIELDS{$_}{name
} } @
{$FIELD_ORDER{$type}};
1189 =item ($source, $version) = field_parse_binary_source($ctrl)
1191 Parse the B<Source> field in a binary package control stanza. The field
1192 contains the source package name where it was built from, and optionally
1193 a space and the source version enclosed in parenthesis if it is different
1194 from the binary version.
1196 Returns a list with the $source name, and the source $version, or undef
1197 or an empty list when $ctrl does not contain a binary package control stanza.
1198 Neither $source nor $version are validated, but that can be done with
1199 Dpkg::Package::pkg_name_is_illegal() and Dpkg::Version::version_check().
1203 sub field_parse_binary_source
($) {
1205 my $ctrl_type = $ctrl->get_type();
1207 if ($ctrl_type != CTRL_INDEX_PKG
and
1208 $ctrl_type != CTRL_PKG_DEB
and
1209 $ctrl_type != CTRL_FILE_CHANGES
and
1210 $ctrl_type != CTRL_FILE_BUILDINFO
and
1211 $ctrl_type != CTRL_FILE_STATUS
) {
1215 my ($source, $version);
1217 # For .changes and .buildinfo the Source field always exists,
1218 # and there is no Package field.
1219 if (exists $ctrl->{'Source'}) {
1220 $source = $ctrl->{'Source'};
1221 if ($source =~ m/^([^ ]+) +\(([^)]*)\)$/) {
1225 $version = $ctrl->{'Version'};
1228 $source = $ctrl->{'Package'};
1229 $version = $ctrl->{'Version'};
1232 return ($source, $version);
1235 =item @field_list = field_list_src_dep()
1237 List of fields that contains dependencies-like information in a source
1242 sub field_list_src_dep
() {
1246 $FIELDS{$a}{dep_order
} <=> $FIELDS{$b}{dep_order
}
1248 field_is_allowed_in
($_, CTRL_PKG_SRC
) and
1249 exists $FIELDS{$_}{dependency
}
1254 =item @field_list = field_list_pkg_dep()
1256 List of fields that contains dependencies-like information in a binary
1257 Debian package. The fields that express real dependencies are sorted from
1258 the stronger to the weaker.
1262 sub field_list_pkg_dep
() {
1266 $FIELDS{$a}{dep_order
} <=> $FIELDS{$b}{dep_order
}
1268 field_is_allowed_in
($_, CTRL_PKG_DEB
) and
1269 exists $FIELDS{$_}{dependency
}
1274 =item $dep_type = field_get_dep_type($field)
1276 Return the type of the dependency expressed by the given field. Can
1277 either be "normal" for a real dependency field (Pre-Depends, Depends, ...)
1278 or "union" for other relation fields sharing the same syntax (Conflicts,
1279 Breaks, ...). Returns undef for fields which are not dependencies.
1283 sub field_get_dep_type
($) {
1284 my $field = lc shift;
1286 return unless exists $FIELDS{$field};
1287 return $FIELDS{$field}{dependency
} if exists $FIELDS{$field}{dependency
};
1291 =item $sep_type = field_get_sep_type($field)
1293 Return the type of the field value separator. Can be one of FIELD_SEP_UNKNOWN,
1294 FIELD_SEP_SPACE, FIELD_SEP_COMMA or FIELD_SEP_LINE.
1298 sub field_get_sep_type
($) {
1299 my $field = lc shift;
1301 return $FIELDS{$field}{separator
} if exists $FIELDS{$field}{separator
};
1302 return FIELD_SEP_UNKNOWN
;
1305 =item field_register($field, $allowed_types, %opts)
1307 Register a new field as being allowed in control information of specified
1308 types. %opts is optional.
1312 sub field_register
($$;@
) {
1313 my ($field, $types, %opts) = @_;
1317 name
=> field_capitalize
($field),
1325 =item $bool = field_insert_after($type, $ref, @fields)
1327 Place field after another one ($ref) in output of control information of
1330 Return true if the field was inserted, otherwise false.
1334 sub field_insert_after
($$@
) {
1335 my ($type, $field, @fields) = @_;
1337 return 0 if not exists $FIELD_ORDER{$type};
1339 ($field, @fields) = map { lc } ($field, @fields);
1340 @
{$FIELD_ORDER{$type}} = map {
1341 ($_ eq $field) ?
($_, @fields) : $_
1342 } @
{$FIELD_ORDER{$type}};
1347 =item $bool = field_insert_before($type, $ref, @fields)
1349 Place field before another one ($ref) in output of control information of
1352 Return true if the field was inserted, otherwise false.
1356 sub field_insert_before
($$@
) {
1357 my ($type, $field, @fields) = @_;
1359 return 0 if not exists $FIELD_ORDER{$type};
1361 ($field, @fields) = map { lc } ($field, @fields);
1362 @
{$FIELD_ORDER{$type}} = map {
1363 ($_ eq $field) ?
(@fields, $_) : $_
1364 } @
{$FIELD_ORDER{$type}};
1373 =head2 Version 1.02 (dpkg 1.22.0)
1375 Deprecate argument: field_transfer_single() implicit argument usage.
1377 =head2 Version 1.01 (dpkg 1.21.0)
1379 New function: field_parse_binary_source().
1381 =head2 Version 1.00 (dpkg 1.17.0)
1383 Mark the module as public.