aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/import_orig.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-04-04 07:13:15 +0200
committerGuido Günther <agx@sigxcpu.org>2017-04-12 11:19:09 +0200
commite890ce326ee66e0339ae4c83644473173fc4758e (patch)
tree9eeddd3c212c0b1c1af1ee894363ba973bf10e9a /gbp/scripts/import_orig.py
parent7cfe71d6d45399ded9b50209a2c0dcbf132afd3d (diff)
ipmort_orig: pick best way to import upstream tarball automatically
Add new value --merge-mode=auto that selects either 'replace' or 'merge' depending on the source format version. Closes: #700411
Diffstat (limited to 'gbp/scripts/import_orig.py')
-rw-r--r--gbp/scripts/import_orig.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 61ad7a26..2ff342e5 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -24,6 +24,7 @@ import tempfile
import time
import gbp.command_wrappers as gbpc
from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
+from gbp.deb.format import DebianSourceFormat
from gbp.deb.upstreamsource import DebianUpstreamSource, unpack_component_tarball
from gbp.deb.uscan import (Uscan, UscanError)
from gbp.deb.changelog import ChangeLog, NoChangeLogError
@@ -32,6 +33,7 @@ from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch
from gbp.errors import GbpError
from gbp.pkg import parse_archive_filename
from gbp.format import format_str
+from gbp.git.vfs import GitVfs
import gbp.log
from gbp.scripts.common import ExitCodes, is_download
from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree,
@@ -339,6 +341,22 @@ def debian_branch_merge(repo, tag, version, options):
extra_env=env)()
+def is_30_quilt(repo, options):
+ format_file = DebianSourceFormat.format_file
+ try:
+ content = GitVfs(repo, options.debian_branch).open(format_file).read()
+ except IOError:
+ return False
+ return str(DebianSourceFormat(content)) == "3.0 (quilt)"
+
+
+def debian_branch_merge_by_auto(repo, tag, version, options):
+ if is_30_quilt(repo, options):
+ return debian_branch_merge_by_replace(repo, tag, version, options)
+ else:
+ return debian_branch_merge_by_merge(repo, tag, version, options)
+
+
def debian_branch_merge_by_replace(repo, tag, version, options):
gbp.log.info("Replacing upstream source on '%s'" % options.debian_branch)