python-apt/precise workaround: Don't prematurely close TagFile fd

Don't close underlying fd right after opening an apt_pkg.TagFile, as that will
prematurely end the iteration. This seems to work with more recent python3-apt,
but not with Ubuntu 12.04 LTS.
This commit is contained in:
Martin Pitt 2015-08-24 20:46:52 +02:00
parent 32f33baf09
commit c5f6ad6452

View File

@ -590,8 +590,8 @@ class Britney(object):
filename = os.path.join(basedir, "Sources")
self.__log("Loading source packages from %s" % filename)
with open(filename, encoding='utf-8') as f:
Packages = apt_pkg.TagFile(f)
f = open(filename, encoding='utf-8')
Packages = apt_pkg.TagFile(f)
get_field = Packages.section.get
step = Packages.step
@ -614,6 +614,7 @@ class Britney(object):
False,
get_field('Testsuite', '').startswith('autopkgtest'),
]
f.close()
return sources
def read_binaries(self, basedir, distribution, arch, intern=sys.intern):
@ -647,8 +648,8 @@ class Britney(object):
filename = os.path.join(basedir, "Packages_%s" % arch)
self.__log("Loading binary packages from %s" % filename)
with open(filename, encoding='utf-8') as f:
Packages = apt_pkg.TagFile(f)
f = open(filename, encoding='utf-8')
Packages = apt_pkg.TagFile(f)
get_field = Packages.section.get
step = Packages.step
@ -735,6 +736,8 @@ class Britney(object):
# add the resulting dictionary to the package list
packages[pkg] = dpkg
f.close()
# loop again on the list of packages to register reverse dependencies and conflicts
register_reverses(packages, provides, check_doubles=False)