diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-01-17 20:10:00 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-01-17 20:11:01 +0100 |
commit | 1140886c80d5ef029bfd7b37b9ff8a24f07e6a69 (patch) | |
tree | 50907fe22435da93a1c1c55a96637f58cafa9020 /gbp/scripts/common/buildpackage.py | |
parent | 4eb8c383ad862cbf1fc6c3f7b86400869079035b (diff) |
buildpackage: Don't set a compression level if unset and make this the default
This allows compressors to use the their default compression level. Only
applies when not using pristine-tar.
Thanks: Antoine Beaupré for investigating
Closes: #820846
Diffstat (limited to 'gbp/scripts/common/buildpackage.py')
-rw-r--r-- | gbp/scripts/common/buildpackage.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 72489e5..8fd7102 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -87,8 +87,12 @@ def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level, if comp_type: # Redirect through stdout directly to the correct output file in # order to avoid determining the output filename of the compressor - ret = os.system("%s --stdout -%s %s %s > %s" % - (comp_type, comp_level, comp_opts, main_archive, + try: + comp_level_opt = '-%d' % comp_level if comp_level is not None else '' + except TypeError as e: + raise GbpError("Invalid compression level '%s'" % comp_level) + ret = os.system("%s --stdout %s %s %s > %s" % + (comp_type, comp_level_opt, comp_opts, main_archive, output)) if ret: raise GbpError("Error creating %s: %d" % (output, ret)) @@ -107,8 +111,12 @@ def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts prefix = sanitize_prefix(prefix) pipe = pipes.Template() pipe.prepend("git archive --format=%s --prefix=%s %s" % (format, prefix, treeish), '.-') + try: + comp_level_opt = '-%d' % comp_level if comp_level is not None else '' + except TypeError as e: + raise GbpError("Invalid compression level '%s'" % comp_level) if comp_type: - pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--') + pipe.append('%s -c %s %s' % (comp_type, comp_level_opt, comp_opts), '--') ret = pipe.copy('', output) if ret: raise GbpError("Error creating %s: %d" % (output, ret)) |