repos: extras_to_remove
List EXTRA packages that can be safely removed without causing 'usual' or build unmets to appear in the repository.
This commit is contained in:
parent
a82fc9042d
commit
618b824af3
@ -186,10 +186,11 @@ class Repository:
|
||||
r = config['repos'][repo_name]
|
||||
return cls.load(repo_name, r['path'], r['arch'])
|
||||
|
||||
def binaries_from(self, source_name):
|
||||
def binaries_from(self, *source_names):
|
||||
'''Return binary packages build from this source'''
|
||||
sources = set(source_names)
|
||||
for b in self.binaries.values():
|
||||
if b.source_name == source_name:
|
||||
if b.source_name in sources:
|
||||
yield b
|
||||
|
||||
def providers(self, dependency):
|
||||
@ -212,10 +213,9 @@ class Repository:
|
||||
return self._unmets(self.sources.values())
|
||||
|
||||
def delete_sources(self, *source_names):
|
||||
bin_names = []
|
||||
bin_names = [b.name for b in self.binaries_from(*source_names)]
|
||||
for source in source_names:
|
||||
del self.sources[source]
|
||||
bin_names.extend(b.name for b in self.binaries_from(source))
|
||||
for name in bin_names:
|
||||
del self.binaries[name]
|
||||
self.update_indexes()
|
||||
@ -484,13 +484,42 @@ def unmets_report(repo):
|
||||
return format_triplet_report(_unmets(repo))
|
||||
|
||||
|
||||
def who_cares(repo, source_name):
|
||||
def who_cares(repo, *source_names):
|
||||
'''What new unmets deletion of the pacakge will produce?'''
|
||||
next_repo = repo.copy('next_' + repo.name)
|
||||
next_repo.delete_sources(source_name)
|
||||
next_repo.delete_sources(*source_names)
|
||||
return format_triplet_report(_unmets(next_repo, repo))
|
||||
|
||||
|
||||
_GOOD_EXTRAS_PREFIXES = (b'kernel-', b'u-boot', b'riscv', b'fu540', b'opensbi')
|
||||
|
||||
|
||||
def extras_to_remove(base_repo, repo, ignore=()):
|
||||
extras = set(repo.sources) - set(base_repo.sources) - set(ignore)
|
||||
# filter out certain packages that must be left alone
|
||||
filtered_extras = set(
|
||||
name for name in extras
|
||||
if (not any(name.startswith(p) for p in _GOOD_EXTRAS_PREFIXES)
|
||||
and b'jpp' not in repo.sources[name].release))
|
||||
while True:
|
||||
LOG.info('Checking %d filtered extras', len(filtered_extras))
|
||||
next_repo = repo.copy('removal_test_' + repo.name)
|
||||
next_repo.delete_sources(*filtered_extras)
|
||||
leave_alone = set()
|
||||
for kind, req, pkg in _unmets(next_repo, repo):
|
||||
for b in repo.binaries_from(*filtered_extras):
|
||||
if b.source_name in leave_alone:
|
||||
continue
|
||||
if any(p.is_provide_for(req) for p in b.provides):
|
||||
leave_alone.add(b.source_name)
|
||||
if leave_alone:
|
||||
filtered_extras -= leave_alone
|
||||
else:
|
||||
break
|
||||
for name in sorted(filtered_extras):
|
||||
print(name.decode())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from port_stats.utils import interactive_setup
|
||||
from pydoc import pager # noqa
|
||||
|
Loading…
x
Reference in New Issue
Block a user