From 3c8b7ba11d83995f6c0a66cdf9e4cf1a47ce55dc Mon Sep 17 00:00:00 2001 From: Ivo De Decker Date: Fri, 3 Jan 2020 14:27:51 +0000 Subject: [PATCH] Add source to SourcePackage object Adding a source parameter to the SourcePackage allow finding the source the object is referring to, so that parameter doesn't have to be passed along separately. Signed-off-by: Ivo De Decker --- britney.py | 6 ++++-- britney2/__init__.py | 9 +++++---- britney2/inputs/suiteloader.py | 2 +- britney2/utils.py | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/britney.py b/britney.py index a6b473b..28c7e10 100755 --- a/britney.py +++ b/britney.py @@ -540,7 +540,8 @@ class Britney(object): faux_section = 'faux' if component != 'main': faux_section = "%s/faux" % component - src_data = SourcePackage(version, + src_data = SourcePackage(pkg_name, + version, sys.intern(faux_section), set(), None, @@ -627,7 +628,8 @@ class Britney(object): pkg_list = [x.strip() for x in mandatory_field('Package-List').split("\n") if x.strip() != '' and not x.strip().startswith("#")] - src_data = SourcePackage(faux_version, + src_data = SourcePackage(pkg_name, + faux_version, faux_section, set(), None, diff --git a/britney2/__init__.py b/britney2/__init__.py index f5deae2..99b8573 100644 --- a/britney2/__init__.py +++ b/britney2/__init__.py @@ -230,11 +230,12 @@ class Suites(object): class SourcePackage(object): - __slots__ = ['version', 'section', 'binaries', 'maintainer', 'is_fakesrc', 'build_deps_arch', 'build_deps_indep', - 'testsuite', 'testsuite_triggers'] + __slots__ = ['source', 'version', 'section', 'binaries', 'maintainer', 'is_fakesrc', 'build_deps_arch', + 'build_deps_indep', 'testsuite', 'testsuite_triggers'] - def __init__(self, version, section, binaries, maintainer, is_fakesrc, build_deps_arch, build_deps_indep, - testsuite, testsuite_triggers): + def __init__(self, source, version, section, binaries, maintainer, is_fakesrc, build_deps_arch, + build_deps_indep, testsuite, testsuite_triggers): + self.source = source self.version = version self.section = section self.binaries = binaries diff --git a/britney2/inputs/suiteloader.py b/britney2/inputs/suiteloader.py index 1c6825f..31ebeec 100644 --- a/britney2/inputs/suiteloader.py +++ b/britney2/inputs/suiteloader.py @@ -314,7 +314,7 @@ class DebMirrorLikeSuiteContentLoader(SuiteContentLoader): srcdist[source].binaries.add(pkg_id) # if the source package doesn't exist, create a fake one else: - srcdist[source] = SourcePackage(source_version, 'faux', {pkg_id}, None, True, None, None, [], []) + srcdist[source] = SourcePackage(source, source_version, 'faux', {pkg_id}, None, True, None, None, [], []) # add the resulting dictionary to the package list packages[pkg] = dpkg diff --git a/britney2/utils.py b/britney2/utils.py index 10d352c..3f431f9 100644 --- a/britney2/utils.py +++ b/britney2/utils.py @@ -554,7 +554,7 @@ def read_sources_file(filename, sources=None, intern=sys.intern): # (in unstable) if some architectures have out-of-date # binaries. We only ever consider the source with the # largest version for migration. - if pkg in sources and apt_pkg.version_compare(sources[pkg][0], ver) > 0: + if pkg in sources and apt_pkg.version_compare(sources[pkg].version, ver) > 0: continue maint = get_field('Maintainer') if maint: @@ -571,7 +571,8 @@ def read_sources_file(filename, sources=None, intern=sys.intern): build_deps_indep = get_field('Build-Depends-Indep') if build_deps_indep is not None: build_deps_indep = sys.intern(build_deps_indep) - sources[intern(pkg)] = SourcePackage(intern(ver), + sources[intern(pkg)] = SourcePackage(intern(pkg), + intern(ver), section, set(), maint,