mirror of
https://github.com/lutris/lutris
synced 2024-09-19 15:52:08 +00:00
Add support for deb files, add a better sort for Humble Bundle
This commit is contained in:
parent
c53b5bd91c
commit
1cd0efc17b
|
@ -307,20 +307,27 @@ def pick_download_url_from_download_info(download_info):
|
|||
if not download_info["download_struct"]:
|
||||
logger.warning("No downloads found")
|
||||
return
|
||||
if system.LINUX_SYSTEM.is_64_bit:
|
||||
bad_arch = "32"
|
||||
else:
|
||||
bad_arch = "64"
|
||||
if len(download_info["download_struct"]) > 1:
|
||||
logger.info("There are %s downloads available:", len(download_info["download_struct"]))
|
||||
sorted_downloads = []
|
||||
for _download in download_info["download_struct"]:
|
||||
if "deb" in _download["name"] or "rpm" in _download["name"] or bad_arch in _download["name"]:
|
||||
sorted_downloads.append(_download)
|
||||
else:
|
||||
sorted_downloads.insert(0, _download)
|
||||
return sorted_downloads[0]["url"]["web"]
|
||||
return download_info["download_struct"][0]["url"]["web"]
|
||||
|
||||
def humble_sort(download):
|
||||
name = download["name"]
|
||||
if "rpm" in name:
|
||||
return -99 # Not supported as an extractor
|
||||
bonus = 1
|
||||
if "deb" not in name:
|
||||
bonus = 2
|
||||
if system.LINUX_SYSTEM.is_64_bit:
|
||||
if "386" in name or "32" in name:
|
||||
return -1 * bonus
|
||||
else:
|
||||
if "64" in name:
|
||||
return -10 * bonus
|
||||
return 1 * bonus
|
||||
|
||||
sorted_downloads = sorted(download_info["download_struct"], key=humble_sort, reverse=True)
|
||||
logger.debug("Humble bundle installers:")
|
||||
for download in sorted_downloads:
|
||||
logger.debug(download["name"])
|
||||
return sorted_downloads[0]["url"]["web"]
|
||||
|
||||
|
||||
def get_humble_download_link(humbleid, runner):
|
||||
|
|
|
@ -86,6 +86,8 @@ def guess_extractor(path):
|
|||
extractor = "gzip"
|
||||
elif path.endswith(".exe"):
|
||||
extractor = "exe"
|
||||
elif path.endswith(".deb"):
|
||||
extractor = "deb"
|
||||
elif is_7zip_supported(path, None):
|
||||
extractor = None
|
||||
else:
|
||||
|
@ -110,6 +112,8 @@ def get_archive_opener(extractor, path):
|
|||
opener = "innoextract"
|
||||
elif extractor == "exe":
|
||||
opener = "exe"
|
||||
elif extractor == "deb":
|
||||
opener = "deb"
|
||||
elif extractor is None or is_7zip_supported(path, extractor):
|
||||
opener = "7zip"
|
||||
else:
|
||||
|
@ -185,6 +189,8 @@ def _do_extract(archive, dest, opener, mode=None, extractor=None):
|
|||
extract_exe(archive, dest)
|
||||
elif opener == "innoextract":
|
||||
extract_gog(archive, dest)
|
||||
elif opener == "deb":
|
||||
extract_deb(archive, dest)
|
||||
else:
|
||||
handler = opener(archive, mode)
|
||||
handler.extractall(dest)
|
||||
|
@ -209,6 +215,19 @@ def extract_exe(path, dest):
|
|||
raise RuntimeError("specified exe is not an archive or GOG setup file")
|
||||
|
||||
|
||||
def extract_deb(archive, dest):
|
||||
"""Extract the contents of a deb file to a destination folder"""
|
||||
extract_7zip(archive, dest, archive_type="ar")
|
||||
debian_folder = os.path.join(dest, "debian")
|
||||
os.makedirs(debian_folder)
|
||||
shutil.move(os.path.join(dest, "control.tar.gz"), debian_folder)
|
||||
data_file = os.path.join(dest, "data.tar.gz")
|
||||
handler = tarfile.open(data_file, "r:gz")
|
||||
handler.extractall(dest)
|
||||
handler.close()
|
||||
os.remove(data_file)
|
||||
|
||||
|
||||
def extract_gog(path, dest):
|
||||
if check_inno_exe(path):
|
||||
decompress_gog(path, dest)
|
||||
|
|
Loading…
Reference in a new issue