summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-05-15 18:13:43 +0300
committerTzafrir Cohen <tzafrir@debian.org>2015-03-26 14:34:39 +0200
commit27732ff17ad3a88075787b634ebcc0e591f6c677 (patch)
tree3375dad61f421eb5c2a3adbee5328502c6028871
parent1dc7dd948c08f2f9abfbda1c7c3bb24a024f8905 (diff)
buildpackage/git_archive_single: use GitRepository.archive()
Use GitRepository.archive() method like git_archive_submodules() does. This makes it possible to call git_archive_single() independent of the callers current working directory. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> With some adjustments (e.g.: comp_opts) Signed-off-by: Tzafrir Cohen <tzafrir@debian.org>
-rwxr-xr-xgbp/scripts/buildpackage.py2
-rw-r--r--gbp/scripts/common/buildpackage.py25
2 files changed, 18 insertions, 9 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 3b15e1c..3024bf0 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
comp_type, comp_level, comp_opts)
else:
- git_archive_single(treeish, output, prefix,
+ git_archive_single(repo, treeish, output, prefix,
comp_type, comp_level, comp_opts)
except (GitRepositoryError, CommandExecFailed):
gbp.log.err("Error generating submodules' archives")
diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py
index d57baa4..be7b346 100644
--- a/gbp/scripts/common/buildpackage.py
+++ b/gbp/scripts/common/buildpackage.py
@@ -96,20 +96,29 @@ 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, format='tar'):
+def git_archive_single(repo, treeish, output, prefix, comp_type, comp_level,
+ comp_opts, format='tar'):
"""
Create an archive without submodules
Exception handling is left to the caller.
"""
prefix = sanitize_prefix(prefix)
- pipe = pipes.Template()
- pipe.prepend("git archive --format=%s --prefix=%s %s" % (format, prefix, treeish), '.-')
- if comp_type:
- pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--')
- ret = pipe.copy('', output)
- if ret:
- raise GbpError("Error creating %s: %d" % (output, ret))
+ with open(output, 'w') as archive_fd:
+ if comp_type:
+ # FIXME: assumes comp_opts has a single component
+ cmd = [comp_type, '--stdout', '-%s' % comp_level]
+ if comp_opts != '':
+ cmd.append(comp_opts)
+ else:
+ cmd = ['cat']
+
+ popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=archive_fd)
+ for chunk in repo.archive(format, prefix, None, treeish):
+ popen.stdin.write(chunk)
+ popen.stdin.close()
+ if popen.wait():
+ raise GbpError("Error creating %s: compressor cmd failed" % output)
def untar_data(outdir, data):