From b43b80c7605ad12bc6e0e4e0b22d2f256f246f22 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Thu, 1 Apr 2010 11:42:50 +0100 Subject: 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 --- meta/classes/relocatable.bbclass | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/meta/classes/relocatable.bbclass b/meta/classes/relocatable.bbclass index ca36e5b..25eb99e 100644 --- a/meta/classes/relocatable.bbclass +++ b/meta/classes/relocatable.bbclass @@ -3,27 +3,28 @@ SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess" CHRPATH_BIN ?= "chrpath" PREPROCESS_RELOCATE_DIRS ?= "" -def rpath_replace (path, d): +def process_dir (directory, d): import subprocess as sub cmd = bb.data.expand('${CHRPATH_BIN}', d) - - bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split() tmpdir = bb.data.getVar('TMPDIR', d) basedir = bb.data.expand('${base_prefix}', d) - for d in bindirs: - dir = path + "/" + d - bb.debug("Checking %s for binaries to process" % dir) - if not os.path.exists(dir): - continue - for file in os.listdir(dir): - fpath = dir + "/" + file - if os.path.islink(fpath): - fpath = os.readlink(fpath) - if not os.path.isabs(fpath): - fpath = os.path.normpath(os.path.join(dir, fpath)) - + 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 + if os.path.islink(fpath): + fpath = os.readlink(fpath) + if not os.path.isabs(fpath): + fpath = os.path.normpath(os.path.join(directory, fpath)) + + if os.path.isdir(fpath): + process_dir(fpath, d) + else: #bb.note("Testing %s for relocatability" % fpath) p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE) err, out = p.communicate() @@ -65,6 +66,14 @@ def rpath_replace (path, d): #bb.note("Setting rpath to " + args) sub.call([cmd, '-r', args, fpath]) +def rpath_replace (path, d): + bindirs = bb.data.expand("${bindir} ${sbindir} ${base_sbindir} ${base_bindir} ${libdir} ${base_libdir} ${PREPROCESS_RELOCATE_DIRS}", d).split() + + for bindir in bindirs: + bb.note ("Processing directory " + bindir) + directory = path + "/" + bindir + process_dir (directory, d) + python relocatable_binaries_preprocess() { rpath_replace(bb.data.expand('${SYSROOT_DESTDIR}', d), d) } -- cgit v1.1