From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 116EE1381F3 for ; Mon, 24 Dec 2012 11:01:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 16E0E21C0A2; Mon, 24 Dec 2012 10:59:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C70221C0A2 for ; Mon, 24 Dec 2012 10:59:12 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4D2E233D9F7 for ; Mon, 24 Dec 2012 10:59:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 36B43E545A for ; Mon, 24 Dec 2012 10:59:09 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1356346677.17902e46f4b63ee273a6f3c8af505ae07e9faa21.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:elfix-0.7.x commit in: misc/ X-VCS-Repository: proj/elfix X-VCS-Files: misc/alt-revdep-pax X-VCS-Directories: misc/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 17902e46f4b63ee273a6f3c8af505ae07e9faa21 X-VCS-Branch: elfix-0.7.x Date: Mon, 24 Dec 2012 10:59:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 2aaa610d-d244-4754-a765-748eac26e16d X-Archives-Hash: c2e84968e2e67cbc7f7109827d346e6c commit: 17902e46f4b63ee273a6f3c8af505ae07e9faa21 Author: Anthony G. Basile gentoo org> AuthorDate: Mon Dec 24 02:18:28 2012 +0000 Commit: Anthony G. Basile gentoo 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 )