diff mbox

[1/2] check-host-rpath: support symlinks in rpath

Message ID 1475230194-18524-2-git-send-email-jezz@sysmic.org
State Rejected
Headers show

Commit Message

Jérôme Pouiller Sept. 30, 2016, 10:09 a.m. UTC
If compilation path contains symlinks, rpath may sometime contains
symlinks and sometime canonicalized path.

A pratical example:

  $ ln -s /opt/buildroot /opt/buildroot-symblink
  $ cd /opt/buildroot-symlink
  $ make O=out
  $ make -C out package-rebuild

This last command produce an error since already installed host binaries
contains /opt/buildroot/out/host/usr/lib as rpath while check-host-rpath expect
/opt/buildroot-symlink/out/host/usr/lib

This patch canonicalize all paths used in check-host-rpath in order to avoid
problem

Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
---
 support/scripts/check-host-rpath | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Arnout Vandecappelle Oct. 4, 2016, 9:33 p.m. UTC | #1
On 30-09-16 12:09, Jérôme Pouiller wrote:
> If compilation path contains symlinks, rpath may sometime contains
> symlinks and sometime canonicalized path.
> 
> A pratical example:
> 
>   $ ln -s /opt/buildroot /opt/buildroot-symblink
>   $ cd /opt/buildroot-symlink
>   $ make O=out
>   $ make -C out package-rebuild
> 
> This last command produce an error since already installed host binaries
> contains /opt/buildroot/out/host/usr/lib as rpath while check-host-rpath expect
> /opt/buildroot-symlink/out/host/usr/lib
> 
> This patch canonicalize all paths used in check-host-rpath in order to avoid
> problem

 Wouldn't this also be fixed by http://patchwork.ozlabs.org/patch/613854/ ? With
that patch (series) applied, there shouldn't be any symlinks anymore once the
real make starts.

 Note that I still had remarks on that specific patch and Samuel hasn't respun.
Maybe something for in Berlin.


 Regards,
 Arnout

