Added support for AR (.a) archives.
This commit is contained in:
parent
9a04371f07
commit
6cba779475
|
@ -7,6 +7,7 @@
|
||||||
* Fix permissions of extracted files: make them readable by the
|
* Fix permissions of extracted files: make them readable by the
|
||||||
current user.
|
current user.
|
||||||
* Added support for ACE (.ace) archives.
|
* Added support for ACE (.ace) archives.
|
||||||
|
* Added support for AR (.a) archives.
|
||||||
|
|
||||||
0.5 "Vanishing Point" (released 4.3.2010)
|
0.5 "Vanishing Point" (released 4.3.2010)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ files without having to remember a myriad of programs and options.
|
||||||
The archive format is determined by the file(1) program and as a fallback
|
The archive format is determined by the file(1) program and as a fallback
|
||||||
by the archive file extension.
|
by the archive file extension.
|
||||||
.PP
|
.PP
|
||||||
\fBpatool\fP supports 7z (.7z), ACE (.ace), ZIP (.zip, .jar), GZIP (.gz), compress (.Z),
|
\fBpatool\fP supports 7z (.7z), ACE (.ace), AR (.a), ZIP (.zip, .jar), GZIP (.gz), compress (.Z),
|
||||||
BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO (.cpio),
|
BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO (.cpio),
|
||||||
RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma), RAR (.rar)
|
RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma), RAR (.rar)
|
||||||
and XZ (.xz) formats.
|
and XZ (.xz) formats.
|
||||||
|
|
|
@ -18,11 +18,12 @@ DESCRIPTION
|
||||||
The archive format is determined by the file(1) program and as a fall‐
|
The archive format is determined by the file(1) program and as a fall‐
|
||||||
back by the archive file extension.
|
back by the archive file extension.
|
||||||
|
|
||||||
patool supports 7z (.7z), ACE (.ace), ZIP (.zip, .jar), GZIP (.gz),
|
patool supports 7z (.7z), ACE (.ace), AR (.a), ZIP (.zip, .jar), GZIP
|
||||||
compress (.Z), BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO
|
(.gz), compress (.Z), BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab),
|
||||||
(.cpio), RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA (.lzma),
|
CPIO (.cpio), RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA
|
||||||
RAR (.rar) and XZ (.xz) formats. It relies on helper applications to
|
(.lzma), RAR (.rar) and XZ (.xz) formats. It relies on helper applica‐
|
||||||
handle those archive formats (for example bzip2 for BZIP2 archives).
|
tions to handle those archive formats (for example bzip2 for BZIP2 ar‐
|
||||||
|
chives).
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
patool extract archive.zip otherarchive.rar
|
patool extract archive.zip otherarchive.rar
|
||||||
|
@ -34,19 +35,19 @@ COMMANDS
|
||||||
Several commands and options are available.
|
Several commands and options are available.
|
||||||
|
|
||||||
extract
|
extract
|
||||||
Extract files from an archive. This is the default command if no com‐
|
Extract files from an archive. This is the default command if no com‐
|
||||||
mand was given.
|
mand was given.
|
||||||
Often one wants to extract all files in an archive to a single subdi‐
|
Often one wants to extract all files in an archive to a single subdi‐
|
||||||
rectory. However, some archives contain multiple files in their root
|
rectory. However, some archives contain multiple files in their root
|
||||||
directories. The patool program overcomes this problem by first
|
directories. The patool program overcomes this problem by first
|
||||||
extracting files to a unique (temporary) directory, and then moving its
|
extracting files to a unique (temporary) directory, and then moving its
|
||||||
contents back if possible. This also prevents local files from being
|
contents back if possible. This also prevents local files from being
|
||||||
overwritten by mistake.
|
overwritten by mistake.
|
||||||
All extracted files are checked that they are readable by the current
|
All extracted files are checked that they are readable by the current
|
||||||
user.
|
user.
|
||||||
|
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
Be verbose when extracting (if the helper application supports
|
Be verbose when extracting (if the helper application supports
|
||||||
it).
|
it).
|
||||||
|
|
||||||
--help Show help for this command.
|
--help Show help for this command.
|
||||||
|
@ -60,7 +61,7 @@ COMMANDS
|
||||||
--help Show help for this command.
|
--help Show help for this command.
|
||||||
|
|
||||||
create
|
create
|
||||||
Create an archive from given files. At least on of the given files to
|
Create an archive from given files. At least on of the given files to
|
||||||
add to the archive has to exist.
|
add to the archive has to exist.
|
||||||
|
|
||||||
-v, --verbose
|
-v, --verbose
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
- Support ar archives.
|
|
||||||
- Support lha archives.
|
- Support lha archives.
|
||||||
|
|
|
@ -23,7 +23,8 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
|
||||||
|
|
||||||
# Supported archive formats
|
# Supported archive formats
|
||||||
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
|
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
|
||||||
'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip', 'ace')
|
'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip', 'ace',
|
||||||
|
'ar')
|
||||||
|
|
||||||
# Supported encodings (used with tar for example)
|
# Supported encodings (used with tar for example)
|
||||||
# Note that all encodings must also be archive formats
|
# Note that all encodings must also be archive formats
|
||||||
|
@ -52,6 +53,7 @@ ArchiveMimetypes = {
|
||||||
'application/x-xz': 'xz',
|
'application/x-xz': 'xz',
|
||||||
'application/x-lzip': 'lzip',
|
'application/x-lzip': 'lzip',
|
||||||
'application/x-ace': 'ace',
|
'application/x-ace': 'ace',
|
||||||
|
'application/x-archive': 'ar',
|
||||||
}
|
}
|
||||||
|
|
||||||
# List of programs supporting the given encoding
|
# List of programs supporting the given encoding
|
||||||
|
@ -73,6 +75,9 @@ ArchivePrograms = {
|
||||||
'test': ('unace',),
|
'test': ('unace',),
|
||||||
'list': ('unace',),
|
'list': ('unace',),
|
||||||
},
|
},
|
||||||
|
'ar': {
|
||||||
|
None: ('ar',),
|
||||||
|
},
|
||||||
'bzip2': {
|
'bzip2': {
|
||||||
'extract': ('pbzip2', 'bzip2', '7z'),
|
'extract': ('pbzip2', 'bzip2', '7z'),
|
||||||
'test': ('pbzip2', 'bzip2', '7z'),
|
'test': ('pbzip2', 'bzip2', '7z'),
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2010 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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""Archive commands for the ar program."""
|
||||||
|
|
||||||
|
def extract_ar (archive, encoding, cmd, **kwargs):
|
||||||
|
"""Extract a AR archive."""
|
||||||
|
cmdlist = [cmd]
|
||||||
|
opts = 'x'
|
||||||
|
if kwargs['verbose']:
|
||||||
|
opts += 'v'
|
||||||
|
cmdlist.extend([opts, archive, kwargs['outdir']])
|
||||||
|
return cmdlist
|
||||||
|
|
||||||
|
def list_ar (archive, encoding, cmd, **kwargs):
|
||||||
|
"""List a AR archive."""
|
||||||
|
cmdlist = [cmd]
|
||||||
|
opts = 't'
|
||||||
|
if kwargs['verbose']:
|
||||||
|
opts += 'v'
|
||||||
|
cmdlist.extend([opts, archive])
|
||||||
|
return cmdlist
|
||||||
|
|
||||||
|
test_ar = list_ar
|
||||||
|
|
||||||
|
def create_ar (archive, encoding, cmd, *args, **kwargs):
|
||||||
|
"""Create a AR archive."""
|
||||||
|
cmdlist = [cmd]
|
||||||
|
opts = 'rc'
|
||||||
|
if kwargs['verbose']:
|
||||||
|
opts += 'v'
|
||||||
|
cmdlist.extend([opts, archive])
|
||||||
|
cmdlist.extend(args)
|
||||||
|
return cmdlist
|
||||||
|
|
|
@ -40,6 +40,8 @@ mimedb.add_type('application/x-cab', '.cab', strict=False)
|
||||||
mimedb.add_type('application/x-rpm', '.rpm', strict=False)
|
mimedb.add_type('application/x-rpm', '.rpm', strict=False)
|
||||||
mimedb.add_type('application/x-debian-package', '.deb', strict=False)
|
mimedb.add_type('application/x-debian-package', '.deb', strict=False)
|
||||||
mimedb.add_type('application/x-ace', '.ace', strict=False)
|
mimedb.add_type('application/x-ace', '.ace', strict=False)
|
||||||
|
# Since .a is already a common type, strict=True must be used.
|
||||||
|
mimedb.add_type('application/x-archive', '.a', strict=True)
|
||||||
|
|
||||||
|
|
||||||
class PatoolError (StandardError):
|
class PatoolError (StandardError):
|
||||||
|
@ -190,6 +192,7 @@ FileText2Mime = {
|
||||||
"Zip archive data": "application/zip",
|
"Zip archive data": "application/zip",
|
||||||
"compress'd data": "application/x-compress",
|
"compress'd data": "application/x-compress",
|
||||||
"lzip compressed data": "application/x-lzip",
|
"lzip compressed data": "application/x-lzip",
|
||||||
|
"current ar archive": "application/x-archive",
|
||||||
}
|
}
|
||||||
|
|
||||||
def guess_mime_file (file_prog, filename):
|
def guess_mime_file (file_prog, filename):
|
||||||
|
|
|
@ -76,7 +76,7 @@ class ArchiveTest (unittest.TestCase):
|
||||||
kwargs = dict(
|
kwargs = dict(
|
||||||
program=self.program,
|
program=self.program,
|
||||||
format=format,
|
format=format,
|
||||||
encoding=encoding
|
encoding=encoding,
|
||||||
)
|
)
|
||||||
self._archive_create(filename, topack, kwargs)
|
self._archive_create(filename, topack, kwargs)
|
||||||
kwargs['verbose'] = True
|
kwargs['verbose'] = True
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
!<arch>
|
||||||
|
t.txt/ 1266562138 1000 1000 100640 3 `
|
||||||
|
42
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
!<arch>
|
||||||
|
t.txt/ 1266562138 1000 1000 100640 3 `
|
||||||
|
42
|
||||||
|
|
|
@ -212,6 +212,11 @@ class TestArchives (ArchiveTest):
|
||||||
self.program = 'arj'
|
self.program = 'arj'
|
||||||
self.archive_commands('t.arj')
|
self.archive_commands('t.arj')
|
||||||
|
|
||||||
|
@needs_program('ar')
|
||||||
|
def test_ar (self):
|
||||||
|
self.program = 'ar'
|
||||||
|
self.archive_commands('t.a', singlefile=True)
|
||||||
|
|
||||||
@needs_program('cpio')
|
@needs_program('cpio')
|
||||||
def test_cpio (self):
|
def test_cpio (self):
|
||||||
self.program = 'cpio'
|
self.program = 'cpio'
|
||||||
|
|
|
@ -243,6 +243,12 @@ class TestArchives (ArchiveTest):
|
||||||
self.program = 'arj'
|
self.program = 'arj'
|
||||||
self.archive_commands('t.arj.foo', format="arj")
|
self.archive_commands('t.arj.foo', format="arj")
|
||||||
|
|
||||||
|
@needs_program('file')
|
||||||
|
@needs_program('ar')
|
||||||
|
def test_ar (self):
|
||||||
|
self.program = 'ar'
|
||||||
|
self.archive_commands('t.a.foo', format='ar', singlefile=True)
|
||||||
|
|
||||||
@needs_program('file')
|
@needs_program('file')
|
||||||
@needs_program('cpio')
|
@needs_program('cpio')
|
||||||
def test_cpio (self):
|
def test_cpio (self):
|
||||||
|
|
|
@ -88,3 +88,5 @@ class TestMime (unittest.TestCase):
|
||||||
self.mime_test("t.zip.foo", "application/zip", None)
|
self.mime_test("t.zip.foo", "application/zip", None)
|
||||||
self.mime_test("t.ace", "application/x-ace", None)
|
self.mime_test("t.ace", "application/x-ace", None)
|
||||||
self.mime_test("t.ace.foo", "application/x-ace", None)
|
self.mime_test("t.ace.foo", "application/x-ace", None)
|
||||||
|
self.mime_test("t.a", "application/x-archive", None)
|
||||||
|
self.mime_test("t.a.foo", "application/x-archive", None)
|
||||||
|
|
Loading…
Reference in New Issue