From 7267bdee22ead7f3d34a0741d427426bd436b3a7 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Tue, 30 May 2006 13:37:14 +0000 Subject: [PATCH] Compression level for lzma. (#2832) --- pisi/archive.py | 8 +++++++- pisi/cli/commands.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pisi/archive.py b/pisi/archive.py index 47e1e996..d35b2830 100644 --- a/pisi/archive.py +++ b/pisi/archive.py @@ -143,7 +143,13 @@ class ArchiveTar(ArchiveBase): self.tar.close() if self.tar.mode == 'wb' and self.type == 'tarlzma': - ret, out, err = util.run_batch("lzma e -a2 -d26 -fb64 %s %s" % (self.file_path, self.file_path + '.lzma')) + batch = None + if ctx.get_option('compression_level'): + batch = "lzmash -k -%s %s" % (ctx.get_option('compression_level'), self.file_path) + else: + batch = "lzmash -k %s" % self.file_path + + ret, out, err = util.run_batch(batch) if ret != 0: raise LZMAError(err) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 3b6130fa..37ea46ee 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -401,7 +401,17 @@ unpack, setup, build, install, package self.init() if ctx.get_option('package_format') not in Build.package_formats: - raise Error(_('package_format must be one of %s ') % pisi.util.strlist(Build.package_formats)) + raise Error(_('package_format must be one of %s ') % pisi.util.strlist(Build.package_formats)) + + if ctx.get_option('compression_level'): + if ctx.get_option('package_format') != "1.1": + raise Error(_('compression level is for lzma compression')) + + try: + if int(ctx.get_option('compression_level')) not in range(1, 10): + raise Error(_('compression level must be between 1 and 9')) + except ValueError: + raise Error(_('compression level must be an integer')) if ctx.get_option('output_dir'): ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir)