def emerge(A, rebuild_all=False): # A was a list, remove duplicates and expand components A = [str(x) for x in A] A_0 = A = expand_src_components(set(A)) ctx.ui.debug('A = %s' % str(A)) if len(A) == 0: ctx.ui.info(_('No packages to emerge.')) return #A |= upgrade_base(A) # FIXME: Errr... order_build changes type conditionally and this # is not good. - baris if not ctx.config.get_option('ignore_dependency'): G_f, order_inst, order_build = plan_emerge(A, rebuild_all) else: G_f = None order_inst = [] order_build = A if order_inst: ctx.ui.info( _("""The following minimal list of packages will be installed from repository in the respective order to satisfy dependencies: """) + util.strlist(order_inst)) ctx.ui.info( _("""The following minimal list of packages will be built and installed in the respective order to satisfy dependencies: """) + util.strlist(order_build)) if ctx.get_option('dry_run'): return if len(order_inst) + len(order_build) > len(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_inst) pisi_installed = ctx.installdb.is_installed('pisi') for x in order_inst: atomicoperations.install_single_name(x) #ctx.ui.notify(ui.packagestogo, order = order_build) for x in order_build: package_names = atomicoperations.build(x)[0] install_pkg_files(package_names) # handle inter-package deps here # FIXME: take a look at the fixme above :(, we have to be sure # that order_build is a known type... U = set(order_build) U.update(order_inst) if 'pisi' in order_build or (('pisi' in U) and pisi_installed): upgrade_pisi()
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""" A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates and expand components A_0 = A = expand_components(set(A)) ctx.ui.debug('A = %s' % str(A)) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning( _('Not re-installing the following packages: ') + util.strlist(d)) A = Ap if len(A) == 0: ctx.ui.info(_('No packages to install.')) return A |= upgrade_base(A) if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = A ctx.ui.info( _("""Following packages will be installed in the respective order to satisfy dependencies: """) + util.strlist(order)) total_size = sum([ctx.packagedb.get_package(p).packageSize for p in order]) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of packages: %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if len(order) > len(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) pisi_installed = ctx.installdb.is_installed('pisi') for x in order: atomicoperations.install_single_name(x, True) # allow reinstalls here if 'pisi' in order and pisi_installed: upgrade_pisi()
def install_pkg_names(A): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" # A was a list, remove duplicates and expand components A_0 = A = expand_components(set(A)) ctx.ui.debug("A = %s" % str(A)) if len(A) == 0: ctx.ui.info(_("No packages to install.")) return if ctx.config.get_option("ignore_dependency"): # simple code path then for x in A: atomicoperations.install_single_name(x) return # short circuit # try to construct a pisi graph of packages to # install / reinstall G_f = pgraph.PGraph(packagedb) # construct G_f # find the "install closure" graph of G_f by package # set A using packagedb for x in A: G_f.add_package(x) B = A while len(B) > 0: Bp = set() for x in B: pkg = packagedb.get_package(x) for dep in pkg.runtimeDependencies(): ctx.ui.debug("checking %s" % str(dep)) # we don't deal with already *satisfied* dependencies if not dependency.installed_satisfies_dep(dep): if not dep.package in G_f.vertices(): Bp.add(str(dep.package)) G_f.add_dep(x, dep) B = Bp if ctx.config.get_option("debug"): G_f.write_graphviz(sys.stdout) order = G_f.topological_sort() order.reverse() check_conflicts(order) ctx.ui.info( _( """The following minimal list of packages will be installed in the respective order to satisfy dependencies: """ ) + util.strlist(order) ) if len(order) > len(A_0): if not ctx.ui.confirm(_("Do you want to continue?")): return False for x in order: atomicoperations.install_single_name(x)
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 = pisi.db.installdb.InstallDB() 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(filter(lambda x: not installdb.has_package(x), A)) 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:\n") + util.strlist(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 = pisi.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(_("Following packages will be installed in the respective " "order to satisfy dependencies:\n") + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) 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) for x in order: atomicoperations.install_single_name(x, True) # allow reinstalls here return True
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""" A = [str(x) for x in A] # FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates and expand components A_0 = A = expand_components(set(A)) ctx.ui.debug("A = %s" % str(A)) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A)) 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:\n") + util.strlist(d) ) A = Ap if len(A) == 0: ctx.ui.info(_("No packages to install.")) return A |= 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) if len(order) > 1: ctx.ui.info( _("Following packages will be installed in the respective " "order to satisfy dependencies:\n") + util.strlist(order) ) total_size = sum([ctx.packagedb.get_package(p).packageSize for p in order]) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_("Total size of package(s): %.2f %s") % (total_size, symbol)) if ctx.get_option("dry_run"): return 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) pisi_installed = ctx.installdb.is_installed("pisi") for x in order: atomicoperations.install_single_name(x, True) # allow reinstalls here if "pisi" in order and pisi_installed: upgrade_pisi()
def emerge(A, rebuild_all = False): # A was a list, remove duplicates and expand components A = [str(x) for x in A] A_0 = A = expand_src_components(set(A)) ctx.ui.debug('A = %s' % str(A)) if len(A)==0: ctx.ui.info(_('No packages to emerge.')) return #A |= upgrade_base(A) # FIXME: Errr... order_build changes type conditionally and this # is not good. - baris if not ctx.config.get_option('ignore_dependency'): G_f, order_inst, order_build = plan_emerge(A, rebuild_all) else: G_f = None order_inst = [] order_build = A if order_inst: ctx.ui.info(_("""The following minimal list of packages will be installed from repository in the respective order to satisfy dependencies: """) + util.strlist(order_inst)) ctx.ui.info(_("""The following minimal list of packages will be built and installed in the respective order to satisfy dependencies: """) + util.strlist(order_build)) if ctx.get_option('dry_run'): return if len(order_inst) + len(order_build) > len(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_inst) pisi_installed = ctx.installdb.is_installed('pisi') for x in order_inst: atomicoperations.install_single_name(x) #ctx.ui.notify(ui.packagestogo, order = order_build) for x in order_build: package_names = atomicoperations.build(x)[0] install_pkg_files(package_names) # handle inter-package deps here # FIXME: take a look at the fixme above :(, we have to be sure # that order_build is a known type... U = set(order_build) U.update(order_inst) if 'pisi' in order_build or (('pisi' in U) and pisi_installed): upgrade_pisi()
def install_pkg_names(A, reinstall = False, bypass_safety = False): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of installs""" A = [str(x) for x in A] #FIXME: why do we still get unicode input here? :/ -- exa # A was a list, remove duplicates and expand components A_0 = A = expand_components(set(A)) ctx.ui.debug('A = %s' % str(A)) if not bypass_safety: upgrade_base(A) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning(_('Not re-installing the following packages: ') + util.strlist(d)) A = Ap if len(A)==0: ctx.ui.info(_('No packages to install.')) return if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = A ctx.ui.info(_("""Following packages will be installed in the respective order to satisfy dependencies: """) + util.strlist(order)) total_size = sum([ctx.packagedb.get_package(p).packageSize for p in order]) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of packages: %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if len(order) > len(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) pisi_installed = ctx.installdb.is_installed('pisi') for x in order: atomicoperations.install_single_name(x) if not bypass_safety and 'pisi' in order and pisi_installed: upgrade_pisi()
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""" # A was a list, remove duplicates and expand components A_0 = A = expand_components(set(A)) ctx.ui.debug('A = %s' % str(A)) # filter packages that are already installed if not reinstall: Ap = set(filter(lambda x: not ctx.installdb.is_installed(x), A)) d = A - Ap if len(d) > 0: ctx.ui.warning(_('Not re-installing the following packages: ') + util.strlist(d)) A = Ap if len(A)==0: ctx.ui.info(_('No packages to install.')) return if not ctx.config.get_option('ignore_dependency'): G_f, order = plan_install_pkg_names(A) else: G_f = None order = A ctx.ui.info(_("""The following minimal list of packages will be installed in the respective order to satisfy dependencies: """) + util.strlist(order)) #this silly try/except block will be removed soon.. try: total_size = sum([packagedb.get_package(p).packageSize for p in order]) except: total_size = 0 if total_size: total_size, symbol = util.human_readable_size(total_size) ctx.ui.warning(_('Total size of packages: %.2f %s') % (total_size, symbol)) if ctx.get_option('dry_run'): return if len(order) > len(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) for x in order: atomicoperations.install_single_name(x)
def emerge(A, rebuild_all=False): # A was a list, remove duplicates and expand components A_0 = A = expand_src_components(set(A)) ctx.ui.debug("A = %s" % str(A)) if len(A) == 0: ctx.ui.info(_("No packages to emerge.")) return if not ctx.config.get_option("ignore_dependency"): G_f, order_inst, order_build = plan_emerge(A, rebuild_all) else: G_f = None order_inst = [] order_build = A if order_inst: ctx.ui.info( _( """The following minimal list of packages will be installed from repository in the respective order to satisfy dependencies: """ ) + util.strlist(order_inst) ) ctx.ui.info( _( """The following minimal list of packages will be built and installed in the respective order to satisfy dependencies: """ ) + util.strlist(order_build) ) if ctx.get_option("dry_run"): return if len(order_inst) + len(order_build) > len(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_inst) for x in order_inst: atomicoperations.install_single_name(x) # ctx.ui.notify(ui.packagestogo, order = order_build) for x in order_build: package_names, blah = atomicoperations.build(x) install_pkg_files(package_names) # handle inter-package deps here
def emerge(A, rebuild_all = False, bypass_safety = False): # A was a list, remove duplicates and expand components A = [str(x) for x in A] A_0 = A = expand_src_components(set(A)) ctx.ui.debug('A = %s' % str(A)) if len(A)==0: ctx.ui.info(_('No packages to emerge.')) return #if not bypass_safety: # A |= upgrade_base(A) if not ctx.config.get_option('ignore_dependency'): G_f, order_inst, order_build = plan_emerge(A, rebuild_all) else: G_f = None order_inst = [] order_build = A if order_inst: ctx.ui.info(_("""The following minimal list of packages will be installed from repository in the respective order to satisfy dependencies: """) + util.strlist(order_inst)) ctx.ui.info(_("""The following minimal list of packages will be built and installed in the respective order to satisfy dependencies: """) + util.strlist(order_build)) if ctx.get_option('dry_run'): return if len(order_inst) + len(order_build) > len(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_inst) pisi_installed = ctx.installdb.is_installed('pisi') for x in order_inst: atomicoperations.install_single_name(x) #ctx.ui.notify(ui.packagestogo, order = order_build) for x in order_build: package_names, blah = atomicoperations.build(x) install_pkg_files(package_names) # handle inter-package deps here if 'pisi' in order_build or ( ('pisi' in order_inst + order_build) and pisi_installed): upgrade_pisi()
def upgrade_pkg_names(A = []): """Re-installs packages from the repository, trying to perform a maximum number of upgrades.""" ignore_build = ctx.config.options and ctx.config.options.ignore_build_no if not A: # if A is empty, then upgrade all packages A = ctx.installdb.list_installed() # filter packages that are not upgradable A_0 = A = expand_components(set(A)) Ap = [] for x in A: if x.endswith(ctx.const.package_suffix): ctx.ui.debug(_("Warning: package *name* ends with '.pisi'")) if not ctx.installdb.is_installed(x): ctx.ui.info(_('Package %s is not installed.') % x) continue (version, release, build) = ctx.installdb.get_version(x) pkg = packagedb.get_package(x) # First check version. If they are same, check release. Again # if releases are same and checking buildno is premitted, # check build number. if version < pkg.version: Ap.append(x) elif version == pkg.version: if release < pkg.release: Ap.append(x) if release == pkg.release and build and not ignore_build: if build < pkg.build: Ap.append(x) else: #ctx.ui.info('Package %s cannot be upgraded. ' % x) ctx.ui.info(_('Package %s is already at its latest \ version %s, release %s, build %s.') % (x, pkg.version, pkg.release, pkg.build)) A = set(Ap) 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) else: G_f = None order = A ctx.ui.info(_("""The following packages will be upgraded:\n""") + util.strlist(order)) if ctx.get_option('dry_run'): return if len(order) > len(A_0): if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False for x in order: atomicoperations.install_single_name(x, True)
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 = pisi.db.installdb.InstallDB() 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(filter(lambda x: not installdb.has_package(x), A)) 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:\n" ) + util.strlist(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 = pisi.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( _("Following packages will be installed in the respective " "order to satisfy dependencies:\n") + util.strlist(order)) total_size, cached_size = operations.helper.calculate_download_sizes(order) total_size, symbol = util.human_readable_size(total_size) ctx.ui.info(_('Total size of package(s): %.2f %s') % (total_size, symbol)) 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) for x in order: atomicoperations.install_single_name(x, True) # allow reinstalls here return True
def upgrade_pkg_names(A = []): """Re-installs packages from the repository, trying to perform a maximum number of upgrades.""" ignore_build = ctx.config.options and ctx.config.options.ignore_build_no if not A: # if A is empty, then upgrade all packages A = ctx.installdb.list_installed() # filter packages that are not upgradable A_0 = A = set(A) Ap = [] for x in A: if x.endswith('.pisi'): ctx.ui.debug(_("Warning: package *name* ends with '.pisi'")) if not ctx.installdb.is_installed(x): ctx.ui.info(_('Package %s is not installed.') % x) continue (version, release, build) = ctx.installdb.get_version(x) pkg = packagedb.get_package(x) # First check version. If they are same, check release. Again # if releases are same and checking buildno is premitted, # check build number. if version < pkg.version: Ap.append(x) elif version == pkg.version: if release < pkg.release: Ap.append(x) if release == pkg.release and build and not ignore_build: if build < pkg.build: Ap.append(x) else: #ctx.ui.info('Package %s cannot be upgraded. ' % x) ctx.ui.info(_('Package %s is already at its latest \ version %s, release %s, build %s.') % (x, pkg.version, pkg.release, pkg.build)) A = set(Ap) if len(A)==0: ctx.ui.info(_('No packages to upgrade.')) return True ctx.ui.debug('A = %s' % str(A)) # try to construct a pisi graph of packages to # install / reinstall G_f = pgraph.PGraph(packagedb) # construct G_f # find the "install closure" graph of G_f by package # set A using packagedb for x in A: G_f.add_package(x) B = A def upgradable(dep): #pre dep.package is installed (v,r,b) = ctx.installdb.get_version(dep.package) rep_pkg = packagedb.get_package(dep.package) (vp,rp,bp) = (rep_pkg.version, rep_pkg.release, rep_pkg.build) if ignore_build or (not b) or (not bp): # if we can't look at build if r >= rp: # installed already new return False elif b and bp and b >= bp: return False return True # TODO: conflicts while len(B) > 0: Bp = set() for x in B: pkg = packagedb.get_package(x) for dep in pkg.runtimeDependencies: # add packages that can be upgraded if dependency.repo_satisfies_dep(dep): #TODO: distinguish must upgrade and upgradable if ctx.installdb.is_installed(dep.package): if not ctx.get_option('eager'): if dependency.installed_satisfies_dep(dep): continue else: if not upgradable(dep): continue if not dep.package in G_f.vertices(): Bp.add(str(dep.package)) G_f.add_dep(x, dep) else: raise Error(_("Reverse dependency %s cannot be satisfied") % rev_dep) B = Bp # now, search reverse dependencies to see if anything # should be upgraded B = A while len(B) > 0: Bp = set() for x in B: pkg = packagedb.get_package(x) rev_deps = packagedb.get_rev_deps(x) for (rev_dep, depinfo) in rev_deps: if not ctx.get_option('eager'): # add unsatisfied reverse dependencies if packagedb.has_package(rev_dep) and \ (not dependency.installed_satisfies_dep(depinfo)): if not dependency.repo_satisfies_dep(dep): raise Error(_("Reverse dependency %s cannot be satisfied") % rev_dep) if not rev_dep in G_f.vertices(): Bp.add(rev_dep) G_f.add_plain_dep(rev_dep, x) else: if not rev_dep in G_f.vertices(): Bp.add(rev_dep) G_f.add_plain_dep(rev_dep, x) B = Bp if ctx.config.get_option('debug'): G_f.write_graphviz(sys.stdout) order = G_f.topological_sort() order.reverse() check_conflicts(order) ctx.ui.info(_("""The following packages will be upgraded:\n""") + util.strlist(order)) if len(order) > len(A_0): if not ctx.ui.confirm('Do you want to continue?'): return False for x in order: atomicoperations.install_single_name(x, True)