summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-03-25 11:34:45 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-01-14 13:48:23 +0200
commit1ea4b125cb92818c82dfd49c6fad737d60b9a3b4 (patch)
treef17d94383a1321b00451990d0cf9d8100db09ead
parent4281c1c9ec42d54437cb4f5ee5b7d4960d058c81 (diff)
downloadgit-buildpackage-1ea4b125cb92818c82dfd49c6fad737d60b9a3b4.tar.gz
git-buildpackage-1ea4b125cb92818c82dfd49c6fad737d60b9a3b4.tar.bz2
git-buildpackage-1ea4b125cb92818c82dfd49c6fad737d60b9a3b4.zip
buildpackage-rpm: use config file(s) from exported tree-ish
Use the local per-tree/per-branch config file(s) from the exported tree-ish instead of the current working copy. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rwxr-xr-xgbp/scripts/buildpackage_rpm.py41
1 files changed, 26 insertions, 15 deletions
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py
index 47b352d4..4f8484ce 100755
--- a/gbp/scripts/buildpackage_rpm.py
+++ b/gbp/scripts/buildpackage_rpm.py
@@ -174,16 +174,19 @@ def get_tree(repo, tree_name):
Get/create a tree-ish to be used for exporting and diffing. Accepts
special keywords for git index and working copies.
"""
- if tree_name == index_name:
- # Write a tree of the index
- tree = repo.write_tree()
- elif tree_name in wc_names:
- # Write a tree of the working copy
- tree = write_wc(repo,
- force=wc_names[tree_name]['force'],
- untracked=wc_names[tree_name]['untracked'])
- else:
- tree = tree_name
+ try:
+ if tree_name == index_name:
+ # Write a tree of the index
+ tree = repo.write_tree()
+ elif tree_name in wc_names:
+ # Write a tree of the working copy
+ tree = write_wc(repo,
+ force=wc_names[tree_name]['force'],
+ untracked=wc_names[tree_name]['untracked'])
+ else:
+ tree = tree_name
+ except GitRepositoryError as err:
+ raise GbpError(err)
if not repo.has_treeish(tree):
raise GbpError('Invalid treeish object %s' % tree)
@@ -306,7 +309,7 @@ def update_tag_str_fields(tag_format_str, fields, repo, commit):
return extra
-def parse_args(argv, prefix):
+def parse_args(argv, prefix, git_treeish=None):
args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0 ]
builder_args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1 ]
@@ -316,7 +319,8 @@ def parse_args(argv, prefix):
args.append(arg)
try:
- parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix=prefix)
+ parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
+ prefix=prefix, git_treeish=git_treeish)
except ConfigParser.ParsingError, err:
gbp.log.err(err)
return None, None, None
@@ -441,6 +445,16 @@ def main(argv):
else:
repo_dir = os.path.abspath(os.path.curdir)
+ # Determine tree-ish to be exported
+ try:
+ tree = get_tree(repo, options.export)
+ except GbpError as err:
+ gbp.log.err('Failed to determine export treeish: %s' % err)
+ return 1
+ # Re-parse config options with using the per-tree config file(s) from the
+ # exported tree-ish
+ options, gbp_args, builder_args = parse_args(argv, prefix, tree)
+
try:
# Create base temporary directory for this run
options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir,
@@ -469,9 +483,6 @@ def main(argv):
gbp.log.err("You are not on branch '%s' but on '%s'" % (options.packaging_branch, branch))
raise GbpError, "Use --git-ignore-branch to ignore or --git-packaging-branch to set the branch name."
- # Determine tree-ish to be exported
- tree = get_tree(repo, options.export)
-
# Dump from git to a temporary directory:
dump_dir = tempfile.mkdtemp(dir=options.tmp_dir,
prefix='dump_tree_')