.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Lintian::Deb822Parser 3" .TH Lintian::Deb822Parser 3 "2020-06-03" "Lintian v2.79.0~bpo10+1" "Debian Package Checker" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Lintian::Deb822Parser \- Lintian's generic Deb822 parser functions .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Lintian::Deb822Parser qw(read_dpkg_control); \& \& my (@paragraphs); \& eval { @paragraphs = read_dpkg_control(\*(Aqsome/debian/ctrl/file\*(Aq); }; \& if ($@) { \& # syntax error etc. \& die "ctrl/file: $@"; \& } \& \& foreach my $para (@paragraphs) { \& my $value = $para\->{\*(Aqsome\-field\*(Aq}; \& if (defined $value) { \& # ... \& } \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module contains a number of utility subs that are nice to have, but on their own did not warrant their own module. .PP Most subs are imported only on request. .SS "Debian control parsers" .IX Subsection "Debian control parsers" At first glance, this module appears to contain several debian control parsers. In practise, there is only one real parser (\*(L"visit_dpkg_paragraph\*(R") \- the rest are convenience functions around it. .PP If you have very large files (e.g. Packages_amd64), you almost certainly want \*(L"visit_dpkg_paragraph\*(R". Otherwise, one of the convenience functions are probably what you are looking for. .ie n .IP "Use ""get_deb_info"" in Lintian::Util when" 4 .el .IP "Use ``get_deb_info'' in Lintian::Util when" 4 .IX Item "Use get_deb_info in Lintian::Util when" You have a \fI.deb\fR (or \fI.udeb\fR) file and you want the control file from it. .ie n .IP "Use ""get_dsc_info"" in Lintian::Util when" 4 .el .IP "Use ``get_dsc_info'' in Lintian::Util when" 4 .IX Item "Use get_dsc_info in Lintian::Util when" You have a \fI.dsc\fR (or \fI.changes\fR) file. Alternative, it is also useful if you have a control file and only care about the first paragraph. .ie n .IP "Use ""read_dpkg_control"" when" 4 .el .IP "Use ``read_dpkg_control'' when" 4 .IX Item "Use read_dpkg_control when" You have a debian control file (such \fIdebian/control\fR) and you want a number of paragraphs from it. .ie n .IP "Use ""parse_dpkg_control"" when" 4 .el .IP "Use ``parse_dpkg_control'' when" 4 .IX Item "Use parse_dpkg_control when" When you would have used \*(L"read_dpkg_control\*(R", except you have an open filehandle rather than a file name. .SH "CONSTANTS" .IX Header "CONSTANTS" The following constants can be passed to the Debian control file parser functions to alter their parsing flag. .IP "\s-1DCTRL_DEBCONF_TEMPLATE\s0" 4 .IX Item "DCTRL_DEBCONF_TEMPLATE" The file should be parsed as debconf template. These have slightly syntax rules for whitespace in some cases. .IP "\s-1DCTRL_NO_COMMENTS\s0" 4 .IX Item "DCTRL_NO_COMMENTS" The file do not allow comments. With this flag, any comment in the file is considered a syntax error. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .IP "parse_dpkg_control(HANDLE[, FLAGS[, \s-1LINES\s0]])" 4 .IX Item "parse_dpkg_control(HANDLE[, FLAGS[, LINES]])" Reads a debian control file from \s-1HANDLE\s0 and returns a list of paragraphs in it. A paragraph is represented via a hashref, which maps (lower cased) field names to their values. .Sp \&\s-1FLAGS\s0 (if given) is a bitmask of the \fIDCTRL_*\fR constants. Please refer to \*(L"\s-1CONSTANTS\*(R"\s0 for the list of constants and their meaning. The default value for \s-1FLAGS\s0 is 0. .Sp If \s-1LINES\s0 is given, it should be a reference to an empty list. On return, \s-1LINES\s0 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 "\fISTART-OF-PARAGRAPH\fR" 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. .Sp This is a convenience sub around \*(L"visit_dpkg_paragraph\*(R" and can therefore produce the same errors as it. Please see \&\*(L"visit_dpkg_paragraph\*(R" for the finer semantics of how the control file is parsed. .Sp \&\s-1NB:\s0 parse_dpkg_control does \fInot\fR close the handle for the caller. .IP "parse_dpkg_control_string(STRING[, FLAGS[, \s-1LINES\s0]])" 4 .IX Item "parse_dpkg_control_string(STRING[, FLAGS[, LINES]])" .PD 0 .IP "visit_dpkg_paragraph (\s-1CODE,\s0 HANDLE[, \s-1FLAGS\s0])" 4 .IX Item "visit_dpkg_paragraph (CODE, HANDLE[, FLAGS])" .PD Reads a debian control file from \s-1HANDLE\s0 and passes each paragraph to \&\s-1CODE.\s0 A paragraph is represented via a hashref, which maps (lower cased) field names to their values. .Sp \&\s-1FLAGS\s0 (if given) is a bitmask of the \fIDCTRL_*\fR constants. Please refer to \*(L"\s-1CONSTANTS\*(R"\s0 for the list of constants and their meaning. The default value for \s-1FLAGS\s0 is 0. .Sp If the file is empty (i.e. it contains no paragraphs), the method will contain an \fIempty\fR list. The deb822 contents may be inside a \&\fIsigned\fR \s-1PGP\s0 message with a signature. .Sp visit_dpkg_paragraph will require the \s-1PGP\s0 headers to be correct (if present) and require that the entire file is covered by the signature. However, it will \fInot\fR validate the signature (in fact, the contents of the \s-1PGP SIGNATURE\s0 part can be empty). The signature should be validated separately. .Sp visit_dpkg_paragraph will pass paragraphs to \s-1CODE\s0 as they are completed. If \s-1CODE\s0 can process the paragraphs as they are seen, very large control files can be processed without keeping all the paragraphs in memory. .Sp As a consequence of how the file is parsed, \s-1CODE\s0 may be passed a number of (valid) paragraphs before parsing is stopped due to a syntax error. .Sp \&\s-1NB:\s0 visit_dpkg_paragraph does \fInot\fR close the handle for the caller. .Sp \&\s-1CODE\s0 is expected to be a callable reference (e.g. a sub) and will be invoked as the following: .RS 4 .IP "\s-1CODE\-\s0>(\s-1PARA, LINE_NUMBERS\s0)" 4 .IX Item "CODE->(PARA, LINE_NUMBERS)" The first argument, \s-1PARA,\s0 is a hashref to the most recent paragraph parsed. The second argument, \s-1LINE_NUMBERS,\s0 is a hashref mapping each of the field names to the line number where the field name appeared. \&\s-1LINE_NUMBERS\s0 will also have a special key "\fISTART-OF-PARAGRAPH\fR" that gives the line number of the first field in that paragraph. .Sp The return value of \s-1CODE\s0 is ignored. .Sp If the \s-1CODE\s0 invokes die (or similar) the error is propagated to the caller. .RE .RS 4 .Sp \&\fIOn syntax errors\fR, visit_dpkg_paragraph will call die with the following string: .Sp .Vb 1 \& "syntax error at line %d: %s\en" .Ve .Sp Where \f(CW%d\fR is the line number of the issue and \f(CW%s\fR is one of: .ie n .IP "Duplicate field %s" 4 .el .IP "Duplicate field \f(CW%s\fR" 4 .IX Item "Duplicate field %s" The field appeared twice in the paragraph. .ie n .IP "Continuation line outside a paragraph (maybe line %d should be "" ."")" 4 .el .IP "Continuation line outside a paragraph (maybe line \f(CW%d\fR should be `` .'')" 4 .IX Item "Continuation line outside a paragraph (maybe line %d should be .)" A continuation line appears outside a paragraph \- usually caused by an unintended empty line before it. .ie n .IP "Whitespace line not allowed (possibly missing a ""."")" 4 .el .IP "Whitespace line not allowed (possibly missing a ``.'')" 4 .IX Item "Whitespace line not allowed (possibly missing a .)" An empty continuation line was found. This usually means that a period is missing to denote an \*(L"empty line\*(R" in (e.g.) the long description of a package. .ie n .IP "Cannot parse line ""%s""" 4 .el .IP "Cannot parse line ``%s''" 4 .IX Item "Cannot parse line %s" Generic error containing the text of the line that confused the parser. Note that all non-printables in \f(CW%s\fR will be replaced by underscores. .IP "Comments are not allowed" 4 .IX Item "Comments are not allowed" A comment line appeared and \s-1FLAGS\s0 contained \s-1DCTRL_NO_COMMENTS.\s0 .IP "\s-1PGP\s0 signature seen before start of signed message" 4 .IX Item "PGP signature seen before start of signed message" A \*(L"\s-1BEGIN PGP SIGNATURE\*(R"\s0 header is seen and a \*(L"\s-1BEGIN PGP MESSAGE\*(R"\s0 has not been seen yet. .ie n .IP "Two \s-1PGP\s0 signatures (first one at line %d)" 4 .el .IP "Two \s-1PGP\s0 signatures (first one at line \f(CW%d\fR)" 4 .IX Item "Two PGP signatures (first one at line %d)" Two \*(L"\s-1BEGIN PGP SIGNATURE\*(R"\s0 headers are seen in the same file. .ie n .IP "Unexpected %s header" 4 .el .IP "Unexpected \f(CW%s\fR header" 4 .IX Item "Unexpected %s header" A valid \s-1PGP\s0 header appears (e.g. \*(L"\s-1BEGIN PUBLIC KEY BLOCK\*(R"\s0). .IP "Malformed \s-1PGP\s0 header" 4 .IX Item "Malformed PGP header" An invalid or malformed \s-1PGP\s0 header appears. .ie n .IP "Expected at most one signed message (previous at line %d)" 4 .el .IP "Expected at most one signed message (previous at line \f(CW%d\fR)" 4 .IX Item "Expected at most one signed message (previous at line %d)" Two \*(L"\s-1BEGIN PGP MESSAGE\*(R"\s0 headers appears in the same message. .ie n .IP "End of file but expected an ""\s-1END PGP SIGNATURE""\s0 header" 4 .el .IP "End of file but expected an ``\s-1END PGP SIGNATURE''\s0 header" 4 .IX Item "End of file but expected an END PGP SIGNATURE header" The file ended after a \*(L"\s-1BEGIN PGP SIGNATURE\*(R"\s0 header without being followed by an \*(L"\s-1END PGP SIGNATURE\*(R".\s0 .IP "\s-1PGP MESSAGE\s0 header must be first content if present" 4 .IX Item "PGP MESSAGE header must be first content if present" The file had content before \s-1PGP MESSAGE.\s0 .IP "Data after the \s-1PGP SIGNATURE\s0" 4 .IX Item "Data after the PGP SIGNATURE" The file had data after the \s-1PGP SIGNATURE\s0 block ended. .ie n .IP "End of file before ""\s-1BEGIN PGP SIGNATURE""\s0" 4 .el .IP "End of file before ``\s-1BEGIN PGP SIGNATURE''\s0" 4 .IX Item "End of file before BEGIN PGP SIGNATURE" The file had a \*(L"\s-1BEGIN PGP MESSAGE\*(R"\s0 header, but no signature was present. .RE .RS 4 .RE .IP "visit_dpkg_paragraph_string (\s-1CODE,\s0 STRING[, \s-1FLAGS\s0])" 4 .IX Item "visit_dpkg_paragraph_string (CODE, STRING[, FLAGS])" .PD 0 .IP "read_dpkg_control(FILE[, FLAGS[, \s-1LINES\s0]])" 4 .IX Item "read_dpkg_control(FILE[, FLAGS[, LINES]])" .PD This is a convenience function to ease using \*(L"parse_dpkg_control\*(R" with paths to files (rather than open handles). The first argument must be the path to a \s-1FILE,\s0 which should be read as a debian control file. If the file is empty, an empty list is returned. .Sp Otherwise, this behaves like: .Sp .Vb 1 \& use autodie; \& \& open(my $fd, \*(Aq<:encoding(UTF\-8)\*(Aq, FILE); # or \*(Aq<\*(Aq \& my @p = parse_dpkg_control($fd, FLAGS, LINES); \& close($fd); \& return @p; .Ve .Sp This goes without saying that may fail with any of the messages that \&\*(L"parse_dpkg_control(HANDLE[, FLAGS[, \s-1LINES\s0]])\*(R" do. It can also emit autodie exceptions if open or close fails. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBlintian\fR\|(1)