From df8f0841f3a604f94a92b8ab16fffb836fcd370d Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Wed, 23 May 2012 18:22:16 +0200 Subject: [PATCH] Support bsdtar. --- patoolib/__init__.py | 8 ++++---- patoolib/programs/bsdcpio.py | 18 ++++++++++++++++++ patoolib/programs/cpio.py | 2 +- tests/test_archives.py | 11 +++++------ tests/test_foo_archives.py | 11 +++++------ 5 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 patoolib/programs/bsdcpio.py diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 1addcd5..d0ad39e 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -168,10 +168,10 @@ ArchivePrograms = { 'test': ('7z',), }, 'cpio': { - 'extract': ('cpio', '7z'), - 'list': ('cpio', '7z'), - 'test': ('7z',), - 'create': ('cpio',), + 'extract': ('cpio', 'bsdcpio', '7z'), + 'list': ('cpio', 'bsdcpio', '7z'), + 'test': ('cpio', 'bsdcpio', '7z',), + 'create': ('cpio', 'bsdcpio'), }, 'rpm': { 'extract': ('rpm2cpio', '7z'), diff --git a/patoolib/programs/bsdcpio.py b/patoolib/programs/bsdcpio.py new file mode 100644 index 0000000..bbca459 --- /dev/null +++ b/patoolib/programs/bsdcpio.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2012 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +"""Archive commands for the bsdcpio program.""" +from .cpio import extract_cpio, list_cpio, test_cpio, create_cpio + diff --git a/patoolib/programs/cpio.py b/patoolib/programs/cpio.py index 94708f9..382feef 100644 --- a/patoolib/programs/cpio.py +++ b/patoolib/programs/cpio.py @@ -22,7 +22,7 @@ def extract_cpio (archive, compression, cmd, **kwargs): """Extract a CPIO archive.""" cmdlist = [util.shell_quote(cmd), '--extract', '--make-directories', '--preserve-modification-time'] - if sys.platform != 'darwin': + if sys.platform.startswith('linux') and not cmd.endswith('bsdcpio'): cmdlist.extend(['--no-absolute-filenames', '--force-local', '--nonmatching', r'"*\.\.*"']) if kwargs['verbose']: diff --git a/tests/test_archives.py b/tests/test_archives.py index daac6d5..90fe6d6 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -314,13 +314,12 @@ class TestArchives (ArchiveTest): @needs_program('cpio') def test_cpio (self): self.program = 'cpio' - self.archive_list('t.cpio') - self.archive_extract('t.cpio') + self.archive_commands('t.cpio') - @needs_program('cpio') - @needs_program('7z') - def test_cpio_create (self): - self.archive_create('t.cpio') + @needs_program('bsdcpio') + def test_bsdcpio (self): + self.program = 'bsdcpio' + self.archive_commands('t.cpio') @needs_program('unace') def test_unace (self): diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index f280805..4a06f4b 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -346,14 +346,13 @@ class TestArchives (ArchiveTest): @needs_program('cpio') def test_cpio (self): self.program = 'cpio' - self.archive_list('t.cpio.foo') - self.archive_extract('t.cpio.foo') + self.archive_commands('t.cpio.foo', format="cpio") @needs_program('file') - @needs_program('cpio') - @needs_program('7z') - def test_cpio (self): - self.archive_create('t.cpio.foo', format="cpio") + @needs_program('bsdcpio') + def test_bsdcpio (self): + self.program = 'bsdcpio' + self.archive_commands('t.cpio.foo', format="cpio") @needs_program('file') @needs_program('unace')