def __str__(self): s = specfile.Package.__str__(self) i_size = util.human_readable_size(self.installedSize) size = "%.2f %s" % (i_size[0], i_size[1]) s += _('Distribution: %s, Dist. Release: %s\n') % \ (self.distribution, self.distributionRelease) s += _('Architecture: %s, Installed Size: %s') % \ (self.architecture, size) if self.packageSize: p_size = util.human_readable_size(self.packageSize) size = "%.2f %s" % (p_size[0], p_size[1]) s += _(', Package Size: %s') % size s += _(', install.tar.xz sha1sum: %s') % self.installTarHash return s
def upgrade(A=[], repo=None): """Re-installs packages from the repository, trying to perform a minimum or maximum number of upgrades according to options.""" packagedb = pisilinux.db.packagedb.PackageDB() installdb = pisilinux.db.installdb.InstallDB() replaces = packagedb.get_replaces() if not A: # if A is empty, then upgrade all packages A = installdb.list_installed() if repo: repo_packages = set(packagedb.list_packages(repo)) A = set(A).intersection(repo_packages) A_0 = A = set(A) Ap = find_upgrades(A, replaces) A = set(Ap) # Force upgrading of installed but replaced packages or else they will be removed (they are obsoleted also). # This is not wanted for a replaced driver package (eg. nvidia-X). A |= set(pisilinux.util.flatten_list(list(replaces.values()))) A |= upgrade_base(A) A = pisilinux.blacklist.exclude_from(A, ctx.const.blacklist) if ctx.get_option('exclude_from'): A = pisilinux.blacklist.exclude_from(A, ctx.get_option('exclude_from')) if ctx.get_option('exclude'): A = pisilinux.blacklist.exclude(A, ctx.get_option('exclude')) ctx.ui.debug('A = %s' % str(A)) if len(A)==0: ctx.ui.info(_('No packages to upgrade.')) return True ctx.ui.debug('A = %s' % str(A)) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_upgrade(A, replaces=replaces) else: G_f = None order = list(A) componentdb = pisilinux.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) ctx.ui.status(_('The following packages will be upgraded:')) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(util.colorize(_('Total size of package(s): %.2f %s') % (total_size, symbol), "yellow")) needs_confirm = check_update_actions(order) # NOTE: replaces.values() was already flattened above, it can be reused if set(order) - A_0 - set(pisilinux.util.flatten_list(list(replaces.values()))): ctx.ui.warning(_("There are extra packages due to dependencies.")) needs_confirm = True if ctx.get_option('dry_run'): return if needs_confirm and \ not ctx.ui.confirm(_("Do you want to continue?")): return False ctx.ui.notify(ui.packagestogo, order = order) conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be upgraded packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) operations.remove.remove_obsoleted_packages() for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path, ignore_file_conflicts = True) install_op.install(not ctx.get_option('compare_sha1sum'))
def install_pkg_names(A, reinstall = False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" installdb = pisilinux.db.installdb.InstallDB() packagedb = pisilinux.db.packagedb.PackageDB() A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates A_0 = A = set(A) # filter packages that are already installed if not reinstall: Ap = set([x for x in A if not installdb.has_package(x)]) d = A - Ap if len(d) > 0: ctx.ui.warning(_("The following package(s) are already installed " "and are not going to be installed again:")) ctx.ui.info(util.format_by_columns(sorted(d))) A = Ap if len(A)==0: ctx.ui.info(_('No packages to install.')) return True A |= operations.upgrade.upgrade_base(A) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = list(A) componentdb = pisilinux.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = operations.helper.reorder_base_packages(order) if len(order) > 1: ctx.ui.info(util.colorize(_("Following packages will be installed:"), "brightblue")) ctx.ui.info(util.format_by_columns(sorted(order))) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(util.colorize(_('Total size of package(s): %.2f %s') % (total_size, symbol), "yellow")) if ctx.get_option('dry_run'): return True if set(order) - A_0: if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False ctx.ui.notify(ui.packagestogo, order = order) ignore_dep = ctx.config.get_option('ignore_dependency') conflicts = [] if not ctx.get_option('ignore_package_conflicts'): conflicts = operations.helper.check_conflicts(order, packagedb) paths = [] for x in order: ctx.ui.info(util.colorize(_("Downloading %d / %d") % (order.index(x)+1, len(order)), "yellow")) install_op = atomicoperations.Install.from_name(x) paths.append(install_op.package_fname) # fetch to be installed packages but do not install them. if ctx.get_option('fetch_only'): return if conflicts: operations.remove.remove_conflicting_packages(conflicts) for path in paths: ctx.ui.info(util.colorize(_("Installing %d / %d") % (paths.index(path)+1, len(paths)), "yellow")) install_op = atomicoperations.Install(path) install_op.install(False) return True