diff --git a/britney.py b/britney.py index 511e03d..b50ad9f 100755 --- a/britney.py +++ b/britney.py @@ -213,7 +213,7 @@ from hints import HintCollection from britney import buildSystem from britney_util import (old_libraries_format, same_source, undo_changes, register_reverses, compute_reverse_tree, - read_nuninst, write_nuninst) + read_nuninst, write_nuninst, write_heidi) from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC, SOURCE, SOURCEVER, ARCHITECTURE, DEPENDS, CONFLICTS, PROVIDES, RDEPENDS, RCONFLICTS) @@ -806,39 +806,6 @@ class Britney(object): return hints - def write_heidi(self, filename): - """Write the output HeidiResult - - This method write the output for Heidi, which contains all the - binary packages and the source packages in the form: - - - source - """ - self.__log("Writing Heidi results to %s" % filename) - f = open(filename, 'w') - - # local copies - sources = self.sources['testing'] - - # write binary packages - for arch in sorted(self.options.architectures): - binaries = self.binaries['testing'][arch][0] - for pkg_name in sorted(binaries): - pkg = binaries[pkg_name] - pkgv = pkg[VERSION] - pkgarch = pkg[ARCHITECTURE] or 'all' - pkgsec = pkg[SECTION] or 'faux' - f.write('%s %s %s %s\n' % (pkg_name, pkgv, pkgarch, pkgsec)) - - # write sources - for src_name in sorted(sources): - src = sources[src_name] - srcv = src[VERSION] - srcsec = src[SECTION] or 'unknown' - f.write('%s %s source %s\n' % (src_name, srcv, srcsec)) - - f.close() def write_controlfiles(self, basedir, suite): """Write the control files @@ -2356,7 +2323,9 @@ class Britney(object): self.write_dates(self.options.testing, self.dates) # write HeidiResult - self.write_heidi(self.options.heidi_output) + self.__log("Writing Heidi results to %s" % self.options.heidi_output) + write_heidi(self.options.heidi_output, self.sources["testing"], + self.binaries["testing"]) self.printuninstchange() self.__log("Test completed!", type="I") diff --git a/britney_util.py b/britney_util.py index d4739e1..86d3f68 100644 --- a/britney_util.py +++ b/britney_util.py @@ -25,8 +25,8 @@ import re import time -from consts import (BINARIES, PROVIDES, DEPENDS, CONFLICTS, - RDEPENDS, RCONFLICTS) +from consts import (VERSION, BINARIES, PROVIDES, DEPENDS, CONFLICTS, + RDEPENDS, RCONFLICTS, ARCHITECTURE, SECTION) binnmu_re = re.compile(r'^(.*)\+b\d+$') @@ -292,3 +292,40 @@ def read_nuninst(filename, architectures): nuninst[arch] = set(packages.split()) return nuninst + +def write_heidi(filename, sources_t, packages_t, + VERSION=VERSION, SECTION=SECTION, + ARCHITECTURE=ARCHITECTURE, sorted=sorted): + """Write the output HeidiResult + + This method write the output for Heidi, which contains all the + binary packages and the source packages in the form: + + + source + + The file is written as "filename", it assumes all sources and + packages in "sources_t" and "packages_t" to be the packages in + "testing". + + The "X=X" parameters are optimizations to avoid "load global" in + the loops. + """ + with open(filename, 'w') as f: + + # write binary packages + for arch in sorted(packages_t): + binaries = packages_t[arch][0] + for pkg_name in sorted(binaries): + pkg = binaries[pkg_name] + pkgv = pkg[VERSION] + pkgarch = pkg[ARCHITECTURE] or 'all' + pkgsec = pkg[SECTION] or 'faux' + f.write('%s %s %s %s\n' % (pkg_name, pkgv, pkgarch, pkgsec)) + + # write sources + for src_name in sorted(sources_t): + src = sources_t[src_name] + srcv = src[VERSION] + srcsec = src[SECTION] or 'unknown' + f.write('%s %s source %s\n' % (src_name, srcv, srcsec))