diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2019-01-03 17:26:07 +0100 |
---|---|---|
committer | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2019-01-03 17:26:07 +0100 |
commit | d7d3fd7e8ce4e7ec4974dfa5853bb75673e0ff3a (patch) | |
tree | b256a6633aa769f39da4306aa77004f1b6b63475 | |
parent | 91df6076a64c25b1ad8fea69a395ea7529f9588a (diff) |
Rewrite genbuildusing to process all dirtbiked packages
-rw-r--r-- | debian/control | 19 | ||||
-rwxr-xr-x | debian/genbuildusing.py | 84 | ||||
-rwxr-xr-x | debian/genbuildusing.sh | 9 | ||||
-rwxr-xr-x | debian/rules | 2 |
4 files changed, 10 insertions, 104 deletions
diff --git a/debian/control b/debian/control index 8ce9f4c..8154dae 100644 --- a/debian/control +++ b/debian/control @@ -82,25 +82,6 @@ Architecture: all Depends: ca-certificates, ${misc:Depends}, Built-Using: ${pip:Built-Using} -X-Built-Using: - chardet, - distlib, - html5lib, - pyparsing, - appdirs, - python-cachecontrol, - python-colorama, - python-distro, - python-ipaddress, - python-lockfile, - python-packaging, - python-progress, - python-retrying, - python-setuptools, - python-urllib3, - python-webencodings, - requests, - six, Breaks: python-chardet-whl (<< 2.3.0-2), python-colorama-whl (<< 0.3.6-1), python-distlib-whl (<< 0.2.2-1), diff --git a/debian/genbuildusing.py b/debian/genbuildusing.py deleted file mode 100755 index a082b58..0000000 --- a/debian/genbuildusing.py +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/python3 -import os -import sys -import gzip -from debian.deb822 import Deb822, PkgRelation, _PkgRelationMixin -from debian.changelog import Changelog - -class Control(Deb822, _PkgRelationMixin): - """ - This class automatically parses relationship fields. - """ - _relationship_fields = [ - 'build-depends', - 'x-built-using', - 'built-using', - 'depends', - 'pre-depends', - 'recommends', - 'suggests', - 'breaks', - 'conflicts', - 'provides', - 'replaces', - 'enhances', - ] - - def __init__(self, *args, **kwargs): - # type: (*Any, **Any) -> None - Deb822.__init__(self, *args, **kwargs) - _PkgRelationMixin.__init__(self, *args, **kwargs) - -source_pkg = None -wheel_pkg = None - -# We cannot put unversioned source package names in Built-Using -# since dpkg-gencontrol doesn’t allow overriding them with -# versioned package names (unlike in, say, Depends), making -# that non-trivial to substitute. -# -# Instead, we put them into X-Built-Using, which also prevents -# them from leaking into the binary package’s control file. - -for pkg in Control.iter_paragraphs(open('debian/control')): - if 'Source' in pkg: - source_pkg = pkg - if 'X-Built-Using' in pkg: - wheel_pkg = pkg - -if not source_pkg and not wheel_pkg: - print('no source packages or packages with Built-Using found', file=sys.stderr) - exit(1) - -if len(sys.argv) < 2: - print('substvars file required', file=sys.stderr) - exit(1) - -substvars_file = sys.argv[1] - -def nowarn(*args): - pass - -# To prevent the parser from complaining about substitutions -import warnings -warnings.warn = nowarn - -# if len(...) is needed to allow the trailing comma -# this doesn’t allow alternative built-dependencies -build_depends = [x[0]['name'] for x in source_pkg.relations['build-depends'] if len(x[0]['name'])] -# this also filters out substitutions — no longer needed since we need X-Built-Using anyway :( -built_using = [x[0]['name'] for x in wheel_pkg.relations['x-built-using'] if not x[0]['name'].startswith('${')] - -def get_source_and_version(pkg): - # try non-native location first - changelog_path = os.path.join('/usr/share/doc', pkg, 'changelog.Debian.gz') - if not os.path.exists(changelog_path): - changelog_path = os.path.join('/usr/share/doc', pkg, 'changelog.gz') - changelog = Changelog(file=gzip.open(changelog_path, 'rb')) - return changelog.get_package(), changelog.get_version() - -build_depends_sources = [get_source_and_version(x) for x in build_depends] - -built_using_versions = [[{'name': pkg, 'version': ('=', str(ver))}] for (pkg, ver) in build_depends_sources if pkg in built_using] - -print('pip:Built-Using=%s' % PkgRelation.str(built_using_versions), file=open(substvars_file, 'a')) diff --git a/debian/genbuildusing.sh b/debian/genbuildusing.sh new file mode 100755 index 0000000..8eb0be4 --- /dev/null +++ b/debian/genbuildusing.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +pydeps=$(grep -o 'dirtbike.*' debian/rules | cut -d' ' -f 2) +debdeps=$(for pkg in $pydeps +do + dpkg -S /usr/lib/python3/dist-packages/$pkg* 2>/dev/null 2>/dev/null | cut -d: -f1 +done) + +echo "pip:Built-Using="$(dpkg-query -f '${source:Package} (= ${source:Version}),\n' -W $debdeps | sort) diff --git a/debian/rules b/debian/rules index ae5e15d..2f50b96 100755 --- a/debian/rules +++ b/debian/rules @@ -71,7 +71,7 @@ override_dh_auto_install: python3 setup.py bdist_wheel \ --universal \ -d $(CURDIR)/debian/python-pip-whl/usr/share/python-wheels - debian/genbuildusing.py debian/python-pip-whl.substvars + debian/genbuildusing.sh >> debian/python-pip-whl.substvars override_dh_installchangelogs: dh_installchangelogs NEWS.rst |