aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes/chrpath.bbclass
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2012-08-17 23:44:13 -0700
committerKhem Raj <raj.khem@gmail.com>2012-10-06 11:16:31 -0700
commitf6d579ba66973218aee1f80cbf5afdcfc127a9e3 (patch)
tree574bdca0552d52ec16ce742d8502216dfa55ad3b /meta/classes/chrpath.bbclass
parent15400ac51655ef77d7fc0cba999a42f9a1a2a534 (diff)
downloadopenembedded-core-contrib-f6d579ba66973218aee1f80cbf5afdcfc127a9e3.tar.gz
classes: Rename chrpath.bbclass -> patchelf.bbclasskraj/patchelf
Fix references to chrpath bbclass Rename CHRPATH_BIN to PATCHELF_BIN Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta/classes/chrpath.bbclass')
-rw-r--r--meta/classes/chrpath.bbclass94
1 files changed, 0 insertions, 94 deletions
diff --git a/meta/classes/chrpath.bbclass b/meta/classes/chrpath.bbclass
deleted file mode 100644
index 3263505041..0000000000
--- a/meta/classes/chrpath.bbclass
+++ /dev/null
@@ -1,94 +0,0 @@
-CHRPATH_BIN ?= "patchelf"
-PREPROCESS_RELOCATE_DIRS ?= ""
-
-def process_dir (directory, d):
- import subprocess as sub
- import stat
-
- cmd = d.expand('${CHRPATH_BIN}')
- tmpdir = d.getVar('TMPDIR')
- basedir = d.expand('${base_prefix}')
-
- #bb.debug("Checking %s for binaries to process" % directory)
- if not os.path.exists(directory):
- return
-
- dirs = os.listdir(directory)
- for file in dirs:
- fpath = directory + "/" + file
- fpath = os.path.normpath(fpath)
- if os.path.islink(fpath):
- # Skip symlinks
- continue
-
- if os.path.isdir(fpath):
- process_dir(fpath, d)
- else:
- #bb.note("Testing %s for relocatability" % fpath)
-
- # 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 patchelf it
- os.chmod(fpath, perms|stat.S_IRWXU)
-
- 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
-
- #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
- if rpath.find("$ORIGIN") != -1:
- new_rpaths.append(rpath.strip())
- continue
- # 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('/')
- 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 patchelf cannot insert an
- # rpath longer than that which is already set.
- elif rpath.find(tmpdir) != -1:
- depth = fpath.rpartition(tmpdir)[2].count('/')
- libpath = rpath.partition(tmpdir)[2].strip()
- else:
- new_rpaths.append(rpath.strip())
- continue
- base = "$ORIGIN"
- while depth > 1:
- base += "/.."
- depth-=1
- new_rpaths.append("%s%s" % (base, libpath))
-
- # 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, '--set-rpath', args, fpath],stdout=sub.PIPE,stderr=sub.PIPE)
- out, err = p.communicate()
- if p.returncode != 0:
- 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:
- os.chmod(fpath, perms)
-
-def rpath_replace (path, d):
- bindirs = d.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${libexecdir} ${PREPROCESS_RELOCATE_DIRS}").split()
-
- for bindir in bindirs:
- #bb.note ("Processing directory " + bindir)
- directory = path + "/" + bindir
- process_dir (directory, d)
-