From 0299c3747bd1235b9ad28454177368e9fbf0c17b Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Mon, 25 Mar 2013 11:34:45 +0200 Subject: 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 --- gbp/scripts/buildpackage_rpm.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 9ed3bf98..00d32026 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -169,16 +169,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 # git-ls-tree printed an error message already @@ -301,7 +304,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 ] @@ -311,7 +314,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 @@ -437,6 +441,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, @@ -465,9 +479,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_') -- cgit v1.2.3