diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2011-10-06 15:46:25 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2011-10-08 14:53:27 -0400 |
commit | 1c3eb9ed50bc21b46ac4eb75a96a565163bc5b43 (patch) | |
tree | 634d67de34fabe917607769d421834af7d21e491 | |
parent | poc/paxmark-libs: moved paxmark-libs branch into poc directory (diff) | |
download | elfix-1c3eb9ed50bc21b46ac4eb75a96a565163bc5b43.tar.gz elfix-1c3eb9ed50bc21b46ac4eb75a96a565163bc5b43.tar.bz2 elfix-1c3eb9ed50bc21b46ac4eb75a96a565163bc5b43.zip |
scripts/revdep-pax: organize into functions
-rwxr-xr-x | scripts/revdep-pax | 89 |
1 files changed, 48 insertions, 41 deletions
diff --git a/scripts/revdep-pax b/scripts/revdep-pax index ac21bae..df78e35 100755 --- a/scripts/revdep-pax +++ b/scripts/revdep-pax @@ -1,56 +1,63 @@ #!/usr/bin/env python from os import listdir -#from os import path +#from os import listdir, path import re import pax -var_db_pkg = '/var/db/pkg' - -binaries = {} -for cat in listdir(var_db_pkg): - catdir = '%s/%s' % (var_db_pkg, cat) - for pkg in listdir(catdir): - pkgdir = '%s/%s' % (catdir, pkg) - need = '%s/%s' % (pkgdir, 'NEEDED') - try: - g = open(need, 'r') - needs = g.readlines() - for line in needs: - line = line.strip() - linking = re.split('\s', line) - binary = linking[0] - print binary - library_list = re.split(',', linking[1]) - print "\t%s" % library_list - binaries[binary] = library_list - except: - break -""" Print out mapping: binary -> library, library, library ... -for binary in binaries: - print binary - for library in binaries[binary]: - print "\t", library -""" +def forward_linkings(): + var_db_pkg = '/var/db/pkg' + elf_objects = {} + for cat in listdir(var_db_pkg): + catdir = '%s/%s' % (var_db_pkg, cat) + for pkg in listdir(catdir): + pkgdir = '%s/%s' % (catdir, pkg) + need = '%s/%s' % (pkgdir, 'NEEDED') + try: + g = open(need, 'r') + needs = g.readlines() + for line in needs: + line = line.strip() + linking = re.split('\s', line) + elf = linking[0] + elf_deps = re.split(',', linking[1]) + elf_objects[elf] = elf_deps + except: + break + + return elf_objects + + +def reverse_linkings( binaries ): + libraries = {} + for binary in binaries: + for library in binaries[binary]: + libraries[library] = [] + + for binary in binaries: + for library in binaries[binary]: + libraries[library].append(binary) -libraries = {} -for binary in binaries: - for library in binaries[binary]: - libraries[library] = [] + return libraries -for binary in binaries: - for library in binaries[binary]: - libraries[library].append(binary) + +elf_objects = forward_linkings() +elf_deps = reverse_linkings( elf_objects ) + +""" Print out mapping: binary -> library, library, library ... +for elf in elf_objects: + print elf + for elf_deps in elf_objects[elf]: + print "\t", elf_deps +""" """ Print out mapping: library -> binary, binary, binary ... -for library in libraries: - print library - for binary in libraries[library]: - print "\t", binary +for elf in elf_deps: + print elf + for elf_object in elf_deps[elf]: + print "\t", elf_object #if not path.exists(binary): # print "%s doesn't exist!" % binary """ - - |