Lintian::Deb822(3) | Debian Package Checker | Lintian::Deb822(3) |
Lintian::Deb822 -- A deb822 control file
use Lintian::Deb822;
Represents a paragraph in a Deb822 control file.
At first glance, this module appears to contain several debian control parsers. In practise, there is only one real parser ("visit_dpkg_paragraph_string") - the rest are convenience functions around it.
Otherwise, this behaves like:
use autodie; open(my $fd, '<:encoding(UTF-8)', FILE); # or '<' my @p = parse_dpkg_control($fd, FLAGS, LINES); close($fd); return @p;
This goes without saying that may fail with any of the messages that "parse_dpkg_control(HANDLE[, FLAGS[, LINES]])" do. It can also emit autodie exceptions if open or close fails.
FLAGS (if given) is a bitmask of the DCTRL_* constants. Please refer to "CONSTANTS" for the list of constants and their meaning. The default value for FLAGS is 0.
If LINES is given, it should be a reference to an empty list. On return, LINES will be populated with a hashref for each paragraph (in the same order as the returned list). Each hashref will also have a special key "START-OF-PARAGRAPH" that gives the line number of the first field in that paragraph. These hashrefs will map the field name of the given paragraph to the line number where the field name appeared.
This is a convenience sub around "visit_dpkg_paragraph" and can therefore produce the same errors as it. Please see "visit_dpkg_paragraph" for the finer semantics of how the control file is parsed.
NB: parse_dpkg_control does not close the handle for the caller.
FLAGS (if given) is a bitmask of the DCTRL_* constants. Please refer to "CONSTANTS" for the list of constants and their meaning. The default value for FLAGS is 0.
If the file is empty (i.e. it contains no paragraphs), the method will contain an empty list. The deb822 contents may be inside a signed PGP message with a signature.
visit_dpkg_paragraph will require the PGP headers to be correct (if present) and require that the entire file is covered by the signature. However, it will not validate the signature (in fact, the contents of the PGP SIGNATURE part can be empty). The signature should be validated separately.
visit_dpkg_paragraph will pass paragraphs to CODE as they are completed. If CODE can process the paragraphs as they are seen, very large control files can be processed without keeping all the paragraphs in memory.
As a consequence of how the file is parsed, CODE may be passed a number of (valid) paragraphs before parsing is stopped due to a syntax error.
NB: visit_dpkg_paragraph does not close the handle for the caller.
CODE is expected to be a callable reference (e.g. a sub) and will be invoked as the following:
The return value of CODE is ignored.
If the CODE invokes die (or similar) the error is propagated to the caller.
On syntax errors, visit_dpkg_paragraph will call die with the following string:
"syntax error at line %d: %s\n"
Where %d is the line number of the issue and %s is one of:
Originally written Christian Schwarz and many other people.
Moo version by Felix Lechner <felix.lechner@lease-up.com> for Lintian.
lintian(1)
2024-10-16 | Lintian v2.117.0ubuntu1.2 |