diff options
| author | Joshua Lock <josh@linux.intel.com> | 2010-04-01 11:42:50 +0100 |
|---|---|---|
| committer | Joshua Lock <josh@linux.intel.com> | 2010-04-01 11:53:29 +0100 |
| commit | b43b80c7605ad12bc6e0e4e0b22d2f256f246f22 (patch) | |
| tree | a678ba4b1e195600a63453813436b2864966d4f1 | |
| parent | cf929499aa503d6b9226f823bc366d24a7b26651 (diff) | |
| download | poky-b43b80c7605ad12bc6e0e4e0b22d2f256f246f22.tar.gz | |
relocatable: Handle directories having subdirectories of binaries
Make the processing of directories less naive so that it can handle a directory
with children that are directories. We now scan for and process binaries in all
directories below the scanned paths rather than only the top-level directory.
This patch moves the meat of the post-processing into a separate function which
is fed paths, process_dir (). Then when the function finds a subdirectory of
the passed path which is itself a directory it recursively calls itself.
Signed-off-by: Joshua Lock <josh@linux.intel.com>
| -rw-r--r-- | meta/classes/relocatable.bbclass | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass index ca36e5b263..25eb99ecff 100644 --- a/meta/classes/relocatable.bbclass +++ b/meta/classes/relocatable.bbclass | |||
| @@ -3,27 +3,28 @@ SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess" | |||
| 3 | CHRPATH_BIN ?= "chrpath" | 3 | CHRPATH_BIN ?= "chrpath" |
| 4 | PREPROCESS_RELOCATE_DIRS ?= "" | 4 | PREPROCESS_RELOCATE_DIRS ?= "" |
| 5 | 5 | ||
| 6 | def rpath_replace (path, d): | 6 | def process_dir (directory, d): |
| 7 | import subprocess as sub | 7 | import subprocess as sub |
| 8 | 8 | ||
| 9 | cmd = bb.data.expand('${CHRPATH_BIN}', d) | 9 | cmd = bb.data.expand('${CHRPATH_BIN}', d) |
| 10 | |||
| 11 | bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split() | ||
| 12 | tmpdir = bb.data.getVar('TMPDIR', d) | 10 | tmpdir = bb.data.getVar('TMPDIR', d) |
| 13 | basedir = bb.data.expand('${base_prefix}', d) | 11 | basedir = bb.data.expand('${base_prefix}', d) |
| 14 | 12 | ||
| 15 | for d in bindirs: | 13 | bb.debug("Checking %s for binaries to process" % directory) |
| 16 | dir = path + "/" + d | 14 | if not os.path.exists(directory): |
| 17 | bb.debug("Checking %s for binaries to process" % dir) | 15 | return |
| 18 | if not os.path.exists(dir): | 16 | |
| 19 | continue | 17 | dirs = os.listdir(directory) |
| 20 | for file in os.listdir(dir): | 18 | for file in dirs: |
| 21 | fpath = dir + "/" + file | 19 | fpath = directory + "/" + file |
| 22 | if os.path.islink(fpath): | 20 | if os.path.islink(fpath): |
| 23 | fpath = os.readlink(fpath) | 21 | fpath = os.readlink(fpath) |
| 24 | if not os.path.isabs(fpath): | 22 | if not os.path.isabs(fpath): |
| 25 | fpath = os.path.normpath(os.path.join(dir, fpath)) | 23 | fpath = os.path.normpath(os.path.join(directory, fpath)) |
| 26 | 24 | ||
| 25 | if os.path.isdir(fpath): | ||
| 26 | process_dir(fpath, d) | ||
| 27 | else: | ||
| 27 | #bb.note("Testing %s for relocatability" % fpath) | 28 | #bb.note("Testing %s for relocatability" % fpath) |
| 28 | p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) | 29 | p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) |
| 29 | err, out = p.communicate() | 30 | err, out = p.communicate() |
| @@ -65,6 +66,14 @@ def rpath_replace (path, d): | |||
| 65 | #bb.note("Setting rpath to " + args) | 66 | #bb.note("Setting rpath to " + args) |
| 66 | sub.call([cmd, '-r', args, fpath]) | 67 | sub.call([cmd, '-r', args, fpath]) |
| 67 | 68 | ||
| 69 | def rpath_replace (path, d): | ||
| 70 | bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split() | ||
| 71 | |||
| 72 | for bindir in bindirs: | ||
| 73 | bb.note ("Processing directory " + bindir) | ||
| 74 | directory = path + "/" + bindir | ||
| 75 | process_dir (directory, d) | ||
| 76 | |||
| 68 | python relocatable_binaries_preprocess() { | 77 | python relocatable_binaries_preprocess() { |
| 69 | rpath_replace(bb.data.expand('${SYSROOT_DESTDIR}', d), d) | 78 | rpath_replace(bb.data.expand('${SYSROOT_DESTDIR}', d), d) |
| 70 | } | 79 | } |
