Add 'format' option to extract installer task

This commit is contained in:
Mathieu Comandon 2014-02-09 12:25:39 +01:00
parent f79a8c1e9b
commit 6affb64150
2 changed files with 11 additions and 7 deletions

View file

@ -449,6 +449,8 @@ class ScriptInterpreter(object):
exec_id = data
args = []
exec_path = self._get_file(exec_id)
if not exec_path:
raise ScriptingError("Unable to find file %s" % exec_id, exec_id)
if not os.path.exists(exec_path):
raise ScriptingError("Unable to find required executable",
exec_path)
@ -535,8 +537,9 @@ class ScriptInterpreter(object):
logger.debug(msg)
self.parent.set_status(msg)
merge_single = not 'nomerge' in data
extractor = data.get('format')
logger.debug("extracting file %s to %s", filename, dest_path)
extract.extract_archive(filename, dest_path, merge_single)
extract.extract_archive(filename, dest_path, merge_single, extractor)
def _append_steam_data_to_files(self, runner_class):
steam_runner = runner_class()

View file

@ -8,18 +8,19 @@ from lutris.util.system import merge_folders
from lutris.util.log import logger
def extract_archive(path, to_directory='.', merge_single=True):
def extract_archive(path, to_directory='.', merge_single=True, extractor=None):
path = os.path.abspath(path)
logger.debug("Extracting %s to %s", path, to_directory)
if path.endswith('.zip'):
if path.endswith('.zip') or extractor == 'zip':
opener, mode = zipfile.ZipFile, 'r'
elif path.endswith('.tar.gz') or path.endswith('.tgz'):
elif path.endswith('.tar.gz') or path.endswith('.tgz') \
or extractor == 'tgz':
opener, mode = tarfile.open, 'r:gz'
elif path.endswith('.gz'):
elif path.endswith('.gz') or extractor == 'gzip':
decompress_gz(path, to_directory)
return
elif path.endswith('.tar.bz2') or path.endswith('.tbz'):
elif path.endswith('.tar.bz2') or path.endswith('.tbz') \
or extractor == 'bz2':
opener, mode = tarfile.open, 'r:bz2'
else:
raise RuntimeError(