]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
Provide LAYERDIR_RE for layer.conf
authorChristopher Larson <chris_larson@mentor.com>
Sat, 30 Apr 2016 19:52:49 +0000 (12:52 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 18 May 2016 22:21:07 +0000 (23:21 +0100)
This variable is a regex-escaped version of LAYERDIR, for safer use in
BBFILE_PATTERN, so as to avoid issues with regex special characters in the
layer path.

[YOCTO #8402]

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
doc/bitbake-user-manual/bitbake-user-manual-hello.xml
doc/bitbake-user-manual/bitbake-user-manual-ref-variables.xml
lib/bb/cookerdata.py

index f6d82b4f3fdd77cb14c7d5e5b73eef93860da43b..8b7edbff5403b9618dfebceebd6cad67c8a92ba1 100644 (file)
@@ -399,7 +399,7 @@ ERROR: Unable to parse base: ParseError in configuration INHERITs: Could not inh
      <link linkend='var-BBFILES'>BBFILES</link> += "${LAYERDIR}/*.bb"
 
      <link linkend='var-BBFILE_COLLECTIONS'>BBFILE_COLLECTIONS</link> += "mylayer"
-     <link linkend='var-BBFILE_PATTERN'>BBFILE_PATTERN_mylayer</link> := "^${LAYERDIR}/"
+     <link linkend='var-BBFILE_PATTERN'>BBFILE_PATTERN_mylayer</link> := "^${LAYERDIR_RE}/"
                 </literallayout>
                 For information on these variables, click the links
                 to go to the definitions in the glossary.</para>
index ae7e4cee8c0cc4ecf57d1a142330b4a5c21de949..4d06ff950c988a5e84ceaf8a9ccfe058c45eb983 100644 (file)
             </glossdef>
         </glossentry>
 
+        <glossentry id='var-LAYERDIR_RE'><glossterm>LAYERDIR_RE</glossterm>
+            <glossdef>
+                <para>When used inside the <filename>layer.conf</filename> configuration
+                    file, this variable provides the path of the current layer,
+                    escaped for use in a regular expression
+                    (<link linkend='var-BBFILE_PATTERN'><filename>BBFILE_PATTERN</filename></link>).
+                    This variable is not available outside of <filename>layer.conf</filename>
+                    and references are expanded immediately when parsing of the file completes.</para>
+            </glossdef>
+        </glossentry>
+
         <glossentry id='var-LAYERVERSION'><glossterm>LAYERVERSION</glossterm>
             <glossdef>
                 <para>Optionally specifies the version of a layer as a single number.
index fba95afa54fa40a3a340ac839f906695f2d72198..1615db5b175f2117b32338cd60266dd4504562f0 100644 (file)
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-import os, sys
-from functools import wraps
 import logging
+import os
+import re
+import sys
+from functools import wraps
 import bb
 from bb import data
 import bb.parse
@@ -296,9 +298,12 @@ class CookerDataBuilder(object):
                 if layer.endswith('/'):
                     layer = layer.rstrip('/')
                 data.setVar('LAYERDIR', layer)
+                data.setVar('LAYERDIR_RE', re.escape(layer))
                 data = parse_config_file(os.path.join(layer, "conf", "layer.conf"), data)
                 data.expandVarref('LAYERDIR')
+                data.expandVarref('LAYERDIR_RE')
 
+            data.delVar('LAYERDIR_RE')
             data.delVar('LAYERDIR')
 
         if not data.getVar("BBPATH", True):