Example #1
0
def update_runtime():
    remote_version = get_remote_version()
    local_version = get_local_version()
    if remote_version <= local_version:
        return
    runtime32_file = "lutris-runtime-i386.tar.gz"
    runtime64_file = "lutris-runtime-amd64.tar.gz"

    runtime32_path = os.path.join(settings.RUNTIME_DIR, runtime32_file)
    http.download_asset(settings.RUNTIME_URL + runtime32_file,
                        runtime32_path,
                        overwrite=True)
    runtime64_path = os.path.join(settings.RUNTIME_DIR, runtime64_file)
    http.download_asset(settings.RUNTIME_URL + runtime64_file,
                        runtime64_path,
                        overwrite=True)
    extract.extract_archive(runtime32_path,
                            settings.RUNTIME_DIR,
                            merge_single=False)
    extract.extract_archive(runtime64_path,
                            settings.RUNTIME_DIR,
                            merge_single=False)
    os.unlink(runtime32_path)
    os.unlink(runtime64_path)

    with open(LOCAL_VERSION_PATH, 'w') as version_file:
        version_file.write(str(remote_version))
Example #2
0
def update_runtime(set_status):
    logger.debug("Updating runtime")
    remote_version = get_remote_version()
    local_version = get_local_version()
    if remote_version <= local_version:
        logger.debug("Runtime already up to date")
        return
    runtime32_file = "lutris-runtime-i386.tar.gz"
    runtime64_file = "lutris-runtime-amd64.tar.gz"

    set_status("Updating Runtime")
    runtime32_path = os.path.join(settings.RUNTIME_DIR, runtime32_file)
    http.download_asset(settings.RUNTIME_URL + runtime32_file, runtime32_path,
                        overwrite=True)
    runtime64_path = os.path.join(settings.RUNTIME_DIR, runtime64_file)
    http.download_asset(settings.RUNTIME_URL + runtime64_file, runtime64_path,
                        overwrite=True)
    system.remove_folder(os.path.join(settings.RUNTIME_DIR, 'lib32'))
    system.remove_folder(os.path.join(settings.RUNTIME_DIR, 'lib64'))
    extract.extract_archive(runtime32_path, settings.RUNTIME_DIR,
                            merge_single=False)
    extract.extract_archive(runtime64_path, settings.RUNTIME_DIR,
                            merge_single=False)
    os.unlink(runtime32_path)
    os.unlink(runtime64_path)

    with open(LOCAL_VERSION_PATH, 'w') as version_file:
        version_file.write(str(remote_version))
    set_status("Runtime updated")
    logger.debug("Runtime updated")
Example #3
0
    def install(self):
        """ Install snes9x from lutris.net """
        logger.debug("Installing snes9x")
        tarball_url = SNES9X_64 if self.arch == 'x64' else SNES9X_32
        tarball_file = os.path.basename(tarball_url)
        dest = os.path.join(settings.TMP_PATH, tarball_file)
        logger.debug("Downloading %s" % tarball_url)
        urllib.urlretrieve(tarball_url, dest)

        logger.debug("Extracting %s" % dest)
        extract_archive(dest, SNES9X_DIR)

        lib_dir = os.path.join(SNES9X_DIR, "lib")
        os.mkdir(lib_dir)

        libpng_url = LIBPNG_64 if self.arch == 'x64' else LIBPNG_32
        libpng_file = os.path.basename(libpng_url)
        lib_abspath = os.path.join(lib_dir, libpng_file)
        logger.debug("Downloading %s" % libpng_url)
        urllib.urlretrieve(libpng_url, lib_abspath)
        logger.debug("Extracting %s" % lib_abspath)
        decompress_gz(lib_abspath)
        logger.debug("Creating lib symlinks")
        os.link(lib_abspath[:-3], lib_abspath[:-5])
        os.link(lib_abspath[:-3], lib_abspath[:-8])
