Use a proper Suite object for MigrationItem.suite

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 7 years ago
parent 21528f6f0c
commit d1350606bb

@ -295,6 +295,7 @@ class Britney(object):
self.suite_info = None # Initialized during __parse_arguments self.suite_info = None # Initialized during __parse_arguments
self.__parse_arguments() self.__parse_arguments()
MigrationItem.set_architectures(self.options.architectures) MigrationItem.set_architectures(self.options.architectures)
MigrationItem.set_suites(self.suite_info)
# initialize the apt_pkg back-end # initialize the apt_pkg back-end
apt_pkg.init() apt_pkg.init()
@ -1776,7 +1777,7 @@ class Britney(object):
* "source_name" is the name of the source package, whose * "source_name" is the name of the source package, whose
binaries are migrating. binaries are migrating.
* "suite" is the suite from which the binaries are migrating. * "suite" is the suite from which the binaries are migrating.
[Same as item.suite, where available] [Same as item.suite.name, where available]
* "migration_architecture" is the architecture determines * "migration_architecture" is the architecture determines
architecture of the migrating binaries (can be "source" for architecture of the migrating binaries (can be "source" for
a "source"-migration, meaning all binaries regardless of a "source"-migration, meaning all binaries regardless of
@ -1976,7 +1977,7 @@ class Britney(object):
eqv_set = set() eqv_set = set()
updates, rms, _ = self._compute_groups(item.package, updates, rms, _ = self._compute_groups(item.package,
item.suite, item.suite.name,
item.architecture, item.architecture,
item.is_removal, item.is_removal,
removals=removals) removals=removals)
@ -1993,7 +1994,7 @@ class Britney(object):
# add/update the source package # add/update the source package
if not item.is_removal: if not item.is_removal:
sources['testing'][item.package] = sources[item.suite][item.package] sources['testing'][item.package] = sources[item.suite.name][item.package]
# If we are removing *and* updating packages, then check for eqv. packages # If we are removing *and* updating packages, then check for eqv. packages
if rms and updates: if rms and updates:
@ -2041,7 +2042,7 @@ class Britney(object):
# Add/Update binary packages in testing # Add/Update binary packages in testing
if updates: if updates:
packages_s = self.binaries[item.suite] packages_s = self.binaries[item.suite.name]
for updated_pkg_id in updates: for updated_pkg_id in updates:
binary, new_version, parch = updated_pkg_id binary, new_version, parch = updated_pkg_id
@ -2132,7 +2133,7 @@ class Britney(object):
affected_pos = set() affected_pos = set()
affected_remain = set() affected_remain = set()
for item in actions: for item in actions:
_, rms, _ = self._compute_groups(item.package, item.suite, _, rms, _ = self._compute_groups(item.package, item.suite.name,
item.architecture, item.architecture,
item.is_removal, item.is_removal,
allow_smooth_updates=False) allow_smooth_updates=False)
@ -2213,7 +2214,7 @@ class Britney(object):
output_logger = self.output_logger output_logger = self.output_logger
for y in sorted((y for y in packages), key=attrgetter('uvname')): for y in sorted((y for y in packages), key=attrgetter('uvname')):
updates, rms, _ = self._compute_groups(y.package, y.suite, y.architecture, y.is_removal) updates, rms, _ = self._compute_groups(y.package, y.suite.name, y.architecture, y.is_removal)
result = (y, frozenset(updates), frozenset(rms)) result = (y, frozenset(updates), frozenset(rms))
group_info[y] = result group_info[y] = result
@ -2664,22 +2665,23 @@ class Britney(object):
if pkg.is_removal: if pkg.is_removal:
continue continue
suite_name = pkg.suite.name
inunstable = pkg.package in self.sources['unstable'] inunstable = pkg.package in self.sources['unstable']
rightversion = inunstable and (apt_pkg.version_compare(self.sources['unstable'][pkg.package].version, pkg.version) == 0) rightversion = inunstable and (apt_pkg.version_compare(self.sources['unstable'][pkg.package].version, pkg.version) == 0)
if pkg.suite == 'unstable' and not rightversion: if suite_name == 'unstable' and not rightversion:
for suite in ['pu', 'tpu']: for suite in ['pu', 'tpu']:
if suite not in self.suite_info: if suite_name not in self.suite_info:
continue continue
if pkg.package in self.sources[suite] and apt_pkg.version_compare(self.sources[suite][pkg.package].version, pkg.version) == 0: if pkg.package in self.sources[suite_name] and apt_pkg.version_compare(self.sources[suite_name][pkg.package].version, pkg.version) == 0:
pkg.suite = suite pkg.suite = self.suite_info[suite]
_pkgvers[idx] = pkg _pkgvers[idx] = pkg
break break
# handle *-proposed-updates # handle *-proposed-updates
if pkg.suite in ['pu', 'tpu']: if suite_name in ['pu', 'tpu']:
if pkg.suite not in self.suite_info or pkg.package not in self.sources[pkg.suite]: if suite_name not in self.suite_info or pkg.package not in self.sources[suite_name]:
continue continue
if apt_pkg.version_compare(self.sources[pkg.suite][pkg.package].version, pkg.version) != 0: if apt_pkg.version_compare(self.sources[suite_name][pkg.package].version, pkg.version) != 0:
issues.append("Version mismatch, %s %s != %s" % (pkg.package, pkg.version, issues.append("Version mismatch, %s %s != %s" % (pkg.package, pkg.version,
self.sources[pkg.suite][pkg.package].version)) self.sources[pkg.suite][pkg.package].version))
# does the package exist in unstable? # does the package exist in unstable?

@ -12,18 +12,28 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
class MigrationItem(object): class MigrationItem(object):
_architectures = [] _architectures = []
_suites = None
@classmethod @classmethod
def set_architectures(cls, architectures = None): def set_architectures(cls, architectures=None):
cls._architectures = architectures or [] cls._architectures = architectures or []
@classmethod @classmethod
def get_architectures(cls): def get_architectures(cls):
return cls._architectures return cls._architectures
def __init__(self, name = None, versionned = True): @classmethod
def set_suites(cls, suites):
cls._suites = suites
@classmethod
def get_suites(cls):
return cls._suites
def __init__(self, name=None, versionned=True):
self._name = None self._name = None
self._uvname = None self._uvname = None
self._package = None self._package = None
@ -69,10 +79,11 @@ class MigrationItem(object):
value = value[1:] value = value[1:]
parts = value.split('/', 3) parts = value.split('/', 3)
package = parts[0] package = parts[0]
suite_name = self.__class__._suites.primary_source_suite.name
if '_' in package: if '_' in package:
self._package, self._suite = package.split('_', 2) self._package, suite_name = package.split('_', 2)
else: else:
self._package, self._suite = (package, 'unstable') self._package = package
if self._versionned and len(parts) > 1: if self._versionned and len(parts) > 1:
if len(parts) == 3: if len(parts) == 3:
self._architecture = parts[1] self._architecture = parts[1]
@ -95,7 +106,9 @@ class MigrationItem(object):
self._architecture.split('_', 2) self._architecture.split('_', 2)
if self.is_removal: if self.is_removal:
self._suite = 'testing' self._suite = self.__class__._suites.target_suite
else:
self._suite = self.__class__._suites.by_name_or_alias[suite_name]
self._canonicalise_name() self._canonicalise_name()
@ -106,8 +119,8 @@ class MigrationItem(object):
self._uvname = self._package self._uvname = self._package
else: else:
self._uvname = "%s/%s" % (self._package, self._architecture) self._uvname = "%s/%s" % (self._package, self._architecture)
if self._suite not in ('testing', 'unstable'): if self._suite.suite_class.is_additional_source:
self._uvname = '%s_%s' % (self._uvname, self._suite) self._uvname = '%s_%s' % (self._uvname, self._suite.suite_short_name)
if is_removal: if is_removal:
self._uvname = '-%s' % (self._uvname) self._uvname = '-%s' % (self._uvname)
if self._versionned: if self._versionned:
@ -133,7 +146,7 @@ class MigrationItem(object):
@suite.setter @suite.setter
def suite(self, value): def suite(self, value):
self._suite = value self._suite = self.__class__._suites[value]
self._canonicalise_name() self._canonicalise_name()
@property @property

@ -128,8 +128,8 @@ def undo_changes(lundo, inst_tester, sources, binaries, all_binary_packages):
# STEP 2 # STEP 2
# undo all new binaries (consequence of the above) # undo all new binaries (consequence of the above)
for (undo, item) in lundo: for (undo, item) in lundo:
if not item.is_removal and item.package in sources[item.suite]: if not item.is_removal and item.package in sources[item.suite.name]:
source_data = sources[item.suite][item.package] source_data = sources[item.suite.name][item.package]
for pkg_id in source_data.binaries: for pkg_id in source_data.binaries:
binary, _, arch = pkg_id binary, _, arch = pkg_id
if item.architecture in ['source', arch]: if item.architecture in ['source', arch]:
@ -356,7 +356,7 @@ def make_migrationitem(package, sources):
""" """
item = UnversionnedMigrationItem(package) item = UnversionnedMigrationItem(package)
return MigrationItem("%s/%s" % (item.uvname, sources[item.suite][item.package].version)) return MigrationItem("%s/%s" % (item.uvname, sources[item.suite.name][item.package].version))
def write_excuses(excuselist, dest_file, output_format="yaml"): def write_excuses(excuselist, dest_file, output_format="yaml"):

@ -1,10 +1,19 @@
import logging
import unittest import unittest
from britney2 import Suite, Suites, SuiteClass
from britney2.hints import HintParser, single_hint_taking_list_of_packages from britney2.hints import HintParser, single_hint_taking_list_of_packages
from britney2.migrationitem import MigrationItem
from . import HINTS_ALL, TEST_HINTER from . import HINTS_ALL, TEST_HINTER
SUITES = Suites(
Suite(SuiteClass.TARGET_SUITE, 'testing', "/somewhere/target", ''),
[Suite(SuiteClass.PRIMARY_SOURCE_SUITE, 'unstable', "/somewhere/source", '')],
)
MigrationItem.set_suites(SUITES)
def new_hint_parser(): def new_hint_parser():
return HintParser() return HintParser()

@ -4,6 +4,7 @@ import os
from britney2 import Suites, Suite, SuiteClass, SourcePackage from britney2 import Suites, Suite, SuiteClass, SourcePackage
from britney2.excuse import Excuse from britney2.excuse import Excuse
from britney2.hints import HintParser from britney2.hints import HintParser
from britney2.migrationitem import MigrationItem
from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy, PolicyVerdict from britney2.policies.policy import AgePolicy, RCBugPolicy, PiupartsPolicy, PolicyVerdict
from . import MockObject, TEST_HINTER, HINTS_ALL, DEFAULT_URGENCY from . import MockObject, TEST_HINTER, HINTS_ALL, DEFAULT_URGENCY
@ -22,6 +23,7 @@ def initialize_policy(test_name, policy_class, *args, **kwargs):
Suite(SuiteClass.TARGET_SUITE, 'testing', os.path.join(test_dir, 'testing'), ''), Suite(SuiteClass.TARGET_SUITE, 'testing', os.path.join(test_dir, 'testing'), ''),
[Suite(SuiteClass.PRIMARY_SOURCE_SUITE, 'unstable', os.path.join(test_dir, 'unstable'), '')], [Suite(SuiteClass.PRIMARY_SOURCE_SUITE, 'unstable', os.path.join(test_dir, 'unstable'), '')],
) )
MigrationItem.set_suites(suite_info)
policy = policy_class(options, suite_info, *args) policy = policy_class(options, suite_info, *args)
fake_britney = MockObject(log=lambda x, y='I': None) fake_britney = MockObject(log=lambda x, y='I': None)
hint_parser = HintParser() hint_parser = HintParser()

Loading…
Cancel
Save