diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-08-26 10:22:00 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-06-05 14:20:04 +0300 |
commit | c203f35e994dd686cc63e6217ad4b0151faacba5 (patch) | |
tree | 003fbf382e5046bf711c7a369126af3e346f3f61 /tests/testutils.py | |
parent | 536df9ab1c21cdffa3f7c32eed0bbbbf38409f5b (diff) | |
download | git-buildpackage-c203f35e994dd686cc63e6217ad4b0151faacba5.tar.gz git-buildpackage-c203f35e994dd686cc63e6217ad4b0151faacba5.tar.bz2 git-buildpackage-c203f35e994dd686cc63e6217ad4b0151faacba5.zip |
import-orig: new function for filtering/re-packing sources
Introduces a new function prepare_sources() that prepares upstream
sources for importing into upstream branch and pristine-tar. That
includes unpacking, filtering and re-packing sources. What somewhat
complicates the logic is that it tries to avoid excess unpacking/packing
of the sources.
Also fixes the unpacking / filtering / repacking logic which was broken
with some parameter combinations.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'tests/testutils.py')
-rw-r--r-- | tests/testutils.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/testutils.py b/tests/testutils.py index e161dbe5..96a164da 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -5,6 +5,7 @@ from . import context import os import shutil import subprocess +import tarfile import tempfile import unittest @@ -113,3 +114,24 @@ def get_dch_default_urgency(): shutil.rmtree(tempdir) return urgency +def ls_dir(directory): + """List the contents of directory, recurse to subdirectories""" + contents = set() + for root, dirs, files in os.walk(directory): + prefix = '' + if root != directory: + prefix = os.path.relpath(root, directory) + '/' + contents.update(['%s%s' % (prefix, fname) for fname in files] + + ['%s%s' % (prefix, dname) for dname in dirs]) + return contents + +def ls_tar(tarball): + """List the contents of tar archive""" + tmpdir = tempfile.mkdtemp() + try: + tarobj = tarfile.open(tarball, 'r') + tarobj.extractall(tmpdir) + return ls_dir(tmpdir) + finally: + shutil.rmtree(tmpdir) + |