]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
chrpath,sanity: Use patchelf instead of chrpath
authorKhem Raj <raj.khem@gmail.com>
Sat, 18 Aug 2012 06:35:09 +0000 (23:35 -0700)
committerKhem Raj <raj.khem@gmail.com>
Sat, 6 Oct 2012 18:16:31 +0000 (11:16 -0700)
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 <raj.khem@gmail.com>
meta/classes/chrpath.bbclass
meta/classes/sanity.bbclass

index 4a6e6973809809b0476a37955e5d3eee9dbb736d..32635050411c174ae5c6090226111773d69dab8a 100644 (file)
@@ -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:
index f2e9a74441dbd8ce74e519b2b78074f6581ae0d2..2c0f7661a3b8ed347bae2a3988112e142333d48d 100644 (file)
@@ -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 != "":