public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-08-21 18:50 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-08-21 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     e55b567997c501074196392e58ccb2b07f8ef3f5
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sun Aug 21 21:32:25 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sun Aug 21 21:32:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=e55b5679

modified expand_new_virt function, disabled use flag checking

---
 .../package_utils/portage_misc_functions.py        |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index 3889a1f..bff9ce2 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -2,7 +2,7 @@
 # Thanks to Zac Medico <zmedico@gentoo.org> for working example of using an api
 
 import portage
-from portage.dep import Atom, _get_useflag_re
+from portage.dep import Atom
 
 # to not use own emerge option parser. Options may change but I hope 
 # parse_opts function will always be there



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-08-21 18:50 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-08-21 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     cf149aa2d7ded45f578f0438899fd11c74223ee4
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sun Aug 21 21:42:48 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sun Aug 21 21:42:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=cf149aa2

use checking logic changed

---
 .../package_utils/portage_misc_functions.py        |   23 +++++++------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index 2b6d4e1..fd00be9 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -76,22 +76,17 @@ class portage_api:
 			yield atom
 			continue
 
-		valid_iuse = []
-		for x in iuse.split():
-			if x[:1] in ("+", "-"):
-				x = x[1:]
-			valid_iuse.append(x)
-		valid_iuse = frozenset(valid_iuse)
-
-		iuse_implicit_match = vardb.settings._iuse_implicit_match
-		valid_use = []
-		for x in use.split():
-			if x in valid_iuse or iuse_implicit_match(x):
-				valid_use.append(x)
-		valid_use = frozenset(valid_use)
+		iuse_defaults=[
+		  u[1:] for u in iuse.split() if u.startswith("+")]
+
+		use=use.split()
+
+		for u in iuse_defaults:
+		  if u not in use:
+			use.append(u)
 
 		success, atoms = portage.dep_check(rdepend,
-			None, vardb.settings, myuse=valid_use,
+			None, vardb.settings, myuse=use,
 			myroot=vardb.root, trees={vardb.root:{"porttree":vardb.vartree,
 			"vartree":vardb.vartree}})
 



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-08-21 18:50 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-08-21 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     81850d177f2444d470eb72c7eb40570b20bc8b04
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sun Aug 21 21:34:56 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sun Aug 21 21:34:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=81850d17

trivial typo

---
 .../package_utils/portage_misc_functions.py        |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index bff9ce2..2b6d4e1 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -280,7 +280,7 @@ class portage_api:
 		if not atomname:
 		  continue
 		
-		for unvirt_pkg in expand_new_virt('='+atomname):
+		for unvirt_pkg in self.expand_new_virt('='+atomname):
 		  for pkg in self.vartree.dep_match(unvirt_pkg):
 			ret.add(pkg)
 			unknown_packages.add(pkg)



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-08-21 18:50 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-08-21 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     51564746247441766cdfbd7d74860f01477059ef
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sun Aug 21 21:24:28 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sun Aug 21 21:24:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=51564746

add expand_new_virt function from portage

---
 .../package_utils/portage_misc_functions.py        |   80 +++++++++++++++++++-
 1 files changed, 76 insertions(+), 4 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index aa95845..d05c4be 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -2,7 +2,7 @@
 # Thanks to Zac Medico <zmedico@gentoo.org> for working example of using an api
 
 import portage
-from portage.dbapi._expand_new_virt import expand_new_virt
+from portage.dep import Atom, _get_useflag_re
 
 # to not use own emerge option parser. Options may change but I hope 
 # parse_opts function will always be there
@@ -32,6 +32,78 @@ class portage_api:
 	self.metadata_keys = [k for k in portage.auxdbkeys if not k.startswith("UNUSED_")]
 	self.use=self.settings["USE"]
 
