diff --git a/DeComp/compress.py b/DeComp/compress.py index 6cb5421..f81f984 100644 --- a/DeComp/compress.py +++ b/DeComp/compress.py @@ -18,7 +18,7 @@ Maintained in full by: import os from DeComp.definitions import (DEFINITION_FIELDS, EXTENSION_SEPARATOR, - COMPRESSOR_PROGRAM_OPTIONS) + COMPRESSOR_PROGRAM_OPTIONS, DECOMPRESSOR_PROGRAM_OPTIONS) from DeComp import log from DeComp.utils import create_classes, subcmd, check_available @@ -33,7 +33,8 @@ class CompressMap(object): def __init__(self, definitions=None, env=None, default_mode=None, separator=EXTENSION_SEPARATOR, search_order=None, logger=None, - comp_prog=COMPRESSOR_PROGRAM_OPTIONS['linux']): + comp_prog=COMPRESSOR_PROGRAM_OPTIONS['linux'], + decomp_opt=DECOMPRESSOR_PROGRAM_OPTIONS['linux']): """Class init :param definitions: dictionary of @@ -78,6 +79,7 @@ class CompressMap(object): self.search_order = self.search_order.split() self.logger = logger or log self.comp_prog = comp_prog + self.decomp_opt = decomp_opt self.logger.info("COMPRESS: __init__(), search_order = %s", str(self.search_order)) # create the (de)compression definition namedtuple classes @@ -341,7 +343,8 @@ class CompressMap(object): 'mode': mode or self.mode, 'auto-ext': auto_extension, 'other_options': other_options, - 'comp_prog': self.comp_prog + 'comp_prog': self.comp_prog, + 'decomp_opt': self.decomp_opt } diff --git a/DeComp/contents.py b/DeComp/contents.py index ea33577..db5c9d6 100644 --- a/DeComp/contents.py +++ b/DeComp/contents.py @@ -19,7 +19,8 @@ import os from subprocess import Popen, PIPE from DeComp.definitions import (CONTENTS_SEARCH_ORDER, DEFINITION_FIELDS, - EXTENSION_SEPARATOR, COMPRESSOR_PROGRAM_OPTIONS) + EXTENSION_SEPARATOR, COMPRESSOR_PROGRAM_OPTIONS, + DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS) from DeComp import log from DeComp.utils import create_classes, check_available @@ -36,7 +37,9 @@ class ContentsMap(object): def __init__(self, definitions=None, env=None, default_mode=None, separator=EXTENSION_SEPARATOR, search_order=None, logger=None, - comp_prog=COMPRESSOR_PROGRAM_OPTIONS['linux']): + comp_prog=COMPRESSOR_PROGRAM_OPTIONS['linux'], + decomp_opt=DECOMPRESSOR_PROGRAM_OPTIONS['linux'], + list_xattrs_opt=LIST_XATTRS_OPTIONS['linux']): """Class init :param definitions: dictionary of @@ -66,6 +69,8 @@ class ContentsMap(object): self.search_order = self.search_order.split() self.logger = logger or log self.comp_prog = comp_prog + self.decomp_opt = decomp_opt + self.list_xattrs_opt = list_xattrs_opt self.logger.info("ContentsMap: __init__(), search_order = %s", str(self.search_order)) # create the contents definitions namedtuple classes @@ -155,11 +160,13 @@ class ContentsMap(object): :returns: string, list of the contents """ _cmd = [cmd] - _cmd.extend((' '.join(args) + _cmd.extend(('\t'.join(args) % {'source': source, "destination": destination, 'comp_prog': self.comp_prog, + 'decomp_opt': self.decomp_opt, + 'list_xattrs_opt': self.list_xattrs_opt, } - ).split() + ).split('\t') ) try: proc = Popen(_cmd, stdout=PIPE, stderr=PIPE) diff --git a/DeComp/definitions.py b/DeComp/definitions.py index 4f31829..4a3ce36 100644 --- a/DeComp/definitions.py +++ b/DeComp/definitions.py @@ -77,6 +77,14 @@ COMPRESSOR_PROGRAM_OPTIONS = {"linux": "-I", "bsd": "--use-compress-program", } +DECOMPRESSOR_PROGRAM_OPTIONS = {"linux": "", + "bsd": " -d", + } + +LIST_XATTRS_OPTIONS = {"linux": "--xattrs", + "bsd": "", + } + DEFAULT_TAR="linux-tar" COMPRESS_DEFINITIONS = { @@ -217,7 +225,7 @@ DECOMPRESS_DEFINITIONS = { "lbzip2": [ "_common", "tar", [ - "other_options", "%(comp_prog)s", "lbzip2", "-xpf", + "other_options", "%(comp_prog)s", '"lbzip2%(decomp_opt)s"', "-xpf", "%(source)s", "-C", "%(destination)s" ], "LBZIP2", ["tar.bz2", "bz2", "tbz2"], {"tar", "lbzip2"}, @@ -226,7 +234,7 @@ DECOMPRESS_DEFINITIONS = { "_common", "tar", [ "--xattrs", "--xattrs-include=security.capability", - "--xattrs-include=user.pax.flags", "%(comp_prog)s", "lbzip2", + "--xattrs-include=user.pax.flags", "%(comp_prog)s", '"lbzip2%(decomp_opt)s"', "-xpf", "%(source)s", "-C", "%(destination)s" ], "LBZIP2", ["tar.bz2", "bz2", "tbz2"], {"tar", "lbzip2"}, @@ -279,7 +287,7 @@ DECOMPRESS_DEFINITIONS = { "pixz": [ "_common", "tar", [ - "other_options", "%(comp_prog)s", "pixz", "-xpf", + "other_options", "%(comp_prog)s", '"pixz%(decomp_opt)s"', "-xpf", "%(source)s", "-C", "%(destination)s" ], "PIXZ", ["tar.xz", "xz"], {"tar", "pixz"}, @@ -288,7 +296,7 @@ DECOMPRESS_DEFINITIONS = { "_common", "tar", [ "--xattrs", "--xattrs-include=security.capability", - "--xattrs-include=user.pax.flags", "%(comp_prog)s", "pixz", "-xpf", + "--xattrs-include=user.pax.flags", "%(comp_prog)s", '"pixz%(decomp_opt)s"', "-xpf", "%(source)s", "-C", "%(destination)s" ], "PIXZ", ["tar.xz", "xz"], {"tar", "pixz"}, @@ -337,32 +345,32 @@ EXTENSION_SEPARATOR = '.' CONTENTS_DEFINITIONS = { "tar": [ "_common", "tar", - ["--xattrs", "-tvf", "%(source)s"], + ["%(list_xattrs_opt)s", "-tvf", "%(source)s"], "TAR", [".tar"], {"tar"}, ], "gzip": [ "_common", "tar", - ["--xattrs", "-tvzf", "%(source)s"], + ["%(list_xattrs_opt)s", "-tvzf", "%(source)s"], "GZIP", [".tgz", ".tar.gz", "gz"], {"tar"}, ], "lbzip2": [ "_common", "tar", - ["--xattrs", "%(comp_prog)s", "lbzip2", "-tvf", "%(source)s"], + ["%(list_xattrs_opt)s", "%(comp_prog)s", "lbzip2%(decomp_opt)s", "-tvf", "%(source)s"], "LBZIP2", [".tbz2", "bz2", ".tar.bz2"], {"tar", "lbzip2"}, ], "bzip2": [ "_common", "tar", - ["--xattrs", "-tvf", "%(source)s"], + ["%(list_xattrs_opt)s", "-tvf", "%(source)s"], "BZIP2", [".tbz2", "bz2", ".tar.bz2"], {"tar", "bzip2"}, ], "xz": [ "_common", "tar", - ["--xattrs", "-tvf", "%(source)s"], + ["%(list_xattrs_opt)s", "-tvf", "%(source)s"], "XZ", ["tar.xz", "xz"], {"tar"}, ], "pixz": [ "_common", "tar", - ["--xattrs", "%(comp_prog)s", "pixz", "-tvf", "%(source)s"], + ["%(list_xattrs_opt)s", "%(comp_prog)s", "pixz%(decomp_opt)s", "-tvf", "%(source)s"], "PIXZ", ["tar.xz", "xz"], {"tar", "pixz"}, ], "isoinfo_l": [