[sysadmin-bin] py-install-module: add hack to check for valid tarball extension
- From: Olav Vitters <ovitters src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] py-install-module: add hack to check for valid tarball extension
- Date: Mon, 7 Mar 2011 00:42:54 +0000 (UTC)
commit 41600947906fe5c4d2359ba0e55bf5a533e48a6f
Author: Olav Vitters <olav vitters nl>
Date: Mon Mar 7 01:42:48 2011 +0100
py-install-module: add hack to check for valid tarball extension
py-install-module | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/py-install-module b/py-install-module
index f5cdf50..3bf1e9a 100755
--- a/py-install-module
+++ b/py-install-module
@@ -210,6 +210,10 @@ class BasicInfo(object):
# Note: this defines the formats install-module can read
# formats install-module creates is defined in
# ModuleInstall.INSTALL_FORMATS
+ #
+ # WARNING: When extending this, make sure tarfile.TarFile
+ # actually also supports the new compression!
+ # See e.g. XzTarFile class
FORMATS = {
'tar.gz': gzip.GzipFile,
'tar.bz2': bz2.BZ2File,
@@ -250,8 +254,6 @@ class TarInfo(BasicInfo):
errors = {}
files = self.files
- # XXX - this will automatically decompress bz2 and gz tarballs.. However,
- # xz is NOT handled. Should wrap this using self.FORMATS
t = None
try:
t = tarfile.open(self.path, 'r', errors=2)
@@ -296,6 +298,9 @@ class TarInfo(BasicInfo):
if test_eof_data > MAX_EXTRA_DATA:
errors['EXTRA_DATA'] = 'Tarball has too much extra data (expected max %s, found %s)' % (human_size(MAX_EXTRA_DATA), human_size(test_eof_data))
+ if not isinstance(t.fileobj, self.FORMATS.get(self.format, "")):
+ errors['WRONG_EXT'] = 'Compression used is different than what extension suggests'
+
self.size_files = size_files
self.file_count = file_count
self.tar_end_of_data_pos = tar_end_of_data_pos
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]