summaryrefslogtreecommitdiffstats
path: root/meta/classes/relocatable.bbclass
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2010-04-08 16:35:16 +0100
committerJoshua Lock <josh@linux.intel.com>2010-04-08 16:41:24 +0100
commit10b6d140622e56f70dd5f84b66b8580be6f78c68 (patch)
tree405eb4d8c08e6c6735c7ec15cd491e35e61acd07 /meta/classes/relocatable.bbclass
parent572f86ce5bf7be6913a4a451f52241fcc6c682da (diff)
downloadpoky-10b6d140622e56f70dd5f84b66b8580be6f78c68.tar.gz
relocatable.bbclass: Handle files which don't have read/write permissions
It's possible to have files in our sysroot which don't have the write (or in some cases even the read) bit set. Test for these and if they are not set temporarily set them so that we can chrpath the binaries. Signed-off-by: Joshua Lock <josh@linux.intel.com>
Diffstat (limited to 'meta/classes/relocatable.bbclass')
-rw-r--r--meta/classes/relocatable.bbclass19
1 files changed, 17 insertions, 2 deletions
diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass
index 25eb99ecff..d92847b25d 100644
--- a/meta/classes/relocatable.bbclass
+++ b/meta/classes/relocatable.bbclass
@@ -5,12 +5,13 @@ PREPROCESS_RELOCATE_DIRS ?= ""
5 5
6def process_dir (directory, d): 6def process_dir (directory, d):
7 import subprocess as sub 7 import subprocess as sub
8 import stat
8 9
9 cmd = bb.data.expand('${CHRPATH_BIN}', d) 10 cmd = bb.data.expand('${CHRPATH_BIN}', d)
10 tmpdir = bb.data.getVar('TMPDIR', d) 11 tmpdir = bb.data.getVar('TMPDIR', d)
11 basedir = bb.data.expand('${base_prefix}', d) 12 basedir = bb.data.expand('${base_prefix}', d)
12 13
13 bb.debug("Checking %s for binaries to process" % directory) 14 #bb.debug("Checking %s for binaries to process" % directory)
14 if not os.path.exists(directory): 15 if not os.path.exists(directory):
15 return 16 return
16 17
@@ -26,6 +27,17 @@ def process_dir (directory, d):
26 process_dir(fpath, d) 27 process_dir(fpath, d)
27 else: 28 else:
28 #bb.note("Testing %s for relocatability" % fpath) 29 #bb.note("Testing %s for relocatability" % fpath)
30
31 # We need read and write permissions for chrpath, if we don't have
32 # them then set them temporarily. Take a copy of the files
33 # permissions so that we can restore them afterwards.
34 perms = os.stat(fpath)[stat.ST_MODE]
35 if os.access(fpath, os.W_OK|os.R_OK):
36 perms = None
37 else:
38 # Temporarily make the file writeable so we can chrpath it
39 os.chmod(fpath, perms|stat.S_IRWXU)
40
29 p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) 41 p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
30 err, out = p.communicate() 42 err, out = p.communicate()
31 # If returned succesfully, process stderr for results 43 # If returned succesfully, process stderr for results
@@ -63,9 +75,12 @@ def process_dir (directory, d):
63 # if we have modified some rpaths call chrpath to update the binary 75 # if we have modified some rpaths call chrpath to update the binary
64 if len(new_rpaths): 76 if len(new_rpaths):
65 args = ":".join(new_rpaths) 77 args = ":".join(new_rpaths)
66 #bb.note("Setting rpath to " + args) 78 #bb.note("Setting rpath for %s to %s" %(fpath, args))
67 sub.call([cmd, '-r', args, fpath]) 79 sub.call([cmd, '-r', args, fpath])
68 80
81 if perms:
82 os.chmod(fpath, perms)
83
69def rpath_replace (path, d): 84def rpath_replace (path, d):
70 bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split() 85 bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split()
71 86