> 
> Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
> ---
>  support/scripts/check-host-rpath | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath
> index 6ce547c..2541e53 100755
> --- a/support/scripts/check-host-rpath
> +++ b/support/scripts/check-host-rpath
> @@ -13,8 +13,8 @@ main() {
>      local hostdir="${2}"
>      local file ret
>  
> -    # Remove duplicate and trailing '/' for proper match
> -    hostdir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${hostdir}" )"
> +    # Canonicalize path: follow symlinks, remove duplicate and trailing '/'
> +    hostdir="$( readlink -m "${hostdir}" )"
>  
>      ret=0
>      while read file; do
> @@ -56,8 +56,8 @@ check_elf_has_rpath() {
>  
>      while read rpath; do
>          for dir in ${rpath//:/ }; do
> -            # Remove duplicate and trailing '/' for proper match
> -            dir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )"
> +            # Canonicalize path: follow symlinks, remove duplicate and trailing '/'
> +            dir="$( readlink -m "${dir}" )"
>              [ "${dir}" = "${hostdir}/usr/lib" ] && return 0
>          done
>      done < <( readelf -d "${file}"                                              \
>
Jérôme Pouiller Oct. 5, 2016, 8:54 a.m. UTC | #2
Hi Arnout,

On Tuesday 04 October 2016 23:33:34 Arnout Vandecappelle wrote:
> On 30-09-16 12:09, Jérôme Pouiller wrote:
> > If compilation path contains symlinks, rpath may sometime contains
> > symlinks and sometime canonicalized path.
> > 
> > A pratical example:
> >   $ ln -s /opt/buildroot /opt/buildroot-symblink
> >   $ cd /opt/buildroot-symlink
> >   $ make O=out
> >   $ make -C out package-rebuild
> > 
> > This last command produce an error since already installed host
> > binaries contains /opt/buildroot/out/host/usr/lib as rpath while
> > check-host-rpath expect /opt/buildroot-symlink/out/host/usr/lib
> > 
> > This patch canonicalize all paths used in check-host-rpath in order
> > to avoid problem
> 
>  Wouldn't this also be fixed by
> http://patchwork.ozlabs.org/patch/613854/ ? With that patch (series)
> applied, there shouldn't be any symlinks anymore once the real make
> starts.

I didn't saw Samuel's patch. I will test it soon. I think it supersede 
mine.

BR,
Arnout Vandecappelle Oct. 16, 2016, 10:58 a.m. UTC | #3
Hi Jerome,

On 05-10-16 10:54, Jérôme Pouiller wrote:
> Hi Arnout,
> 
> On Tuesday 04 October 2016 23:33:34 Arnout Vandecappelle wrote:
>> On 30-09-16 12:09, Jérôme Pouiller wrote:
>>> If compilation path contains symlinks, rpath may sometime contains
>>> symlinks and sometime canonicalized path.
>>>
>>> A pratical example:
>>>   $ ln -s /opt/buildroot /opt/buildroot-symblink
>>>   $ cd /opt/buildroot-symlink
>>>   $ make O=out
>>>   $ make -C out package-rebuild
>>>
>>> This last command produce an error since already installed host
>>> binaries contains /opt/buildroot/out/host/usr/lib as rpath while
>>> check-host-rpath expect /opt/buildroot-symlink/out/host/usr/lib
>>>
>>> This patch canonicalize all paths used in check-host-rpath in order
>>> to avoid problem
>>
>>  Wouldn't this also be fixed by
>> http://patchwork.ozlabs.org/patch/613854/ ? With that patch (series)
>> applied, there shouldn't be any symlinks anymore once the real make
>> starts.
> 
> I didn't saw Samuel's patch. I will test it soon. I think it supersede 
> mine.

 You never came back to this. We will apply Samuel's patches soon. Can you
re-test after that and resubmit your patches if still needed?

 I've marked you patches as Rejected for now.

 Regards,
 Arnout
Samuel Martin Oct. 16, 2016, 11:43 a.m. UTC | #4
Hi Jerome,

On Sun, Oct 16, 2016 at 12:58 PM, Arnout Vandecappelle <arnout@mind.be> wrote:
>  Hi Jerome,
>
> On 05-10-16 10:54, Jérôme Pouiller wrote:
>> Hi Arnout,
>>
>> On Tuesday 04 October 2016 23:33:34 Arnout Vandecappelle wrote:
>>> On 30-09-16 12:09, Jérôme Pouiller wrote:
>>>> If compilation path contains symlinks, rpath may sometime contains
>>>> symlinks and sometime canonicalized path.
>>>>
>>>> A pratical example:
>>>>   $ ln -s /opt/buildroot /opt/buildroot-symblink
>>>>   $ cd /opt/buildroot-symlink
>>>>   $ make O=out
>>>>   $ make -C out package-rebuild
>>>>
>>>> This last command produce an error since already installed host
>>>> binaries contains /opt/buildroot/out/host/usr/lib as rpath while
>>>> check-host-rpath expect /opt/buildroot-symlink/out/host/usr/lib
>>>>
>>>> This patch canonicalize all paths used in check-host-rpath in order
>>>> to avoid problem
>>>
>>>  Wouldn't this also be fixed by
>>> http://patchwork.ozlabs.org/patch/613854/ ? With that patch (series)
>>> applied, there shouldn't be any symlinks anymore once the real make
>>> starts.
>>
>> I didn't saw Samuel's patch. I will test it soon. I think it supersede
>> mine.
>
>  You never came back to this. We will apply Samuel's patches soon. Can you
> re-test after that and resubmit your patches if still needed?

I've just reposted a new iteration of this change:
http://lists.busybox.net/pipermail/buildroot/2016-October/174677.html

Regards,
diff mbox

Patch

diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath
index 6ce547c..2541e53 100755
--- a/support/scripts/check-host-rpath
+++ b/support/scripts/check-host-rpath
@@ -13,8 +13,8 @@  main() {
     local hostdir="${2}"
     local file ret
 
-    # Remove duplicate and trailing '/' for proper match
-    hostdir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${hostdir}" )"
+    # Canonicalize path: follow symlinks, remove duplicate and trailing '/'
+    hostdir="$( readlink -m "${hostdir}" )"
 
     ret=0
     while read file; do
@@ -56,8 +56,8 @@  check_elf_has_rpath() {
 
     while read rpath; do
         for dir in ${rpath//:/ }; do
-            # Remove duplicate and trailing '/' for proper match
-            dir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )"
+            # Canonicalize path: follow symlinks, remove duplicate and trailing '/'
+            dir="$( readlink -m "${dir}" )"
             [ "${dir}" = "${hostdir}/usr/lib" ] && return 0
         done
     done < <( readelf -d "${file}"                                              \