diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2019-06-25 16:42:52 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2019-07-04 14:44:30 +0300 |
commit | 84e5f407c66832a0d0bdbf6e6bd3c8f6e661be28 (patch) | |
tree | c58896a70a4e735a2491c9136dc5dc75fc3dfc5f /calm/pkg2html.py | |
parent | f0cf563288d3b0e17bb53b570395a4fd23b13f19 (diff) |
Identify x86 or x86_64 only depends in package summary page
Diffstat (limited to 'calm/pkg2html.py')
-rwxr-xr-x | calm/pkg2html.py | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/calm/pkg2html.py b/calm/pkg2html.py index 9216139..f46ea37 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -90,7 +90,9 @@ def ldesc(po, bv): return header +# # try hard to find a package object for package p +# def arch_package(packages, p): for arch in common_constants.ARCHES: if p in packages[arch]: @@ -99,6 +101,17 @@ def arch_package(packages, p): # +# build a dict of the arches which contain package p +# +def arch_packages(packages, p): + result = {} + for arch in common_constants.ARCHES: + if p in packages[arch]: + result[arch] = packages[arch][p] + return result + + +# # ensure a directory exists # def ensure_dir_exists(args, path): @@ -155,10 +168,11 @@ def update_package_listings(args, packages): with open(summary, 'w') as f: os.fchmod(f.fileno(), 0o755) - po = arch_package(packages, p) - if not po: + pos = arch_packages(packages, p) + if not pos: continue + po = next(iter(pos.values())) bv = po.best_version if po.kind == package.Kind.source: @@ -194,9 +208,28 @@ def update_package_listings(args, packages): details = ['depends', 'obsoletes', 'provides', 'conflicts'] for key in details: - value = po.version_hints[bv].get(key, None) - if value: - print('<span class="detail">%s</span>: %s<br><br>' % (key, ', '.join([linkify_package(p) for p in value.split(', ')])), file=f) + # make the union of the package list for this detail + # across arches, and then annotate any items which don't + # appear for all arches + value = {} + values = set() + for arch in pos: + t = pos[arch].version_hints[pos[arch].best_version].get(key, None) + if t: + value[arch] = set(t.split(', ')) + else: + value[arch] = set() + values.update(value[arch]) + + if values: + detail = [] + for detail_pkg in sorted(values): + if all(detail_pkg in value[arch] for arch in pos): + detail.append(linkify_package(detail_pkg)) + else: + detail.append(linkify_package(detail_pkg) + ' (%s)' % (','.join([arch for arch in pos if detail_pkg in value[arch]]))) + + print('<span class="detail">%s</span>: %s<br><br>' % (key, ', '.join(detail)), file=f) if po.kind == package.Kind.source: es = p |