diff --git a/doc/changelog.txt b/doc/changelog.txt index aeac41a..2a67355 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -2,6 +2,8 @@ * Added support for ZPAQ archives. Closes: GH bug #14 +* Use options for maximum compression when creating archives + and the archive program has such options. 1.7 (released 27.6.2014) diff --git a/doc/patool.1 b/doc/patool.1 index bc3bcb2..9a5682e 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -1,5 +1,5 @@ .\" -*- nroff -*- -.\" Copyright (C) 2010-2014 Bastian Kleineidam +.\" Copyright (C) 2010-2015 Bastian Kleineidam .\" .\" 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 @@ -94,7 +94,8 @@ List files in archives. Create an archive from given files. All of the given files to add to the archive must be readable by the current user. The format of the archive to create is determined by the archive file -extension. +extension. If the archive program has options to maximize file compression, +\fBpatool\fP uses those options. .SS test \fBpatool\fP \fBtest\fP <\fIarchive\fP>... .PP @@ -137,4 +138,4 @@ When running under a Unix shell the following aliases can be defined to save som .SH AUTHOR Bastian Kleineidam .SH COPYRIGHT -Copyright \(co 2010-2014 Bastian Kleineidam +Copyright \(co 2010-2015 Bastian Kleineidam diff --git a/doc/patool.txt b/doc/patool.txt index 38dbd2a..44cdcb0 100644 --- a/doc/patool.txt +++ b/doc/patool.txt @@ -1,4 +1,4 @@ -PATOOL(1) PATOOL(1) +PATOOL(1) General Commands Manual PATOOL(1) @@ -91,10 +91,11 @@ COMMANDS create patool create ... - Create an archive from given files. All of the given files to - add to the archive must be readable by the current user. The - format of the archive to create is determined by the archive - file extension. + Create an archive from given files. All of the given files to + add to the archive must be readable by the current user. The + format of the archive to create is determined by the archive + file extension. If the archive program has options to maximize + file compression, patool uses those options. test patool test ... @@ -146,7 +147,7 @@ AUTHOR Bastian Kleineidam COPYRIGHT - Copyright © 2010-2014 Bastian Kleineidam + Copyright © 2010-2015 Bastian Kleineidam diff --git a/patoolib/programs/bzip2.py b/patoolib/programs/bzip2.py index 05a28f4..f228128 100644 --- a/patoolib/programs/bzip2.py +++ b/patoolib/programs/bzip2.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -25,7 +25,7 @@ def create_bzip2 (archive, compression, cmd, verbosity, filenames): cmdlist = [util.shell_quote(cmd)] if verbosity > 1: cmdlist.append('-v') - cmdlist.extend(['-c', '-z', '--']) + cmdlist.extend(['-c', '-z', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) diff --git a/patoolib/programs/clzip.py b/patoolib/programs/clzip.py index 8120f52..46795e9 100644 --- a/patoolib/programs/clzip.py +++ b/patoolib/programs/clzip.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2011-2012 Bastian Kleineidam +# Copyright (C) 2011-2015 Bastian Kleineidam # # 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 @@ -14,10 +14,19 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the clzip program.""" -from . import extract_singlefile_standard, \ - test_singlefile_standard, create_singlefile_standard +from . import extract_singlefile_standard, test_singlefile_standard +from .. import util extract_lzip = extract_singlefile_standard test_lzip = test_singlefile_standard -create_lzip = create_singlefile_standard + +def create_lzip(archive, compression, cmd, verbosity, filenames): + """Create an LZIP archive.""" + cmdlist = [util.shell_quote(cmd)] + if verbosity > 1: + cmdlist.append('-v') + cmdlist.extend(['-c', '-9', '--']) + cmdlist.extend([util.shell_quote(x) for x in filenames]) + cmdlist.extend(['>', util.shell_quote(archive)]) + return (cmdlist, {'shell': True}) diff --git a/patoolib/programs/flac.py b/patoolib/programs/flac.py index 378e9ce..1cd44d1 100644 --- a/patoolib/programs/flac.py +++ b/patoolib/programs/flac.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2012-2014 Bastian Kleineidam +# Copyright (C) 2012-2015 Bastian Kleineidam # # 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 @@ -25,7 +25,7 @@ def extract_flac (archive, compression, cmd, verbosity, outdir): def create_flac (archive, compression, cmd, verbosity, filenames): """Compress a WAV file to a FLAC archive.""" - cmdlist = [cmd, filenames[0], '--output-name', archive] + cmdlist = [cmd, filenames[0], '--best', '--output-name', archive] return cmdlist diff --git a/patoolib/programs/gzip.py b/patoolib/programs/gzip.py index 2e49ac0..fc909cb 100644 --- a/patoolib/programs/gzip.py +++ b/patoolib/programs/gzip.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -14,12 +14,23 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the gzip program.""" -from . import extract_singlefile_standard, \ - test_singlefile_standard, create_singlefile_standard +from . import extract_singlefile_standard, test_singlefile_standard +from .. import util extract_gzip = extract_compress = extract_singlefile_standard test_gzip = test_compress = test_singlefile_standard -create_gzip = create_singlefile_standard + + +def create_gzip(archive, compression, cmd, verbosity, filenames): + """Create a GZIP archive.""" + cmdlist = [util.shell_quote(cmd)] + if verbosity > 1: + cmdlist.append('-v') + cmdlist.extend(['-c', '-9', '--']) + cmdlist.extend([util.shell_quote(x) for x in filenames]) + cmdlist.extend(['>', util.shell_quote(archive)]) + return (cmdlist, {'shell': True}) + def list_gzip (archive, compression, cmd, verbosity): """List a GZIP archive.""" diff --git a/patoolib/programs/p7zip.py b/patoolib/programs/p7zip.py index 2707f4b..dfff888 100644 --- a/patoolib/programs/p7zip.py +++ b/patoolib/programs/p7zip.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -84,7 +84,7 @@ test_bzip2 = \ def create_7z (archive, compression, cmd, verbosity, filenames): """Create a 7z archive.""" - cmdlist = [cmd, 'a', '--', archive] + cmdlist = [cmd, 'a', '-mx=9', '--', archive] cmdlist.extend(filenames) return cmdlist diff --git a/patoolib/programs/py_lzma.py b/patoolib/programs/py_lzma.py index 7f709bd..fdf0045 100644 --- a/patoolib/programs/py_lzma.py +++ b/patoolib/programs/py_lzma.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2012-2014 Bastian Kleineidam +# Copyright (C) 2012-2015 Bastian Kleineidam # # 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 @@ -48,7 +48,7 @@ def _create(archive, compression, cmd, format, verbosity, filenames): if len(filenames) > 1: raise util.PatoolError('multi-file compression not supported in Python lzma') try: - with lzma.LZMAFile(archive, mode='wb', format=format) as lzmafile: + with lzma.LZMAFile(archive, mode='wb', format=format, preset=9) as lzmafile: filename = filenames[0] with open(filename, 'rb') as srcfile: data = srcfile.read(READ_SIZE_BYTES) diff --git a/patoolib/programs/rar.py b/patoolib/programs/rar.py index 0483520..d521981 100644 --- a/patoolib/programs/rar.py +++ b/patoolib/programs/rar.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -37,6 +37,6 @@ def test_rar (archive, compression, cmd, verbosity): def create_rar (archive, compression, cmd, verbosity, filenames): """Create a RAR archive.""" - cmdlist = [cmd, 'a', '-r', '--', archive] + cmdlist = [cmd, 'a', '-r', '-m5', '--', archive] cmdlist.extend(filenames) return cmdlist diff --git a/patoolib/programs/rzip.py b/patoolib/programs/rzip.py index 31b0549..3731a01 100644 --- a/patoolib/programs/rzip.py +++ b/patoolib/programs/rzip.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -27,7 +27,7 @@ def extract_rzip (archive, compression, cmd, verbosity, outdir): def create_rzip (archive, compression, cmd, verbosity, filenames): """Create an RZIP archive.""" - cmdlist = [cmd, '-k', '-o', archive] + cmdlist = [cmd, '-k', '-9', '-o', archive] if verbosity > 1: cmdlist.append('-v') cmdlist.extend(filenames) diff --git a/patoolib/programs/xz.py b/patoolib/programs/xz.py index 2e5be1f..6d5e677 100644 --- a/patoolib/programs/xz.py +++ b/patoolib/programs/xz.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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 @@ -14,14 +14,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the xz program.""" -from . import extract_singlefile_standard, \ - test_singlefile_standard, create_singlefile_standard +from . import extract_singlefile_standard, test_singlefile_standard from .. import util extract_xz = extract_singlefile_standard test_xz = test_singlefile_standard -create_xz = create_singlefile_standard def list_xz (archive, compression, cmd, verbosity): """List a XZ archive.""" @@ -33,6 +31,17 @@ def list_xz (archive, compression, cmd, verbosity): return cmdlist +def create_xz(archive, compression, cmd, verbosity, filenames): + """Create an XZ archive.""" + cmdlist = [util.shell_quote(cmd)] + if verbosity > 1: + cmdlist.append('-v') + cmdlist.extend(['-c', '-9', '--']) + cmdlist.extend([util.shell_quote(x) for x in filenames]) + cmdlist.extend(['>', util.shell_quote(archive)]) + return (cmdlist, {'shell': True}) + + def extract_lzma(archive, compression, cmd, verbosity, outdir): """Extract an LZMA archive.""" cmdlist = [util.shell_quote(cmd), '--format=lzma'] @@ -58,7 +67,7 @@ def create_lzma(archive, compression, cmd, verbosity, filenames): cmdlist = [util.shell_quote(cmd), '--format=lzma'] if verbosity > 1: cmdlist.append('-v') - cmdlist.extend(['-c', '--']) + cmdlist.extend(['-c', '-9', '--']) cmdlist.extend([util.shell_quote(x) for x in filenames]) cmdlist.extend(['>', util.shell_quote(archive)]) return (cmdlist, {'shell': True}) diff --git a/patoolib/programs/zip.py b/patoolib/programs/zip.py index 7ed0c07..a84a5ce 100644 --- a/patoolib/programs/zip.py +++ b/patoolib/programs/zip.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (C) 2010-2014 Bastian Kleineidam +# Copyright (C) 2010-2015 Bastian Kleineidam # # 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,7 +17,7 @@ def create_zip (archive, compression, cmd, verbosity, filenames): """Create a ZIP archive.""" - cmdlist = [cmd, '-r'] + cmdlist = [cmd, '-r', '-9'] if verbosity > 1: cmdlist.append('-v') cmdlist.append(archive)