britney: Rewrite should_* to be (almost) suite agnostic

The "almost" comes from the fact that there is a reference to
"pu"/"stable" which does not have an obvious fix at the moment.

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 7 years ago
parent 9a5c0c3fa8
commit 9a7394c89d

@ -1118,18 +1118,18 @@ class Britney(object):
"""Check if a source package should be removed from testing """Check if a source package should be removed from testing
This method checks if a source package should be removed from the This method checks if a source package should be removed from the
testing distribution; this happens if the source package is not target suite; this happens if the source package is not
present in the unstable distribution anymore. present in the primary source suite anymore.
It returns True if the package can be removed, False otherwise. It returns True if the package can be removed, False otherwise.
In the former case, a new excuse is appended to the object In the former case, a new excuse is appended to the object
attribute excuses. attribute excuses.
""" """
# if the source package is available in unstable, then do nothing # if the source package is available in unstable, then do nothing
if pkg in self.sources['unstable']: if pkg in self.suite_info.primary_source_suite.sources:
return False return False
# otherwise, add a new excuse for its removal # otherwise, add a new excuse for its removal
src = self.sources['testing'][pkg] src = self.suite_info.target_suite.sources[pkg]
excuse = Excuse("-" + pkg) excuse = Excuse("-" + pkg)
excuse.addhtml("Package not in unstable, will try to remove") excuse.addhtml("Package not in unstable, will try to remove")
excuse.set_vers(src.version, None) excuse.set_vers(src.version, None)
@ -1148,7 +1148,7 @@ class Britney(object):
self.excuses[excuse.name] = excuse self.excuses[excuse.name] = excuse
return True return True
def should_upgrade_srcarch(self, src, arch, suite): def should_upgrade_srcarch(self, src, arch, suite_name):
"""Check if a set of binary packages should be upgraded """Check if a set of binary packages should be upgraded
This method checks if the binary packages produced by the source This method checks if the binary packages produced by the source
@ -1160,12 +1160,14 @@ class Britney(object):
the object attribute excuses. the object attribute excuses.
""" """
# retrieve the source packages for testing and suite # retrieve the source packages for testing and suite
source_t = self.sources['testing'][src]
source_u = self.sources[suite][src] source_suite = self.suite_info[suite_name]
suite_info = self.suite_info[suite] target_suite = self.suite_info.target_suite
source_t = target_suite.sources[src]
source_u = source_suite.sources[src]
suffix = '' suffix = ''
if suite_info.excuses_suffix: if source_suite.excuses_suffix:
suffix = "_%s" % suite_info.excuses_suffix suffix = "_%s" % source_suite.excuses_suffix
# build the common part of the excuse, which will be filled by the code below # build the common part of the excuse, which will be filled by the code below
ref = "%s/%s%s" % (src, arch, suffix) ref = "%s/%s%s" % (src, arch, suffix)
@ -1189,8 +1191,8 @@ class Britney(object):
anywrongver = False anywrongver = False
anyworthdoing = False anyworthdoing = False
packages_t_a = self.binaries['testing'][arch][0] packages_t_a = target_suite.binaries[arch][0]
packages_s_a = self.binaries[suite][arch][0] packages_s_a = source_suite.binaries[arch][0]
# for every binary package produced by this source in unstable for this architecture # for every binary package produced by this source in unstable for this architecture
for pkg_id in sorted(x for x in source_u.binaries if x.architecture == arch): for pkg_id in sorted(x for x in source_u.binaries if x.architecture == arch):
@ -1234,7 +1236,7 @@ class Britney(object):
continue continue
# find unsatisfied dependencies for the new binary package # find unsatisfied dependencies for the new binary package
self.excuse_unsat_deps(pkg_name, src, arch, suite, excuse) self.excuse_unsat_deps(pkg_name, src, arch, suite_name, excuse)
# if the binary is not present in testing, then it is a new binary; # if the binary is not present in testing, then it is a new binary;
# in this case, there is something worth doing # in this case, there is something worth doing
@ -1264,10 +1266,11 @@ class Britney(object):
ssrc = source_t.version == srcv ssrc = source_t.version == srcv
# if this is a binary-only migration via *pu, we never want to try # if this is a binary-only migration via *pu, we never want to try
# removing binary packages # removing binary packages
if not (ssrc and suite != 'unstable'): primary_source_suite = self.suite_info.primary_source_suite
if not (ssrc and source_suite is not primary_source_suite):
# for every binary package produced by this source in testing for this architecture # for every binary package produced by this source in testing for this architecture
_, _, smoothbins = self._compute_groups(src, _, _, smoothbins = self._compute_groups(src,
"unstable", primary_source_suite.name,
arch, arch,
False) False)
@ -1306,36 +1309,37 @@ class Britney(object):
# otherwise, return False # otherwise, return False
return False return False
def should_upgrade_src(self, src, suite): def should_upgrade_src(self, src, suite_name):
"""Check if source package should be upgraded """Check if source package should be upgraded
This method checks if a source package should be upgraded. The analysis This method checks if a source package should be upgraded. The analysis
is performed for the source package specified by the `src' parameter, is performed for the source package specified by the `src' parameter,
for the distribution `suite'. for the distribution `suite_name'.
It returns False if the given package doesn't need to be upgraded, It returns False if the given package doesn't need to be upgraded,
True otherwise. In the former case, a new excuse is appended to True otherwise. In the former case, a new excuse is appended to
the object attribute excuses. the object attribute excuses.
""" """
source_u = self.sources[suite][src] source_suite = self.suite_info[suite_name]
source_u = self.sources[suite_name][src]
if source_u.is_fakesrc: if source_u.is_fakesrc:
# it is a fake package created to satisfy Britney implementation details; silently ignore it # it is a fake package created to satisfy Britney implementation details; silently ignore it
return False return False
target_suite = self.suite_info.target_suite
# retrieve the source packages for testing (if available) and suite # retrieve the source packages for testing (if available) and suite
if src in self.sources['testing']: if src in target_suite.sources:
source_t = self.sources['testing'][src] source_t = target_suite.sources[src]
# if testing and unstable have the same version, then this is a candidate for binary-NMUs only # if testing and unstable have the same version, then this is a candidate for binary-NMUs only
if apt_pkg.version_compare(source_t.version, source_u.version) == 0: if apt_pkg.version_compare(source_t.version, source_u.version) == 0:
return False return False
else: else:
source_t = None source_t = None
suite_info = self.suite_info[suite]
suffix = '' suffix = ''
if suite_info.excuses_suffix: if source_suite.excuses_suffix:
suffix = "_%s" % suite_info.excuses_suffix suffix = "_%s" % source_suite.excuses_suffix
# build the common part of the excuse, which will be filled by the code below # build the common part of the excuse, which will be filled by the code below
ref = "%s%s" % (src, suffix) ref = "%s%s" % (src, suffix)
@ -1346,7 +1350,7 @@ class Britney(object):
# if the version in unstable is older, then stop here with a warning in the excuse and return False # if the version in unstable is older, then stop here with a warning in the excuse and return False
if source_t and apt_pkg.version_compare(source_u.version, source_t.version) < 0: if source_t and apt_pkg.version_compare(source_u.version, source_t.version) < 0:
excuse.addhtml("ALERT: %s is newer in testing (%s %s)" % (src, source_t.version, source_u.version)) excuse.addhtml("ALERT: %s is newer in the target suite (%s %s)" % (src, source_t.version, source_u.version))
self.excuses[excuse.name] = excuse self.excuses[excuse.name] = excuse
excuse.addreason("newerintesting") excuse.addreason("newerintesting")
return False return False
@ -1380,8 +1384,8 @@ class Britney(object):
blocked['block'] = hint blocked['block'] = hint
excuse.add_hint(hint) excuse.add_hint(hint)
break break
if suite in ('pu', 'tpu'): if suite_name in ('pu', 'tpu'):
blocked['block'] = '%s-block' % (suite) blocked['block'] = '%s-block' % (suite_name)
excuse.needs_approval = True excuse.needs_approval = True
# if the source is blocked, then look for an `unblock' hint; the unblock request # if the source is blocked, then look for an `unblock' hint; the unblock request
@ -1406,7 +1410,7 @@ class Britney(object):
else: else:
excuse.addhtml("%s request by %s ignored due to version mismatch: %s" % excuse.addhtml("%s request by %s ignored due to version mismatch: %s" %
(unblock_cmd.capitalize(), unblocks[0].user, unblocks[0].version)) (unblock_cmd.capitalize(), unblocks[0].user, unblocks[0].version))
if suite == 'unstable' or block_cmd == 'block-udeb': if suite_name == 'unstable' or block_cmd == 'block-udeb':
tooltip = "please contact debian-release if update is needed" tooltip = "please contact debian-release if update is needed"
# redirect people to d-i RM for udeb things: # redirect people to d-i RM for udeb things:
if block_cmd == 'block-udeb': if block_cmd == 'block-udeb':
@ -1421,7 +1425,7 @@ class Britney(object):
all_binaries = self.all_binaries all_binaries = self.all_binaries
for pkg_id in source_u.binaries: for pkg_id in source_u.binaries:
is_valid = self.excuse_unsat_deps(pkg_id.package_name, src, pkg_id.architecture, suite, excuse) is_valid = self.excuse_unsat_deps(pkg_id.package_name, src, pkg_id.architecture, suite_name, excuse)
if is_valid: if is_valid:
continue continue
@ -1525,13 +1529,13 @@ class Britney(object):
policy_verdict = excuse.policy_verdict policy_verdict = excuse.policy_verdict
policy_info = excuse.policy_info policy_info = excuse.policy_info
for policy in self.policies: for policy in self.policies:
if suite in policy.applicable_suites: if suite_name in policy.applicable_suites:
v = policy.apply_policy(policy_info, suite, src, source_t, source_u, excuse) v = policy.apply_policy(policy_info, suite_name, src, source_t, source_u, excuse)
if v.value > policy_verdict.value: if v.value > policy_verdict.value:
policy_verdict = v policy_verdict = v
excuse.policy_verdict = policy_verdict excuse.policy_verdict = policy_verdict
if suite in ('pu', 'tpu') and source_t: if source_suite.suite_class.is_additional_source and source_t:
# o-o-d(ish) checks for (t-)p-u # o-o-d(ish) checks for (t-)p-u
# This only makes sense if the package is actually in testing. # This only makes sense if the package is actually in testing.
for arch in self.options.architectures: for arch in self.options.architectures:
@ -1545,16 +1549,17 @@ class Britney(object):
# this architecture then we assume it's ok. this allows for # this architecture then we assume it's ok. this allows for
# uploads to (t-)p-u which intentionally drop binary # uploads to (t-)p-u which intentionally drop binary
# packages # packages
if any(x for x in self.binaries[suite][arch][0].values() \ if any(x for x in self.binaries[suite_name][arch][0].values() \
if x.source == src and x.source_version == source_u.version and \ if x.source == src and x.source_version == source_u.version and \
x.architecture != 'all'): x.architecture != 'all'):
continue continue
if suite == 'tpu': # TODO: Find a way to avoid hardcoding pu/stable relation.
base = 'testing' if suite_name == 'pu':
else:
base = 'stable' base = 'stable'
text = "Not yet built on <a href=\"https://buildd.debian.org/status/logs.php?arch=%s&pkg=%s&ver=%s&suite=%s\" target=\"_blank\">%s</a> (relative to testing)" % (quote(arch), quote(src), quote(source_u.version), base, arch) else:
base = target_suite.name
text = "Not yet built on <a href=\"https://buildd.debian.org/status/logs.php?arch=%s&pkg=%s&ver=%s&suite=%s\" target=\"_blank\">%s</a> (relative to target suite)" % (quote(arch), quote(src), quote(source_u.version), base, arch)
if arch in self.options.outofsync_arches: if arch in self.options.outofsync_arches:
text = text + " (but %s isn't keeping up, so never mind)" % (arch) text = text + " (but %s isn't keeping up, so never mind)" % (arch)

@ -1607,7 +1607,7 @@ class T(TestBase):
{'lightgreen': (False, {})}, {'lightgreen': (False, {})},
{'lightgreen': [('old-version', '1'), ('new-version', '0.9~beta'), {'lightgreen': [('old-version', '1'), ('new-version', '0.9~beta'),
('reason', 'newerintesting'), ('reason', 'newerintesting'),
('excuses', 'ALERT: lightgreen is newer in testing (1 0.9~beta)') ('excuses', 'ALERT: lightgreen is newer in the target suite (1 0.9~beta)')
] ]
})[1] })[1]

Loading…
Cancel
Save