--- smart/transaction.py.orig 2006-09-03 20:13:31.000000000 +0200
+++ smart/transaction.py 2006-09-03 21:48:16.000000000 +0200
@@ -106,6 +106,9 @@
self._locked = {}
self._sysconflocked = []
self._priorities = {}
+ #
+ self._softlocked = {}
+ #
def runStarting(self):
self._priorities.clear()
@@ -117,6 +120,9 @@
def runFinished(self):
self._priorities.clear()
+ #
+ self._softlocked.clear()
+ #
for pkg in self._sysconflocked:
del self._locked[pkg]
del self._sysconflocked[:]
@@ -134,6 +140,9 @@
def getLockedSet(self):
return self._locked
+ def getSoftLockedSet(self):
+ return self._softlocked
+
def getWeight(self, changeset):
return 0
@@ -392,6 +401,21 @@
weight += -30*upgradedcount+(installedcount-upgradedcount)
return weight
+class PolicyUpgradeWithoutRemove(PolicyUpgrade):
+ """Give precedence to the choice with more upgrades but without removing any package."""
+
+ def runStarting(self):
+ PolicyUpgrade.runStarting(self)
+ cache = self._trans.getCache()
+ queue = self._trans.getQueue()
+ # Protect those pkgs that are installed
+ protectedpkgs = [p for p in cache.getPackages()
+ if p.installed]
+ d = dict.fromkeys(protectedpkgs, True)
+ self._locked.update(d)
+ self._softlocked.update(d)
+
+
class Failed(Error): pass
PENDING_REMOVE = 1
@@ -483,13 +507,18 @@
# Remove packages with the same name that can't
# coexist with this one.
+ #
+ softlocked = self._policy.getSoftLockedSet()
+ #
namepkgs = self._cache.getPackages(pkg.name)
for namepkg in namepkgs:
if namepkg is not pkg and not pkg.coexists(namepkg):
if not isinst(namepkg):
locked[namepkg] = True
continue
- if namepkg in locked:
+ #
+ if namepkg in locked and namepkg not in softlocked:
+ #
raise Failed, _("Can't install %s: it can't coexist "
"with %s") % (pkg, namepkg)
self._remove(namepkg, changeset, locked, pending, depth)
--- smart/commands/upgrade.py.orig 2006-09-03 20:01:00.000000000 +0200
+++ smart/commands/upgrade.py 2006-09-03 21:47:43.000000000 +0200
@@ -19,7 +19,7 @@
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-from smart.transaction import Transaction, PolicyUpgrade, UPGRADE
+from smart.transaction import Transaction, PolicyUpgrade, PolicyUpgradeWithoutRemove, UPGRADE
from smart.option import OptionParser
from smart.cache import Package
from smart import *
@@ -66,6 +66,8 @@
parser.add_option("--explain", action="store_true",
help=_("include additional information about changes,"
"when possible"))
+ parser.add_option("--dontremove", action="store_true",
+ help=_("don't implicitly remove installed packages"))
parser.add_option("-y", "--yes", action="store_true",
help=_("do not ask for confirmation"))
opts, args = parser.parse_args(argv)
@@ -85,7 +87,10 @@
ctrl.reloadChannels()
cache = ctrl.getCache()
- trans = Transaction(cache, PolicyUpgrade)
+ if opts.dontremove:
+ trans = Transaction(cache, PolicyUpgradeWithoutRemove)
+ else:
+ trans = Transaction(cache, PolicyUpgrade)
if opts.args: