Maintain compatability with Python 2.4
PATCH 1/1 Maintain compatability with Python 2.4
Hi,
I just found this patch lying around, I forgot to submit it here.
A user contacted me about requiring Python 2.5 features in relocatable.bbclass when OE claims Python 2.4 support.
I wrote them this patch and haven't heard any complaints back so assume it works as intended, however I haven't tested it much myself.
When I raised the Python 2.4 vs 2.5 issue a while back it seems the consensus was to stick to 2.4 support as RHEL still uses it.
Anyone care to merge?
Thanks,
Joshua
Signature · 2 lines
Joshua Lock
Intel Open Source Technology CentreFrom 72399a3064367c92fcb7fe832adca289de0c10b2 Mon Sep 17 00:00:00 2001
From: Joshua Lock <[email protected]>
Date: Mon, 10 May 2010 17:01:35 +0100
Subject: [PATCH] relocatable.bbclass: don't use Python 2.5 features
str.partition() is a "new" method for Python 2.5, as we claim Pyhton 2.4 or above is required in the wiki we shouldn't use methods which aren't available in Python 2.4.
This patch adds a (horrible) method, string_after() to replace the use of str.partition()
--- classes/relocatable.bbclass | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
classes/relocatable.bbclass +11 -9
@@ -3,6 +3,11 @@ SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess" CHRPATH_BIN ?= "chrpath" PREPROCESS_RELOCATE_DIRS ?= "" +def string_after(target, split): + target = target.strip().lstrip() + tmp = target[target.rfind(split):len(target)] + return tmp[len(split):len(target)] + def process_dir (directory, d): import subprocess as sub import stat
@@ -44,7 +49,7 @@ def process_dir (directory, d): continue # Throw away everything other than the rpath list - curr_rpath = err.partition("RPATH=")[2] + curr_rpath = string_after(err, "RPATH=") #bb.note("Current rpath for %s is %s" % (fpath, curr_rpath.strip())) rpaths = curr_rpath.split(":") new_rpaths = []
@@ -55,15 +60,12 @@ def process_dir (directory, d): # 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() + depth = string_after(fpath, basedir).count('/') + libpath = string_after(rpath, basedir).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 - # rpath longer than that which is already set. else: - depth = fpath.rpartition(tmpdir)[2].count('/') - libpath = rpath.partition(tmpdir)[2].strip() + depth = string_after(rpath, tmpdir).count('/') + libpath = string_after(rpath, tmpdir).strip() base = "$ORIGIN" while depth > 1:
@@ -74,7 +76,7 @@ def process_dir (directory, d): # if we have modified some rpaths call chrpath to update the binary if len(new_rpaths): args = ":".join(new_rpaths) - #bb.note("Setting rpath for %s to %s" %(fpath,args)) + #bb.note("Setting rpath for %s to %s" %(fpath, args)) sub.call([cmd, '-r', args, fpath]) if perms:
Signature · 1 line
1.6.6.1