diff options
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/config.py | 2 | ||||
-rw-r--r-- | gbp/deb.py | 23 |
2 files changed, 17 insertions, 8 deletions
diff --git a/gbp/config.py b/gbp/config.py index fee3665b..b72b1296 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -53,6 +53,8 @@ class GbpOptionParser(OptionParser): 'id-length' : '0', 'git-author' : 'False', 'ignore-regex' : '', + 'compression' : 'gzip', + 'compression-level': '9', } help = { 'debian-branch': @@ -18,6 +18,12 @@ from errors import GbpError # the valid characters. debian_version_chars = 'a-zA-Z\d.~+-' +# compression types, extra options and extensions +compressor_opts = { 'gzip' : [ '-n', 'gz' ], + 'bzip2' : [ '', 'bz2' ], + 'lzma' : [ '', 'lzma' ], + 'xz' : [ '', 'xz' ] } + class NoChangelogError(Exception): """no changelog found""" pass @@ -140,11 +146,12 @@ def parse_changelog(changelog): except TypeError: raise ParseChangeLogError, output.split('\n')[0] return cp - -def orig_file(cp): + +def orig_file(cp, compression): "The name of the orig.tar.gz belonging to changelog cp" - return "%s_%s.orig.tar.gz" % (cp['Source'], cp['Upstream-Version']) + ext = compressor_opts[compression][1] + return "%s_%s.orig.tar.%s" % (cp['Source'], cp['Upstream-Version'], ext) def is_native(cp): @@ -160,15 +167,15 @@ def has_epoch(cp): except KeyError: return False -def has_orig(cp, dir): +def has_orig(cp, compression, dir): "Check if orig.tar.gz exists in dir" try: - os.stat( os.path.join(dir, orig_file(cp)) ) + os.stat( os.path.join(dir, orig_file(cp, compression)) ) except OSError: return False return True -def symlink_orig(cp, orig_dir, output_dir, force=False): +def symlink_orig(cp, compression, orig_dir, output_dir, force=False): """ symlink orig.tar.gz from orig_dir to output_dir @return: True if link was created or src == dst @@ -180,8 +187,8 @@ def symlink_orig(cp, orig_dir, output_dir, force=False): if orig_dir == output_dir: return True - src = os.path.join(orig_dir, orig_file(cp)) - dst = os.path.join(output_dir, orig_file(cp)) + src = os.path.join(orig_dir, orig_file(cp, compression)) + dst = os.path.join(output_dir, orig_file(cp, compression)) if not os.access(src, os.F_OK): return False try: |