summaryrefslogtreecommitdiff
path: root/geneticone/backend
diff options
context:
space:
mode:
authornecoro <>2006-10-15 21:42:18 +0000
committernecoro <>2006-10-15 21:42:18 +0000
commit48fa7e6ef10bcc87e263f1c52d7430bafa23fe21 (patch)
treebed61c8c997d1f4202b0abadb8ad678570bb713c /geneticone/backend
parent501571fadc81be83017968b098fb05b73a6043b1 (diff)
downloadportato-48fa7e6ef10bcc87e263f1c52d7430bafa23fe21.tar.gz
portato-48fa7e6ef10bcc87e263f1c52d7430bafa23fe21.tar.bz2
portato-48fa7e6ef10bcc87e263f1c52d7430bafa23fe21.zip
Second level of "emerge --update"
Diffstat (limited to '')
-rw-r--r--geneticone/backend/package.py57
-rw-r--r--geneticone/backend/portage_helper.py33
2 files changed, 84 insertions, 6 deletions
diff --git a/geneticone/backend/package.py b/geneticone/backend/package.py
index da2a131..8991117 100644
--- a/geneticone/backend/package.py
+++ b/geneticone/backend/package.py
@@ -14,9 +14,11 @@ from geneticone.helper import *
from portage_helper import *
import flags
-import portage, gentoolkit
+import portage, portage_dep, gentoolkit
from portage_util import unique_array
+import types
+
class Package (gentoolkit.Package):
"""This is a subclass of the gentoolkit.Package-class which a lot of additional functionality we need in Genetic/One."""
@@ -172,6 +174,58 @@ class Package (gentoolkit.Package):
flags.remove_new_use_flags(self)
+ def get_matched_dep_packages (self):
+ """This function looks for all dependencies which are resolved. In normal case it makes only sense for installed packages, but should work for uninstalled ones too.
+
+ @returns: unique list of dependencies resolved (with elements like "<=net-im/foobar-1.2.3")
+ @rtype: string[]"""
+
+ # change the useflags, because we have internally changed some, but not made them visible for portage
+ newUseFlags = self.get_new_use_flags()
+ actual = self.get_settings("USE").split()
+ if newUseFlags:
+ for u in newUseFlags:
+ if u[0] == "-" and flags.invert_use_flag(u) in actual:
+ actual.remove(flags.invert_use_flag(u))
+ elif u not in actual:
+ actual.append(u)
+
+ #
+ # the following stuff is mostly adapted from portage.dep_check()
+ #
+
+ depstring = self.get_env_var("RDEPEND")+" "+self.get_env_var("DEPEND")+" "+self.get_env_var("PDEPEND")
+
+ # change the parentheses into lists
+ mysplit = portage_dep.paren_reduce(depstring)
+
+ # strip off these deps we don't have a flag for
+ mysplit = portage_dep.use_reduce(mysplit, uselist = actual, masklist = [], matchall = False, excludeall = self.get_settings("ARCH"))
+
+ # move the || (or) into the lists
+ mysplit = portage_dep.dep_opconvert(mysplit)
+
+ # turn virtuals into real packages
+ mysplit = portage.dep_virtual(mysplit, self._settings)
+
+ mysplit_reduced= portage.dep_wordreduce(mysplit, self._settings, vartree.dbapi, mode = None)
+
+ retlist = []
+ def add (list, red_list):
+ """Adds the packages to retlist."""
+ for i in range(len(list)):
+ if type(list[i]) == types.ListType:
+ add(list[i], red_list[i])
+ elif list[i] == "||":
+ continue
+ else:
+ if red_list[i]:
+ retlist.append(list[i])
+
+ add(mysplit, mysplit_reduced)
+
+ return unique_array(retlist)
+
def get_dep_packages (self):
"""Returns a cpv-list of packages on which this package depends and which have not been installed yet. This does not check the dependencies in a recursive manner.
@@ -188,7 +242,6 @@ class Package (gentoolkit.Package):
newUseFlags = self.get_new_use_flags()
actual = self.get_settings("USE").split()
if newUseFlags:
- depUses = []
for u in newUseFlags:
if u[0] == "-" and flags.invert_use_flag(u) in actual:
actual.remove(flags.invert_use_flag(u))
diff --git a/geneticone/backend/portage_helper.py b/geneticone/backend/portage_helper.py
index df0275f..9faf953 100644
--- a/geneticone/backend/portage_helper.py
+++ b/geneticone/backend/portage_helper.py
@@ -17,6 +17,8 @@ from portage_util import unique_array
from geneticone.backend import *
import package
+from geneticone.helper import debug
+
def find_lambda (name):
"""Returns the function needed by all the find_all_*-functions. Returns None if no name is given.
@@ -246,6 +248,7 @@ def update_world (newuse = False, deep = False):
@returns: a list containing of the tuple (new_package, old_package)
@rtype: (backend.Package, backend.Package)[]"""
+ # read world file
world = open(portage.WORLD_FILE)
packages = []
for line in world:
@@ -255,13 +258,35 @@ def update_world (newuse = False, deep = False):
packages.append(find_best_match(line))
world.close()
+ checked = []
updating = []
- for p in packages:
- if not p: continue # if a masked package is installed we have "None" here
- if not p.is_installed():
- old = find_installed_packages(p.get_cp())[0] # assume we have only one there; FIXME: slotted packages
+ def check (p, deep = False):
+ """Checks whether a package is updated or not."""
+ if p.get_cp() in checked: return
+ else: checked.append(p.get_cp())
+
+ if not p.is_installed():
+ old = find_installed_packages(p.get_cp())
+ if old:
+ old = old[0] # assume we have only one there; FIXME: slotted packages
+ else:
+ debug("Bug? Not found installed one:",p.get_cp())
+ return
updating.append((p, old))
+ p = old
+
+ if deep:
+ for i in p.get_matched_dep_packages():
+ bm = find_best_match(i)
+ if not bm:
+ debug("Bug? No best match could be found:",i)
+ else:
+ check(bm, deep)
+ for p in packages:
+ if not p: continue # if a masked package is installed we have "None" here
+ check(p, deep)
+
return updating
use_descs = {}