diff --git a/britney.py b/britney.py index 43c1be8..40f808a 100755 --- a/britney.py +++ b/britney.py @@ -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") diff --git a/britney_util.py b/britney_util.py index cfd2fa9..b23f7cf 100644 --- a/britney_util.py +++ b/britney_util.py @@ -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: + + or (if the source is to be removed): + - + + 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