packcore: list libraries with ld-linux.so when ldd is unavailable
When the gdb command is not found on the system, packcore could use the
ldd command to list the shared libraries.  When ldd is neither found now
we will try to list the libraries with the `ld-linux.so` directly.
@@ -84,7 +84,14 @@ def _getLibraryListWithLDD(binary):
'/libx32/libnss_files.so.2',
]
- ldd_output = Popen('ldd `which postgres`', shell=True, stdout=PIPE)
+ ldd = which('ldd')
+ if ldd:
+ args = [ldd]
+ else:
+ # simulate ldd with ld-linux.so
+ args = ['/lib64/ld-linux-x86-64.so.2', '--list']
+
+ ldd_output = Popen(args + [binary], stdout=PIPE)
for line in ldd_output.stdout:
match = re.search(r'(\S+) \(0x', line)
if match and match.group(1):
