[OE-core] [PATCH v6 01/13] update-alternatives: correctly escape PATHs when updating FILES_${PN}

André Draszik git at andred.net
Tue Feb 5 02:32:29 UTC 2019

From: André Draszik <andre.draszik at jci.com>

The recently added support for updating FILES based on the file renames
that are happening here is using a regex replace, but failed to
properly escape the search pattern (the full path). This manifests itself
in FILES not being updated as soon as the full path contains any
character that has a special meaning, e.g. '+'.

In other words an original path (alt_target in the code) like
can't be matched, and hence we fail to update FILES with the new value,
causing packaging errors.

Fix by using re.escape() on the original path before passing into re.sub()

Fixes: 5c23fe378732 ("update-alternatives: try to update FILES_${PN} when
renaming a file"), or bcb3e7b7f88a in poky.git

[YOCTO #13058]

Signed-off-by: André Draszik <andre.draszik at jci.com>
 meta/classes/update-alternatives.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass
index e252651128..537e85d9a3 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -138,12 +138,12 @@ python apply_update_alternative_renames () {
     if not update_alternatives_enabled(d):
-    from re import sub
+    import re
     def update_files(alt_target, alt_target_rename, pkg, d):
         f = d.getVar('FILES_' + pkg)
         if f:
-            f = sub(r'(^|\s)%s(\s|$)' % alt_target, r'\1%s\2' % alt_target_rename, f)
+            f = re.sub(r'(^|\s)%s(\s|$)' % re.escape (alt_target), r'\1%s\2' % alt_target_rename, f)
             d.setVar('FILES_' + pkg, f)
     # Check for deprecated usage...

More information about the Openembedded-core mailing list