Merge pull request #1453 from coolo/add_sle_droplist

Add create_sle_weakremovers command
This commit is contained in:
Ludwig Nussel 2018-03-23 11:21:43 +01:00 committed by GitHub
commit 5d0c024ffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -790,6 +790,66 @@ class CommandLineInterface(ToolBase.CommandLineInterface):
if p.returncode:
raise Exception('failed to create merged solv file')
def do_create_sle_weakremovers(self, subcmd, opts, *prjs):
for prj in prjs:
logger.debug("processing %s", prj)
self.options.repos = ['/'.join([prj, 'standard'])]
self.postoptparse()
opts.project = prj
self.do_update('update', opts)
drops = dict()
for arch in self.tool.architectures:
pool = solv.Pool()
pool.setarch(arch)
sysrepo = None
for prp in prjs:
fn = os.path.join(CACHEDIR, 'repo-{}-{}-{}.solv'.format(prp, 'standard', arch))
r = pool.add_repo(prp)
r.add_solv(fn)
if not sysrepo:
sysrepo = r
pool.createwhatprovides()
for s in pool.solvables_iter():
if s.repo == sysrepo or not (s.arch == 'noarch' or s.arch == arch):
continue
haveit = False
for s2 in pool.whatprovides(s.nameid):
if s2.repo == sysrepo and s.nameid == s2.nameid:
haveit = True
if haveit:
continue
nevr = pool.rel2id(s.nameid, s.evrid, solv.REL_EQ)
for s2 in pool.whatmatchesdep(solv.SOLVABLE_OBSOLETES, nevr):
if s2.repo == sysrepo:
continue
haveit = True
if haveit:
continue
if s.name not in drops:
drops[s.name] = {'repo': s.repo.name, 'archs': []}
if arch not in drops[s.name]['archs']:
drops[s.name]['archs'].append(arch)
for prp in prjs:
exclusives = dict()
print('#', prp)
for name in sorted(drops.keys()):
if drops[name]['repo'] != prp:
continue
if len(drops[name]['archs']) == len(self.tool.architectures):
print('Provides: weakremover({})'.format(name))
else:
jarch = ' '.join(sorted(drops[name]['archs']))
exclusives.setdefault(jarch, []).append(name)
for arch in sorted(exclusives.keys()):
print('%ifarch {}'.format(arch))
for name in sorted(exclusives[arch]):
print('Provides: weakremover({})'.format(name))
print('%endif')
def do_create_droplist(self, subcmd, opts, *oldsolv):
"""${cmd_name}: generate list of obsolete packages