Skip to contentSkip to conversation

Make prune_suffix prune a suffix

PATCH New andre.rosa 1 participant 1 message Apr 6, 2019 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

andre.rosa

author
#1 lore raw

PATCH 1/1 Make prune_suffix prune a suffix

From: Andre Rosa <[email protected]>

... instead of replacing a substring that could happen more than once and not only when it ends with it. Do the same for the prefix.

See related https://github.com/openembedded/bitbake/pull/24 . There it stops replacing sufixes once first one is matched but not here.

---
 meta/lib/oe/utils.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta/lib/oe/utils.py +3 -3
@@ -78,12 +78,12 @@ def prune_suffix(var, suffixes, d):
     # See if var ends with any of the suffixes listed and
     # remove it if found
     for suffix in suffixes:
-        if var.endswith(suffix):
-            var = var.replace(suffix, "")
+        if suffix and var.endswith(suffix):
+            var = var[:-len(suffix)]
 
     prefix = d.getVar("MLPREFIX")
     if prefix and var.startswith(prefix):
-        var = var.replace(prefix, "")
+        var = var[len(prefix):]
 
     return var
 

--
2.20.1.519.g8feddda32c