[28784] in Source-Commits
build-system commit: APTSourcePackage.get_control_file: Support xz files
daemon@ATHENA.MIT.EDU (System T. Builder)
Sun May 7 04:12:16 2017
Date: Sun, 7 May 2017 04:12:11 -0400
From: "System T. Builder" <builder@mit.edu>
Message-Id: <201705070812.v478CBfc024932@drugstore.mit.edu>
To: source-commits@mit.edu
https://github.com/mit-athena/build-system/commit/e7912dd9636926fca66c1dd0553d1bb092ad52d5
commit e7912dd9636926fca66c1dd0553d1bb092ad52d5
Author: Anders Kaseorg <andersk@mit.edu>
Date: Sun May 7 04:11:39 2017 -0400
APTSourcePackage.get_control_file: Support xz files
Signed-off-by: System T. Builder <builder@zulu.mit.edu>
dabuildsys/apt.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dabuildsys/apt.py b/dabuildsys/apt.py
index 457b4df..66022d5 100644
--- a/dabuildsys/apt.py
+++ b/dabuildsys/apt.py
@@ -22,9 +22,11 @@ from common import BuildError
from debian.debian_support import Version
from collections import defaultdict
+from contextlib import closing
import debian.deb822
import glob
import gzip
+import lzma
import os.path
import re
import tarfile
@@ -71,9 +73,11 @@ class APTSourcePackage(object):
except ValueError:
raise BuildError("File %s.{gz,bz2,xz} not found for package %s" % (tarname, self.name))
- with tarfile.open(tarpath, 'r:*') as tar:
- return list(debian.deb822.Deb822.iter_paragraphs(
- tar.extractfile(controlname) ))
+ with closing(lzma.LZMAFile(tarpath, 'r')) if tarpath.endswith('.xz') \
+ else open(tarpath, 'r') as uncompressed:
+ with tarfile.open(fileobj=uncompressed, mode='r:*') as tar:
+ return list(debian.deb822.Deb822.iter_paragraphs(
+ tar.extractfile(controlname) ))
# FIXME: this code should be gone once 1.0 packages are gone
# I still can't believe I actually wrote this