# HG changeset patch # User Brett Smith # Date 1241568876 14400 # Node ID b8316c2b36df9daf8672a0f54c51bce4c6cc896a # Parent 1b7450ae4c67c948a139e97df54431c19881e63a Add support for new .deb archives with data.tar.{bz2,lzma}. We do this just by detecting the compression of the data.tar file at runtime. The current solution is not exactly elegant but at least avoids repeating code. diff -r 1b7450ae4c67 -r b8316c2b36df scripts/dtrx --- a/scripts/dtrx Sun Apr 12 11:22:42 2009 -0400 +++ b/scripts/dtrx Tue May 05 20:14:36 2009 -0400 @@ -290,8 +290,9 @@ self.archive.close() os.chdir(old_path) - def get_filenames(self): - self.pipe(self.list_pipe, "listing") + def get_filenames(self, internal=False): + if not internal: + self.pipe(self.list_pipe, "listing") processes = [] stdin = self.archive for command in [pipe[0] for pipe in self.pipes]: @@ -389,11 +390,25 @@ class DebExtractor(TarExtractor): file_type = 'Debian package' + data_re = re.compile(r'^data\.tar\.[a-z0-9]+$') def prepare(self): - self.pipe(['ar', 'p', self.filename, 'data.tar.gz'], - "data.tar.gz extraction") - self.pipe(['zcat'], "data.tar.gz decompression") + self.pipe(['ar', 't', self.filename], "finding package data file") + for filename in self.get_filenames(internal=True): + if self.data_re.match(filename): + data_filename = filename + break + else: + raise ExtractorError(".deb contains no data.tar file") + self.archive.seek(0, 0) + self.pipes.pop() + # self.pipes = start_pipes + encoding = mimetypes.guess_type(data_filename)[1] + if not encoding: + raise ExtractorError("data.tar file has unrecognized encoding") + self.pipe(['ar', 'p', self.filename, data_filename], + "extracting data.tar from .deb") + self.pipe([self.decoders[encoding]], "decoding data.tar") def basename(self): pieces = os.path.basename(self.filename).split('_') diff -r 1b7450ae4c67 -r b8316c2b36df tests/test-2_all.deb Binary file tests/test-2_all.deb has changed diff -r 1b7450ae4c67 -r b8316c2b36df tests/tests.yml --- a/tests/tests.yml Sun Apr 12 11:22:42 2009 -0400 +++ b/tests/tests.yml Tue May 05 20:14:36 2009 -0400 @@ -29,6 +29,13 @@ cd test-1.23 ar p ../$1 data.tar.gz | tar -zx +- name: .deb with LZMA compression + filenames: test-2_all.deb + baseline: | + mkdir test-2 + cd test-2 + ar p ../$1 data.tar.lzma | lzcat | tar -x + - name: basic .gem filenames: test-1.23.gem baseline: |