diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2020-02-03 09:09:17 +0000 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2020-02-04 17:13:28 +0000 |
commit | 5e33f7fead59e072506a81df8ca3119a4d84f736 (patch) | |
tree | d74093c865ee63965f35cf66a9aed87489276220 /tests/docker | |
parent | 698a71edbed64473ae239de29bf76ef61b5f8115 (diff) | |
download | qemu-5e33f7fead59e072506a81df8ca3119a4d84f736.zip qemu-5e33f7fead59e072506a81df8ca3119a4d84f736.tar.gz qemu-5e33f7fead59e072506a81df8ca3119a4d84f736.tar.bz2 |
tests/docker: better handle symlinked libs
When we are copying we want to ensure we grab the first
resolution (the found in path section). However even that binary might
be a symlink so lets make sure we chase the symlinks to copy the right
binary to where it can be found.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Robert Foley <robert.foley@linaro.org>
Message-Id: <20200203090932.19147-3-alex.bennee@linaro.org>
Diffstat (limited to 'tests/docker')
-rwxr-xr-x | tests/docker/docker.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 31d8adf..d8268c1 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -106,18 +106,19 @@ def _get_so_libs(executable): """Return a list of libraries associated with an executable. The paths may be symbolic links which would need to be resolved to - ensure theright data is copied.""" + ensure the right data is copied.""" libs = [] - ldd_re = re.compile(r"(/.*/)(\S*)") + ldd_re = re.compile(r"(?:\S+ => )?(\S*) \(:?0x[0-9a-f]+\)") try: ldd_output = subprocess.check_output(["ldd", executable]).decode('utf-8') for line in ldd_output.split("\n"): search = ldd_re.search(line) - if search and len(search.groups()) == 2: - so_path = search.groups()[0] - so_lib = search.groups()[1] - libs.append("%s/%s" % (so_path, so_lib)) + if search: + try: + libs.append(s.group(1)) + except IndexError: + pass except subprocess.CalledProcessError: print("%s had no associated libraries (static build?)" % (executable)) @@ -145,7 +146,8 @@ def _copy_binary_with_libs(src, bin_dest, dest_dir): if libs: for l in libs: so_path = os.path.dirname(l) - _copy_with_mkdir(l, dest_dir, so_path) + real_l = os.path.realpath(l) + _copy_with_mkdir(real_l, dest_dir, so_path) def _check_binfmt_misc(executable): |