aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-05-27 19:46:25 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-05-27 19:46:25 -0400
commit8209b9955e06f2238c7c4d2732652e7fb0f3c977 (patch)
treeccd0b9488ba95fd0830d9e0ad694c6bae5b81f5a
parentmisc/ldd: add code to search paths (diff)
downloadelfix-8209b9955e06f2238c7c4d2732652e7fb0f3c977.tar.gz
elfix-8209b9955e06f2238c7c4d2732652e7fb0f3c977.tar.bz2
elfix-8209b9955e06f2238c7c4d2732652e7fb0f3c977.zip
misc/ldd: correct logic for ldpaths()
-rwxr-xr-xmisc/ldd/ldd.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/misc/ldd/ldd.py b/misc/ldd/ldd.py
index 4d6f500..c1bcc19 100755
--- a/misc/ldd/ldd.py
+++ b/misc/ldd/ldd.py
@@ -53,15 +53,17 @@ def ldpaths(ld_so_conf='/etc/ld.so.conf'):
paths = []
include_globs = []
- for l in lines:
- if l == '':
+ for i in range(0,len(lines)):
+ if lines[i] == '':
continue
- if l == 'include':
- f = lines[lines.index(l) + 1]
+ if lines[i] == 'include':
+ f = lines[i + 1]
include_globs.append(f)
continue
- if l not in include_globs:
- paths.append(os.path.realpath(l))
+ if lines[i] not in include_globs:
+ real_path = os.path.realpath(lines[i])
+ if os.path.exists(real_path):
+ paths.append(real_path)
include_files = []
for g in include_globs:
@@ -69,13 +71,17 @@ def ldpaths(ld_so_conf='/etc/ld.so.conf'):
for c in include_files:
paths = paths + ldpaths(os.path.realpath(c))
- return list(set(paths))
+ paths = list(set(paths))
+ paths.sort()
+ return paths
def dynamic_dt_needed_paths( dt_needed, eclass, paths):
for n in dt_needed:
for p in paths:
- print('%s' % p + '/' + n)
+ lib = p + os.sep + n
+ if os.path.exists(lib):
+ print('%s' % lib)
return
SCRIPT_DESCRIPTION = 'Print shared library dependencies'
@@ -98,8 +104,6 @@ def main():
sys.exit(0)
paths = ldpaths()
- print(paths)
- sys.exit(0)
for f in args:
with open(f, 'rb') as file: