From: Andreas Oberritter <obi@opendreambox.org>
To: openembedded-core@lists.openembedded.org
Subject: [RFC PATCH v3] chrpath.bbclass: strip common parent directories from rpath
Date: Tue, 2 Jul 2013 11:50:42 +0200 [thread overview]
Message-ID: <1372758642-6302-1-git-send-email-obi@opendreambox.org> (raw)
In-Reply-To: <1362529925-13211-1-git-send-email-obi@opendreambox.org>
Allows to use shorter TMPDIRs in corner cases, e.g. with native
perl modules, having a deep directory structure.
The problem is that the original absolute rpath may be shorter
than the newly generated relative rpath.
The failing rpaths were '/ab/cde/tmp/sysroots/x86_64-linux/usr/lib'
(old) and '$ORIGIN/../../../../../../../../../usr/lib' (new) for
'/ab/cde/tmp/sysroots/x86_64-linux/usr/lib/perl-native/perl/5.14.3/auto/XML/Parser/Expat/Expat.so'
The new rpath is '$ORIGIN/../../../../../../..'.
The new code doesn't just compare libdir, because I guess it
should also work if only parts of libdir share a parent directory
with the binary.
This patch also adds a check for len(basedir) > 0, because I think
basedir is empty in the cross-compile case, in which case
rpath.find(basedir) would always return 0, but I'm unsure whether
I understood that part of the code correctly or not.
[YOCTO #3989]
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
---
v2: Fixed reassembly of libpath
v3: Really fixed reassembly of libpath:
libpath = '/' + '/'.join(libdirs[nparents + 1:])
I've been using this version of the patch since about four months ago
and didn't notice any problems.
meta/classes/chrpath.bbclass | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
index 0c7ab77..9255aa7 100644
--- a/meta/classes/chrpath.bbclass
+++ b/meta/classes/chrpath.bbclass
@@ -55,9 +55,22 @@ def process_dir (directory, d):
rpath = os.path.normpath(rpath)
# If the rpath shares a root with base_prefix determine a new dynamic rpath from the
# base_prefix shared root
- if rpath.find(basedir) != -1:
- depth = fpath.partition(basedir)[2].count('/')
+ if len(basedir) > 0 and rpath.find(basedir) != -1:
+ relfpath = fpath.partition(basedir)[2].strip()
libpath = rpath.partition(basedir)[2].strip()
+ depth = relfpath.count('/')
+ # Compare common parent directories to reduce the length of the new rpath.
+ # Ignore the first (empty) element.
+ libdirs = libpath.split('/')
+ relfdirs = relfpath.split('/')
+ nparents = 0
+ for i in range(1, min(len(libdirs), len(relfdirs))):
+ if libdirs[i] != relfdirs[i]:
+ break
+ nparents += 1
+ if nparents > 0:
+ libpath = '/' + '/'.join(libdirs[nparents + 1:])
+ depth -= nparents
# otherwise (i.e. cross packages) determine a shared root based on the TMPDIR
# NOTE: This will not work reliably for cross packages, particularly in the case
# where your TMPDIR is a short path (i.e. /usr/poky) as chrpath cannot insert an
--
1.8.1.2
next prev parent reply other threads:[~2013-07-02 9:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-05 23:55 [PATCH][RFC] chrpath.bbclass: strip common parent directories from rpath Andreas Oberritter
2013-03-06 0:32 ` [PATCH v2][RFC] " Andreas Oberritter
2013-03-06 7:19 ` [PATCH v2][RFC] chrpath.bbclass: strip common parent directories from rpath# Henning Heinold
2013-07-02 9:50 ` Andreas Oberritter [this message]
2013-07-30 15:24 ` [RFC PATCH v3] chrpath.bbclass: strip common parent directories from rpath Phil Blundell
2013-07-30 15:27 ` Khem Raj
2013-07-30 15:34 ` Phil Blundell
2013-07-30 18:47 ` Andreas Oberritter
2013-07-31 23:25 ` Trevor Woerner
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=1372758642-6302-1-git-send-email-obi@opendreambox.org \
--to=obi@opendreambox.org \
--cc=openembedded-core@lists.openembedded.org \
/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