qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Robert Foley" <robert.foley@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>
Cc: fam@euphon.net, berrange@redhat.com, stefanb@linux.vnet.ibm.com,
	Richard Henderson <richard.henderson@linaro.org>,
	f4bug@amsat.org, qemu-devel@nongnu.org, cota@braap.org,
	stefanha@redhat.com, pbonzini@redhat.com,
	marcandre.lureau@redhat.com, aurelien@aurel32.net
Subject: Re: [PATCH v2 02/12] tests/docker: better handle symlinked libs
Date: Thu, 30 Jan 2020 15:59:11 +0100	[thread overview]
Message-ID: <95cdd5d6-d7da-8fdc-926a-bff3feda2257@redhat.com> (raw)
In-Reply-To: <CAEyhzFugFgAuy=r+JsoTxzqYWxTB6LAnETBWS4ubMOmbjrFP3w@mail.gmail.com>

On 1/30/20 3:37 PM, Robert Foley wrote:
> Hi,
> I was looking at this patch and have a comment about the number of
> groups that are expected to be found by this regex.
> It seems like the old code expected two groups to be found otherwise
> it will not append the library to the found libs.
> def _get_so_libs(executable):
>      libs = []
>      ldd_re = re.compile(r"(/.*/)(\S*)")
>      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))

Yes you are right, this part need change to handle a single group now.

> 
> I did a bit of experimenting with output from ldd and found a few
> strings where the new regex seems
> to generate only one group for the entire path+lib rather than one group
> for the path and another group for the lib.
> 
> $ ldd build/aarch64-softmmu/qemu-system-aarch64
> __snip__
>        /lib/ld-linux-aarch64.so.1 (0x0000ffff9c41f000)
>        libgmodule-2.0.so.0 =>
> /usr/lib/aarch64-linux-gnu/libgmodule-2.0.so.0 (0x0000ffff9a96e000)
> __snip
> $ python3
> Python 3.6.8 (default, Oct  7 2019, 12:59:55)
> [GCC 8.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import re
>>>> ldd_re = re.compile(r"(?:\S+ => )?(\S*) \(:?0x[0-9a-f]+\)")
>>>> a = "/lib/ld-linux-aarch64.so.1 (0x0000ffff9c41f000)"
>>>> b = "libgmodule-2.0.so.0 => /usr/lib/aarch64-linux-gnu/libgmodule-2.0.so.0 (0x0000ffff9a96e000)"
>>>> ldd_re.search(a).groups()
> ('/lib/ld-linux-aarch64.so.1',)
>>>> ldd_re.search(b).groups()
> ('/usr/lib/aarch64-linux-gnu/libgmodule-2.0.so.0',)
>>>> len(ldd_re.search(a).groups())
> 1
>>>> len(ldd_re.search(b).groups())
> 1
>>>> ldd_re_old = re.compile('(/.*/)(\S*)')
>>>> ldd_re_old.search(a).groups()
> ('/lib/', 'ld-linux-aarch64.so.1')
>>>> ldd_re_old.search(b).groups()
> ('/usr/lib/aarch64-linux-gnu/', 'libgmodule-2.0.so.0')
>>>> len(ldd_re_old.search(a).groups())
> 2
>>>> len(ldd_re_old.search(b).groups())
> 2
>>>>
> 
> Thanks & Regards,
> -Rob
> 
> On Thu, 30 Jan 2020 at 06:40, Alex Bennée <alex.bennee@linaro.org> wrote:
>>
>> 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>
>> ---
>>   tests/docker/docker.py | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>> diff --git a/tests/docker/docker.py b/tests/docker/docker.py
>> index 31d8adf836..7dfca63fe4 100755
>> --- a/tests/docker/docker.py
>> +++ b/tests/docker/docker.py
>> @@ -109,7 +109,7 @@ def _get_so_libs(executable):
>>       ensure theright 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"):
>> @@ -145,7 +145,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):
>> --
>> 2.20.1
>>
> 



  reply	other threads:[~2020-01-30 15:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 14:37 [PATCH v2 02/12] tests/docker: better handle symlinked libs Robert Foley
2020-01-30 14:59 ` Philippe Mathieu-Daudé [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-01-30 11:32 [PATCH v2 00/12] testing/next (with build fixes!) Alex Bennée
2020-01-30 11:32 ` [PATCH v2 02/12] tests/docker: better handle symlinked libs Alex Bennée
2020-01-31 15:58   ` Philippe Mathieu-Daudé
2020-01-31 16:48     ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95cdd5d6-d7da-8fdc-926a-bff3feda2257@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=berrange@redhat.com \
    --cc=cota@braap.org \
    --cc=f4bug@amsat.org \
    --cc=fam@euphon.net \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=robert.foley@linaro.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).