+  # This function is from portage and almost unchanged
+  # It is here because old versions of portage not have this function
+  def expand_new_virt(self,atom):
+	"""
+	Iterate over the recursively expanded RDEPEND atoms of
+	a new-style virtual. If atom is not a new-style virtual
+	or it does not match an installed package then it is
+	yielded without any expansion.
+	"""
+	vardb=self.vartree.dbapi
+	
+	if not isinstance(atom, Atom):
+		atom = Atom(atom)
+
+	if not atom.cp.startswith("virtual/"):
+		yield atom
+		return
+
+	traversed = set()
+	stack = [atom]
+
+	while stack:
+		atom = stack.pop()
+		if atom.blocker or \
+			not atom.cp.startswith("virtual/"):
+			yield atom
+			continue
+
+		matches = vardb.match(atom)
+		if not (matches and matches[-1].startswith("virtual/")):
+			yield atom
+			continue
+
+		virt_cpv = matches[-1]
+		if virt_cpv in traversed:
+			continue
+
+		traversed.add(virt_cpv)
+		eapi, iuse, rdepend, use = vardb.aux_get(virt_cpv,
+			["EAPI", "IUSE", "RDEPEND", "USE"])
+		if not portage.eapi_is_supported(eapi):
+			yield atom
+			continue
+
+		# Validate IUSE and IUSE, for early detection of vardb corruption.
+		useflag_re = _get_useflag_re(eapi)
+		valid_iuse = []
+		for x in iuse.split():
+			if x[:1] in ("+", "-"):
+				x = x[1:]
+			if useflag_re.match(x) is not None:
+				valid_iuse.append(x)
+		valid_iuse = frozenset(valid_iuse)
+
+		iuse_implicit_match = vardb.settings._iuse_implicit_match
+		valid_use = []
+		for x in use.split():
+			if x in valid_iuse or iuse_implicit_match(x):
+				valid_use.append(x)
+		valid_use = frozenset(valid_use)
+
+		success, atoms = portage.dep_check(rdepend,
+			None, vardb.settings, myuse=valid_use,
+			myroot=vardb.root, trees={vardb.root:{"porttree":vardb.vartree,
+			"vartree":vardb.vartree}})
+
+		if success:
+			stack.extend(atoms)
+		else:
+			yield atom
+
+
   def get_best_visible_pkg(self,pkg):
 	"""
 	Gets best candidate on installing. Returns empty string if no found
@@ -145,7 +217,7 @@ class portage_api:
 	  if not atomname:
 		continue
 	
-	  for unvirt_pkg in expand_new_virt(self.vartree.dbapi,'='+atomname):
+	  for unvirt_pkg in self.expand_new_virt('='+atomname):
 		for pkg in self.vartree.dep_match(unvirt_pkg):
 		  ret.add(pkg)
 
@@ -211,7 +283,7 @@ class portage_api:
 		if not atomname:
 		  continue
 		
-		for unvirt_pkg in expand_new_virt(self.vartree.dbapi,'='+atomname):
+		for unvirt_pkg in expand_new_virt('='+atomname):
 		  for pkg in self.vartree.dep_match(unvirt_pkg):
 			ret.add(pkg)
 			unknown_packages.add(pkg)
@@ -239,7 +311,7 @@ class portage_api:
 	ret=[]
 	for atom in self.settings.packages:
 	  for pre_pkg in self.vartree.dep_match(atom):
-		for unvirt_pkg in expand_new_virt(self.vartree.dbapi,'='+pre_pkg):
+		for unvirt_pkg in self.expand_new_virt('='+pre_pkg):
 		  for pkg in self.vartree.dep_match(unvirt_pkg):
 			ret.append(pkg)
 	return ret



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-08-21 18:50 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-08-21 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     0c4556b8a25cc0acc00363d4721b676eb4f2e1c8
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Sun Aug 21 21:30:42 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Sun Aug 21 21:30:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=0c4556b8

modified expand_new_virt function, disabled use flag checking

---
 .../package_utils/portage_misc_functions.py        |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index d05c4be..3889a1f 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -76,14 +76,11 @@ class portage_api:
 			yield atom
 			continue
 
-		# Validate IUSE and IUSE, for early detection of vardb corruption.
-		useflag_re = _get_useflag_re(eapi)
 		valid_iuse = []
 		for x in iuse.split():
 			if x[:1] in ("+", "-"):
 				x = x[1:]
-			if useflag_re.match(x) is not None:
-				valid_iuse.append(x)
+			valid_iuse.append(x)
 		valid_iuse = frozenset(valid_iuse)
 
 		iuse_implicit_match = vardb.settings._iuse_implicit_match



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/
@ 2011-10-03 19:44 Александр Берсенев
  0 siblings, 0 replies; 6+ messages in thread
From: Александр Берсенев @ 2011-10-03 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     e541c423ce50003e05b9a154a0893cafe8bd7445
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Mon Oct  3 15:22:30 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Mon Oct  3 15:22:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=e541c423

minor refactoring, fixed an error when deps weren't calculated

---
 .../package_utils/portage_misc_functions.py        |   82 ++++++++------------
 1 files changed, 34 insertions(+), 48 deletions(-)

diff --git a/src/autodep/package_utils/portage_misc_functions.py b/src/autodep/package_utils/portage_misc_functions.py
index 29fcfec..849c9c8 100644
--- a/src/autodep/package_utils/portage_misc_functions.py
+++ b/src/autodep/package_utils/portage_misc_functions.py
@@ -29,7 +29,8 @@ class portage_api:
 	self.vartree=trees[portage.root]['vartree']
 	self.vardb=self.vartree.dbapi
 	self.portdb=portage.portdb
-	self.metadata_keys = [k for k in portage.auxdbkeys if not k.startswith("UNUSED_")]
+	self.metadata_keys = [
+	  k for k in portage.auxdbkeys if not k.startswith("UNUSED_")]
 	self.use=self.settings["USE"]
 
   # This function is from portage and almost unchanged
@@ -96,15 +97,20 @@ class portage_api:
 			yield atom
 
 
-  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.portdb.xmatch("bestmatch-visible", pkg)
+	  if db=="portdb":
+		return self.portdb.xmatch("bestmatch-visible", pkg)
+	  elif db=="vardb":
+		return self.vardb.match(pkg)[0]
+	  else:
+		return ''
 	except:
 	  return ''
 
@@ -164,27 +170,34 @@ class portage_api:
 	  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
+	Gets current dependencies of a package. Looks in portage db by default
 	
 	: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
 	#import pdb; pdb.set_trace()
 
-	metadata = dict(zip(self.metadata_keys, 
-	  self.portdb.aux_get(pkg, self.metadata_keys)))
+	if db=="portdb":
+	  aux_get=self.portdb.aux_get
+	elif db=="vardb":
+	  aux_get=self.vardb.aux_get
+	else:
+	  return ret
+	
+	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
@@ -214,9 +227,9 @@ class portage_api:
 		  ret.add(pkg)
 
 	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
@@ -224,22 +237,21 @@ class portage_api:
 	: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
 	"""
