Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
GObject.idle_add(task.info_ready_callback, task)
return
task = InstallerTask(pkginfo, self, ready_callback)
if self.pkginfo_is_installed(pkginfo):
# It's not installed, so assume we're installing
task.type = UNINSTALL_TASK
else:
task.type = INSTALL_TASK
if pkginfo.pkg_hash.startswith("a"):
_apt.select_packages(task)
else:
_flatpak.select_packages(task)
def generate_uncached_pkginfos(self, cache):
"""
Flatpaks installed from .flatpakref files may not actually be in the saved
pkginfo cache, specifically, if they're added from no-enumerate-marked remotes.
This gets run at startup to collect and generate their info.
"""
if self.have_flatpak:
_flatpak.generate_uncached_pkginfos(cache)
def _generate_cache(self):
cache = {}
sections = {}
flatpak_remote_infos = {}
if self.have_flatpak:
cache, flatpak_remote_infos = _flatpak.process_full_flatpak_installation(cache)
cache, sections = _apt.process_full_apt_cache(cache)
return cache, sections, flatpak_remote_infos
def find_pkginfo(self, string, pkg_type=None):
if pkg_type in (None, "a"):
pkginfo = _apt.find_pkginfo(self, string)
if pkginfo != None:
return pkginfo
if self.have_flatpak:
if pkg_type in (None, "f"):
pkginfo = _flatpak.find_pkginfo(self, string)
if pkginfo != None:
return pkginfo
return None
def list_flatpak_remotes(self):
"""
Returns a list of FlatpakRemoteInfos. The remote_name can be used to match
with PkgInfo.remote and the title is for display.
"""
if self.have_flatpak:
return _flatpak.list_remotes()
else:
return []
def get_pkginfo_from_ref_file(self, file, ready_callback):
"""
Accepts a GFile to a .flatpakref on a local path. If the flatpak's remote
has not been previously added to the system installation, this also adds
it and downloads Appstream info as well, before calling ready_callback with
the created (or existing) PkgInfo as an argument.
"""
if self.have_flatpak:
_flatpak.get_pkginfo_from_file(self.cache, file, ready_callback)
def pkginfo_is_installed(self, pkginfo):
"""
Returns whether or not a given package is currently installed. This uses
the AptCache or the FlatpakInstallation to check.
"""
if self.inited:
if pkginfo.pkg_hash.startswith("a"):
return _apt.pkginfo_is_installed(pkginfo)
elif self.have_flatpak and pkginfo.pkg_hash.startswith("f"):
return _flatpak.pkginfo_is_installed(pkginfo)
return False