diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2023-12-13 01:01:29 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2023-12-13 21:32:18 +0300 |
commit | c48d8a653378e405bc1083e33b7ea9991b8f6a04 (patch) | |
tree | eec82acaa3dd4baac2c8dadfef78772b94aef449 | |
parent | 23cbaac193afe222962fe12b8a5710973678b363 (diff) |
Also sort by package "importance" in unmaintained packages report
-rwxr-xr-x | calm/package.py | 49 | ||||
-rw-r--r-- | calm/reports.py | 9 |
2 files changed, 54 insertions, 4 deletions
diff --git a/calm/package.py b/calm/package.py index a9aff3d..dd46b57 100755 --- a/calm/package.py +++ b/calm/package.py @@ -56,6 +56,16 @@ class Kind(Enum): source = 2 +@unique +class Importance(IntEnum): + base = 1 # has base category + basedep = 2 # doesn't have base category, but is depended on by something that does + other = 3 # all others + + def __str__(self): + return self.name + + # a path inside a package repository (e.g relative to relarea) class RepoPath(): def __init__(self, _arch=None, _path=None, _fn=None): @@ -1077,9 +1087,48 @@ def validate_packages(args, packages, valid_provides_extra=None, missing_obsolet # validate that all packages are in the package maintainers list error = validate_package_maintainers(args, packages) or error + assign_importance(packages) + return not error +# assign importance classes to packages +def assign_importance(packages): + # XXX: if we had some package popularity data, we'd use it here + for po in packages.values(): + po.importance = Importance.other + + # recursively give dependencies of base packages the basedep importance + def recursive_basedep(p): + bv = p.best_version + requires = p.version_hints[bv].get('depends', '').split(', ') + requires = [re.sub(r'(.*) +\(.*\)', r'\1', r) for r in requires] + for r in requires: + if r in packages: + if packages[r].importance == Importance.other: + packages[r].importance = Importance.basedep + recursive_basedep(packages[r]) + + for po in packages.values(): + bv = po.best_version + categories = po.version_hints[bv]['category'].lower().split() + if 'base' in categories: + recursive_basedep(po) + + # base packages have base importance + for po in packages.values(): + bv = po.best_version + categories = po.version_hints[bv]['category'].lower().split() + if 'base' in categories: + po.importance = Importance.base + + # a source package has the importance of it's most important install package + for po in packages.values(): + if po.kind == Kind.source: + for ip in po.is_used_by: + po.importance = min(po.importance, packages[ip].importance) + + # def validate_package_maintainers(args, packages): error = False diff --git a/calm/reports.py b/calm/reports.py index 6fa570e..d56eb89 100644 --- a/calm/reports.py +++ b/calm/reports.py @@ -112,6 +112,7 @@ def unmaintained(args, packages, reportlist): up.ts = po.tar(v).mtime up.rdepends = len(rdepends) up.build_rdepends = len(build_rdepends) + up.importance = po.importance # some packages are mature. If 'v' is still latest upstream version, # then maybe we don't need to worry about this package quite as much... @@ -125,11 +126,11 @@ def unmaintained(args, packages, reportlist): print('<p>Packages without a maintainer.</p>', file=body) print('<table class="grid">', file=body) - print('<tr><th>last updated</th><th>package</th><th>version</th><th>upstream version</th><th>rdepends</th><th>build_rdepends</th></tr>', file=body) + print('<tr><th>last updated</th><th>package</th><th>version</th><th>upstream version</th><th>rdepends</th><th>build_rdepends</th><th>importance</th></tr>', file=body) - for up in sorted(um_list, key=lambda i: (i.rdepends + i.build_rdepends, not i.unchanged, i.ts), reverse=True): - print('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % - (pkg2html.tsformat(up.ts), linkify(up.pn, up.po), up.v, up.upstream_v, up.rdepends, up.build_rdepends), file=body) + for up in sorted(um_list, key=lambda i: (-i.importance, i.rdepends + i.build_rdepends, not i.unchanged, i.ts), reverse=True): + print('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % + (pkg2html.tsformat(up.ts), linkify(up.pn, up.po), up.v, up.upstream_v, up.rdepends, up.build_rdepends, up.importance), file=body) print('</table>', file=body) |