diff options
author | necoro <> | 2006-12-10 01:05:59 +0000 |
---|---|---|
committer | necoro <> | 2006-12-10 01:05:59 +0000 |
commit | e368eb59dd4f7388fe93387492ef2e12c3993129 (patch) | |
tree | 8b88d52145614d01ff31b28ad16ace39ecca7189 | |
parent | 437364739954d8281ad199e2fa0a9fd57ad8c344 (diff) | |
download | portato-e368eb59dd4f7388fe93387492ef2e12c3993129.tar.gz portato-e368eb59dd4f7388fe93387492ef2e12c3993129.tar.bz2 portato-e368eb59dd4f7388fe93387492ef2e12c3993129.zip |
made slots work for update_world
-rw-r--r-- | doc/Changelog | 1 | ||||
-rw-r--r-- | portato/backend/package.py | 41 | ||||
-rw-r--r-- | portato/backend/portage_helper.py | 99 | ||||
-rw-r--r-- | portato/gui/gtk/windows.py | 4 | ||||
-rw-r--r-- | portato/gui/gui_helper.py | 2 |
5 files changed, 80 insertions, 67 deletions
diff --git a/doc/Changelog b/doc/Changelog index 2e0a987..33af6c1 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,7 @@ - removed gentoolkit-dependency - added support for portage-2.1.2 - added console-status +- working slots (for update_world) 0.5.1: - new config parser and new config-layout diff --git a/portato/backend/package.py b/portato/backend/package.py index 3ff9a79..fc0bd02 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -36,7 +36,6 @@ class Package: if not self._scpv: raise ValueError("invalid cpv: %s" % cpv) - self._db = None self._settings = settings self._settingslock = settingslock @@ -47,8 +46,7 @@ class Package: def is_installed(self): """Returns true if this package is installed (merged)""" - self._initdb() - return os.path.exists(self._db.getpath()) + return vartree.dbapi.cpv_exists(self._cpv) def is_overlay(self): """Returns true if the package is in an overlay.""" @@ -139,13 +137,21 @@ class Package: flags.remove_new_masked(self.get_cpv()) - def get_all_use_flags (self): + def get_all_use_flags (self, installed = False): """Returns a list of _all_ useflags for this package, i.e. all useflags you can set for this package. + @param installed: do not take the ones stated in the ebuild, but the ones it has been installed with + @type installed: boolean + @returns: list of use-flags @rtype: string[]""" - return unique_array(self.get_env_var("IUSE").split()) + if installed: + tree = vartree + else: + tree = porttree + + return unique_array(self.get_env_var("IUSE", tree = tree).split()) def get_installed_use_flags (self): """Returns a list of the useflags enabled at installation time. If package is not installed, it returns an empty list. @@ -332,6 +338,10 @@ class Package: return self.get_category()+"/"+self.get_name() + def get_slot_cp (self): + + return ("%s:%s" % (self.get_cp(), self.get_env_var("SLOT"))) + def get_name(self): """Returns base name of package, no category nor version""" return self._scpv[1] @@ -356,12 +366,9 @@ class Package: self._settingslock.release() return v - def get_ebuild_path(self,in_vartree=0): + def get_ebuild_path(self): """Returns the complete path to the .ebuild file""" - if in_vartree: - return vartree.getebuildpath(self._cpv) - else: - return portage.portdb.findname(self._cpv) + return portage.portdb.findname(self._cpv) def get_package_path(self): """Returns the path to where the ChangeLog, Manifest, .ebuild files reside""" @@ -383,11 +390,9 @@ class Package: return r[0] def get_use_flags(self): - """Returns the USE flags active at time of installation""" - self._initdb() if self.is_installed(): - return self._db.getfile("USE") - return "" + return self.get_env_var("USE", tree = vartree) + else: return "" def compare_version(self,other): """Compares this package's version to another's CPV; returns -1, 0, 1""" @@ -403,14 +408,6 @@ class Package: else: return portage.pkgcmp(v1[1:],v2[1:]) - def _initdb(self): - """Internal helper function; loads package information from disk, - when necessary""" - if not self._db: - cat = self.get_category() - pnv = self.get_name()+"-"+self.get_version() - self._db = portage.dblink(cat, pnv, self._settings["ROOT"], self._settings) - def matches (self, criterion): """This checks, whether this package matches a specific verisioning criterion - e.g.: "<=net-im/foobar-1.2". diff --git a/portato/backend/portage_helper.py b/portato/backend/portage_helper.py index 814a0bb..9c171b4 100644 --- a/portato/backend/portage_helper.py +++ b/portato/backend/portage_helper.py @@ -45,6 +45,10 @@ def geneticize_list (list_of_packages): return [package.Package(x) for x in list_of_packages] +def find_best (list): + + return package.Package(portage.best(list)) + def find_best_match (search_key, only_installed = False): """Finds the best match in the portage tree. It does not find masked packages! @@ -249,29 +253,6 @@ def find_all_system_packages (name=None): sys = unique_array(sys) return geneticize_list(sys) -def get_all_versions (cp): - """Returns all versions of a certain package. - - @param cp: the package - @type cp: string (cat/pkg) - @returns: the list of found packages - @rtype: backend.Package[]""" - - t = porttree.dbapi.cp_list(cp) - t += vartree.dbapi.cp_list(cp) - t = unique_array(t) - return geneticize_list(t) - -def get_all_installed_versions (cp): - """Returns all installed versions of a certain package. - - @param cp: the package - @type cp: string (cat/pkg) - @returns: the list of found packages - @rtype: backend.Package[]""" - - return geneticize_list(vartree.dbapi.cp_list(cp)) - def list_categories (name=None): """Finds all categories matching a name or all if no name is specified. @@ -344,14 +325,34 @@ def update_world (newuse = False, deep = False): # Remove everything that is package.provided from our list # This is copied from emerge.getlist() - for atom in packages[:]: - for expanded_atom in portage.flatten(portage.dep_virtual([atom], settings)): - mykey = portage.dep_getkey(expanded_atom) - if mykey in settings.pprovideddict and portage.match_from_list(expanded_atom, settings.pprovideddict[mykey]): - packages.remove(atom) - break - - packages = [find_best_match(x) for x in packages] + #for atom in packages[:]: + # for expanded_atom in portage.flatten(portage.dep_virtual([atom], settings)): + # mykey = portage.dep_getkey(expanded_atom) + # if mykey in settings.pprovideddict and portage.match_from_list(expanded_atom, settings.pprovideddict[mykey]): + # packages.remove(atom) + # break + + + def get_new_packages (packages): + new_packages = [] + for p in packages: + inst = find_installed_packages(p) + if len(inst) > 1: + myslots = set() + for i in inst: # get the slots of the installed packages + myslots.add(i.get_env_var("SLOT")) + + myslots.add(find_best_match(p).get_env_var("SLOT")) # add the slot of the best package in portage + for slot in myslots: + new_packages.append(\ + find_best(\ + [x.get_cpv() for x in find_packages("%s:%s" % (i.get_cp(), slot))]\ + )) + else: + new_packages.append(find_best_match(p)) + + return new_packages + checked = [] updating = [] @@ -365,9 +366,9 @@ def update_world (newuse = False, deep = False): tempDeep = False if not p.is_installed(): - oldList = find_installed_packages(p.get_cp()) + oldList = find_installed_packages(p.get_slot_cp()) if oldList: - old = oldList[0] # assume we have only one there; FIXME: slotted packages + old = oldList[0] # we should only have one package here - else it is a bug else: debug("Bug? Not found installed one:",p.get_cp()) return @@ -376,26 +377,40 @@ def update_world (newuse = False, deep = False): p = old if newuse: - old = p.get_installed_use_flags() - new = p.get_settings("USE").split() + + new = set(p.get_all_use_flags(False)) # IUSE in the ebuild + old = set(p.get_all_use_flags(True)) # IUSE in the vardb + if old != new: + debug(p.get_cpv(),"old:",old) + debug(p.get_cpv(),"new:",new) + tempDeep = True + if not appended: + updating.append((p,p)) + appended = True - for u in p.get_all_use_flags(): - if (u in new) != (u in old): - if not appended: - updating.append((p,p)) + else: + old = p.get_installed_use_flags() + new = p.get_settings("USE").split() + + for u in p.get_all_use_flags(): + if (u in new) != (u in old): tempDeep = True + if not appended: + updating.append((p,p)) + appended = True + break if deep or tempDeep: for i in p.get_matched_dep_packages(): if i not in raw_checked: raw_checked.append(i) - bm = find_best_match(i) + bm = get_new_packages([i]) if not bm: debug("Bug? No best match could be found:",i) else: - check(bm) + for p in bm: check(p) - for p in packages: + for p in get_new_packages(packages): if not p: continue # if a masked package is installed we have "None" here check(p) diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 65a9f3f..b0bd803 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -282,8 +282,8 @@ class PackageTable: self.instantChange = instantChange # packages and installed packages - self.packages = backend.sort_package_list(backend.get_all_versions(cp)) - self.instPackages = backend.sort_package_list(backend.get_all_installed_versions(cp)) + self.packages = backend.sort_package_list(backend.find_packages(cp)) + self.instPackages = backend.sort_package_list(backend.find_installed_packages(cp)) # version-combo-box self.vCombo = self.build_vers_combo() diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 0529767..4fb4dba 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -336,7 +336,7 @@ class EmergeQueue: try: pkg = self._get_pkg_from_cpv(cpv, unmask) if not pkg.is_installed(): - old = backend.get_all_installed_versions(pkg.get_cp()) + old = backend.find_installed_packages(pkg.get_slot_cp()) if old: old = old[0] # assume we have only one there; FIXME: slotted packages update = True |