diff options
author | 2011-10-03 16:00:07 +0000 | |
---|---|---|
committer | 2011-10-03 16:00:07 +0000 | |
commit | 14c641d3404c14cc87c2fa91ddc761d9a804912b (patch) | |
tree | 254d0d066e1b72bef319672c789814cc6ab2748c | |
parent | minor refactoring, fixed an error when deps weren't calculated (diff) | |
download | autodep-14c641d3404c14cc87c2fa91ddc761d9a804912b.tar.gz autodep-14c641d3404c14cc87c2fa91ddc761d9a804912b.tar.bz2 autodep-14c641d3404c14cc87c2fa91ddc761d9a804912b.zip |
apply previous commit to modfied version of emerge
-rw-r--r-- | portage_with_autodep/pym/_emerge/EventsAnalyser.py | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/portage_with_autodep/pym/_emerge/EventsAnalyser.py b/portage_with_autodep/pym/_emerge/EventsAnalyser.py index df7a345..da4ba93 100644 --- a/portage_with_autodep/pym/_emerge/EventsAnalyser.py +++ b/portage_with_autodep/pym/_emerge/EventsAnalyser.py @@ -18,39 +18,51 @@ class PortageUtils: self.metadata_keys = [k for k in portage.auxdbkeys if not k.startswith("UNUSED_")] self.use=self.settings["USE"] - def get_best_visible_pkg(self,pkg): + def get_best_visible_pkg(self,pkg,db="portdb"): """ Gets best candidate on installing. Returns empty string if no found :param pkg: package name + :param db: name of db to look. Can be "vardb" or "portdb" """ try: - return self.portdbapi.xmatch("bestmatch-visible", pkg) + if db=="portdb": + return self.portdbapi.xmatch("bestmatch-visible", pkg) + elif db=="vardb": + return self.vardbapi.match(pkg)[0] + else: + return '' except: return '' # non-recursive dependency getter - def get_dep(self,pkg,dep_type=["RDEPEND","DEPEND"]): + def get_dep(self,pkg,dep_type=["RDEPEND","DEPEND"],db="portdb"): """ Gets current dependencies of a package. Looks in portage db :param pkg: name of package :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or ["RDEPEND", "DEPEND"] + :param db: name of db to look. Can be "vardb" or "portdb" :returns: **set** of packages names """ ret=set() - pkg = self.get_best_visible_pkg(pkg) + pkg = self.get_best_visible_pkg(pkg,db) if not pkg: return ret # we found the best visible match in common tree + if db=="portdb": + aux_get=self.portdbapi.aux_get + elif db=="vardb": + aux_get=self.vardbapi.aux_get + else: + return ret - metadata = dict(zip(self.metadata_keys, - self.portdbapi.aux_get(pkg, self.metadata_keys))) + metadata = dict(zip(self.metadata_keys, aux_get(pkg, self.metadata_keys))) dep_str = " ".join(metadata[k] for k in dep_type) # the IUSE default are very important for us @@ -82,7 +94,7 @@ class PortageUtils: return ret # recursive dependency getter - def get_deps(self,pkg,dep_type=["RDEPEND","DEPEND"]): + def get_deps(self,pkg,dep_type=["RDEPEND","DEPEND"],db="portdb"): """ Gets current dependencies of a package on any depth All dependencies **must** be installed @@ -90,19 +102,20 @@ class PortageUtils: :param pkg: name of package :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or ["RDEPEND", "DEPEND"] + :param db: name of db to look. Can be "vardb" or "portdb" :returns: **set** of packages names """ ret=set() - + import pdb; pdb.set_trace() # get porttree dependencies on the first package - pkg = self.portdbapi.xmatch("bestmatch-visible", pkg) + pkg = self.get_best_visible_pkg(pkg,db) if not pkg: return ret known_packages=set() - unknown_packages=self.get_dep(pkg,dep_type) + unknown_packages=self.get_dep(pkg,dep_type,db) ret=ret.union(unknown_packages) while unknown_packages: @@ -111,36 +124,40 @@ class PortageUtils: continue known_packages.add(p) - metadata = dict(zip(self.metadata_keys, self.vardbapi.aux_get(p, self.metadata_keys))) + current_deps=self.get_dep(p,dep_type,'vardb') + unknown_packages=unknown_packages.union(current_deps) + ret=ret.union(current_deps) + + #metadata = dict(zip(self.metadata_keys, self.vardbapi.aux_get(p, self.metadata_keys))) - dep_str = " ".join(metadata[k] for k in dep_type) + #dep_str = " ".join(metadata[k] for k in dep_type) # the IUSE default are very important for us - iuse_defaults=[ - u[1:] for u in metadata.get("IUSE",'').split() if u.startswith("+")] + #iuse_defaults=[ + # u[1:] for u in metadata.get("IUSE",'').split() if u.startswith("+")] - use=self.use.split() + #use=self.use.split() - for u in iuse_defaults: - if u not in use: - use.append(u) + #for u in iuse_defaults: + # if u not in use: + # use.append(u) - success, atoms = portage.dep_check(dep_str, None, self.settings, - myuse=use, myroot=self.settings["ROOT"], - trees={self.settings["ROOT"]:{"vartree":self.vartree,"porttree": self.vartree}}) - - if not success: - continue - - for atom in atoms: - atomname = self.vartree.dep_bestmatch(atom) - if not atomname: - continue - - for unvirt_pkg in expand_new_virt(self.vardbapi,'='+atomname): - for pkg in self.vartree.dep_match(unvirt_pkg): - ret.add(pkg) - unknown_packages.add(pkg) + #success, atoms = portage.dep_check(dep_str, None, self.settings, + # myuse=use, myroot=self.settings["ROOT"], + # trees={self.settings["ROOT"]:{"vartree":self.vartree,"porttree": self.vartree}}) + + #if not success: + # continue + + #for atom in atoms: + # atomname = self.vartree.dep_bestmatch(atom) + # if not atomname: + # continue + # + # for unvirt_pkg in expand_new_virt(self.vardbapi,'='+atomname): + # for pkg in self.vartree.dep_match(unvirt_pkg): + # ret.add(pkg) + # unknown_packages.add(pkg) return ret def get_deps_for_package_building(self, pkg): @@ -148,10 +165,10 @@ class PortageUtils: returns buildtime dependencies of current package and all runtime dependencies of that buildtime dependencies """ - buildtime_deps=self.get_dep(pkg, ["DEPEND"]) + buildtime_deps=self.get_dep(pkg, ["DEPEND"],"portdb") runtime_deps=set() for dep in buildtime_deps: - runtime_deps=runtime_deps.union(self.get_deps(dep,["RDEPEND"])) + runtime_deps=runtime_deps.union(self.get_deps(dep,["RDEPEND"],"vardb")) ret=buildtime_deps.union(runtime_deps) |