britney: Refactor a part of doop_source into its own method

Signed-off-by: Niels Thykier <niels@thykier.net>
bzr-import-20160707
Niels Thykier 12 years ago
parent 14cefe379e
commit 3df18bcd53

@ -1840,52 +1840,30 @@ class Britney(object):
return diff <= 0
def doop_source(self, item, hint_undo=[]):
"""Apply a change to the testing distribution as requested by `pkg`
An optional list of undo actions related to packages processed earlier
in a hint may be passed in `hint_undo`.
This method applies the changes required by the action `item` tracking
them so it will be possible to revert them.
The method returns a list of the package name, the suite where the
package comes from, the set of packages affected by the change and
the dictionary undo which can be used to rollback the changes.
"""
undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []}
affected = set()
# local copies for better performances
sources = self.sources
binaries = self.binaries['testing']
# remove all binary packages (if the source already exists)
if item.architecture == 'source' or not item.is_removal:
if item.package in sources['testing']:
source = sources['testing'][item.package]
def find_upgraded_binaries(self, item, source):
bins = []
check = []
smoothbins = []
check = []
# remove all the binaries
binaries_t = self.binaries['testing']
# first, build a list of eligible binaries
for p in source[BINARIES]:
binary, parch = p.split("/")
if item.architecture != 'source':
# for a binary migration, binaries should not be removed:
# - unless they are for the correct architecture
if parch != item.architecture: continue
if parch != item.architecture:
continue
# - if they are arch:all and the migration is via *pu,
# as the packages will not have been rebuilt and the
# source suite will not contain them
if binaries[parch][0][binary][ARCHITECTURE] == 'all' and \
if binaries_t[parch][0][binary][ARCHITECTURE] == 'all' and \
item.suite != 'unstable':
continue
# do not remove binaries which have been hijacked by other sources
if binaries[parch][0][binary][SOURCE] != item.package: continue
if binaries_t[parch][0][binary][SOURCE] != item.package:
continue
bins.append(p)
for p in bins:
@ -1894,14 +1872,14 @@ class Britney(object):
if item.suite == 'unstable' and \
binary not in self.binaries[item.suite][parch][0] and \
('ALL' in self.options.smooth_updates or \
binaries[parch][0][binary][SECTION] in self.options.smooth_updates):
binaries_t[parch][0][binary][SECTION] in self.options.smooth_updates):
# if the package has reverse-dependencies which are
# built from other sources, it's a valid candidate for
# a smooth update. if not, it may still be a valid
# candidate if one if its r-deps is itself a candidate,
# so note it for checking later
rdeps = binaries[parch][0][binary][RDEPENDS]
rdeps = binaries_t[parch][0][binary][RDEPENDS]
# the list of reverse-dependencies may be outdated
# if, for example, we're processing a hint and
@ -1910,10 +1888,10 @@ class Britney(object):
# sure that at least one of the entries is still
# valid
rrdeps = [x for x in rdeps if x not in [y.split("/")[0] for y in bins]]
if len(rrdeps) > 0:
if rrdeps:
for dep in rrdeps:
if dep in binaries[parch][0]:
bin = binaries[parch][0][dep]
if dep in binaries_t[parch][0]:
bin = binaries_t[parch][0][dep]
deps = []
if bin[DEPENDS] is not None:
deps.extend(apt_pkg.parse_depends(bin[DEPENDS], False))
@ -1923,15 +1901,47 @@ class Britney(object):
else:
check.append(p)
# check whether we should perform a smooth update for
# packages which are candidates but do not have r-deps
# outside of the current source
for p in check:
binary, parch = p.split("/")
if any(bin for bin in binaries[parch][0][binary][RDEPENDS] \
if any(bin for bin in binaries_t[parch][0][binary][RDEPENDS] \
if bin in [y.split("/")[0] for y in smoothbins]):
smoothbins.append(p)
return (bins, smoothbins)
def doop_source(self, item, hint_undo=[]):
"""Apply a change to the testing distribution as requested by `pkg`
An optional list of undo actions related to packages processed earlier
in a hint may be passed in `hint_undo`.
This method applies the changes required by the action `item` tracking
them so it will be possible to revert them.
The method returns a list of the package name, the suite where the
package comes from, the set of packages affected by the change and
the dictionary undo which can be used to rollback the changes.
"""
undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []}
affected = set()
# local copies for better performances
sources = self.sources
binaries = self.binaries['testing']
# remove all binary packages (if the source already exists)
if item.architecture == 'source' or not item.is_removal:
if item.package in sources['testing']:
source = sources['testing'][item.package]
bins, smoothbins = self.find_upgraded_binaries(item, source)
# remove all the binaries which aren't being smooth updated
for p in [ bin for bin in bins if bin not in smoothbins ]:
binary, parch = p.split("/")

Loading…
Cancel
Save