aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp/config.py2
-rwxr-xr-xgbp/scripts/buildpackage.py12
-rw-r--r--gbp/scripts/buildpackage_rpm.py16
-rw-r--r--gbp/scripts/common/buildpackage.py14
-rw-r--r--tests/04_test_submodules.py6
-rw-r--r--tests/component/deb/test_buildpackage.py24
6 files changed, 53 insertions, 21 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 557e12c..433bd20 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -142,7 +142,7 @@ class GbpOptionParser(OptionParser):
'git-author': 'False',
'ignore-regex': '',
'compression': 'auto',
- 'compression-level': '9',
+ 'compression-level': '',
'remote-url-pattern': 'ssh://git.debian.org/git/collab-maint/%(pkg)s.git',
'multimaint': 'True',
'multimaint-merge': 'False',
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 04c5e93..8c5a8f9 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2006-2016 Guido Günther <agx@sigxcpu.org>
+# (C) 2006-2017 Guido Günther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -318,12 +318,14 @@ def git_archive_build_orig(repo, cp, output_dir, options):
gbp.log.info("Creating %s from '%s'" % (du.orig_file(cp,
options.comp_type),
upstream_tree))
- gbp.log.debug("Building upstream tarball with compression '%s -%s'" %
- (options.comp_type, options.comp_level))
+ comp_level = int(options.comp_level) if options.comp_level != '' else None
+ gbp.log.debug("Building upstream tarball with compression '%s'%s" %
+ (options.comp_type,
+ "' -%s'" % comp_level if comp_level is not None else ''))
main_tree = repo.tree_drop_dirs(upstream_tree, options.components)
if not git_archive(repo, cp, output_dir, main_tree,
options.comp_type,
- options.comp_level,
+ comp_level,
options.with_submodules):
raise GbpError("Cannot create upstream tarball at '%s'" % output_dir)
for component in options.components:
@@ -336,7 +338,7 @@ def git_archive_build_orig(repo, cp, output_dir, options):
subtree))
if not git_archive(repo, cp, output_dir, subtree,
options.comp_type,
- options.comp_level,
+ comp_level,
options.with_submodules,
component=component):
raise GbpError("Cannot create additional tarball %s at '%s'"
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py
index b34617d..889a863 100644
--- a/gbp/scripts/buildpackage_rpm.py
+++ b/gbp/scripts/buildpackage_rpm.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2006-2011,2015,2016 Guido Günther <agx@sigxcpu.org>
+# (C) 2006-2011,2015-2017 Guido Günther <agx@sigxcpu.org>
# (C) 2012-2015 Intel Corporation <markus.lehtonen@linux.intel.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -207,11 +207,13 @@ def git_archive_build_orig(repo, spec, output_dir, options):
gbp.log.info("%s does not exist, creating from '%s'" %
(spec.orig_src['filename'], upstream_tree))
if spec.orig_src['compression']:
+ comp_level = int(options.comp_level) if options.comp_level != '' else None
+ comp_level_msg = "' -%s'" % comp_level if comp_level is not None else ''
gbp.log.debug("Building upstream source archive with compression "
"'%s -%s'" % (spec.orig_src['compression'],
- options.comp_level))
+ comp_level_msg))
if not git_archive(repo, spec, output_dir, upstream_tree,
- orig_prefix, options.comp_level,
+ orig_prefix, comp_level,
options.with_submodules):
raise GbpError("Cannot create upstream tarball at '%s'" %
output_dir)
@@ -546,14 +548,16 @@ def main(argv):
# Just build source archive from the exported tree
gbp.log.info("Creating (native) source archive %s from '%s'"
% (spec.orig_src['filename'], tree))
+ comp_level = int(options.comp_level) if options.comp_level != '' else None
if spec.orig_src['compression']:
+ comp_level_msg = "' -%s'" % comp_level if comp_level is not None else ''
gbp.log.debug("Building source archive with "
- "compression '%s -%s'" %
+ "compression '%s%s'" %
(spec.orig_src['compression'],
- options.comp_level))
+ comp_level_msg))
orig_prefix = spec.orig_src['prefix']
if not git_archive(repo, spec, source_dir, tree,
- orig_prefix, options.comp_level,
+ orig_prefix, comp_level,
options.with_submodules):
raise GbpError("Cannot create source tarball at '%s'" %
source_dir)
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))
diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py
index 5cd8610..fcd00ba 100644
--- a/tests/04_test_submodules.py
+++ b/tests/04_test_submodules.py
@@ -127,11 +127,11 @@ def test_create_tarballs():
# Tarball with submodules
changelog = {"Source": "test", "Upstream-Version": "0.1"}
ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2",
- "9", True))
+ 9, True))
# Tarball without submodules
changelog = {"Source": "test", "Upstream-Version": "0.2"}
ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2",
- "9", False))
+ 9, False))
def test_create_zip_archives():
@@ -143,7 +143,7 @@ def test_create_zip_archives():
ok_('test/test_submodule/testfile' in contents)
git_archive_single('HEAD', 'without-submodules.zip', 'test',
- '', '', '', 'zip')
+ '', None, '', 'zip')
contents = ls_zip('without-submodules.zip')
ok_('test/test_submodule/testfile' not in contents)
diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py
index 2e4cef6..49db96d 100644
--- a/tests/component/deb/test_buildpackage.py
+++ b/tests/component/deb/test_buildpackage.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2015,2016 Guido Günther <agx@sigxcpu.org>
+# (C) 2015-2017 Guido Günther <agx@sigxcpu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
# <http://www.gnu.org/licenses/>
import os
+import subprocess
from tests.component import (ComponentTestBase,
ComponentTestGitRepository)
@@ -147,8 +148,7 @@ class TestBuildpackage(ComponentTestBase):
self._test_buildpackage('hello-debhelper',
'dsc-3.0',
'2.8-1',
- ['--git-export-dir=../foo/bar'],
- )
+ ['--git-export-dir=../foo/bar'])
ok_(os.path.exists('../foo/bar'))
def test_argument_quoting(self):
@@ -171,3 +171,21 @@ class TestBuildpackage(ComponentTestBase):
'--git-cleaner=/bin/true',
'../arg with spaces'])
ok_(ret == 0, "Building the package failed")
+
+ def test_tarball_default_compression(self):
+ """Test that we use defaults for compression if not given (#820846)"""
+ self._test_buildpackage('hello-debhelper',
+ 'dsc-3.0',
+ '2.8-1',
+ ['--git-no-pristine-tar'])
+ out = subprocess.check_output(["file", "../hello-debhelper_2.8.orig.tar.gz"])
+ ok_("max compression" not in out)
+
+ def test_tarball_max_compression(self):
+ """Test that passing max compression works (#820846)"""
+ self._test_buildpackage('hello-debhelper',
+ 'dsc-3.0',
+ '2.8-1',
+ ['--git-no-pristine-tar', '--git-compression-level=9'])
+ out = subprocess.check_output(["file", "../hello-debhelper_2.8.orig.tar.gz"])
+ ok_("max compression" in out)