aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/import_orig.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-04-19 07:58:58 +0200
committerGuido Günther <agx@sigxcpu.org>2017-04-23 14:19:46 +0200
commitc9aa2889ab322f9909220098e03cbf82bf780996 (patch)
treed19834368a537829381900d402fe784fe5f26c77 /gbp/scripts/import_orig.py
parent9991d0e01e7deef3564d36d5398caa42c10264d9 (diff)
import-orig: move unpacking code to separate function
Gbp-Dch: Ignore
Diffstat (limited to 'gbp/scripts/import_orig.py')
-rw-r--r--gbp/scripts/import_orig.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index b4d5bf35..816960f1 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -417,6 +417,22 @@ def get_component_tarballs(name, version, tarball, components):
return tarballs
+def unpack_tarballs(sourcepackage, source, version, component_tarballs, options):
+ tmpdir = tempfile.mkdtemp(dir='../')
+ if not source.is_dir(): # Unpack main tarball
+ source.unpack(tmpdir, options.filters)
+ gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
+
+ if orig_needs_repack(source, options):
+ gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
+ (source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters)
+
+ if not source.is_dir(): # Unpack component tarballs
+ for (component, tarball) in component_tarballs:
+ unpack_component_tarball(source.unpacked, component, tarball, options.filters)
+ return (source, tmpdir)
+
+
def set_bare_repo_options(options):
"""Modify options for import into a bare repository"""
if options.pristine_tar or options.merge:
@@ -516,7 +532,7 @@ def parse_args(argv):
def main(argv):
ret = 0
- tmpdir = ''
+ tmpdir = None
pristine_orig = None
linked = False
repo = None
@@ -564,18 +580,7 @@ def main(argv):
if repo.bare:
set_bare_repo_options(options)
- if not source.is_dir(): # Unpack main tarball
- tmpdir = tempfile.mkdtemp(dir='../')
- source.unpack(tmpdir, options.filters)
- gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
-
- if orig_needs_repack(source, options):
- gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
- (source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters)
-
- if not source.is_dir(): # Unpack component tarballs
- for (component, tarball) in component_tarballs:
- unpack_component_tarball(source.unpacked, component, tarball, options.filters)
+ source, tmpdir = unpack_tarballs(sourcepackage, source, version, component_tarballs, options)
(pristine_orig, linked) = prepare_pristine_tar(source.path,
sourcepackage,