diff options
Diffstat (limited to 'gbp/scripts/common/buildpackage.py')
-rw-r--r-- | gbp/scripts/common/buildpackage.py | 25 |
1 files changed, 17 insertions, 8 deletions
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): |