Tue, 05 May 2009 20:14:36 -0400
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.
scripts/dtrx | file | annotate | diff | comparison | revisions | |
tests/test-2_all.deb | file | annotate | diff | comparison | revisions | |
tests/tests.yml | file | annotate | diff | comparison | revisions |
--- 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('_')
--- 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: |