Example #4
0
    def extract(self,
                archive=None,
                dest=None,
                merge_single=None,
                callback=None):
        if not system.path_exists(archive):
            raise RunnerInstallationError(
                "Failed to extract {}".format(archive))
        try:
            extract_archive(archive, dest, merge_single=merge_single)
        except ExtractFailure as ex:
            logger.error(
                "Failed to extract the archive %s file may be corrupt",
                archive)
            raise RunnerInstallationError("Failed to extract {}: {}".format(
                archive, ex))
        os.remove(archive)

        if self.name == "wine":
            logger.debug("Clearing wine version cache")
            from lutris.util.wine.wine import get_wine_versions
            get_wine_versions.cache_clear()

        if callback:
            callback()
Example #5
0
    def install(self):
        """ Install snes9x from lutris.net """
        logger.debug("Installing snes9x")
        tarball_url = SNES9X_64 if self.arch == 'x64' else SNES9X_32
        tarball_file = os.path.basename(tarball_url)
        dest = os.path.join(settings.TMP_PATH, tarball_file)
        logger.debug("Downloading %s" % tarball_url)
        urllib.urlretrieve(tarball_url, dest)

        logger.debug("Extracting %s" % dest)
        extract_archive(dest, SNES9X_DIR)

        lib_dir = os.path.join(SNES9X_DIR, "lib")
        os.mkdir(lib_dir)

        libpng_url = LIBPNG_64 if self.arch == 'x64' else LIBPNG_32
        libpng_file = os.path.basename(libpng_url)
        lib_abspath = os.path.join(lib_dir, libpng_file)
        logger.debug("Downloading %s" % libpng_url)
        urllib.urlretrieve(libpng_url, lib_abspath)
        logger.debug("Extracting %s" % lib_abspath)
        decompress_gz(lib_abspath)
        logger.debug("Creating lib symlinks")
        os.link(lib_abspath[:-3], lib_abspath[:-5])
        os.link(lib_abspath[:-3], lib_abspath[:-8])
Example #6
0
    def download(self):
        """Download DXVK to the local cache"""
        dxvk_url = self.base_url.format(self.version, self.version)
        if self.is_available():
            logger.warning("%s already available at %s",
                           self.base_name.upper(), self.dxvk_path)

        dxvk_archive_path = os.path.join(self.base_dir,
                                         os.path.basename(dxvk_url))

        downloader = Downloader(dxvk_url, dxvk_archive_path)
        downloader.start()
        while downloader.check_progress(
        ) < 1 and downloader.state != downloader.ERROR:
            time.sleep(0.3)
        if not system.path_exists(dxvk_archive_path):
            raise UnavailableDXVKVersion(
                "Failed to download %s %s" %
                (self.base_name.upper(), self.version))
        if os.stat(dxvk_archive_path).st_size:
            extract_archive(dxvk_archive_path,
                            self.dxvk_path,
                            merge_single=True)
            os.remove(dxvk_archive_path)
        else:
            os.remove(dxvk_archive_path)
            raise UnavailableDXVKVersion(
                "Failed to download %s %s" %
                (self.base_name.upper(), self.version))
Example #7
0
    def download_and_extract(self, tarball, dest=settings.RUNNER_DIR, **opts):
        runner_archive = os.path.join(settings.CACHE_DIR, tarball)
        merge_single = opts.get('merge_single', False)
        dialog = DownloadDialog(settings.RUNNERS_URL + tarball, runner_archive)
        dialog.run()

        extract_archive(runner_archive, dest, merge_single=merge_single)
        os.remove(runner_archive)
Example #8
0
 def extract(self, archive=None, dest=None, merge_single=None,
             callback=None):
     if not os.path.exists(archive):
         raise RunnerInstallationError("Failed to extract {}", archive)
     extract_archive(archive, dest, merge_single=merge_single)
     os.remove(archive)
     if callback:
         callback()
Example #9
0
 def extract(self, archive=None, dest=None, merge_single=None,
             callback=None):
     if not os.path.exists(archive):
         raise RunnerInstallationError("Failed to extract {}", archive)
     extract_archive(archive, dest, merge_single=merge_single)
     os.remove(archive)
     if callback:
         callback()
