From 710bfd1b2e26b4fd6866464c771fba588c1ad396 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 2 Dec 2009 12:42:05 +0000 Subject: [PATCH 1/4] will be a short lived branch, but the changes are too critical for the stable branch. From 8640c4ac0031d11c6cb694f63ba6b50856aaf539 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 2 Dec 2009 12:42:55 +0000 Subject: [PATCH 2/4] Return all the replacing packages as an array --- pisi/api.py | 2 +- pisi/db/packagedb.py | 2 +- pisi/operations/upgrade.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index 242e1a17..f633d2bf 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -182,7 +182,7 @@ def list_replaces(repo=None): @param repo: Repository of the replaced packages. If repo is None than returns a dictionary of all the replaced packages in all the repositories - {'gaim':'pidgin, 'actioncube':'assaultcube'} + {'gaim':['pidgin'], 'gimp-i18n':['gimp-i18n-tr', 'gimp-18n-de', ...]} gaim replaced by pidgin and actioncube replaced by assaultcube """ diff --git a/pisi/db/packagedb.py b/pisi/db/packagedb.py index ba5f8130..118d5423 100644 --- a/pisi/db/packagedb.py +++ b/pisi/db/packagedb.py @@ -203,7 +203,7 @@ class PackageDB(lazydb.LazyDB): replaces = self.get_package(pkg_name).replaces for r in replaces: if pisi.replace.installed_package_replaced(r): - pairs[r.package] = pkg_name + pairs.setdefault(r.package, []).append(pkg_name) return pairs diff --git a/pisi/operations/upgrade.py b/pisi/operations/upgrade.py index 2910962e..5316443c 100644 --- a/pisi/operations/upgrade.py +++ b/pisi/operations/upgrade.py @@ -114,7 +114,9 @@ def upgrade(A=[], repo=None): # 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(replaces.values()) + # + # sum(array, []) is a nice trick to flatten an array of arrays + A |= set(sum(replaces.values(), [])) A |= upgrade_base(A) From d4455a2802805e6b7df82b499c5c911f58dc9a53 Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 2 Dec 2009 13:42:11 +0000 Subject: [PATCH 3/4] * dont do anything special for replaced packages in find_upgrades. Replaced packages are obsoleted and so they are forced to upgrade. * replaces.values is now array of arrays --- pisi/operations/upgrade.py | 44 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/pisi/operations/upgrade.py b/pisi/operations/upgrade.py index 5316443c..ca2bb676 100644 --- a/pisi/operations/upgrade.py +++ b/pisi/operations/upgrade.py @@ -36,31 +36,23 @@ def find_upgrades(packages, replaces): Ap = [] for i_pkg in packages: - u_pkg = i_pkg # upgrade package and installed package are the same if there is no replacement in place + if i_pkg in replaces.keys(): + # Replaced packages will be forced for upgrade, cause replaced packages are marked as obsoleted also. So we + # pass them. + continue if i_pkg.endswith(ctx.const.package_suffix): ctx.ui.debug(_("Warning: package *name* ends with '.pisi'")) - # pisi up has "installed to be replaced package" as argument - if i_pkg in replaces.keys(): - u_pkg = replaces[i_pkg] - - # pisi up has "not installed but replacement package" as argument - if i_pkg in replaces.values(): - for i, u in replaces.items(): - if i_pkg == u: - i_pkg = i - u_pkg = u - if not installdb.has_package(i_pkg): ctx.ui.info(_('Package %s is not installed.') % i_pkg, True) continue - if not packagedb.has_package(u_pkg): - ctx.ui.info(_('Package %s is not available in repositories.') % u_pkg, True) + if not packagedb.has_package(i_pkg): + ctx.ui.info(_('Package %s is not available in repositories.') % i_pkg, True) continue - pkg = packagedb.get_package(u_pkg) + pkg = packagedb.get_package(i_pkg) (version, release, build, distro, distro_release) = installdb.get_version_and_distro_release(i_pkg) updates = [i for i in pkg.history if pisi.version.Version(i.release) > pisi.version.Version(release)] @@ -69,20 +61,20 @@ def find_upgrades(packages, replaces): continue if pisi.util.any(lambda u:"reverseDependencyUpdate" in u.required_actions() , updates): - rev_deps = map(lambda d:d[0], packagedb.get_rev_deps(u_pkg)) + rev_deps = map(lambda d:d[0], packagedb.get_rev_deps(i_pkg)) Ap.extend(filter(lambda name:is_upgradable(name), rev_deps)) if pkg.distribution == distro and pisi.version.Version(pkg.distributionRelease) > pisi.version.Version(distro_release): - Ap.append(u_pkg) + Ap.append(i_pkg) elif ignore_build or (not build) or (not pkg.build): if pisi.version.Version(release) < pisi.version.Version(pkg.release): - Ap.append(u_pkg) + Ap.append(i_pkg) else: ctx.ui.info(_('Package %s is already at the latest release %s.') % (pkg.name, pkg.release), True) else: - if build < pkg.build or u_pkg != i_pkg: - Ap.append(u_pkg) + if build < pkg.build: + Ap.append(i_pkg) else: ctx.ui.info(_('Package %s is already at the latest build %s.') % (pkg.name, pkg.build), True) @@ -108,16 +100,16 @@ def upgrade(A=[], repo=None): Ap = find_upgrades(A, replaces) A = set(Ap) - if len(A)==0: - ctx.ui.info(_('No packages to upgrade.')) - return True - # 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). # # sum(array, []) is a nice trick to flatten an array of arrays A |= set(sum(replaces.values(), [])) + if len(A)==0: + ctx.ui.info(_('No packages to upgrade.')) + return True + A |= upgrade_base(A) ctx.ui.debug('A = %s' % str(A)) @@ -144,7 +136,7 @@ def upgrade(A=[], repo=None): if ctx.get_option('dry_run'): return - if set(order) - A_0 - set(replaces.values()): + if set(order) - A_0 - set(sum(replaces.values(), [])): if not ctx.ui.confirm(_('There are extra packages due to dependencies. Do you want to continue?')): return False @@ -185,7 +177,7 @@ def plan_upgrade(A): replaces = packagedb.get_replaces() # 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(A) | set(replaces.values()) + A = set(A) | set(sum(replaces.values(), [])) # find the "install closure" graph of G_f by package # set A using packagedb From becea2b413f993ea4c3ef15eb5c7e72ec13b885f Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Wed, 2 Dec 2009 13:46:59 +0000 Subject: [PATCH 4/4] fix comment --- pisi/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pisi/api.py b/pisi/api.py index f633d2bf..35d241a7 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -184,7 +184,8 @@ def list_replaces(repo=None): {'gaim':['pidgin'], 'gimp-i18n':['gimp-i18n-tr', 'gimp-18n-de', ...]} - gaim replaced by pidgin and actioncube replaced by assaultcube + gaim replaced by pidgin and gimp-i18n is divided into smaller packages which also + replaces gimp-i18n """ return pisi.db.packagedb.PackageDB().get_replaces(repo)