Write "HeidiResultDelta" file containing the changes of the run

Based on Colin Watson's code to do the same from the "britney2-ubuntu"
repository[1] revision 306, 308 and 309.

Notable differences include:
 * output include version of source package being removed
 * output prefix removals with a "-" (otherwise it would be identical to
   a upgrade/new source with the change above).

[1] http://bazaar.launchpad.net/~ubuntu-release/britney/britney2-ubuntu/revision/306

Signed-off-by: Niels Thykier <niels@thykier.net>
master
Niels Thykier 10 years ago
parent 3c8f72607e
commit 691bda4bd8

@ -216,7 +216,7 @@ from britney_util import (old_libraries_format, same_source, undo_changes,
register_reverses, compute_reverse_tree,
read_nuninst, write_nuninst, write_heidi,
eval_uninst, newly_uninst, make_migrationitem,
write_excuses)
write_excuses, write_heidi_delta)
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
SOURCE, SOURCEVER, ARCHITECTURE, DEPENDS, CONFLICTS,
PROVIDES, RDEPENDS, RCONFLICTS, MULTIARCH, ESSENTIAL)
@ -257,6 +257,8 @@ class Britney(object):
apt_pkg.init()
self.sources = {}
self.binaries = {}
self.all_selected = []
try:
self.hints = self.read_hints(self.options.hintsdir)
except AttributeError:
@ -385,6 +387,9 @@ class Britney(object):
not getattr(self.options, k.lower()):
setattr(self.options, k.lower(), v)
if not hasattr(self.options, "heidi_delta_output"):
self.options.heidi_delta_output = self.options.heidi_output + "Delta"
# Sort the architecture list
allarches = sorted(self.options.architectures.split())
arches = [x for x in allarches if x in self.options.nobreakall_arches.split()]
@ -2272,6 +2277,7 @@ class Britney(object):
newly_uninst(nuninst_start, nuninst_end)) + "\n")
self.output_write("SUCCESS (%d/%d)\n" % (len(actions or self.upgrade_me), len(extra)))
self.nuninst_orig = nuninst_end
self.all_selected += selected
if not actions:
if recurse:
self.upgrade_me = sorted(extra)
@ -2401,6 +2407,11 @@ class Britney(object):
write_heidi(self.options.heidi_output, self.sources["testing"],
self.binaries["testing"])
self.__log("Writing delta to %s" % self.options.heidi_delta_output)
write_heidi_delta(self.options.heidi_delta_output,
self.all_selected)
self.printuninstchange()
self.__log("Test completed!", type="I")

@ -407,6 +407,34 @@ def write_heidi(filename, sources_t, packages_t,
srcsec = src[SECTION] or 'unknown'
f.write('%s %s source %s\n' % (src_name, srcv, srcsec))
def write_heidi_delta(filename, all_selected):
"""Write the output delta
This method writes the packages to be upgraded, in the form:
<src-name> <src-version>
or (if the source is to be removed):
-<src-name> <src-version>
The order corresponds to that shown in update_output.
"""
with open(filename, "w") as fd:
fd.write("#HeidiDelta\n")
for item in all_selected:
prefix = ""
if item.is_removal:
prefix = "-"
if item.architecture == 'source':
fd.write('%s%s %s\n' % (prefix, item.package, item.version))
else:
fd.write('%s%s %s %s\n' % (prefix, item.package,
item.version, item.architecture))
def make_migrationitem(package, sources, VERSION=VERSION):
"""Convert a textual package specification to a MigrationItem

Loading…
Cancel
Save