summaryrefslogtreecommitdiff
path: root/gbp/scripts/pq_rpm.py
diff options
context:
space:
mode:
Diffstat (limited to 'gbp/scripts/pq_rpm.py')
-rwxr-xr-xgbp/scripts/pq_rpm.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py
index d8fcbf2f..32ffadee 100755
--- a/gbp/scripts/pq_rpm.py
+++ b/gbp/scripts/pq_rpm.py
@@ -26,12 +26,12 @@ import sys
import re
import gzip
import bz2
+import tarfile
import subprocess
-
import gbp.tmpfile as tempfile
from gbp.config import GbpOptionParserRpm
from gbp.rpm.git import GitRepositoryError, RpmGitRepository
-from gbp.git.modifier import GitModifier
+from gbp.git.modifier import GitModifier, GitTz
from gbp.command_wrappers import GitCommand, CommandExecFailed
from gbp.errors import GbpError
import gbp.log
@@ -243,13 +243,14 @@ def parse_spec(options, repo, treeish=None):
return spec
-def find_upstream_commit(repo, upstreamversion, upstream_tag):
+def find_upstream_commit(repo, spec, upstream_tag):
"""Find commit corresponding upstream version"""
- tag_str_fields = {'upstreamversion': upstreamversion,
+ tag_str_fields = {'upstreamversion': spec.upstreamversion,
'vendor': 'Upstream'}
upstream_commit = repo.find_version(upstream_tag, tag_str_fields)
if not upstream_commit:
- raise GbpError("Couldn't find upstream version %s" % upstreamversion)
+ raise GbpError("Couldn't find upstream version %s" %
+ spec.upstreamversion)
return upstream_commit
@@ -265,10 +266,11 @@ def export_patches(repo, options):
else:
spec = parse_spec(options, repo)
pq_branch = pq_branch_name(current, options, spec.version)
- upstream_commit = find_upstream_commit(repo, spec.upstreamversion,
- options.upstream_tag)
+ upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
export_treeish = options.export_rev if options.export_rev else pq_branch
+ if not repo.has_treeish(export_treeish):
+ raise GbpError('Invalid treeish object %s' % export_treeish)
update_patch_series(repo, spec, upstream_commit, export_treeish, options)
@@ -299,6 +301,9 @@ def safe_patches(queue, tmpdir_base):
gbp.log.debug("Uncompressing '%s'" % os.path.basename(patch.path))
src = uncompressors[comp](patch.path, 'r')
dst_name = os.path.join(tmpdir, os.path.basename(base))
+ if _archive_fmt:
+ tar_name = dst_name
+ dst_name += '.tar'
elif comp:
raise GbpError("Unsupported patch compression '%s', giving up"
% comp)
@@ -310,6 +315,11 @@ def safe_patches(queue, tmpdir_base):
dst.writelines(src)
src.close()
dst.close()
+ if _archive_fmt:
+ t = tarfile.open(dst_name, 'r:')
+ t.extractall(path = tmpdir)
+ t.close()
+ dst_name = tar_name
safequeue.append(patch)
safequeue[-1].path = dst_name
@@ -377,8 +387,7 @@ def import_spec_patches(repo, options):
spec = parse_spec(options, repo)
spec_treeish = None
base = current
- upstream_commit = find_upstream_commit(repo, spec.upstreamversion,
- options.upstream_tag)
+ upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
packager = get_packager(spec)
pq_branch = pq_branch_name(base, options, spec.version)
@@ -435,8 +444,7 @@ def rebase_pq(repo, options):
else:
base = current
spec = parse_spec(options, repo)
- upstream_commit = find_upstream_commit(repo, spec.upstreamversion,
- options.upstream_tag)
+ upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
switch_to_pq_branch(repo, base, options)
GitCommand("rebase")([upstream_commit])
@@ -502,8 +510,7 @@ def convert_package(repo, options):
pq_branch = pq_branch_name(old_packaging, options, spec.version)
raise GbpError(err_msg_base + "pq branch %s already exists" % pq_branch)
# Check that the current branch is based on upstream
- upstream_commit = find_upstream_commit(repo, spec.upstreamversion,
- options.upstream_tag)
+ upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
if not is_ancestor(repo, upstream_commit, old_packaging):
raise GbpError(err_msg_base + "%s is not based on upstream version %s" %
(old_packaging, spec.upstreamversion))