From: Ed Bartosh Date: Fri, 11 May 2012 11:57:14 +0000 (+0300) Subject: git_archive_single: Changed directory before running git-archive if needed X-Git-Tag: release/20120807~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa3c551a23ada2d9fefbbe56d7bd0574f21e9018;p=tools%2Fgit-buildpackage.git git_archive_single: Changed directory before running git-archive if needed Change-Id: If585fd6169f7fd7b3473f28beb25adfbe20b7cc4 --- diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 5d495fad..691261db 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -58,7 +58,7 @@ def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submo else: git_archive_single(treeish, output, prefix, - comp_type, comp_level, comp_opts) + comp_type, comp_level, comp_opts, repo.path) except CommandExecFailed: gbp.log.err("Error generating submodules' archives") return False diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 3f0cbcfb..1d36f6f6 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -59,8 +59,8 @@ def git_archive(repo, spec, output_dir, treeish, comp_type, comp_level, with_sub comp_type, comp_level, comp_opts) else: - git_archive_single(treeish, output, prefix, - comp_type, comp_level, comp_opts, spec.orig_format) + git_archive_single(treeish, output, prefix, comp_type, comp_level, + comp_opts, spec.orig_format, repo.path) except CommandExecFailed: gbp.log.err("Error generating submodules' archives") return False diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 85420b7e..a45b83a9 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -70,17 +70,26 @@ def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level, shutil.rmtree(tempdir) -def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts, formt='tar'): +def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts, + formt='tar', directory=None): """ Create tar.gz of an archive without submodules Exception handling is left to the caller. """ + if directory: + prevdir = os.getcwd() + out = os.path.relpath(os.path.abspath(output), directory) + os.chdir(directory) + else: + out = output pipe = pipes.Template() pipe.prepend("git archive --format=%s --prefix=%s/ %s" % (formt, prefix, treeish), '.-') if comp_type: pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--') - ret = pipe.copy('', output) + ret = pipe.copy('', out) + if directory: + os.chdir(prevdir) if ret: raise GbpError("Error creating %s: %d" % (output, ret))