mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-10 22:17:36 +00:00
Make the source pkg consistency checks a TargetSuite method
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
e3d68164f1
commit
e0b46e5196
16
britney.py
16
britney.py
@ -214,7 +214,6 @@ from britney2.utils import (log_and_format_old_libraries, get_dependency_solvers
|
||||
invalidate_excuses, compile_nuninst,
|
||||
find_smooth_updateable_binaries, parse_provides,
|
||||
MigrationConstraintException,
|
||||
check_target_suite_source_pkg_consistency,
|
||||
)
|
||||
|
||||
__author__ = 'Fabio Tranchitella and the Debian Release Team'
|
||||
@ -1440,6 +1439,7 @@ class Britney(object):
|
||||
output_logger = self.output_logger
|
||||
solver = InstallabilitySolver(self.pkg_universe, self._inst_tester)
|
||||
mm = self._migration_manager
|
||||
target_suite = self.suite_info.target_suite
|
||||
|
||||
for y in sorted((y for y in packages), key=attrgetter('uvname')):
|
||||
try:
|
||||
@ -1489,7 +1489,7 @@ class Britney(object):
|
||||
len(selected),
|
||||
" ".join(x.uvname for x in selected[-20:]))
|
||||
if self.options.check_consistency_level >= 3:
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "iter_packages after commit", self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('iter_packages after commit')
|
||||
nuninst_last_accepted = nuninst_after
|
||||
rescheduled_packages.extend(maybe_rescheduled_packages)
|
||||
maybe_rescheduled_packages.clear()
|
||||
@ -1510,7 +1510,7 @@ class Britney(object):
|
||||
output_logger.info(" got: %s", self.eval_nuninst(nuninst_after, compare_nuninst))
|
||||
output_logger.info(" * %s: %s", failed_arch, ", ".join(broken))
|
||||
if self.options.check_consistency_level >= 3:
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "iter_package after rollback (not accepted)",self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('iter_package after rollback (not accepted)')
|
||||
|
||||
except MigrationConstraintException as e:
|
||||
transaction.rollback()
|
||||
@ -1522,7 +1522,7 @@ class Britney(object):
|
||||
)
|
||||
output_logger.info(" got exception: %s"%(repr(e)))
|
||||
if self.options.check_consistency_level >= 3:
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "iter_package after rollback (MigrationConstraintException)",self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('iter_package after rollback (MigrationConstraintException)')
|
||||
|
||||
if not accepted:
|
||||
if len(comp) > 1:
|
||||
@ -1567,6 +1567,7 @@ class Britney(object):
|
||||
upgrade_me = self.upgrade_me[:]
|
||||
nuninst_start = self.nuninst_orig
|
||||
output_logger = self.output_logger
|
||||
target_suite = self.suite_info.target_suite
|
||||
|
||||
# these are special parameters for hints processing
|
||||
force = False
|
||||
@ -1674,7 +1675,7 @@ class Britney(object):
|
||||
if transaction:
|
||||
transaction.commit()
|
||||
if self.options.check_consistency_level >= 2:
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "do_all after commit", self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('do_all after commit')
|
||||
if not actions:
|
||||
if recurse:
|
||||
self.upgrade_me = extra
|
||||
@ -1686,7 +1687,7 @@ class Britney(object):
|
||||
return
|
||||
transaction.rollback()
|
||||
if self.options.check_consistency_level >= 2:
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "do_all after rollback", self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('do_all after rollback')
|
||||
|
||||
output_logger.info("")
|
||||
|
||||
@ -1818,8 +1819,9 @@ class Britney(object):
|
||||
|
||||
self.printuninstchange()
|
||||
if self.options.check_consistency_level >= 1:
|
||||
target_suite = self.suite_info.target_suite
|
||||
self.assert_nuninst_is_correct()
|
||||
check_target_suite_source_pkg_consistency(self.suite_info, "end", self.logger)
|
||||
target_suite.check_suite_source_pkg_consistency('end')
|
||||
|
||||
# output files
|
||||
if not self.options.dry_run:
|
||||
|
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from enum import Enum, unique
|
||||
|
||||
@ -89,6 +90,8 @@ class TargetSuite(Suite):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.inst_tester = None
|
||||
logger_name = ".".join((self.__class__.__module__, self.__class__.__name__))
|
||||
self._logger = logging.getLogger(logger_name)
|
||||
|
||||
def any_of_these_are_in_the_suite(self, pkg_ids):
|
||||
"""Test if at least one package of a given set is in the suite
|
||||
@ -133,6 +136,36 @@ class TargetSuite(Suite):
|
||||
"""
|
||||
self.inst_tester.remove_binary(pkg_id)
|
||||
|
||||
def check_suite_source_pkg_consistency(self, comment):
|
||||
sources_t = self.sources
|
||||
binaries_t = self.binaries
|
||||
logger = self._logger
|
||||
issues_found = False
|
||||
|
||||
logger.info("check_target_suite_source_pkg_consistency %s", comment)
|
||||
|
||||
for arch in binaries_t:
|
||||
for pkg_name in binaries_t[arch]:
|
||||
pkg = binaries_t[arch][pkg_name]
|
||||
src = pkg.source
|
||||
|
||||
if src not in sources_t: # pragma: no cover
|
||||
issues_found = True
|
||||
logger.error("inconsistency found (%s): src %s not in target, target has pkg %s with source %s" % (
|
||||
comment, src, pkg_name, src))
|
||||
|
||||
for src in sources_t:
|
||||
source_data = sources_t[src]
|
||||
for pkg_id in source_data.binaries:
|
||||
binary, _, parch = pkg_id
|
||||
if binary not in binaries_t[parch]: # pragma: no cover
|
||||
issues_found = True
|
||||
logger.error("inconsistency found (%s): binary %s from source %s not in binaries_t[%s]" % (
|
||||
comment, binary, src, parch))
|
||||
|
||||
if issues_found: # pragma: no cover
|
||||
raise AssertionError("inconsistencies found in target suite")
|
||||
|
||||
|
||||
class Suites(object):
|
||||
|
||||
|
@ -338,36 +338,6 @@ def old_libraries(mi_factory, suite_info, outofsync_arches=frozenset()):
|
||||
return removals
|
||||
|
||||
|
||||
def check_target_suite_source_pkg_consistency(suite_info, comment, logger):
|
||||
sources_t = suite_info.target_suite.sources
|
||||
binaries_t = suite_info.target_suite.binaries
|
||||
issues_found = False
|
||||
|
||||
logger.info("check_target_suite_source_pkg_consistency %s", comment)
|
||||
|
||||
for arch in binaries_t:
|
||||
for pkg_name in binaries_t[arch]:
|
||||
pkg = binaries_t[arch][pkg_name]
|
||||
src = pkg.source
|
||||
|
||||
if src not in sources_t: # pragma: no cover
|
||||
issues_found = True
|
||||
logger.error("inconsistency found (%s): src %s not in target, target has pkg %s with source %s" % (
|
||||
comment, src, pkg_name, src))
|
||||
|
||||
for src in sources_t:
|
||||
source_data = sources_t[src]
|
||||
for pkg_id in source_data.binaries:
|
||||
binary, _, parch = pkg_id
|
||||
if binary not in binaries_t[parch]: # pragma: no cover
|
||||
issues_found = True
|
||||
logger.error("inconsistency found (%s): binary %s from source %s not in binaries_t[%s]" % (
|
||||
comment, binary, src, parch))
|
||||
|
||||
if issues_found: # pragma: no cover
|
||||
raise AssertionError("inconsistencies found in target suite")
|
||||
|
||||
|
||||
def is_nuninst_asgood_generous(constraints, architectures, old, new, break_arches=frozenset()):
|
||||
"""Compares the nuninst counters and constraints to see if they improved
|
||||
|
||||
|
@ -10,7 +10,7 @@ def should_skip_codestyle():
|
||||
|
||||
|
||||
EXCEPTIONS_BY_FILE = {
|
||||
'britney.py': 36,
|
||||
'britney.py': 32,
|
||||
'britney2/__init__.py': 2,
|
||||
'britney2/excuse.py': 5,
|
||||
'britney2/hints.py': 8,
|
||||
|
Loading…
x
Reference in New Issue
Block a user