import-orig: move repacked_tarball_name() out from common
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 15 Jun 2012 06:00:35 +0000 (09:00 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:22:07 +0000 (14:22 +0200)
Moves repacked_tarball_name() from scripts/common back to the
Debian-specific script. The logic is too Debian-specific for RPM, after
all.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/scripts/common/import_orig.py
gbp/scripts/import_orig.py

index d941908..349ec59 100644 (file)
@@ -108,25 +108,9 @@ def ask_package_version(default, ver_validator_func, err_msg):
         gbp.log.warn("\nNot a valid upstream version: '%s'.\n%s" % (version, err_msg))
 
 
-def repacked_tarball_name(source, name, version):
-    if source.is_orig():
-        # Repacked orig tarball needs a different name since there's already
-        # one with that name
-        name = os.path.join(
-                    os.path.dirname(source.path),
-                    os.path.basename(source.path).replace(".tar", ".gbp.tar"))
-    else:
-        # Repacked sources or other archives get canonical name
-        name = os.path.join(
-                    os.path.dirname(source.path),
-                    "%s_%s.orig.tar.bz2" % (name, version))
-    return name
-
-
-def repack_source(source, name, version, unpack_dir, filters):
+def repack_source(source, new_name, unpack_dir, filters):
     """Repack the source tree"""
-    name = repacked_tarball_name(source, name, version)
-    repacked = source.pack(name, filters)
+    repacked = source.pack(new_name, filters)
     if source.is_orig(): # the tarball was filtered on unpack
         repacked.unpacked = source.unpacked
     else: # otherwise unpack the generated tarball get a filtered tree
index 888cebb..3707186 100644 (file)
@@ -173,6 +173,21 @@ def find_source(use_uscan, args):
         return archive
 
 
+def repacked_tarball_name(source, name, version):
+    if source.is_orig():
+        # Repacked orig tarball needs a different name since there's already
+        # one with that name
+        name = os.path.join(
+                    os.path.dirname(source.path),
+                    os.path.basename(source.path).replace(".tar", ".gbp.tar"))
+    else:
+        # Repacked sources or other archives get canonical name
+        name = os.path.join(
+                    os.path.dirname(source.path),
+                    "%s_%s.orig.tar.bz2" % (name, version))
+    return name
+
+
 def set_bare_repo_options(options):
     """Modify options for import into a bare repository"""
     if options.pristine_tar or options.merge:
@@ -312,7 +327,8 @@ def main(argv):
         if orig_needs_repack(source, options):
             gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
             repack_dir = tempfile.mkdtemp(prefix='repack', dir=tmpdir)
-            source = repack_source(source, sourcepackage, version, repack_dir, options.filters)
+            repack_name = repacked_tarball_name(source, sourcepackage, version)
+            source = repack_source(source, repack_name, repack_dir, options.filters)
 
         (pristine_orig, linked) = prepare_pristine_tar(source.path,
                                                        sourcepackage,