From 1a0e07ea68bde866ca1179bb23427114438d0442 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Fri, 4 Nov 2016 13:51:45 +0100 Subject: [PATCH] check if all packages in a repo are newer than all other repos (#588) --- README.asciidoc | 2 ++ checknewer | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100755 checknewer diff --git a/README.asciidoc b/README.asciidoc index a06fbec9..ad172024 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -32,6 +32,8 @@ Scripts * *link:docs/maintbot.asciidoc[maintbot].* script that checks maintenance incidents to make sure the Factory maintainer submitted the package. +* *link:checknewer[checknewer].* script compares version numbers in repos to + make sure all packages e.g. in a new distro are newer Installation ------------ diff --git a/checknewer b/checknewer new file mode 100755 index 00000000..bcd98964 --- /dev/null +++ b/checknewer @@ -0,0 +1,77 @@ +#!/usr/bin/python +# Copyright (c) 2016 SUSE LLC +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# check if all packages in a repo are newer than all other repos + +import sys +import os +import re +import solv + +pool = solv.Pool() +args = sys.argv[1:] +if len(args) < 2: + print("usage: checknewer NEWREPO OLDREPO1 [OLDREPO2...]") + sys.exit(1) + +firstrepo = None +for arg in args: + argf = solv.xfopen(arg) + repo = pool.add_repo(arg) + if not firstrepo: + firstrepo = repo + if re.search(r'solv$', arg): + repo.add_solv(argf) + elif re.search(r'primary\.xml', arg): + repo.add_rpmmd(argf, None) + elif re.search(r'packages', arg): + repo.add_susetags(argf, 0, None) + else: + print("%s: unknown repo type" % (arg)) + sys.exit(1) + +# we only want self-provides +for p in pool.solvables: + if p.archid == solv.ARCH_SRC or p.archid == solv.ARCH_NOSRC: + continue + selfprovides = pool.rel2id(p.nameid, p.evrid, solv.REL_EQ) + p.unset(solv.SOLVABLE_PROVIDES) + p.add_deparray(solv.SOLVABLE_PROVIDES, selfprovides) + +pool.createwhatprovides() + +for p in firstrepo.solvables: + newerdep = pool.rel2id(p.nameid, p.evrid, solv.REL_GT | solv.REL_EQ) + for pp in pool.whatprovides(newerdep): + if pp.repo == firstrepo: + continue + if p.nameid != pp.nameid: + continue + if p.identical(pp): + continue + if p.archid != pp.archid and p.archid != solv.ARCH_NOARCH and pp.archid != solv.ARCH_NOARCH: + continue + src = p.name + if not p.lookup_void(solv.SOLVABLE_SOURCENAME): + src = p.lookup_str(solv.SOLVABLE_SOURCENAME) + if src is None: + src = "?" + print("%s: %s is older than %s from %s" % (src, p, pp, pp.repo))