-	#pkg="kde-meta"
-	#print self.vardb.match("<sys-apps/paludis-0.26.0_alpha5")
-	#metadata = dict(zip(self.metadata_keys, self.vardb.aux_get(pkg, self.metadata_keys)))
 	
 	ret=set()
 
     # get porttree dependencies on the first package
 
-	pkg = self.portdb.xmatch("bestmatch-visible", pkg)	
+	pkg = self.get_best_visible_pkg(pkg,db)
 	if not pkg:
 	  return ret
+	#print "doing",pkg
 
 	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:
@@ -249,36 +261,10 @@ class portage_api:
 		continue
 	  known_packages.add(p)
 
-	  metadata = dict(zip(self.metadata_keys, self.vardb.aux_get(p, self.metadata_keys)))
-
-	  dep_str = " ".join(metadata[k] for k in dep_type)
+	  current_deps=self.get_dep(p,dep_type,'vardb')
+	  unknown_packages=unknown_packages.union(current_deps)
+	  ret=ret.union(current_deps)
 
-	  # the IUSE default are very important for us
-	  iuse_defaults=[
-		u[1:] for u in metadata.get("IUSE",'').split() if u.startswith("+")]
-
-	  use=self.use.split()
-
-	  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,
-		trees=portage.db, myroot=self.settings["ROOT"])
-
-	  if not success:
-		continue
-
-	  for atom in atoms:
-		atomname = self.vartree.dep_bestmatch(atom)
-		#print atomname
-		if not atomname:
-		  continue
-		
-		for unvirt_pkg in self.expand_new_virt('='+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):
@@ -286,10 +272,10 @@ class portage_api:
 	  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)
 	return ret



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-03 19:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-21 18:50 [gentoo-commits] proj/autodep:master commit in: src/autodep/package_utils/ Александр Берсенев
  -- strict thread matches above, loose matches on Subject: below --
2011-10-03 19:44 Александр Берсенев
2011-08-21 18:50 Александр Берсенев
2011-08-21 18:50 Александр Берсенев
2011-08-21 18:50 Александр Берсенев
2011-08-21 18:50 Александр Берсенев

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox