public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:elfix-0.7.x commit in: misc/
Date: Mon, 24 Dec 2012 10:59:09 +0000 (UTC)	[thread overview]
Message-ID: <1356346677.17902e46f4b63ee273a6f3c8af505ae07e9faa21.blueness@gentoo> (raw)

commit:     17902e46f4b63ee273a6f3c8af505ae07e9faa21
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 24 02:18:28 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Dec 24 10:57:57 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=17902e46

misc/alt-revdep-pax: read NEEDED.ELF.2 via portage

---
 misc/alt-revdep-pax |   67 +++++++++++++++++++--------------------------------
 1 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/misc/alt-revdep-pax b/misc/alt-revdep-pax
index f35a9ea..69086af 100755
--- a/misc/alt-revdep-pax
+++ b/misc/alt-revdep-pax
@@ -31,6 +31,7 @@ import os
 import sys
 import re
 import pax
+import portage
 
 
 """ python2/3 compat input """
@@ -51,32 +52,20 @@ Here the sonames were obtained from the ELF object by scanelf -nm
 """
 def get_object_needed():
 
-	"""
-	import portage
 	vardb = portage.db[portage.root]["vartree"].dbapi
-	vardb.aux_get('sys-apps/coreutils-8.20', ['NEEDED.ELF.2'])
-	vardb.cpv_all() # list of all packages
-	"""
-
-	var_db_pkg = '/var/db/pkg'
 
 	object_needed = {}
-	for cat in os.listdir(var_db_pkg):
-		catdir = '%s/%s' % (var_db_pkg, cat)
-		for pkg in os.listdir(catdir):
-			pkgdir = '%s/%s' % (catdir, pkg)
-			need = '%s/%s' % (pkgdir, 'NEEDED.ELF.2')
-			try:
-				g = open(need, 'r')
-				needs = g.readlines()
-				for line in needs:
-					line = line.strip()
-					link = re.split(';', line)
-					elf = link[1]
-					sonames = re.split(',', link[4])
-					object_needed[elf] = sonames
-			except IOError:
-				continue #File probably doesn't exist, which is okay
+
+	for pkg in vardb.cpv_all():
+		needs = vardb.aux_get(pkg, ['NEEDED.ELF.2'])[0].strip()
+		if not needs:			#skip empty lines
+			continue
+		lines = re.split('\n', needs)
+		for line in lines:
+			link = re.split(';', line)
+			elf = link[1]
+			sonames = re.split(',', link[4])
+			object_needed[elf] = sonames
 
 	return object_needed
 
@@ -92,29 +81,23 @@ and its inverse which has structure
 """
 def get_libraries():
 
-	var_db_pkg = '/var/db/pkg'
+	vardb = portage.db[portage.root]["vartree"].dbapi
 
 	library2soname = {}
 	soname2library = {}
 
-	for cat in os.listdir(var_db_pkg):
-		catdir = '%s/%s' % (var_db_pkg, cat)
-		for pkg in os.listdir(catdir):
-			pkgdir = '%s/%s' % (catdir, pkg)
-			need = '%s/%s' % (pkgdir, 'NEEDED.ELF.2')
-			try:
-				g = open(need, 'r')
-				needs = g.readlines()
-				for line in needs:
-					line = line.strip()
-					link = re.split(';', line)
-					elf = link[1]
-					soname = link[2]
-					if soname:				#no soname => executable
-						library2soname[elf] = soname
-						soname2library[soname] = elf
-			except IOError:
-				continue #File probably doesn't exist, which is okay
+	for pkg in vardb.cpv_all():
+		needs = vardb.aux_get(pkg, ['NEEDED.ELF.2'])[0].strip()
+		if not needs:			#skip empty lines
+			continue
+		lines = re.split('\n', needs)
+		for line in lines:
+			link = re.split(';', line)
+			elf = link[1]
+			soname = link[2]
+			if soname:				#no soname => executable
+				library2soname[elf] = soname
+				soname2library[soname] = elf
 
 	return ( library2soname, soname2library )
 


             reply	other threads:[~2012-12-24 11:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24 10:59 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-12-29  1:29 [gentoo-commits] proj/elfix:elfix-0.7.x commit in: misc/ Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-29  1:16 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1356346677.17902e46f4b63ee273a6f3c8af505ae07e9faa21.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox