Ejemplo n.º 1
0
    def update(self, progress, sources_list=None):
        src_list = aptsources.sourceslist.SourcesList()

        src_count = 0
        for src in src_list.list:
            if not src.disabled and not src.invalid:
                src_count += len(src.comps) + 1

        updating_sources = "{}-updating-apt-sources".format(
            progress.get_current_phase().name)
        cache_init = "{}-apt-cache-init".format(
            progress.get_current_phase().name)
        progress.split(Phase(updating_sources, _("Updating apt sources")),
                       Phase(cache_init, _("Initialising apt cache")))

        progress.start(updating_sources)
        apt_progress = AptDownloadProgress(progress, src_count)
        try:
            self._cache.update(fetch_progress=apt_progress,
                               sources_list=sources_list)
        except apt.cache.FetchFailedException:
            err_msg = N_("Failed to update sources")
            logger.error(err_msg)
            progress.fail(_(err_msg))

        progress.start(cache_init)
        ops = [("reading-package-lists", _("Reading package lists")),
               ("building-dependency-tree", _("Building dependency tree")),
               ("reading-state-information", _("Reading state information")),
               ("building-data-structures", _("Building data structures"))]
        op_progress = AptOpProgress(progress, ops)
        self._cache.open(op_progress)
Ejemplo n.º 2
0
    def upgrade(self, packages, progress=None, priority=Priority.NONE):
        if not isinstance(packages, list):
            packages = [packages]

        for pkg_name in packages:
            if pkg_name in self._cache:
                pkg = self._cache[pkg_name]

                if self._is_package_upgradable(pkg, priority=priority):
                    pkg.mark_upgrade()

        phase_name = progress.get_current_phase().name
        download = "{}-downloading".format(phase_name)
        install = "{}-installing".format(phase_name)
        progress.split(Phase(download, _("Downloading packages")),
                       Phase(install, _("Installing packages")))

        progress.start(download)
        apt_progress = AptDownloadProgress(progress, self._cache.install_count)
        self._cache.fetch_archives(apt_progress)

        progress.start(install)
        inst_progress = AptInstallProgress(progress)
        self._cache.commit(install_progress=inst_progress)
        self._cache.open()
        self._cache.clear()
Ejemplo n.º 3
0
    def _do_fetch_archives(self, progress):
        '''
        Raises: apt.cache.FetchFailedException
        Raises: DownloadFailException
        '''

        apt_progress = AptDownloadProgress(progress, self._cache.install_count)
        self._cache.fetch_archives(apt_progress)
Ejemplo n.º 4
0
    def _do_update_cache(self, progress, src_count, sources_list):
        '''
        Raises: apt.cache.FetchFailedException
        Raises: DownloadFailException
        '''

        apt_progress = AptDownloadProgress(progress, src_count)
        self._cache.update(fetch_progress=apt_progress,
                           sources_list=sources_list)
Ejemplo n.º 5
0
    def cache_updates(self, progress, priority=Priority.NONE):
        self._mark_all_for_update(priority=priority)

        apt_progress = AptDownloadProgress(progress, self._cache.install_count)
        self._cache.fetch_archives(apt_progress)