Example #10
0
 def extract(archive=None, dest=None, merge_single=None, callback=None):
     if not system.path_exists(archive):
         raise RunnerInstallationError(
             "Failed to extract {}".format(archive))
     extract_archive(archive, dest, merge_single=merge_single)
     os.remove(archive)
     if callback:
         callback()
Example #11
0
 def on_installer_downloaded(self, path):
     row = self.runner_store[path]
     version = row[0]
     architecture = row[1]
     archive_path = self.get_dest_path(path)
     dest_path = self.get_runner_path(version, architecture)
     extract_archive(archive_path, dest_path)
     row[self.COL_PROGRESS] = 0
     row[self.COL_INSTALLED] = True
Example #12
0
    def download_and_extract(self, tarball):
        runner_archive = os.path.join(settings.CACHE_DIR, tarball)

        dialog = DownloadDialog(settings.RUNNERS_URL + tarball, runner_archive)
        dialog.run()

        extract_archive(runner_archive, settings.RUNNER_DIR,
                        merge_single=False)
        os.remove(runner_archive)
Example #13
0
 def extract(self, archive=None, dest=None, merge_single=None, callback=None):
     if not os.path.exists(archive):
         logger.error("Can't find %s, aborting install", archive)
         return False
     extract_archive(archive, dest, merge_single=merge_single)
     os.remove(archive)
     if callback:
         callback()
     else:
         return True
Example #14
0
 def download_and_extract(self, tarball, dest=settings.RUNNER_DIR, **opts):
     runner_archive = os.path.join(settings.CACHE_DIR, tarball)
     merge_single = opts.get('merge_single', False)
     source_url = opts.get('source_url', settings.RUNNERS_URL)
     dialogs.DownloadDialog(source_url + tarball, runner_archive)
     if not os.path.exists(runner_archive):
         logger.error("Can't find %s, aborting install", runner_archive)
         dialogs.ErrorDialog("Installation aborted")
         return
     extract_archive(runner_archive, dest, merge_single=merge_single)
     os.remove(runner_archive)
Example #15
0
 def download_and_extract(self, tarball, dest=settings.RUNNER_DIR, **opts):
     runner_archive = os.path.join(settings.CACHE_DIR, tarball)
     merge_single = opts.get('merge_single', False)
     source_url = opts.get('source_url', settings.RUNNERS_URL)
     dialog = dialogs.DownloadDialog(source_url + tarball, runner_archive)
     dialog.run()
     if not os.path.exists(runner_archive):
         logger.error("Can't find %s, aborting install", runner_archive)
         return False
     extract_archive(runner_archive, dest, merge_single=merge_single)
     os.remove(runner_archive)
     return True
Example #16
0
 def on_runner_installed(*args):
     config_path = system.create_folder("~/.atari800")
     bios_archive = os.path.join(config_path, 'atari800-bioses.zip')
     dlg = DownloadDialog(self.bios_url, bios_archive)
     dlg.run()
     if not system.path_exists(bios_archive):
         ErrorDialog("Could not download Atari800 BIOS archive")
         return
     extract.extract_archive(bios_archive, config_path)
     os.remove(bios_archive)
     config = LutrisConfig(runner_slug='atari800')
     config.raw_runner_config.update({'bios_path': config_path})
     config.save()
     if callback:
         callback()
Example #17
0
 def on_runner_installed(*args):
     config_path = system.create_folder("~/.atari800")
     bios_archive = os.path.join(config_path, "atari800-bioses.zip")
     dlg = DownloadDialog(self.bios_url, bios_archive)
     dlg.run()
     if not system.path_exists(bios_archive):
         ErrorDialog("Could not download Atari800 BIOS archive")
         return
     extract.extract_archive(bios_archive, config_path)
     os.remove(bios_archive)
     config = LutrisConfig(runner_slug="atari800")
     config.raw_runner_config.update({"bios_path": config_path})
     config.save()
     if callback:
         callback()
