From 2dff670c3cc57258c0b2295270fb6f9ed26f96df Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 17 Aug 2012 23:35:09 -0700 Subject: chrpath,sanity: Use patchelf instead of chrpath patchelf can dynamically increase the size of RPATH if need be unlike chrpath where we have limit on editing RPATH. Signed-off-by: Khem Raj --- meta/classes/chrpath.bbclass | 22 ++++++++++------------ meta/classes/sanity.bbclass | 4 +++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass index 4a6e697380..3263505041 100644 --- a/meta/classes/chrpath.bbclass +++ b/meta/classes/chrpath.bbclass @@ -1,4 +1,4 @@ -CHRPATH_BIN ?= "chrpath" +CHRPATH_BIN ?= "patchelf" PREPROCESS_RELOCATE_DIRS ?= "" def process_dir (directory, d): @@ -26,26 +26,24 @@ def process_dir (directory, d): else: #bb.note("Testing %s for relocatability" % fpath) - # We need read and write permissions for chrpath, if we don't have + # We need read and write permissions for patchelf, if we don't have # them then set them temporarily. Take a copy of the files # permissions so that we can restore them afterwards. perms = os.stat(fpath)[stat.ST_MODE] if os.access(fpath, os.W_OK|os.R_OK): perms = None else: - # Temporarily make the file writeable so we can chrpath it + # Temporarily make the file writeable so we can patchelf it os.chmod(fpath, perms|stat.S_IRWXU) - p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) + p = sub.Popen([cmd, '--print-rpath', fpath],stdout=sub.PIPE,stderr=sub.PIPE) err, out = p.communicate() # If returned succesfully, process stderr for results if p.returncode != 0: continue - # Throw away everything other than the rpath list - curr_rpath = err.partition("RPATH=")[2] - #bb.note("Current rpath for %s is %s" % (fpath, curr_rpath.strip())) - rpaths = curr_rpath.split(":") + #bb.note("Current rpath for %s is %s" % (fpath, err.strip())) + rpaths = err.split(":") new_rpaths = [] for rpath in rpaths: # If rpath is already dynamic copy it to new_rpath and continue @@ -59,7 +57,7 @@ def process_dir (directory, d): libpath = rpath.partition(basedir)[2].strip() # 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 + # where your TMPDIR is a short path (i.e. /usr/poky) as patchelf cannot insert an # rpath longer than that which is already set. elif rpath.find(tmpdir) != -1: depth = fpath.rpartition(tmpdir)[2].count('/') @@ -73,14 +71,14 @@ def process_dir (directory, d): depth-=1 new_rpaths.append("%s%s" % (base, libpath)) - # if we have modified some rpaths call chrpath to update the binary + # if we have modified some rpaths call patchelf to update the binary if len(new_rpaths): args = ":".join(new_rpaths) #bb.note("Setting rpath for %s to %s" %(fpath, args)) - p = sub.Popen([cmd, '-r', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE) + p = sub.Popen([cmd, '--set-rpath', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE) out, err = p.communicate() if p.returncode != 0: - bb.error("%s: chrpath command failed with exit code %d:\n%s%s" % (d.getVar('PN', True), p.returncode, out, err)) + bb.error("%s: patchelf command failed with exit code %d:\n%s%s" % (d.getVar('PN', True), p.returncode, out, err)) raise bb.build.FuncFailed if perms: diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index f2e9a74441..2c0f7661a3 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass @@ -2,7 +2,7 @@ # Sanity check the users setup for common misconfigurations # -SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk chrpath wget cpio" +SANITY_REQUIRED_UTILITIES ?= "patch diffstat makeinfo git bzip2 tar gzip gawk patchelf wget cpio" python check_bblayers_conf() { bblayers_fn = os.path.join(d.getVar('TOPDIR', True), 'conf/bblayers.conf') @@ -483,6 +483,8 @@ def check_sanity(sanity_data): if missing != "": missing = missing.rstrip(',') messages = messages + "Please install the following missing utilities: %s\n" % missing + if 'patchelf' in missing: + messages = messages + "\n If patchelf for your build host is not available from default feeds\n Get it from http://hydra.nixos.org/release/patchelf/patchelf-0.6\n the package works on later versions of respective OSes\n along with published one e.g. ubuntu 8.04 package works on\n ubuntu 12.04 as well\n" pseudo_msg = check_pseudo_wrapper() if pseudo_msg != "": -- cgit 1.2.3-korg