aboutsummaryrefslogtreecommitdiffhomepage
path: root/git-buildpackage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-12-24 00:55:10 +0100
committerGuido Günther <agx@sigxcpu.org>2009-12-24 01:18:36 +0100
commit0eb45804bb45511e5d61b274b55a76e52a41d601 (patch)
tree027a215a6c0b69b57facfa39d03fdb9335d5a38d /git-buildpackage
parentcf45595d9bea1ec95f25c33ce5b63d24235ad7f5 (diff)
Allow to set compression type
Closes: #554520
Diffstat (limited to 'git-buildpackage')
-rwxr-xr-xgit-buildpackage47
1 files changed, 32 insertions, 15 deletions
diff --git a/git-buildpackage b/git-buildpackage
index 839af90f..7f2b2d40 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -56,14 +56,19 @@ def git_archive_pipe(prefix, pipe, output, treeish):
return True
-def git_archive(cp, output_dir, treeish):
- "create an orig.tar.gz in output_dir using git_archive"
- output = os.path.join(output_dir, du.orig_file(cp))
+def git_archive(cp, output_dir, treeish, comp_type, comp_level):
+ "create a compressed orig tarball in output_dir using git_archive"
+
+ try:
+ comp_opts = du.compressor_opts[comp_type][0]
+ except KeyError:
+ raise GbpError, "Unsupported compression type '%s'" % comp_type
+
+ output = os.path.join(output_dir, du.orig_file(cp, comp_type))
prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])
- gzip_opts = "-9 -n"
pipe = pipes.Template()
- pipe.append('gzip -c %s' % gzip_opts, '--')
+ pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--')
return git_archive_pipe(prefix, pipe, output, treeish)
@@ -107,7 +112,7 @@ def pristine_tar_build_orig(repo, cp, output_dir, options):
pt = PristineTar()
if not repo.has_branch(pt.branch):
print >>sys.stderr, 'Pristine-tar branch "%s" not found' % pt.branch
- pt.checkout(os.path.join(output_dir, du.orig_file(cp)))
+ pt.checkout(os.path.join(output_dir, du.orig_file(cp, options.comp_type)))
return True
else:
return False
@@ -123,10 +128,16 @@ def git_archive_build_orig(repo, cp, output_dir, options):
# fall back to the upstream-branch tip if the tag doesn't exist
if not repo.has_treeish(upstream_tree):
upstream_tree = GbpOptionParser.defaults['upstream-branch']
- print "%s does not exist, creating from '%s'" % (du.orig_file(cp), upstream_tree)
+ print "%s does not exist, creating from '%s'" % (du.orig_file(cp,
+ options.comp_type),
+ upstream_tree)
if not repo.has_treeish(upstream_tree):
raise GbpError # git-ls-tree printed an error message already
- if not git_archive(cp, output_dir, upstream_tree):
+ if options.verbose:
+ print "Building upstream tarball with compression '%s -%s'" % (options.comp_type,
+ options.comp_level)
+ if not git_archive(cp, output_dir, upstream_tree,
+ options.comp_type, options.comp_level):
raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
@@ -171,6 +182,7 @@ def main(argv):
args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0 ]
dpkg_args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1 ]
+ # We handle these although they don't have a --git- prefix
for arg in [ "--help", "-h", "--version" ]:
if arg in dpkg_args:
args.append(arg)
@@ -210,6 +222,10 @@ def main(argv):
help="don't create orig.tar.gz", action="store_true")
orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir",
help="location to look for external tarballs")
+ orig_group.add_config_file_option(option_name="compression", dest="comp_type",
+ help="Compression type, default is '%(compression)s'")
+ orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
+ help="Compression level, default is '%(compression-level)s'")
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
cmd_group.add_config_file_option(option_name="builder", dest="builder",
@@ -278,7 +294,6 @@ def main(argv):
raise GbpError, "Can't parse version from changelog"
if not options.tag_only:
-
output_dir = prepare_output_dir(options.export_dir)
if options.tarball_dir:
tarball_dir = options.tarball_dir
@@ -287,15 +302,17 @@ def main(argv):
# Get/build the orig.tar.gz if necessary:
if not du.is_native(cp):
+ orig_file = du.orig_file(cp, options.comp_type)
+
# look in tarball_dir first, if found force a symlink to it
if options.tarball_dir:
- print "Looking for orig tarball '%s' at '%s'" % (du.orig_file(cp), tarball_dir)
- if not du.symlink_orig(cp, tarball_dir, output_dir, force=True):
- print "Orig tarball '%s' not found at '%s'" % (du.orig_file(cp), tarball_dir)
+ print "Looking for orig tarball '%s' at '%s'" % (orig_file, tarball_dir)
+ if not du.symlink_orig(cp, options.comp_type, tarball_dir, output_dir, force=True):
+ print "Orig tarball '%s' not found at '%s'" % (orig_file, tarball_dir)
else:
- print "Orig tarball '%s' found at '%s'" % (du.orig_file(cp), tarball_dir)
+ print "Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir)
# build an orig unless the user forbidds it
- if not options.no_create_orig and not du.has_orig(cp, output_dir):
+ if not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir):
if not pristine_tar_build_orig(repo, cp, output_dir, options):
git_archive_build_orig(repo, cp, output_dir, options)
@@ -316,7 +333,7 @@ def main(argv):
if options.overlay:
if du.is_native(cp):
raise GbpError, "Cannot overlay Debian native package"
- extract_orig(os.path.join(output_dir, du.orig_file(cp)) , tmp_dir)
+ extract_orig(os.path.join(output_dir, du.orig_file(cp, options.comp_type)), tmp_dir)
print "Exporting '%s' to '%s'" % (options.export, tmp_dir)
dump_tree(tmp_dir, tree)