Example #18
0
 def on_runner_installed(*args):  # pylint: disable=unused-argument
     config_path = system.create_folder("~/.atari800")
     bios_archive = os.path.join(config_path, "atari800-bioses.zip")
     dlg = DownloadDialog(self.bios_url, bios_archive)
     dlg.run()
     if not system.path_exists(bios_archive):
         ErrorDialog(_("Could not download Atari 800 BIOS archive"))
         return
     extract.extract_archive(bios_archive, config_path)
     os.remove(bios_archive)
     config = LutrisConfig(runner_slug="atari800")
     config.raw_runner_config.update({"bios_path": config_path})
     config.save()
     if callback:
         callback()
Example #19
0
    def download(self):
        """Download DXVK to the local cache"""
        if self.is_available():
            logger.warning("DXVK already available at %s", self.dxvk_path)

        dxvk_url = self.get_dxvk_download_url()
        if not dxvk_url:
            logger.warning("Could not find a release for DXVK %s", self.version)
            return
        dxvk_archive_path = os.path.join(self.base_dir, os.path.basename(dxvk_url))
        download_file(dxvk_url, dxvk_archive_path, overwrite=True)
        if not system.path_exists(dxvk_archive_path) or not os.stat(dxvk_archive_path).st_size:
            logger.error("Failed to download DXVK %s", self.version)
            return
        extract_archive(dxvk_archive_path, self.dxvk_path, merge_single=True)
        os.remove(dxvk_archive_path)
Example #20
0
    def download(self):
        """Download component to the local cache"""
        if self.is_available():
            logger.warning("%s already available at %s", self.component, self.path)

        url = self.get_download_url()
        if not url:
            logger.warning("Could not find a release for %s %s", self.component, self.version)
            return
        archive_path = os.path.join(self.base_dir, os.path.basename(url))
        download_file(url, archive_path, overwrite=True)
        if not system.path_exists(archive_path) or not os.stat(archive_path).st_size:
            logger.error("Failed to download %s %s", self.component, self.version)
            return
        extract_archive(archive_path, self.path, merge_single=True)
        os.remove(archive_path)
Example #21
0
    def extract(self, archive=None, dest=None, merge_single=None, callback=None):
        if not system.path_exists(archive):
            raise RunnerInstallationError("Failed to extract {}".format(archive))
        try:
            extract_archive(archive, dest, merge_single=merge_single)
        except ExtractFailure as ex:
            logger.error("Failed to extract the archive %s file may be corrupt", archive)
            raise RunnerInstallationError("Failed to extract {}: {}".format(archive, ex))
        os.remove(archive)

        if self.name == "wine":
            logger.debug("Clearing wine version cache")
            from lutris.util.wine.wine import get_wine_versions
            get_wine_versions.cache_clear()

        if callback:
            callback()
Example #22
0
 def install(self):
     success = super(atari800, self).install()
     if not success:
         return False
     config_path = os.path.expanduser("~/.atari800")
     if not os.path.exists(config_path):
         os.makedirs(config_path)
     bios_archive = os.path.join(config_path, 'atari800-bioses.zip')
     dlg = DownloadDialog(self.bios_url, bios_archive)
     dlg.run()
     if not os.path.exists(bios_archive):
         ErrorDialog("Could not download Atari800 BIOS archive")
         return
     extract.extract_archive(bios_archive, config_path)
     os.remove(bios_archive)
     config = LutrisConfig(runner_slug='atari800')
     config.raw_runner_config.update({'bios_path': config_path})
     config.save()
Example #23
0
 def install(self):
     success = super(atari800, self).install()
     if not success:
         return False
     config_path = os.path.expanduser("~/.atari800")
     if not os.path.exists(config_path):
         os.makedirs(config_path)
     bios_archive = os.path.join(config_path, 'atari800-bioses.zip')
     dlg = DownloadDialog(self.bios_url, bios_archive)
     dlg.run()
     if not os.path.exists(bios_archive):
         ErrorDialog("Could not download Atari800 BIOS archive")
         return
     extract_archive(bios_archive, config_path)
     os.remove(bios_archive)
     runner_config = LutrisConfig(runner='atari800')
     runner_config.config_type = 'runner'
     runner_config.runner_config = {'atari800': {'bios_path': config_path}}
     runner_config.save()
