Dpkg/Control/FieldsCore.pm

filter: Statementstmt 78.7% 111 / 141 Branchbran 57.6% 30 / 52 Conditioncond 42.1% 24 / 57 MC/DCmcdc 20.0% 6 / 30 Subroutinesub 87.5% 21 / 24 Podpod 100% 17 / 17 totaltotal 65.1% 209 / 321 CC 48 SCAR 28.2
CC
48
Cov
66%
field_transfer_single
53.3
field_transfer_all
20.0
field_get_dep_type
12.0
CRAP 16.7
« Dpkg/Source/Archive.pm ↑ Summary Dpkg/Shlibs/Objdump/Object.pm »
1 # Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org>
2 # Copyright © 2012-2025 Guillem Jover <guillem@debian.org>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16  
17 =encoding utf8
18  
19 =head1 NAME
20  
21 Dpkg::Control::FieldsCore - manage (list of official) control fields
22  
23 =head1 DESCRIPTION
24  
25 The modules contains a list of field names with associated meta-data explaining
26 in which type of control information they are allowed. The types are the
27 CTRL_* constants exported by L<Dpkg::Control>.
28  
29 =cut
30  
31 package Dpkg::Control::FieldsCore 1.05;
32  
33 15 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 15 our @EXPORT = qw(
36 field_capitalize
37 field_is_official
38 field_is_allowed_in
39 field_transfer_single
40 field_transfer_all
41 field_parse_maintainer
42 field_parse_uploaders
43 field_parse_binary_source
44 field_list_src_dep
45 field_list_pkg_dep
46 field_get_dep_type
47 field_get_sep_type
48 field_get_default_value
49 field_ordered_list
50 field_register
51 field_insert_after
52 field_insert_before
53 FIELD_SEP_UNKNOWN
54 FIELD_SEP_SPACE
55 FIELD_SEP_COMMA
56 FIELD_SEP_LINE
57 );
58  
59 15 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 15 ▶use Dpkg::Gettext;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 15 ▶use Dpkg::ErrorHandling;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 15 ▶use Dpkg::Control::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 15 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
66 15 ALL_PKG => CTRL_TMPL_PKG | CTRL_REPO_PKG | CTRL_DEB | CTRL_FILE_STATUS,
67 ALL_SRC => CTRL_TMPL_SRC | CTRL_REPO_SRC | CTRL_DSC,
68 ALL_FILE_MANIFEST => CTRL_FILE_BUILDINFO | CTRL_FILE_CHANGES,
69 ALL_CHANGES => CTRL_FILE_CHANGES | CTRL_CHANGELOG,
70 ALL_COPYRIGHT => CTRL_COPYRIGHT_HEADER | CTRL_COPYRIGHT_FILES | CTRL_COPYRIGHT_LICENSE,
71 15 };
72  
73 15 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
74 15 FIELD_SEP_UNKNOWN => 0,
75 FIELD_SEP_SPACE => 1,
76 FIELD_SEP_COMMA => 2,
77 FIELD_SEP_LINE => 4,
78 15 };
79  
80 # The canonical list of fields.
81  
82 # Note that fields used only in dpkg's available file are not listed.
83 # Deprecated fields of dpkg's status file are also not listed.
84 15 our %FIELDS = (
85 'acquire-by-hash' => {
86 name => 'Acquire-By-Hash',
87 allowed => CTRL_REPO_RELEASE,
88 },
89 'architecture' => {
90 name => 'Architecture',
91 allowed => (ALL_PKG | ALL_SRC | ALL_FILE_MANIFEST | CTRL_TESTS) & (~CTRL_TMPL_SRC),
92 separator => FIELD_SEP_SPACE,
93 },
94 'architectures' => {
95 name => 'Architectures',
96 allowed => CTRL_REPO_RELEASE,
97 separator => FIELD_SEP_SPACE,
98 },
99 'auto-built-package' => {
100 name => 'Auto-Built-Package',
101 allowed => ALL_PKG & ~CTRL_TMPL_PKG,
102 separator => FIELD_SEP_SPACE,
103 },
104 'binary' => {
105 name => 'Binary',
106 allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST,
107 # XXX: This field values are separated either by space or comma
108 # depending on the context.
109 separator => FIELD_SEP_SPACE | FIELD_SEP_COMMA,
110 },
111 'binary-only' => {
112 name => 'Binary-Only',
113 allowed => ALL_CHANGES,
114 },
115 'binary-only-changes' => {
116 name => 'Binary-Only-Changes',
117 allowed => CTRL_FILE_BUILDINFO,
118 },
119 'breaks' => {
120 name => 'Breaks',
121 allowed => ALL_PKG,
122 separator => FIELD_SEP_COMMA,
123 dependency => 'union',
124 dep_order => 7,
125 },
126 'bugs' => {
127 name => 'Bugs',
128 allowed => (ALL_PKG | CTRL_TMPL_SRC | CTRL_FILE_VENDOR) & (~CTRL_TMPL_PKG),
129 },
130 'build-architecture' => {
131 name => 'Build-Architecture',
132 allowed => CTRL_FILE_BUILDINFO,
133 },
134 'build-conflicts' => {
135 name => 'Build-Conflicts',
136 allowed => ALL_SRC,
137 separator => FIELD_SEP_COMMA,
138 dependency => 'union',
139 dep_order => 4,
140 },
141 'build-conflicts-arch' => {
142 name => 'Build-Conflicts-Arch',
143 allowed => ALL_SRC,
144 separator => FIELD_SEP_COMMA,
145 dependency => 'union',
146 dep_order => 5,
147 },
148 'build-conflicts-indep' => {
149 name => 'Build-Conflicts-Indep',
150 allowed => ALL_SRC,
151 separator => FIELD_SEP_COMMA,
152 dependency => 'union',
153 dep_order => 6,
154 },
155 'build-date' => {
156 name => 'Build-Date',
157 allowed => CTRL_FILE_BUILDINFO,
158 },
159 'build-depends' => {
160 name => 'Build-Depends',
161 allowed => ALL_SRC,
162 separator => FIELD_SEP_COMMA,
163 dependency => 'normal',
164 dep_order => 1,
165 },
166 'build-depends-arch' => {
167 name => 'Build-Depends-Arch',
168 allowed => ALL_SRC,
169 separator => FIELD_SEP_COMMA,
170 dependency => 'normal',
171 dep_order => 2,
172 },
173 'build-depends-indep' => {
174 name => 'Build-Depends-Indep',
175 allowed => ALL_SRC,
176 separator => FIELD_SEP_COMMA,
177 dependency => 'normal',
178 dep_order => 3,
179 },
180 'build-driver' => {
181 name => 'Build-Driver',
182 allowed => CTRL_TMPL_SRC,
183 },
184 'build-essential' => {
185 name => 'Build-Essential',
186 allowed => ALL_PKG,
187 },
188 'build-kernel-version' => {
189 name => 'Build-Kernel-Version',
190 allowed => CTRL_FILE_BUILDINFO,
191 },
192 'build-origin' => {
193 name => 'Build-Origin',
194 allowed => CTRL_FILE_BUILDINFO,
195 },
196 'build-path' => {
197 name => 'Build-Path',
198 allowed => CTRL_FILE_BUILDINFO,
199 },
200 'build-profiles' => {
201 name => 'Build-Profiles',
202 allowed => CTRL_TMPL_PKG,
203 separator => FIELD_SEP_SPACE,
204 },
205 'build-tainted-by' => {
206 name => 'Build-Tainted-By',
207 allowed => CTRL_FILE_BUILDINFO,
208 separator => FIELD_SEP_SPACE,
209 },
210 'built-for-profiles' => {
211 name => 'Built-For-Profiles',
212 allowed => ALL_PKG | CTRL_FILE_CHANGES,
213 separator => FIELD_SEP_SPACE,
214 },
215 'built-using' => {
216 name => 'Built-Using',
217 allowed => ALL_PKG,
218 separator => FIELD_SEP_COMMA,
219 dependency => 'union',
220 dep_order => 10,
221 },
222 'butautomaticupgrades' => {
223 name => 'ButAutomaticUpgrades',
224 allowed => CTRL_REPO_RELEASE,
225 },
226 'changed-by' => {
227 name => 'Changed-By',
228 allowed => CTRL_FILE_CHANGES,
229 },
230 'changelogs' => {
231 name => 'Changelogs',
232 allowed => CTRL_REPO_RELEASE,
233 },
234 'changes' => {
235 name => 'Changes',
236 allowed => ALL_CHANGES,
237 },
238 'checksums-md5' => {
239 name => 'Checksums-Md5',
240 allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST,
241 },
242 'checksums-sha1' => {
243 name => 'Checksums-Sha1',
244 allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST,
245 },
246 'checksums-sha256' => {
247 name => 'Checksums-Sha256',
248 allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST,
249 },
250 'classes' => {
251 name => 'Classes',
252 allowed => CTRL_TESTS,
253 separator => FIELD_SEP_COMMA,
254 },
255 'closes' => {
256 name => 'Closes',
257 allowed => ALL_CHANGES,
258 separator => FIELD_SEP_SPACE,
259 },
260 'codename' => {
261 name => 'Codename',
262 allowed => CTRL_REPO_RELEASE,
263 },
264 'comment' => {
265 name => 'Comment',
266 allowed => ALL_COPYRIGHT,
267 },
268 'components' => {
269 name => 'Components',
270 allowed => CTRL_REPO_RELEASE,
271 separator => FIELD_SEP_SPACE,
272 },
273 'conffiles' => {
274 name => 'Conffiles',
275 allowed => CTRL_FILE_STATUS,
276 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
277 },
278 'config-version' => {
279 name => 'Config-Version',
280 allowed => CTRL_FILE_STATUS,
281 },
282 'conflicts' => {
283 name => 'Conflicts',
284 allowed => ALL_PKG,
285 separator => FIELD_SEP_COMMA,
286 dependency => 'union',
287 dep_order => 6,
288 },
289 'copyright' => {
290 name => 'Copyright',
291 allowed => CTRL_COPYRIGHT_HEADER | CTRL_COPYRIGHT_FILES,
292 },
293 'date' => {
294 name => 'Date',
295 allowed => ALL_CHANGES | CTRL_REPO_RELEASE,
296 },
297 'depends' => {
298 name => 'Depends',
299 allowed => ALL_PKG | CTRL_TESTS,
300 separator => FIELD_SEP_COMMA,
301 dependency => 'normal',
302 dep_order => 2,
303 },
304 'description' => {
305 name => 'Description',
306 allowed => ALL_SRC | ALL_PKG | CTRL_FILE_CHANGES | CTRL_REPO_RELEASE,
307 },
308 'disclaimer' => {
309 name => 'Disclaimer',
310 allowed => CTRL_COPYRIGHT_HEADER,
311 },
312 'directory' => {
313 name => 'Directory',
314 allowed => CTRL_REPO_SRC,
315 },
316 'distribution' => {
317 name => 'Distribution',
318 allowed => ALL_CHANGES,
319 },
320 'enhances' => {
321 name => 'Enhances',
322 allowed => ALL_PKG,
323 separator => FIELD_SEP_COMMA,
324 dependency => 'union',
325 dep_order => 5,
326 },
327 'environment' => {
328 name => 'Environment',
329 allowed => CTRL_FILE_BUILDINFO,
330 separator => FIELD_SEP_LINE,
331 },
332 'essential' => {
333 name => 'Essential',
334 allowed => ALL_PKG,
335 },
336 'features' => {
337 name => 'Features',
338 allowed => CTRL_TESTS,
339 separator => FIELD_SEP_SPACE,
340 },
341 'filename' => {
342 name => 'Filename',
343 allowed => CTRL_REPO_PKG,
344 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
345 },
346 'files' => {
347 name => 'Files',
348 allowed => CTRL_DSC | CTRL_REPO_SRC | CTRL_FILE_CHANGES | CTRL_COPYRIGHT_FILES,
349 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
350 },
351 'format' => {
352 name => 'Format',
353 allowed => CTRL_DSC | CTRL_REPO_SRC | ALL_FILE_MANIFEST | CTRL_COPYRIGHT_HEADER,
354 },
355 'homepage' => {
356 name => 'Homepage',
357 allowed => ALL_SRC | ALL_PKG,
358 },
359 'installed-build-depends' => {
360 name => 'Installed-Build-Depends',
361 allowed => CTRL_FILE_BUILDINFO,
362 separator => FIELD_SEP_COMMA,
363 dependency => 'union',
364 dep_order => 12,
365 },
366 'installed-size' => {
367 name => 'Installed-Size',
368 allowed => ALL_PKG & ~CTRL_TMPL_PKG,
369 },
370 'installer-menu-item' => {
371 name => 'Installer-Menu-Item',
372 allowed => ALL_PKG,
373 },
374 'kernel-version' => {
375 name => 'Kernel-Version',
376 allowed => ALL_PKG,
377 },
378 'label' => {
379 name => 'Label',
380 allowed => CTRL_REPO_RELEASE,
381 },
382 'license' => {
383 name => 'License',
384 allowed => ALL_COPYRIGHT,
385 },
386 'origin' => {
387 name => 'Origin',
388 allowed => (ALL_PKG | ALL_SRC | CTRL_REPO_RELEASE) & (~CTRL_TMPL_PKG),
389 },
390 'maintainer' => {
391 name => 'Maintainer',
392 allowed => CTRL_DEB | CTRL_REPO_PKG | CTRL_FILE_STATUS | ALL_SRC | ALL_CHANGES,
393 },
394 'md5sum' => {
395 # XXX: Wrong capitalization due to historical reasons.
396 name => 'MD5sum',
397 allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE,
398 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
399 },
400 'multi-arch' => {
401 name => 'Multi-Arch',
402 allowed => ALL_PKG,
403 },
404 'no-support-for-architecture-all' => {
405 name => 'No-Support-for-Architecture-all',
406 allowed => CTRL_REPO_RELEASE,
407 },
408 'notautomatic' => {
409 name => 'NotAutomatic',
410 allowed => CTRL_REPO_RELEASE,
411 },
412 'package' => {
413 name => 'Package',
414 allowed => ALL_PKG | CTRL_REPO_SRC,
415 },
416 'package-list' => {
417 name => 'Package-List',
418 allowed => ALL_SRC & ~CTRL_TMPL_SRC,
419 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
420 },
421 'package-type' => {
422 name => 'Package-Type',
423 allowed => ALL_PKG,
424 },
425 'parent' => {
426 name => 'Parent',
427 allowed => CTRL_FILE_VENDOR,
428 },
429 'pre-depends' => {
430 name => 'Pre-Depends',
431 allowed => ALL_PKG,
432 separator => FIELD_SEP_COMMA,
433 dependency => 'normal',
434 dep_order => 1,
435 },
436 'priority' => {
437 name => 'Priority',
438 allowed => CTRL_TMPL_SRC | CTRL_REPO_SRC | ALL_PKG,
439 default => 'optional',
440 },
441 'protected' => {
442 name => 'Protected',
443 allowed => ALL_PKG,
444 },
445 'provides' => {
446 name => 'Provides',
447 allowed => ALL_PKG,
448 separator => FIELD_SEP_COMMA,
449 dependency => 'union',
450 dep_order => 9,
451 },
452 'recommends' => {
453 name => 'Recommends',
454 allowed => ALL_PKG,
455 separator => FIELD_SEP_COMMA,
456 dependency => 'normal',
457 dep_order => 3,
458 },
459 'replaces' => {
460 name => 'Replaces',
461 allowed => ALL_PKG,
462 separator => FIELD_SEP_COMMA,
463 dependency => 'union',
464 dep_order => 8,
465 },
466 'restrictions' => {
467 name => 'Restrictions',
468 allowed => CTRL_TESTS,
469 separator => FIELD_SEP_SPACE,
470 },
471 'rules-requires-root' => {
472 name => 'Rules-Requires-Root',
473 allowed => CTRL_TMPL_SRC,
474 separator => FIELD_SEP_SPACE,
475 },
476 'section' => {
477 name => 'Section',
478 allowed => CTRL_TMPL_SRC | CTRL_REPO_SRC | ALL_PKG,
479 default => 'unknown',
480 },
481 'sha1' => {
482 # XXX: Wrong capitalization due to historical reasons.
483 name => 'SHA1',
484 allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE,
485 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
486 },
487 'sha256' => {
488 # XXX: Wrong capitalization due to historical reasons.
489 name => 'SHA256',
490 allowed => CTRL_REPO_PKG | CTRL_REPO_RELEASE,
491 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
492 },
493 'size' => {
494 name => 'Size',
495 allowed => CTRL_REPO_PKG,
496 separator => FIELD_SEP_LINE | FIELD_SEP_SPACE,
497 },
498 'source' => {
499 name => 'Source',
500 allowed => (ALL_PKG | ALL_SRC | ALL_CHANGES | CTRL_COPYRIGHT_HEADER | CTRL_FILE_BUILDINFO) &
501 (~(CTRL_REPO_SRC | CTRL_TMPL_PKG)),
502 },
503 'standards-version' => {
504 name => 'Standards-Version',
505 allowed => ALL_SRC,
506 },
507 'static-built-using' => {
508 name => 'Static-Built-Using',
509 allowed => ALL_PKG,
510 separator => FIELD_SEP_COMMA,
511 dependency => 'union',
512 dep_order => 11,
513 },
514 'status' => {
515 name => 'Status',
516 allowed => CTRL_FILE_STATUS,
517 separator => FIELD_SEP_SPACE,
518 },
519 'subarchitecture' => {
520 name => 'Subarchitecture',
521 allowed => ALL_PKG,
522 },
523 'suite' => {
524 name => 'Suite',
525 allowed => CTRL_REPO_RELEASE,
526 },
527 'suggests' => {
528 name => 'Suggests',
529 allowed => ALL_PKG,
530 separator => FIELD_SEP_COMMA,
531 dependency => 'normal',
532 dep_order => 4,
533 },
534 'tag' => {
535 name => 'Tag',
536 allowed => ALL_PKG,
537 separator => FIELD_SEP_COMMA,
538 },
539 'task' => {
540 name => 'Task',
541 allowed => ALL_PKG,
542 },
543 'test-command' => {
544 name => 'Test-Command',
545 allowed => CTRL_TESTS,
546 },
547 'tests' => {
548 name => 'Tests',
549 allowed => CTRL_TESTS,
550 separator => FIELD_SEP_SPACE,
551 },
552 'tests-directory' => {
553 name => 'Tests-Directory',
554 allowed => CTRL_TESTS,
555 },
556 'testsuite' => {
557 name => 'Testsuite',
558 allowed => ALL_SRC,
559 separator => FIELD_SEP_COMMA,
560 },
561 'testsuite-triggers' => {
562 name => 'Testsuite-Triggers',
563 allowed => ALL_SRC,
564 separator => FIELD_SEP_COMMA,
565 },
566 'timestamp' => {
567 name => 'Timestamp',
568 allowed => CTRL_CHANGELOG,
569 },
570 'triggers-awaited' => {
571 name => 'Triggers-Awaited',
572 allowed => CTRL_FILE_STATUS,
573 separator => FIELD_SEP_SPACE,
574 },
575 'triggers-pending' => {
576 name => 'Triggers-Pending',
577 allowed => CTRL_FILE_STATUS,
578 separator => FIELD_SEP_SPACE,
579 },
580 'uploaders' => {
581 name => 'Uploaders',
582 allowed => ALL_SRC,
583 separator => FIELD_SEP_COMMA,
584 },
585 'upstream-name' => {
586 name => 'Upstream-Name',
587 allowed => CTRL_COPYRIGHT_HEADER,
588 },
589 'upstream-contact' => {
590 name => 'Upstream-Contact',
591 allowed => CTRL_COPYRIGHT_HEADER,
592 },
593 'urgency' => {
594 name => 'Urgency',
595 allowed => ALL_CHANGES,
596 },
597 'valid-until' => {
598 name => 'Valid-Until',
599 allowed => CTRL_REPO_RELEASE,
600 },
601 'vcs-browser' => {
602 name => 'Vcs-Browser',
603 allowed => ALL_SRC,
604 },
605 'vcs-arch' => {
606 name => 'Vcs-Arch',
607 allowed => ALL_SRC,
608 },
609 'vcs-bzr' => {
610 name => 'Vcs-Bzr',
611 allowed => ALL_SRC,
612 },
613 'vcs-cvs' => {
614 name => 'Vcs-Cvs',
615 allowed => ALL_SRC,
616 },
617 'vcs-darcs' => {
618 name => 'Vcs-Darcs',
619 allowed => ALL_SRC,
620 },
621 'vcs-git' => {
622 name => 'Vcs-Git',
623 allowed => ALL_SRC,
624 },
625 'vcs-hg' => {
626 name => 'Vcs-Hg',
627 allowed => ALL_SRC,
628 },
629 'vcs-mtn' => {
630 name => 'Vcs-Mtn',
631 allowed => ALL_SRC,
632 },
633 'vcs-svn' => {
634 name => 'Vcs-Svn',
635 allowed => ALL_SRC,
636 },
637 'vendor' => {
638 name => 'Vendor',
639 allowed => CTRL_FILE_VENDOR,
640 },
641 'vendor-url' => {
642 name => 'Vendor-Url',
643 allowed => CTRL_FILE_VENDOR,
644 },
645 'version' => {
646 name => 'Version',
647 allowed => (ALL_PKG | ALL_SRC | CTRL_FILE_BUILDINFO | ALL_CHANGES | CTRL_REPO_RELEASE) &
648 (~(CTRL_TMPL_SRC | CTRL_TMPL_PKG)),
649 },
650 );
651  
652 15 my @src_vcs_fields = qw(
653 vcs-browser
654 vcs-arch
655 vcs-bzr
656 vcs-cvs
657 vcs-darcs
658 vcs-git
659 vcs-hg
660 vcs-mtn
661 vcs-svn
662 );
663  
664 15 my @src_dep_fields = qw(
665 build-depends
666 build-depends-arch
667 build-depends-indep
668 build-conflicts
669 build-conflicts-arch
670 build-conflicts-indep
671 );
672 15 my @bin_dep_fields = qw(
673 pre-depends
674 depends
675 recommends
676 suggests
677 enhances
678 conflicts
679 breaks
680 replaces
681 provides
682 built-using
683 static-built-using
684 );
685  
686 15 my @src_test_fields = qw(
687 testsuite
688 testsuite-triggers
689 );
690  
691 15 my @src_checksums_fields = qw(
692 checksums-md5
693 checksums-sha1
694 checksums-sha256
695 );
696 15 my @bin_checksums_fields = qw(
697 md5sum
698 sha1
699 sha256
700 );
701  
702 15 our %FIELD_ORDER = (
703 CTRL_TMPL_SRC() => [
704 qw(
705 source
706 section
707 priority
708 maintainer
709 uploaders
710 origin
711 bugs
712 ),
713 @src_vcs_fields,
714 qw(
715 homepage
716 standards-version
717 rules-requires-root
718 ),
719 @src_dep_fields,
720 @src_test_fields,
721 qw(
722 description
723 ),
724 ],
725 CTRL_TMPL_PKG() => [
726 qw(
727 package
728 package-type
729 section
730 priority
731 architecture
732 subarchitecture
733 multi-arch
734 essential
735 protected
736 build-essential
737 build-profiles
738 built-for-profiles
739 kernel-version
740 ),
741 @bin_dep_fields,
742 qw(
743 homepage
744 installer-menu-item
745 task
746 tag
747 description
748 ),
749 ],
750 CTRL_DSC() => [
751 qw(
752 format
753 source
754 binary
755 architecture
756 version
757 origin
758 maintainer
759 uploaders
760 homepage
761 description
762 standards-version
763 ),
764 @src_vcs_fields,
765 @src_test_fields,
766 @src_dep_fields,
767 qw(
768 package-list
769 ),
770 @src_checksums_fields,
771 qw(
772 files
773 ),
774 ],
775 CTRL_DEB() => [
776 qw(
777 package
778 package-type
779 source
780 version
781 kernel-version
782 built-for-profiles
783 auto-built-package
784 architecture
785 subarchitecture
786 installer-menu-item
787 build-essential
788 essential
789 protected
790 origin
791 bugs
792 maintainer
793 installed-size
794 ),
795 @bin_dep_fields,
796 qw(
797 section
798 priority
799 multi-arch
800 homepage
801 description
802 tag
803 task
804 ),
805 ],
806 CTRL_REPO_SRC() => [
807 qw(
808 format
809 package
810 binary
811 architecture
812 version
813 priority
814 section
815 origin
816 maintainer
817 uploaders
818 homepage
819 description
820 standards-version
821 ),
822 @src_vcs_fields,
823 @src_test_fields,
824 @src_dep_fields,
825 qw(
826 package-list
827 directory
828 ),
829 @src_checksums_fields,
830 qw(
831 files
832 ),
833 ],
834 CTRL_REPO_PKG() => [
835 qw(
836 package
837 package-type
838 source
839 version
840 kernel-version
841 built-for-profiles
842 auto-built-package
843 architecture
844 subarchitecture
845 installer-menu-item
846 build-essential
847 essential
848 protected
849 origin
850 bugs
851 maintainer
852 installed-size
853 ),
854 @bin_dep_fields,
855 qw(
856 filename
857 size
858 ),
859 @bin_checksums_fields,
860 qw(
861 section
862 priority
863 multi-arch
864 homepage
865 description
866 tag
867 task
868 ),
869 ],
870 CTRL_REPO_RELEASE() => [
871 qw(
872 origin
873 label
874 suite
875 version
876 codename
877 changelogs
878 date
879 valid-until
880 notautomatic
881 butautomaticupgrades
882 acquire-by-hash
883 no-support-for-architecture-all
884 architectures
885 components
886 description
887 ),
888 @bin_checksums_fields
889 ],
890 CTRL_CHANGELOG() => [
891 qw(
892 source
893 binary-only
894 version
895 distribution
896 urgency
897 maintainer
898 timestamp
899 date
900 closes
901 changes
902 ),
903 ],
904 CTRL_COPYRIGHT_HEADER() => [
905 qw(
906 format
907 upstream-name
908 upstream-contact
909 source
910 disclaimer
911 comment
912 license
913 copyright
914 ),
915 ],
916 CTRL_COPYRIGHT_FILES() => [
917 qw(
918 files
919 copyright
920 license
921 comment
922 ),
923 ],
924 CTRL_COPYRIGHT_LICENSE() => [
925 qw(
926 license
927 comment
928 ),
929 ],
930 CTRL_FILE_BUILDINFO() => [
931 qw(
932 format
933 source
934 binary
935 architecture
936 version
937 binary-only-changes
938 ),
939 @src_checksums_fields,
940 qw(
941 build-origin
942 build-architecture
943 build-kernel-version
944 build-date
945 build-path
946 build-tainted-by
947 installed-build-depends
948 environment
949 ),
950 ],
951 CTRL_FILE_CHANGES() => [
952 qw(
953 format
954 date
955 source
956 binary
957 binary-only
958 built-for-profiles
959 architecture
960 version
961 distribution
962 urgency
963 maintainer
964 changed-by
965 description
966 closes
967 changes
968 ),
969 @src_checksums_fields,
970 qw(
971 files
972 ),
973 ],
974 CTRL_FILE_VENDOR() => [
975 qw(
976 vendor
977 vendor-url
978 bugs
979 parent
980 ),
981 ],
982 CTRL_FILE_STATUS() => [
983 # Same as fieldinfos in «lib/dpkg/parse.c».
984 qw(
985 package
986 essential
987 protected
988 status
989 priority
990 section
991 installed-size
992 origin
993 maintainer
994 bugs
995 architecture
996 multi-arch
997 source
998 version
999 config-version
1000 replaces
1001 provides
1002 depends
1003 pre-depends
1004 recommends
1005 suggests
1006 breaks
1007 conflicts
1008 enhances
1009 conffiles
1010 description
1011 triggers-pending
1012 triggers-awaited
1013 ),
1014 # These are allowed here, but not tracked by lib/dpkg/parse.c.
1015 qw(
1016 auto-built-package
1017 build-essential
1018 built-for-profiles
1019 built-using
1020 static-built-using
1021 homepage
1022 installer-menu-item
1023 kernel-version
1024 package-type
1025 subarchitecture
1026 tag
1027 task
1028 ),
1029 ],
1030 CTRL_TESTS() => [
1031 qw(
1032 test-command
1033 tests
1034 tests-directory
1035 architecture
1036 restrictions
1037 features
1038 classes
1039 depends
1040 ),
1041 ],
1042 );
1043  
1044 =head1 FUNCTIONS
1045  
1046 =over 4
1047  
1048 =item $field = field_capitalize($field_name)
1049  
1050 Returns the field name properly capitalized. All characters are lowercase,
1051 except the first of each word (words are separated by a hyphen in field names).
1052  
1053 =cut
1054  
1055 5901 ▶sub field_capitalize {
Subroutine field_capitalize: called CC=2 SCAR=6.9
Pod documented
1056 5901 my $field = lc(shift);
1057  
1058 # Use known fields first.
1059 5901 ▶ return $FIELDS{$field}{name} if exists $FIELDS{$field};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Dpkg::Control::FieldsCore::FIELDS{$field} 5835 66 5901
1060  
1061 # Generic case.
1062 66 return join '-', map { ucfirst } split /-/, $field;
1063 }
1064  
1065 =item $bool = field_is_official($fname)
1066  
1067 Returns true if the field is official and known.
1068  
1069 =cut
1070  
1071 352 ▶sub field_is_official {
Subroutine field_is_official: called CC=1 SCAR=0.0
Pod documented
1072 352 my $field = lc shift;
1073  
1074 352 return exists $FIELDS{$field};
1075 }
1076  
1077 =item $bool = field_is_allowed_in($fname, @types)
1078  
1079 Returns true (1) if the field $fname is allowed in all the types listed in
1080 the list. Note that you can use type sets instead of individual types (ex:
1081 CTRL_FILE_CHANGES | CTRL_CHANGELOG).
1082  
1083 field_allowed_in(A|B, C) returns true only if the field is allowed in C
1084 and either A or B.
1085  
1086 Undef is returned for non-official fields.
1087  
1088 =cut
1089  
1090 2468 ▶sub field_is_allowed_in {
Subroutine field_is_allowed_in: called CC=6 SCAR=18.0
Pod documented
1091 2468 my ($field, @types) = @_;
1092 2468 $field = lc $field;
1093  
1094 2468 ▶ return unless exists $FIELDS{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Dpkg::Control::FieldsCore::FIELDS{$field} 22 2446 2468
1095  
1096 2446 ▶ return 0 if not scalar(@types);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @types 0 2446 2446
1097 2446 foreach my $type (@types) {
1098 # Unknown control type is always allowed.
1099 2784 ▶ next if $type == CTRL_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
if $type == 0 0 2784 2784
1100 2784 ▶ return 0 unless $FIELDS{$field}{allowed} & $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $Dpkg::Control::FieldsCore::FIELDS{$field}{"allowed"} & $type 1709 1075 2784
1101 }
1102 737 return 1;
1103 }
1104  
1105 =item $new_field = field_transfer_single($from, $to, $field)
1106  
1107 If appropriate, copy the value of the field named $field taken from the
1108 $from L<Dpkg::Control> object to the $to L<Dpkg::Control> object.
1109  
1110 Official fields are copied only if the field is allowed in both types of
1111 objects. Custom fields are treated in a specific manner. When the target
1112 is not among CTRL_DSC, CTRL_DEB or CTRL_FILE_CHANGES, then they
1113 are always copied as is (the X- prefix is kept). Otherwise they are not
1114 copied except if the target object matches the target destination encoded
1115 in the field name. The initial X denoting custom fields can be followed by
1116 one or more letters among "S" (Source: corresponds to CTRL_DSC), "B"
1117 (Binary: corresponds to CTRL_DEB) or "C" (Changes: corresponds to
1118 CTRL_FILE_CHANGES).
1119  
1120 Returns undef if nothing has been copied or the name of the new field
1121 added to $to otherwise.
1122  
1123 =cut
1124  
1125 360 ▶sub field_transfer_single {
Subroutine field_transfer_single: called CC=16 SCAR=39.8
Pod documented
1126 360 my ($from, $to, $field) = @_;
1127 360 my ($from_type, $to_type) = ($from->get_type(), $to->get_type());
1128 360 $field = field_capitalize($field);
1129  
1130 360 ▶ if (field_is_allowed_in($field, $from_type, $to_type)) {
Branch: 3 branches
BranchTrueFalseTotal
if (field_is_allowed_in($field, $from_type, $to_type)) { } 338 22 360
elsif ($field =~ /^X([SBC]*)-/iu) { } 22 0 22
elsif (not field_is_allowed_in($field, $from_type)) { } 0 0 0
1131 338 $to->{$field} = $from->{$field};
1132 338 return $field;
1133 } elsif ($field =~ /^X([SBC]*)-/i) {
1134 22 my $dest = $1;
1135  
1136 22 ▶ if ($dest =~ /SC/i and $from_type == CTRL_TMPL_PKG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dest =~ /SC/iu and $from_type == 2) 0 22 22
Condition33%1/3
$dest =~ /SC/iu and $from_type == 2
!ll&&!rl&&r
2200
MC/DC0%0/2
$dest =~ /SC/iu and $from_type == 2
$dest =~ /SC/iu $from_type == 2
Truth table33%1/3
A and B
A= $dest =~ /SC/iuB= $from_type == 2
ABresult
0X0
100
111
1137 0 warning(g_('non-sensical field export rules (%s) in field %s in ' .
1138 'binary stanza from source package template control file'),
1139 $dest, $field);
1140 }
1141 22 ▶ if (($dest =~ /B/i and $to_type == CTRL_DEB) or
Branch: 2 branches
BranchTrueFalseTotal
if ($dest =~ /B/iu and $to_type == 32 or $dest =~ /S/iu and $to_type == 16 or $dest =~ /C/iu and $to_type == 64) { } 0 22 22
elsif ($to_type != 32 and $to_type != 16 and $to_type != 64) { } 22 0 22
Condition46%7/15
$dest =~ /B/iu and $to_type == 32 or $dest =~ /S/iu and $to_type == 16 or $dest =~ /C/iu and $to_type == 64
l!l&&r!l&&!r
0022
$dest =~ /B/iu and $to_type == 32 or $dest =~ /S/iu and $to_type == 16
l!l&&r!l&&!r
0022
$dest =~ /B/iu and $to_type == 32
!ll&&!rl&&r
12100
$dest =~ /S/iu and $to_type == 16
!ll&&!rl&&r
2200
$dest =~ /C/iu and $to_type == 64
!ll&&!rl&&r
10120
MC/DC0%0/6
$dest =~ /B/iu and $to_type == 32 or $dest =~ /S/iu and $to_type == 16 or $dest =~ /C/iu and $to_type == 64
$dest =~ /B/iu $to_type == 32 $dest =~ /S/iu $to_type == 16 $dest =~ /C/iu $to_type == 64
Truth table13%2/15
A and B or C and D or E and F
A= $dest =~ /B/iuB= $to_type == 32C= $dest =~ /S/iuD= $to_type == 16E= $dest =~ /C/iuF= $to_type == 64
ABCDEFresult
11XXXX1
0X11XX1
1011XX1
0X0X111
0X10111
100X111
1010111
0X0X0X0
0X0X100
0X100X0
0X10100
100X0X0
100X100
10100X0
1010100
1142 ($dest =~ /S/i and $to_type == CTRL_DSC) or
1143 ($dest =~ /C/i and $to_type == CTRL_FILE_CHANGES))
1144 {
1145 0 my $new = $field;
1146 0 $new =~ s/^X([SBC]*)-//i;
1147 0 $to->{$new} = $from->{$field};
1148 0 return $new;
1149 ▶ } elsif ($to_type != CTRL_DEB and
Condition33%2/6
$to_type != 32 and $to_type != 16 and $to_type != 64
!ll&&!rl&&r
0022
$to_type != 32 and $to_type != 16
!ll&&!rl&&r
0022
MC/DC0%0/3
$to_type != 32 and $to_type != 16 and $to_type != 64
$to_type != 32 $to_type != 16 $to_type != 64
Truth table25%1/4
A and B and C
A= $to_type != 32B= $to_type != 16C= $to_type != 64
ABCresult
0XX0
10X0
1100
1111
1150 $to_type != CTRL_DSC and
1151 $to_type != CTRL_FILE_CHANGES)
1152 {
1153 22 $to->{$field} = $from->{$field};
1154 22 return $field;
1155 }
1156 } elsif (not field_is_allowed_in($field, $from_type)) {
1157 0 ▶ warning(g_("unknown information field '%s' in input data in %s"),
Condition0%0/3
$from->get_option('name') || g_('control information')
l!l&&r!l&&!r
000
MC/DC0%0/2
$from->get_option('name') || g_('control information')
$from->get_option('name') g_('control information')
Truth table0%0/3
A || B
A= $from->get_option('name')B= g_('control information')
ABresult
1X1
011
000
1158 $field, $from->get_option('name') || g_('control information'));
1159 }
1160 0 return;
1161 }
1162  
1163 =item @field_list = field_transfer_all($from, $to)
1164  
1165 Transfer all appropriate fields from $from to $to. Calls
1166 field_transfer_single() on all fields available in $from.
1167  
1168 Returns the list of fields that have been added to $to.
1169  
1170 =cut
1171  
1172 0 ▶sub field_transfer_all {
Subroutine field_transfer_all: not called CC=4 SCAR=30.0
Pod documented
1173 0 my ($from, $to) = @_;
1174 0 my (@res, $res);
1175 0 foreach my $k (keys %$from) {
1176 0 $res = field_transfer_single($from, $to, $k);
1177 0 ▶ push @res, $res if $res and defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if $res and defined wantarray 0 0 0
Condition0%0/3
$res and defined wantarray
!ll&&!rl&&r
000
MC/DC0%0/2
$res and defined wantarray
$res defined wantarray
Truth table0%0/3
A and B
A= $resB= defined wantarray
ABresult
0X0
100
111
1178 }
1179 0 return @res;
1180 }
1181  
1182 =item @field_list = field_ordered_list($type)
1183  
1184 Returns an ordered list of fields for a given type of control information.
1185 This list can be used to output the fields in a predictable order.
1186 The list might be empty for types where the order does not matter much.
1187  
1188 =cut
1189  
1190 816 ▶sub field_ordered_list {
Subroutine field_ordered_list: called CC=2 SCAR=7.2
Pod documented
1191 816 my $type = shift;
1192  
1193 816 ▶ if (exists $FIELD_ORDER{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $Dpkg::Control::FieldsCore::FIELD_ORDER{$type}) 816 0 816
1194 816 return map { $FIELDS{$_}{name} } @{$FIELD_ORDER{$type}};
1195 }
1196 0 return ();
1197 }
1198  
1199 =item $email = field_parse_maintainer($ctrl)
1200  
1201 Parses the C<Maintainer> field from the Dpkg::Control $ctrl object, and
1202 returns a Dpkg::Email::Address object.
1203  
1204 =cut
1205  
1206 3 ▶sub field_parse_maintainer($ctrl)
Subroutine field_parse_maintainer: called CC=3 SCAR=12.3
Pod documented
1207 {
1208 3 my $maint = $ctrl->{'Maintainer'};
1209  
1210 # XXX: Catch and remove bogus trailing comma for a transitory period.
1211 3 ▶ if ($maint =~ s{,\s*$}{}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($maint =~ s/,\s*$//u) 0 3 3
1212 0 warning(g_('unexpected trailing comma in %s field with value "%s"'),
1213 'Maintainer', $maint);
1214 }
1215  
1216 3 require Dpkg::Email::Address;
1217 eval {
1218 3 return Dpkg::Email::Address->new($maint);
1219 3 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { return "Dpkg::Email::Address"->new($maint) } } or do { error(g_("cannot parse %s field value \"%s\""), "Maintainer", $maint) } 3 0 3
1220 0 error(g_('cannot parse %s field value "%s"'),
1221 'Maintainer', $maint);
1222 };
1223 }
1224  
1225 =item $email_list = field_parse_uploaders($ctrl)
1226  
1227 Parses the C<Uploaders> field from the Dpkg::Control $ctrl object, and
1228 returns a Dpkg::Email::AddressList object, containing the list of
1229 Dpkg::Email::Address for each uploader.
1230  
1231 =cut
1232  
1233 7 ▶sub field_parse_uploaders($ctrl)
Subroutine field_parse_uploaders: called CC=2 SCAR=7.4
Pod documented
1234 {
1235 7 my $uploaders = $ctrl->{'Uploaders'};
1236  
1237 7 require Dpkg::Email::AddressList;
1238 eval {
1239 7 return Dpkg::Email::AddressList->new($uploaders);
1240 7 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { return "Dpkg::Email::AddressList"->new($uploaders) } } or do { error(g_("cannot parse %s field value \"%s\""), "Uploaders", $uploaders) } 7 0 7
1241 0 error(g_('cannot parse %s field value "%s"'),
1242 'Uploaders', $uploaders);
1243 };
1244 }
1245  
1246 =item ($source, $version) = field_parse_binary_source($ctrl)
1247  
1248 Parse the B<Source> field in a binary package control stanza. The field
1249 contains the source package name where it was built from, and optionally
1250 a space and the source version enclosed in parenthesis if it is different
1251 from the binary version.
1252  
1253 Returns a list with the $source name, and the source $version, or undef
1254 or an empty list when $ctrl does not contain a binary package control stanza.
1255 Neither $source nor $version are validated, but that can be done with
1256 Dpkg::Package::pkg_name_is_invalid() and Dpkg::Version::version_check().
1257  
1258 =cut
1259  
1260 3 ▶sub field_parse_binary_source {
Subroutine field_parse_binary_source: called CC=8 SCAR=23.0
Pod documented
1261 3 my $ctrl = shift;
1262 3 my $ctrl_type = $ctrl->get_type();
1263  
1264 3 ▶ if ($ctrl_type != CTRL_REPO_PKG and
Branch: 1 branch
BranchTrueFalseTotal
if ($ctrl_type != 8 and $ctrl_type != 32 and $ctrl_type != 64 and $ctrl_type != 32768 and $ctrl_type != 256) 0 3 3
Condition33%4/12
$ctrl_type != 8 and $ctrl_type != 32 and $ctrl_type != 64 and $ctrl_type != 32768 and $ctrl_type != 256
!ll&&!rl&&r
300
$ctrl_type != 8 and $ctrl_type != 32 and $ctrl_type != 64 and $ctrl_type != 32768
!ll&&!rl&&r
300
$ctrl_type != 8 and $ctrl_type != 32 and $ctrl_type != 64
!ll&&!rl&&r
300
$ctrl_type != 8 and $ctrl_type != 32
!ll&&!rl&&r
030
MC/DC0%0/5
$ctrl_type != 8 and $ctrl_type != 32 and $ctrl_type != 64 and $ctrl_type != 32768 and $ctrl_type != 256
$ctrl_type != 8 $ctrl_type != 32 $ctrl_type != 64 $ctrl_type != 32768 $ctrl_type != 256
Truth table16%1/6
A and B and C and D and E
A= $ctrl_type != 8B= $ctrl_type != 32C= $ctrl_type != 64D= $ctrl_type != 32768E= $ctrl_type != 256
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1265 $ctrl_type != CTRL_DEB and
1266 $ctrl_type != CTRL_FILE_CHANGES and
1267 $ctrl_type != CTRL_FILE_BUILDINFO and
1268 $ctrl_type != CTRL_FILE_STATUS) {
1269 0 return;
1270 }
1271  
1272 3 my ($source, $version);
1273  
1274 # For .changes and .buildinfo the Source field always exists,
1275 # and there is no Package field.
1276 3 ▶ if (exists $ctrl->{'Source'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ctrl->{'Source'}) { } 2 1 3
1277 2 $source = $ctrl->{'Source'};
1278 2 ▶ if ($source =~ m/^([^ ]+) +\(([^)]*)\)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source =~ /^([^ ]+) +\(([^)]*)\)$/u) { } 1 1 2
1279 1 $source = $1;
1280 1 $version = $2;
1281 } else {
1282 1 $version = $ctrl->{'Version'};
1283 }
1284 } else {
1285 1 $source = $ctrl->{'Package'};
1286 1 $version = $ctrl->{'Version'};
1287 }
1288  
1289 3 return ($source, $version);
1290 }
1291  
1292 =item @field_list = field_list_src_dep()
1293  
1294 List of fields that contains dependencies-like information in a source
1295 Debian package.
1296  
1297 =cut
1298  
1299 1 ▶sub field_list_src_dep {
Subroutine field_list_src_dep: called CC=2 SCAR=6.9
Pod documented
1300 my @list = map {
1301 $FIELDS{$_}{name}
1302 6 } sort {
1303 $FIELDS{$a}{dep_order} <=> $FIELDS{$b}{dep_order}
1304 10 } grep {
1305 1 field_is_allowed_in($_, CTRL_DSC) and
1306 exists $FIELDS{$_}{dependency}
1307 118 ▶ } keys %FIELDS;
Condition100%3/3
field_is_allowed_in($_, 16) && exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
!ll&&!rl&&r
85276
MC/DC100%2/2
field_is_allowed_in($_, 16) && exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
field_is_allowed_in($_, 16) exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
Truth table100%3/3
A && B
A= field_is_allowed_in($_, 16)B= exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
ABresult
0X0
100
111
1308 1 return @list;
1309 }
1310  
1311 =item @field_list = field_list_pkg_dep()
1312  
1313 List of fields that contains dependencies-like information in a binary
1314 Debian package. The fields that express real dependencies are sorted from
1315 the stronger to the weaker.
1316  
1317 =cut
1318  
1319 1 ▶sub field_list_pkg_dep {
Subroutine field_list_pkg_dep: called CC=2 SCAR=6.9
Pod documented
1320 my @list = map {
1321 $FIELDS{$_}{name}
1322 11 } sort {
1323 $FIELDS{$a}{dep_order} <=> $FIELDS{$b}{dep_order}
1324 28 } grep {
1325 1 field_is_allowed_in($_, CTRL_DEB) and
1326 exists $FIELDS{$_}{dependency}
1327 118 ▶ } keys %FIELDS;
Condition100%3/3
field_is_allowed_in($_, 32) && exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
!ll&&!rl&&r
832411
MC/DC100%2/2
field_is_allowed_in($_, 32) && exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
field_is_allowed_in($_, 32) exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
Truth table100%3/3
A && B
A= field_is_allowed_in($_, 32)B= exists $Dpkg::Control::FieldsCore::FIELDS{$_}{'dependency'}
ABresult
0X0
100
111
1328 1 return @list;
1329 }
1330  
1331 =item $dep_type = field_get_dep_type($field)
1332  
1333 Return the type of the dependency expressed by the given field. Can
1334 either be "normal" for a real dependency field (Pre-Depends, Depends, ...)
1335 or "union" for other relation fields sharing the same syntax (Conflicts,
1336 Breaks, ...). Returns undef for fields which are not dependencies.
1337  
1338 =cut
1339  
1340 0 ▶sub field_get_dep_type {
Subroutine field_get_dep_type: not called CC=3 SCAR=24.8
Pod documented
1341 0 my $field = lc shift;
1342  
1343 return $FIELDS{$field}{dependency}
1344 0 ▶ if exists $FIELDS{$field} && exists $FIELDS{$field}{dependency};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"dependency"} 0 0 0
Condition0%0/3
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"dependency"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"dependency"}
exists $Dpkg::Control::FieldsCore::FIELDS{$field} exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"dependency"}
Truth table0%0/3
A and B
A= exists $Dpkg::Control::FieldsCore::FIELDS{$field}B= exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"dependency"}
ABresult
0X0
100
111
1345 0 return;
1346 }
1347  
1348 =item $sep_type = field_get_sep_type($field)
1349  
1350 Return the type of the field value separator. Can be one of FIELD_SEP_UNKNOWN,
1351 FIELD_SEP_SPACE, FIELD_SEP_COMMA or FIELD_SEP_LINE.
1352  
1353 =cut
1354  
1355 9 ▶sub field_get_sep_type {
Subroutine field_get_sep_type: called CC=3 SCAR=11.0
Pod documented
1356 9 my $field = lc shift;
1357  
1358 return $FIELDS{$field}{separator}
1359 9 ▶ if exists $FIELDS{$field} && exists $FIELDS{$field}{separator};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"separator"} 7 2 9
Condition66%2/3
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"separator"}
!ll&&!rl&&r
207
MC/DC50%1/2
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"separator"}
exists $Dpkg::Control::FieldsCore::FIELDS{$field} exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"separator"}
Truth table66%2/3
A and B
A= exists $Dpkg::Control::FieldsCore::FIELDS{$field}B= exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"separator"}
ABresult
0X0
100
111
1360 2 return FIELD_SEP_UNKNOWN;
1361 }
1362  
1363 =item $value = field_get_default_value($field)
1364  
1365 Return the default value (if any) for the field. If there is no default value
1366 then it returns "undef".
1367  
1368 =cut
1369  
1370 3 ▶sub field_get_default_value {
Subroutine field_get_default_value: called CC=3 SCAR=11.0
Pod documented
1371 3 my $field = lc shift;
1372  
1373 return $FIELDS{$field}{default}
1374 3 ▶ if exists $FIELDS{$field} && exists $FIELDS{$field}{default};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"default"} 2 1 3
Condition66%2/3
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"default"}
!ll&&!rl&&r
012
MC/DC50%1/2
exists $Dpkg::Control::FieldsCore::FIELDS{$field} and exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"default"}
exists $Dpkg::Control::FieldsCore::FIELDS{$field} exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"default"}
Truth table66%2/3
A and B
A= exists $Dpkg::Control::FieldsCore::FIELDS{$field}B= exists $Dpkg::Control::FieldsCore::FIELDS{$field}{"default"}
ABresult
0X0
100
111
1375 1 return;
1376 }
1377  
1378 =item field_register($field, $allowed_types, %opts)
1379  
1380 Register a new field as being allowed in control information of specified
1381 types. %opts is optional.
1382  
1383 =cut
1384  
1385 1 ▶sub field_register {
Subroutine field_register: called CC=1 SCAR=0.0
Pod documented
1386 1 my ($field, $types, %opts) = @_;
1387  
1388 1 $field = lc $field;
1389 1 $FIELDS{$field} = {
1390 name => field_capitalize($field),
1391 allowed => $types,
1392 %opts
1393 };
1394  
1395 1 return;
1396 }
1397  
1398 =item $bool = field_insert_after($type, $ref, @fields)
1399  
1400 Place field after another one ($ref) in output of control information of
1401 type $type.
1402  
1403 Return true if the field was inserted, otherwise false.
1404  
1405 =cut
1406  
1407 2 ▶sub field_insert_after {
Subroutine field_insert_after: called CC=3 SCAR=11.0
Pod documented
1408 2 my ($type, $field, @fields) = @_;
1409  
1410 2 ▶ return 0 if not exists $FIELD_ORDER{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Dpkg::Control::FieldsCore::FIELD_ORDER{$type} 0 2 2
1411  
1412 2 ($field, @fields) = map { lc } ($field, @fields);
1413 2 @{$FIELD_ORDER{$type}} = map {
1414 29 ▶ ($_ eq $field) ? ($_, @fields) : $_
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $field ? : 2 27 29
1415 2 } @{$FIELD_ORDER{$type}};
1416  
1417 2 return 1;
1418 }
1419  
1420 =item $bool = field_insert_before($type, $ref, @fields)
1421  
1422 Place field before another one ($ref) in output of control information of
1423 type $type.
1424  
1425 Return true if the field was inserted, otherwise false.
1426  
1427 =cut
1428  
1429 0 ▶sub field_insert_before {
Subroutine field_insert_before: not called CC=3 SCAR=24.8
Pod documented
1430 0 my ($type, $field, @fields) = @_;
1431  
1432 0 ▶ return 0 if not exists $FIELD_ORDER{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Dpkg::Control::FieldsCore::FIELD_ORDER{$type} 0 0 0
1433  
1434 0 ($field, @fields) = map { lc } ($field, @fields);
1435 0 @{$FIELD_ORDER{$type}} = map {
1436 0 ▶ ($_ eq $field) ? (@fields, $_) : $_
Branch: 1 branch
BranchTrueFalseTotal
$_ eq $field ? : 0 0 0
1437 0 } @{$FIELD_ORDER{$type}};
1438  
1439 0 return 1;
1440 }
1441  
1442 =back
1443  
1444 =head1 CHANGES
1445  
1446 =head2 Version 1.05 (dpkg 1.23.4)
1447  
1448 New functions: field_parse_maintainer(), field_parse_uploaders().
1449  
1450 =head2 Version 1.04 (dpkg 1.23.0)
1451  
1452 Remove argument: field_transfer_single() implicit argument usage.
1453  
1454 =head2 Version 1.03 (dpkg 1.22.12)
1455  
1456 New function: field_get_default_value().
1457  
1458 =head2 Version 1.02 (dpkg 1.22.0)
1459  
1460 Deprecate argument: field_transfer_single() implicit argument usage.
1461  
1462 =head2 Version 1.01 (dpkg 1.21.0)
1463  
1464 New function: field_parse_binary_source().
1465  
1466 =head2 Version 1.00 (dpkg 1.17.0)
1467  
1468 Mark the module as public.
1469  
1470 =cut
1471  
1472 15 1;
« Dpkg/Source/Archive.pm ↑ Summary Dpkg/Shlibs/Objdump/Object.pm »