amprolla

devuan's apt repo merger
git clone git://parazyd.org/amprolla.git
Log | Files | Refs | README | LICENSE

commit fd7239cebe21187c34ff7b4c56bd70ebf32716e2
parent 6dd25d4218ae3536eaffd1eee3dd05f8836ee49d
Author: parazyd <parazyd@dyne.org>
Date:   Mon, 12 Jun 2017 14:07:46 +0200

implement checking if a package with a lower priority is newer

Diffstat:
Mlib/package.py | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/lib/package.py b/lib/package.py @@ -92,6 +92,20 @@ def package_banned(pkg, banned_pkgs): return bool(deps.intersection(banned_pkgs)) +def package_newer(pkg1, pkg2): + """ + Checks whether the package of a lower priority is newer than the package + of the higher priority and returns True if so. + """ + higher_prio = pkg1.get('Version').split('+') + lower_prio = pkg2.get('Version').split('+') + + if lower_prio[0] > higher_prio[0]: + return True + + return False + + def merge_packages(pkg1, pkg2, name1, name2, banned_packages=set(), rewriter=None): """ @@ -110,6 +124,12 @@ def merge_packages(pkg1, pkg2, name1, name2, banned_packages=set(), if rewriter: pkg1_pkg = rewriter(pkg1_pkg, name1) new_pkgs[pkg] = pkg1_pkg + if package_newer(pkg1_pkg, pkg2_pkg): + # TODO: proper logfile + print('There is a newer version of "%s"' % + pkg1_pkg.get('Package')) + print('Old version: %s' % pkg1_pkg.get('Version')) + print('New version: %s' % pkg2_pkg.get('Version')) elif pkg1_pkg: if not package_banned(pkg1_pkg, banned_packages): if rewriter: