[PATCH 1/3] Let apt_pkg.TagFile open and uncompress the files
It can now do that for us, so let it do the work.
Signed-off-by: Emilio Pozuelo Monfort <pochu@debian.org>
---
dak/check_archive.py | 22 ++--------------------
dak/cruft_report.py | 26 +++-----------------------
2 files changed, 5 insertions(+), 43 deletions(-)
diff --git a/dak/check_archive.py b/dak/check_archive.py
index 926b4fb..0d57970 100755
--- a/dak/check_archive.py
+++ b/dak/check_archive.py
@@ -383,14 +383,7 @@ def validate_sources(suite, component):
"""
filename = "%s/dists/%s/%s/source/Sources.gz" % (Cnf["Dir::Root"], suite, component)
print "Processing %s..." % (filename)
- # apt_pkg.TagFile needs a real file handle and can't handle a GzipFile instance...
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
- if (result != 0):
- sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
- sys.exit(result)
- sources = utils.open_file(temp_filename)
- Sources = apt_pkg.TagFile(sources)
+ Sources = apt_pkg.TagFile(filename)
while Sources.step():
source = Sources.section.find('Package')
directory = Sources.section.find('Directory')
@@ -413,8 +406,6 @@ def validate_sources(suite, component):
src = utils.clean_symlink(pool_filename, filename, Cnf["Dir::Root"])
print "Symlinking: %s -> %s" % (filename, src)
#os.symlink(src, filename)
- sources.close()
- os.unlink(temp_filename)
########################################
@@ -425,20 +416,11 @@ def validate_packages(suite, component, architecture):
filename = "%s/dists/%s/%s/binary-%s/Packages.gz" \
% (Cnf["Dir::Root"], suite, component, architecture)
print "Processing %s..." % (filename)
- # apt_pkg.TagFile needs a real file handle and can't handle a GzipFile instance...
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
- if (result != 0):
- sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
- sys.exit(result)
- packages = utils.open_file(temp_filename)
- Packages = apt_pkg.TagFile(packages)
+ Packages = apt_pkg.TagFile(filename)
while Packages.step():
filename = "%s/%s" % (Cnf["Dir::Root"], Packages.section.find('Filename'))
if not os.path.exists(filename):
print "W: %s missing." % (filename)
- packages.close()
- os.unlink(temp_filename)
########################################
diff --git a/dak/cruft_report.py b/dak/cruft_report.py
index fbbc044..238409e 100755
--- a/dak/cruft_report.py
+++ b/dak/cruft_report.py
@@ -579,14 +579,7 @@ def main ():
components = get_component_names(session)
for component in components:
filename = "%s/dists/%s/%s/source/Sources.gz" % (suite.archive.path, suite_name, component)
- # apt_pkg.TagFile needs a real file handle and can't handle a GzipFile instance...
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
- if (result != 0):
- sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
- sys.exit(result)
- sources = utils.open_file(temp_filename)
- Sources = apt_pkg.TagFile(sources)
+ Sources = apt_pkg.TagFile(filename)
while Sources.step():
source = Sources.section.find('Package')
source_version = Sources.section.find('Version')
@@ -612,9 +605,6 @@ def main ():
source_binaries[source] = binaries
source_versions[source] = source_version
- sources.close()
- os.unlink(temp_filename)
-
# Checks based on the Packages files
check_components = components[:]
if suite_name != "experimental":
@@ -627,20 +617,13 @@ def main ():
for architecture in architectures:
if component == 'main/debian-installer' and re.match("kfreebsd", architecture):
continue
- filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (suite.archive.path, suite_name, component, architecture)
- # apt_pkg.TagFile needs a real file handle
- (fd, temp_filename) = utils.temp_filename()
- (result, output) = commands.getstatusoutput("gunzip -c %s > %s" % (filename, temp_filename))
- if (result != 0):
- sys.stderr.write("Gunzip invocation failed!\n%s\n" % (output))
- sys.exit(result)
if "nfu" in checks:
nfu_packages.setdefault(architecture,[])
nfu_entries = parse_nfu(architecture)
- packages = utils.open_file(temp_filename)
- Packages = apt_pkg.TagFile(packages)
+ filename = "%s/dists/%s/%s/binary-%s/Packages.gz" % (suite.archive.path, suite_name, component, architecture)
+ Packages = apt_pkg.TagFile(filename)
while Packages.step():
package = Packages.section.find('Package')
source = Packages.section.find('Source', "")
@@ -668,9 +651,6 @@ def main ():
if package in nfu_entries and \
version != source_versions[source]: # only suggest to remove out-of-date packages
nfu_packages[architecture].append((package,version,source_versions[source]))
-
- packages.close()
- os.unlink(temp_filename)
# Distinguish dubious (version numbers match) and 'real' NBS (they don't)
dubious_nbs = {}
--
2.9.3
Reply to: