Bug#875306: python-debian: include a type for buildinfo files
Stuart Prescott
stuart at debian.org
Sun Oct 25 06:32:19 GMT 2020
Dear reproducible-builds folks,
python-debian has classes to wrap many of Debian's deb822 format files, trying
to use an underlying parser that always exposes the data in more or less the
same key/value way via a dictionary, plus also providing extra syntactic sugar
to help make sense of the values that are included. For example, package
dependencies such as Depends or Build-Depends are split up into a list of
relationships, with the standard syntax that we use everywhere interpreted to
include version restrictions etc.
The .buildinfo files have two places where interpreting the values seems
worthwhile:
Environment: split the lines and extract the key="value" data into a
dictionary in the same format as Python's normal `os.environ`. (Some
dequoting is needed but not currently implemented.)
Installed-Build-Depends: use the standard package-relation code on this to
return interpret the list of packages.
We could thus do something like:
In [1]: from debian import deb822
In [2]: info = deb822.BuildInfo(open("debian/tests/test_BuildInfo"))
In [3]: info.get_environment()
Out[3]:
{'DEB_BUILD_OPTIONS': 'parallel=4',
'LANG': 'en_AU.UTF-8',
'LC_ALL': 'C.UTF-8',
'LC_TIME': 'en_GB.UTF-8',
'LD_LIBRARY_PATH': '/usr/lib/libeatmydata',
'SOURCE_DATE_EPOCH': '1601784586'}
In [4]: info.relations['installed-build-depends']
Out[4]:
[[{'name': 'autoconf',
'archqual': None,
'version': ('=', '2.69-11.1'),
'arch': None,
'restrictions': None}],
[{'name': 'automake',
'archqual': None,
'version': ('=', '1:1.16.2-4'),
'arch': None,
'restrictions': None}],
[{'name': 'autopoint',
'archqual': None,
'version': ('=', '0.19.8.1-10'),
'arch': None,
'restrictions': None}],
[{'name': 'autotools-dev',
'archqual': None,
'version': ('=', '20180224.1'),
'arch': None,
'restrictions': None}],
[{'name': 'base-files',
'archqual': None,
'version': ('=', '11'),
'arch': None,
'restrictions': None}],
...(trimmed)...
In [5]: for dep in info.relations['installed-build-depends']:
...: print("Installed %s/%s" % (dep[0]['name'], dep[0]['version'][1]))
...:
Installed autoconf/2.69-11.1
Installed automake/1:1.16.2-4
Installed autopoint/0.19.8.1-10
Installed autotools-dev/20180224.1
Installed base-files/11
...(trimmed)...
The standard format for the list of package relationships contains features
that the buildinfo format doesn't need ("foo | bar", architecture and build-
profile restrictions), but it seems better to use exactly the same format as is
used for Packages and Sources. That does however mean there are lots of
single-element lists used, as seen in the `dep[0]` usage above. A bit ugly,
but consistency wins here, I think.
How does this look to you?
Are there additional data that would be nice to extract and interpret in a
structured way?
The current code doesn't handle dequoting the environment values and will
react particularly badly to environment values with newlines in them.
The current work-in-progress code is at
https://salsa.debian.org/python-debian-team/python-debian/-/merge_requests/29
Comments, suggestions and encouragement gratefully accepted :)
thanks
Stuart
--
Stuart Prescott http://www.nanonanonano.net/ stuart at nanonanonano.net
Debian Developer http://www.debian.org/ stuart at debian.org
GPG fingerprint 90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7
More information about the pkg-python-debian-maint
mailing list