From fb799a074fef9d4d3e3d3181d7438f9f0fc93d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Sun, 23 Oct 2005 20:50:22 +0000 Subject: [PATCH] * implement high level conflict checking --- pisi/operations.py | 26 ++++++++++++++++++++++++++ tests/beta-light.sh | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pisi/operations.py b/pisi/operations.py index 0458e621..bbaea9e4 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -156,6 +156,30 @@ def install_pkg_files(package_URIs): return True # everything went OK. +def check_conflicts(order): + """check if upgrading to the latest versions will cause havoc + done in a simple minded way without regard for dependencies of + conflicts, etc.""" + B_0 = B = set(order) + C = set() + # calculate conflict closure + while len(B) > 0: + Bp = set() + for x in B: + pkg = packagedb.get_package(x) # get latest version! + #TODO: read conflicts from a conflicts db... + for conflict in pkg.conflicts: + if ctx.installdb.is_installed(self.pkginfo): + Bp.add(conflict) + C.add(conflict) + B = Bp + if B_0.intersection(C): + raise Error(_("Selected packages %s and %s are in conflict.") % (x, pkg)) + if C: + if not ctx.ui.confirm(_('Remove the following conflicting packages?')): + #raise Error(_("Package %s conflicts installed package %s") % (x, pkg)) + raise Error(_("Conflicts remain")) + def install_pkg_names(A): """This is the real thing. It installs packages from the repository, trying to perform a minimum number of @@ -201,6 +225,7 @@ def install_pkg_names(A): 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)) @@ -312,6 +337,7 @@ version %s, release %s, build %s.') 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): diff --git a/tests/beta-light.sh b/tests/beta-light.sh index 74cb01cf..7eb2518b 100755 --- a/tests/beta-light.sh +++ b/tests/beta-light.sh @@ -1,4 +1,4 @@ -#!/bin/sh +bi#!/bin/sh pwd PATH=$PATH:. @@ -18,6 +18,6 @@ pisi-cli -Dtmp --ignore-comar install zip pisi-cli -Dtmp list-installed pisi-cli -Dtmp --ignore-comar remove unzip pisi-cli -Dtmp info zip*.pisi -pisi-cli -Dtmp --ignore-comar install zip*.pisi +pisi-cli -d -Dtmp --ignore-comar install zip*.pisi pisi-cli -Dtmp list-pending pisi-cli -Dtmp configure-pending