summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-05-01 04:17:34 +0000
committerZac Medico <zmedico@gentoo.org>2008-05-01 04:17:34 +0000
commit63237ba756d7c17f97dd84a372925b00d8cc136e (patch)
tree008606ca587ee829e6c7c926f428ef62c125c6f3 /pym
parenta08eee91d7f42f30c836cfe36680741479d46c27 (diff)
downloadportage-63237ba756d7c17f97dd84a372925b00d8cc136e.tar.gz
portage-63237ba756d7c17f97dd84a372925b00d8cc136e.tar.bz2
portage-63237ba756d7c17f97dd84a372925b00d8cc136e.zip
* Add a Package.operation attribute and use it to distinguish "uninstall"
operations. svn path=/main/trunk/; revision=10050
Diffstat (limited to 'pym')
-rw-r--r--pym/_emerge/__init__.py64
1 files changed, 27 insertions, 37 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 06c034dd7..794abddd8 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1268,7 +1268,8 @@ class Blocker(Task):
class Package(Task):
__slots__ = ("built", "cpv", "depth",
- "installed", "metadata", "root", "onlydeps", "type_name",
+ "installed", "metadata", "onlydeps", "operation",
+ "root", "type_name",
"cp", "cpv_slot", "pv_split", "slot_atom")
def __init__(self, **kwargs):
Task.__init__(self, **kwargs)
@@ -1280,11 +1281,12 @@ class Package(Task):
def _get_hash_key(self):
hash_key = getattr(self, "_hash_key", None)
if hash_key is None:
- operation = "merge"
- if self.onlydeps or self.installed:
- operation = "nomerge"
+ if self.operation is None:
+ self.operation = "merge"
+ if self.onlydeps or self.installed:
+ self.operation = "nomerge"
self._hash_key = \
- (self.type_name, self.root, self.cpv, operation)
+ (self.type_name, self.root, self.cpv, self.operation)
return self._hash_key
def __lt__(self, other):
@@ -1315,15 +1317,6 @@ class Package(Task):
return True
return False
-class Uninstall(Package):
- __slots__ = ()
- def _get_hash_key(self):
- hash_key = getattr(self, "_hash_key", None)
- if hash_key is None:
- self._hash_key = \
- (self.type_name, self.root, self.cpv, "uninstall")
- return self._hash_key
-
class DependencyArg(object):
def __init__(self, arg=None, root_config=None):
self.arg = arg
@@ -3370,9 +3363,10 @@ class depgraph(object):
if not unresolved_blocks and depends_on_order:
for inst_pkg, inst_task in depends_on_order:
- uninst_task = Uninstall(built=inst_pkg.built,
+ uninst_task = Package(built=inst_pkg.built,
cpv=inst_pkg.cpv, installed=inst_pkg.installed,
- metadata=inst_pkg.metadata, root=inst_pkg.root,
+ metadata=inst_pkg.metadata,
+ operation="uninstall", root=inst_pkg.root,
type_name=inst_pkg.type_name)
self._pkg_cache[uninst_task] = uninst_task
# Enforce correct merge order with a hard dep.
@@ -3485,7 +3479,8 @@ class depgraph(object):
since those should be executed as late as possible.
"""
return [node for node in mygraph.leaf_nodes(**kwargs) \
- if not isinstance(node, Uninstall)]
+ if isinstance(node, Package) and \
+ node.operation != "uninstall"]
if True:
for node in mygraph.order:
if node.root == "/" and \
@@ -3812,7 +3807,8 @@ class depgraph(object):
# and uninstallation tasks.
solved_blockers = set()
uninst_task = None
- if isinstance(node, Uninstall):
+ if isinstance(node, Package) and \
+ "uninstall" == node.operation:
have_uninstall_task = True
uninst_task = node
else:
@@ -3842,7 +3838,8 @@ class depgraph(object):
if node[-1] != "nomerge":
retlist.append(node)
- if isinstance(node, Uninstall):
+ if isinstance(node, Package) and \
+ "uninstall" == node.operation:
# Include satisfied blockers in the merge list so
# that the user can see why the package had to be
# uninstalled in advance rather than through
@@ -4796,13 +4793,10 @@ class depgraph(object):
metadata["USE"] = pkgsettings["PORTAGE_USE"]
installed = action == "uninstall"
built = pkg_type != "ebuild"
- if installed:
- pkg_constructor = Uninstall
- else:
- pkg_constructor = Package
- pkg = pkg_constructor(built=built, cpv=pkg_key,
+ pkg = Package(built=built, cpv=pkg_key,
installed=installed, metadata=metadata,
- root=myroot, type_name=pkg_type)
+ operation=action, root=myroot,
+ type_name=pkg_type)
self._pkg_cache[pkg] = pkg
fakedb[myroot].cpv_inject(pkg)
self.spinner.update()
@@ -5199,7 +5193,7 @@ class MergeTask(object):
if "--resume" not in self.myopts:
mymergelist = mylist
mtimedb["resume"]["mergelist"] = [list(x) for x in mymergelist \
- if isinstance(x, (Package, Uninstall))]
+ if isinstance(x, Package)]
mtimedb.commit()
myfeat = self.settings.features[:]
@@ -5256,11 +5250,9 @@ class MergeTask(object):
mymergelist = [x for x in mymergelist if x[-1] == "merge"]
mergecount=0
for x in task_list:
- pkg_type = x[0]
- if pkg_type == "blocks":
+ if x[0] == "blocks":
continue
- myroot=x[1]
- pkg_key = x[2]
+ pkg_type, myroot, pkg_key, operation = x
pkgindex=2
built = pkg_type != "ebuild"
installed = pkg_type == "installed"
@@ -5296,14 +5288,12 @@ class MergeTask(object):
# isn't installed anymore. Since it's already
# been uninstalled, move on to the next task.
continue
- if installed:
- pkg_constructor = Uninstall
- else:
- pkg_constructor = Package
+ if not installed:
mergecount += 1
- pkg = pkg_constructor(type_name=pkg_type, root=myroot,
- cpv=pkg_key, built=built, installed=installed,
- metadata=metadata)
+ pkg = Package(cpv=pkg_key, built=built,
+ installed=installed, metadata=metadata,
+ operation=operation, root=myroot,
+ type_name=pkg_type)
if pkg.installed:
if not (buildpkgonly or fetchonly or pretend):
self._uninstall_queue.append(pkg)