1Dpkg::Control::HashCore(3perl) libdpkg-perl Dpkg::Control::HashCore(3perl)
2
3
4
6 Dpkg::Control::HashCore - parse and manipulate a block of RFC822-like
7 fields
8
10 The Dpkg::Control::Hash class is a hash-like representation of a set of
11 RFC822-like fields. The fields names are case insensitive and are
12 always capitalized the same when output (see field_capitalize function
13 in Dpkg::Control::Fields). The order in which fields have been set is
14 remembered and is used to be able to dump back the same content. The
15 output order can also be overridden if needed.
16
17 You can store arbitrary values in the hash, they will always be
18 properly escaped in the output to conform to the syntax of control
19 files. This is relevant mainly for multilines values: while the first
20 line is always output unchanged directly after the field name,
21 supplementary lines are modified. Empty lines and lines containing only
22 dots are prefixed with " ." (space + dot) while other lines are
23 prefixed with a single space.
24
25 During parsing, trailing spaces are stripped on all lines while leading
26 spaces are stripped only on the first line of each field.
27
29 $c = Dpkg::Control::Hash->new(%opts)
30 Creates a new object with the indicated options. Supported options
31 are:
32
33 allow_pgp
34 Configures the parser to accept OpenPGP signatures around
35 the control information. Value can be 0 (default) or 1.
36
37 allow_duplicate
38 Configures the parser to allow duplicate fields in the
39 control information. The last value overrides any previous
40 values. Value can be 0 (default) or 1.
41
42 keep_duplicate
43 Configure the parser to keep values for duplicate fields
44 found in the control information (when allow_duplicate is
45 enabled), as array references. Value can be 0 (default) or
46 1.
47
48 drop_empty
49 Defines if empty fields are dropped during the output.
50 Value can be 0 (default) or 1.
51
52 name The user friendly name of the information stored in the
53 object. It might be used in some error messages or
54 warnings. A default name might be set depending on the
55 type.
56
57 is_pgp_signed
58 Set by the parser (starting in dpkg 1.17.0) if it finds an
59 OpenPGP signature around the control information. Value can
60 be 0 (default) or 1, and undef when the option is not
61 supported by the code (in versions older than dpkg 1.17.0).
62
63 $c->set_options($option, %opts)
64 Changes the value of one or more options.
65
66 $value = $c->get_option($option)
67 Returns the value of the corresponding option.
68
69 $c->parse_error($file, $fmt, ...)
70 Prints an error message and dies on syntax parse errors.
71
72 $c->parse($fh, $description)
73 Parse a control file from the given filehandle. Exits in case of
74 errors. $description is used to describe the filehandle, ideally
75 it's a filename or a description of where the data comes from. It's
76 used in error messages. When called multiple times, the parsed
77 fields are accumulated.
78
79 Returns true if some fields have been parsed.
80
81 $c->load($file)
82 Parse the content of $file. Exits in case of errors. Returns true
83 if some fields have been parsed.
84
85 $c->find_custom_field($name)
86 Scan the fields and look for a user specific field whose name
87 matches the following regex: /X[SBC]*-$name/i. Return the name of
88 the field found or undef if nothing has been found.
89
90 $c->get_custom_field($name)
91 Identify a user field and retrieve its value.
92
93 $str = $c->output()
94 "$c"
95 Get a string representation of the control information. The fields
96 are sorted in the order in which they have been read or set except
97 if the order has been overridden with set_output_order().
98
99 $c->output($fh)
100 Print the string representation of the control information to a
101 filehandle.
102
103 $c->save($filename)
104 Write the string representation of the control information to a
105 file.
106
107 $c->set_output_order(@fields)
108 Define the order in which fields will be displayed in the output()
109 method.
110
111 $c->apply_substvars($substvars)
112 Update all fields by replacing the variables references with the
113 corresponding value stored in the Dpkg::Substvars object.
114
116 Version 1.02 (dpkg 1.21.0)
117 New option: "keep_duplicate" in new().
118
119 Version 1.01 (dpkg 1.17.2)
120 New method: $c->parse_error().
121
122 Version 1.00 (dpkg 1.17.0)
123 Mark the module as public.
124
125
126
1271.21.9 2022-08-04 Dpkg::Control::HashCore(3perl)