Package: devscripts
Version: 2.17.11
User: devscri...@packages.debian.org
Usertags: sadt
sadt fails to correctly parse debian/control files that include comments
in their build-dependencies, for instance:
$ mkdir -p debian/tests
$ cat > debian/control << EOF
Source: s
Build-Depends:
# some comment here
sl
EOF
$ cat > debian/tests/control << EOF
Tests: sl-exists
Depends: @builddeps@
EOF
$ cat > debian/tests/sl-exists << EOF
#!/bin/sh
dpkg -l sl
EOF
$ sadt
Traceback (most recent call last):
File "/usr/bin/sadt", line 476, in <module>
main()
File "/usr/bin/sadt", line 378, in main
for n, para in enumerate(deb822.Packages.iter_paragraphs(file)):
File "/usr/lib/python3/dist-packages/debian/deb822.py", line 378, in
iter_paragraphs
for section in parser:
apt_pkg.Error: E:Unable to parse package file (1)
This is refused by libapt-pkg's deb822 format parser, but permitted by the
pure-Python one in python-debian, as noted in a comment in python-debian:
:param use_apt_pkg: if sequence is a file, apt_pkg can be used
if available to parse the file, since it's much much faster. Set
this parameter to True to enable use of apt_pkg. Note that the
TagFile parser from apt_pkg is a much stricter parser of the
Deb822 format, particularly with regards whitespace between
paragraphs and comments within paragraphs. If these features are
required (for example in debian/control files), ensure that this
parameter is set to False.
The "Packages" subclass (which is intended for parsing Packages files in
apt repos, not deb822 files in general) sets use_apt_pkg to true. The
simplest fix is to change sadt line 378 to pass use_apt_pkg=False, but in
theory, python-debian should gain a new subclass for debian/control files
that has the _PkgRelationMixin but uses the more lenient parser.
If you would like me to commit this change to the collab-maint repo, let
me know. I've confirmed that it does fix the problem.
--
Geoffrey Thomas
https://ldpreload.com
geo...@ldpreload.com