Example #24
0
    def download(self):
        """Download DXVK to the local cache"""
        dxvk_url = self.base_url.format(self.version, self.version)
        if self.is_available():
            logger.warning(self.base_name.upper()+" already available at %s", self.dxvk_path)

        dxvk_archive_path = os.path.join(self.base_dir, os.path.basename(dxvk_url))

        downloader = Downloader(dxvk_url, dxvk_archive_path)
        downloader.start()
        while downloader.check_progress() < 1 and downloader.state != downloader.ERROR:
            time.sleep(0.3)
        if not system.path_exists(dxvk_archive_path):
            raise UnavailableDXVKVersion("Failed to download "+self.base_name.upper()+" %s" % self.version)
        if os.stat(dxvk_archive_path).st_size:
            extract_archive(dxvk_archive_path, self.dxvk_path, merge_single=True)
            os.remove(dxvk_archive_path)
        else:
            os.remove(dxvk_archive_path)
            raise UnavailableDXVKVersion("Failed to download "+self.base_name.upper()+" %s" % self.version)
Example #25
0
    def extract(self, data):
        """Extract a file, guessing the compression method."""
        self._check_required_params('file', data, 'extract')
        filename = self._get_file(data['file'])
        if not filename:
            filename = self._substitute(data['file'])

        if not os.path.exists(filename):
            raise ScriptingError("%s does not exists" % filename)
        if 'dst' in data:
            dest_path = self._substitute(data['dst'])
        else:
            dest_path = self.target_path
        msg = "Extracting %s" % os.path.basename(filename)
        logger.debug(msg)
        self.parent.set_status(msg)
        merge_single = 'nomerge' not in data
        extractor = data.get('format')
        logger.debug("extracting file %s to %s", filename, dest_path)
        extract.extract_archive(filename, dest_path, merge_single, extractor)
Example #26
0
    def extract(self, data):
        """Extract a file, guessing the compression method."""
        self._check_required_params("file", data, "extract")
        filename = self._get_file(data["file"])
        if not filename:
            filename = self._substitute(data["file"])

        if not os.path.exists(filename):
            raise ScriptingError("%s does not exists" % filename)
        if "dst" in data:
            dest_path = self._substitute(data["dst"])
        else:
            dest_path = self.target_path
        msg = "Extracting %s" % os.path.basename(filename)
        logger.debug(msg)
        self.parent.set_status(msg)
        merge_single = "nomerge" not in data
        extractor = data.get("format")
        logger.debug("extracting file %s to %s", filename, dest_path)
        extract.extract_archive(filename, dest_path, merge_single, extractor)
Example #27
0
    def download(self):
        """Download DXVK to the local cache"""
        dxvk_url = self.base_url.format(self.version, self.version)
        if self.is_available():
            logger.warning("DXVK already available at %s", self.dxvk_path)

        dxvk_archive_path = os.path.join(self.base_dir, os.path.basename(dxvk_url))
        downloader = Downloader(dxvk_url, dxvk_archive_path)
        downloader.start()
        while downloader.check_progress() < 1:
            time.sleep(0.3)
        if not os.path.exists(dxvk_archive_path):
            logger.error("DXVK %s not downloaded")
            return
        if os.stat(dxvk_archive_path).st_size:
            extract_archive(dxvk_archive_path, self.dxvk_path, merge_single=True)
            os.remove(dxvk_archive_path)
        else:
            os.remove(dxvk_archive_path)
            raise UnavailableDXVKVersion("Failed to download DXVK %s" % self.version)
