Move {read,write}_nuninst to britney_util

Signed-off-by: Niels Thykier <niels@thykier.net>
debian
Niels Thykier 12 years ago
parent 1c144b3eb2
commit bf9362be83

@ -212,7 +212,8 @@ from migrationitem import MigrationItem, HintItem
from hints import HintCollection from hints import HintCollection
from britney import buildSystem from britney import buildSystem
from britney_util import (old_libraries_format, same_source, undo_changes, from britney_util import (old_libraries_format, same_source, undo_changes,
register_reverses, compute_reverse_tree) register_reverses, compute_reverse_tree,
read_nuninst, write_nuninst)
from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC, from consts import (VERSION, SECTION, BINARIES, MAINTAINER, FAKESRC,
SOURCE, SOURCEVER, ARCHITECTURE, DEPENDS, CONFLICTS, SOURCE, SOURCEVER, ARCHITECTURE, DEPENDS, CONFLICTS,
PROVIDES, RDEPENDS, RCONFLICTS) PROVIDES, RDEPENDS, RCONFLICTS)
@ -273,7 +274,7 @@ class Britney(object):
if self.options.print_uninst: if self.options.print_uninst:
self.nuninst_arch_report(nuninst, arch) self.nuninst_arch_report(nuninst, arch)
if not self.options.print_uninst: if not self.options.print_uninst:
self.write_nuninst(nuninst) write_nuninst(self.options.noninst_status, nuninst)
else: else:
self.__log("Not building the list of non-installable packages, as requested", type="I") self.__log("Not building the list of non-installable packages, as requested", type="I")
@ -888,25 +889,6 @@ class Britney(object):
f.write(output + "\n") f.write(output + "\n")
f.close() f.close()
def write_nuninst(self, nuninst):
"""Write the non-installable report"""
f = open(self.options.noninst_status, 'w')
f.write("Built on: " + time.strftime("%Y.%m.%d %H:%M:%S %z", time.gmtime(time.time())) + "\n")
f.write("Last update: " + time.strftime("%Y.%m.%d %H:%M:%S %z", time.gmtime(time.time())) + "\n\n")
f.write("".join([k + ": " + " ".join(nuninst[k]) + "\n" for k in nuninst]))
f.close()
def read_nuninst(self):
"""Read the non-installable report"""
f = open(self.options.noninst_status)
nuninst = {}
for r in f:
if ":" not in r: continue
arch, packages = r.strip().split(":", 1)
if arch.split("+", 1)[0] in self.options.architectures:
nuninst[arch] = set(packages.split())
return nuninst
# Utility methods for package analysis # Utility methods for package analysis
# ------------------------------------ # ------------------------------------
@ -1670,10 +1652,13 @@ class Britney(object):
It returns a dictionary with the architectures as keys and the list It returns a dictionary with the architectures as keys and the list
of uninstallable packages as values. of uninstallable packages as values.
NB: If build is False, requested_arch is ignored.
""" """
# if we are not asked to build the nuninst, read it from the cache # if we are not asked to build the nuninst, read it from the cache
if not build: if not build:
return self.read_nuninst() return read_nuninst(self.options.noninst_status,
self.options.architectures)
nuninst = {} nuninst = {}

@ -22,6 +22,7 @@ import apt_pkg
from functools import partial from functools import partial
from itertools import chain, ifilter, ifilterfalse, izip, repeat from itertools import chain, ifilter, ifilterfalse, izip, repeat
import re import re
import time
from consts import (BINARIES, PROVIDES, DEPENDS, CONFLICTS, from consts import (BINARIES, PROVIDES, DEPENDS, CONFLICTS,
@ -259,3 +260,35 @@ def compute_reverse_tree(packages_s, pkg, arch,
# the current iteration # the current iteration
rev_deps = set(revfilt(flatten( binaries[x][RDEPENDS] for x in binfilt(rev_deps) ))) rev_deps = set(revfilt(flatten( binaries[x][RDEPENDS] for x in binfilt(rev_deps) )))
return izip(seen, repeat(arch)) return izip(seen, repeat(arch))
def write_nuninst(filename, nuninst):
"""Write the non-installable report
Write the non-installable report derived from "nuninst" to the
file denoted by "filename".
"""
with open(filename, 'w') as f:
# Having two fields with (almost) identical dates seems a bit
# redundant.
f.write("Built on: " + time.strftime("%Y.%m.%d %H:%M:%S %z", time.gmtime(time.time())) + "\n")
f.write("Last update: " + time.strftime("%Y.%m.%d %H:%M:%S %z", time.gmtime(time.time())) + "\n\n")
f.write("".join([k + ": " + " ".join(nuninst[k]) + "\n" for k in nuninst]))
def read_nuninst(filename, architectures):
"""Read the non-installable report
Read the non-installable report from the file denoted by
"filename" and return it. Only architectures in "architectures"
will be included in the report.
"""
nuninst = {}
with open(filename) as f:
for r in f:
if ":" not in r: continue
arch, packages = r.strip().split(":", 1)
if arch.split("+", 1)[0] in architectures:
nuninst[arch] = set(packages.split())
return nuninst

Loading…
Cancel
Save