From 40eaa80dce320c6e64e66d96ec28c9fc532c061c Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sun, 15 Oct 2006 16:13:37 +0000 Subject: First implementation of "emerge --update world" --- geneticone/backend/__init__.py | 4 ++-- geneticone/backend/portage_helper.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'geneticone/backend') diff --git a/geneticone/backend/__init__.py b/geneticone/backend/__init__.py index 5238765..dbebd17 100644 --- a/geneticone/backend/__init__.py +++ b/geneticone/backend/__init__.py @@ -19,8 +19,8 @@ import gentoolkit import portage # this is set to "var/lib/portage/world" by default - so we add the leading / -portage.WORLD_FILE = "/"+portage.WORLD_FILE -portage.settings = None +portage.WORLD_FILE = portage.settings["ROOT"]+portage.WORLD_FILE +portage.settings = None # we use our own one ... # portage tree vars porttree = gentoolkit.porttree diff --git a/geneticone/backend/portage_helper.py b/geneticone/backend/portage_helper.py index 37a2b91..df0275f 100644 --- a/geneticone/backend/portage_helper.py +++ b/geneticone/backend/portage_helper.py @@ -236,6 +236,34 @@ def reload_settings (): """Reloads portage.""" gentoolkit.settings = portage.config(config_incrementals = copy.deepcopy(gentoolkit.settings.incrementals)) +def update_world (newuse = False, deep = False): + """Calculates the packages to get updated in an update world. + + @param newuse: Checks if a use-flag has a different state then to install time. + @type newuse: boolean + @param deep: Not only check world packages but also there dependencies. + @type deep: boolean + @returns: a list containing of the tuple (new_package, old_package) + @rtype: (backend.Package, backend.Package)[]""" + + world = open(portage.WORLD_FILE) + packages = [] + for line in world: + line = line.strip() + if not len(line): continue # empty line + if line[0] == "#": continue + packages.append(find_best_match(line)) + world.close() + + 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 + updating.append((p, old)) + + return updating + use_descs = {} local_use_descs = {} def get_use_desc (flag, package = None): -- cgit v1.2.3-70-g09d2