Example #28
0
    def download(self):
        """Download DXVK to the local cache"""
        # There's a glitch in one of the archive's names
        fixed_version = 'v0.40' if self.version == '0.40' else self.version
        dxvk_url = self.base_url.format(self.version, fixed_version)
        if self.is_available():
            logger.warning("DXVK already available at %s", self.dxvk_path)

        dxvk_archive_path = os.path.join(self.base_dir, os.path.basename(dxvk_url))
        downloader = Downloader(dxvk_url, dxvk_archive_path)
        downloader.start()
        while downloader.check_progress() < 1:
            time.sleep(1)
        if not os.path.exists(dxvk_archive_path):
            logger.error("DXVK %s not downloaded")
            return
        if os.stat(dxvk_archive_path).st_size:
            extract_archive(dxvk_archive_path, self.dxvk_path, merge_single=True)
        else:
            logger.error("%s is an empty file", self.dxvk_path)
        os.remove(dxvk_archive_path)
Example #29
0
    def extract(self, data):
        """ Extracts a file, guessing the compression method """
        if not 'file' in data:
            raise ScriptingError('"file" parameter is mandatory for the '
                                 'extract command', data)
        filename = self._get_file(data['file'])
        if not filename:
            filename = self._substitute(data['file'])

        if not os.path.exists(filename):
            raise ScriptingError("%s does not exists" % filename)
        if 'dst' in data:
            dest_path = self._substitute(data['dst'])
        else:
            dest_path = self.target_path
        msg = "Extracting %s" % filename
        logger.debug(msg)
        self.parent.set_status(msg)
        merge_single = not 'nomerge' in data
        logger.debug("extracting file %s to %s", filename, dest_path)
        extract.extract_archive(filename, dest_path, merge_single)
Example #30
0
    def download(self):
        """Download component to the local cache; returns True if successful but False
        if the component could not be downloaded."""
        if self.is_available():
            logger.warning("%s already available at %s", self.component,
                           self.path)

        url = self.get_download_url()
        if not url:
            logger.warning("Could not find a release for %s %s",
                           self.component, self.version)
            return False
        archive_path = os.path.join(self.base_dir, os.path.basename(url))
        logger.info("Downloading %s to %s", url, archive_path)
        download_file(url, archive_path, overwrite=True)
        if not system.path_exists(archive_path) or not os.stat(
                archive_path).st_size:
            logger.error("Failed to download %s %s", self.component,
                         self.version)
            return False
        logger.info("Extracting %s to %s", archive_path, self.path)
        extract_archive(archive_path, self.path, merge_single=True)
        os.remove(archive_path)
        return True
Example #31
0
def update_runtime(set_status):
    logger.debug("Updating runtime")
    remote_version = get_remote_version()
    local_version = get_local_version()
    if remote_version <= local_version:
        logger.debug("Runtime already up to date")
        return
    runtime32_file = "steam-runtime_32.tar.gz"
    runtime64_file = "steam-runtime_64.tar.gz"

    # Download
    set_status("Updating Runtime")
    runtime32_path = os.path.join(RUNTIME_DIR, runtime32_file)
    http.download_asset(RUNTIME_URL + runtime32_file, runtime32_path,
                        overwrite=True)
    runtime64_path = os.path.join(RUNTIME_DIR, runtime64_file)
    http.download_asset(RUNTIME_URL + runtime64_file, runtime64_path,
                        overwrite=True)
    # Remove current
    system.remove_folder(os.path.join(RUNTIME_DIR, 'steam'))
    # Remove legacy folders
    system.remove_folder(os.path.join(RUNTIME_DIR, 'lib32'))
    system.remove_folder(os.path.join(RUNTIME_DIR, 'lib64'))

    # Extract
    extract.extract_archive(runtime32_path, RUNTIME_DIR,
                            merge_single=False)
    extract.extract_archive(runtime64_path, RUNTIME_DIR,
                            merge_single=False)
    os.unlink(runtime32_path)
    os.unlink(runtime64_path)

    with open(LOCAL_VERSION_PATH, 'w') as version_file:
        version_file.write(str(remote_version))
    set_status("Runtime updated")
    logger.debug("Runtime updated")
Example #32
0
 def extract(src, dst, row):
     """Extract a runner archive to a destination"""
     extract_archive(src, dst)
     return src, row
Example #33
0
 def extract(self, src, dst, row):
     extract_archive(src, dst)
     return src, row
 def extract(src, dst, row):
     extract_archive(src, dst)
     return src, row