ConfHandler: Allow the '@' character in variable flag names
PATCH v2 1/1 ConfHandler: Allow the '@' character in variable flag names
This patch enables the usage of the '@' character in variable flag names.
One use case of variable flags is to indicate and set the namespace of some systemd services/targets. The filenames of systemd services/targets might contain the '@' character if they are template unit files that can take in a single parameter/argument and be instanced multiple times, as indicated by systemd's official manual page.
This patch is successfully verified by creating a custom BitBake recipe that sets and unsets the value of a variable flag with the '@' character in its name and ensuring that no ParseError is being thrown. A regression test has also been added to bb.parse.
bin/bitbake-selftest has also been successfully executed and all tests passed.
---
v2:
Add regression test.
--- lib/bb/parse/parse_py/ConfHandler.py | 4 ++-- lib/bb/tests/parse.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
lib/bb/parse/parse_py/ConfHandler.py +2 -2
@@ -21,7 +21,7 @@ __config_regexp__ = re.compile( r""" ^ (?P<exp>export\s+)? (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?) - (\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])? + (\[(?P<flag>[a-zA-Z0-9\-_+.@]+)\])? \s* ( (?P<colon>:=) |
@@ -45,7 +45,7 @@ __include_regexp__ = re.compile( r"include\s+(.+)" ) __require_regexp__ = re.compile( r"require\s+(.+)" ) __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) -__unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.]+)\]$" ) +__unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.@]+)\]$" ) __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) def init(data):
lib/bb/tests/parse.py +15 -0
@@ -218,3 +218,18 @@ VAR = " \\ with self.assertRaises(bb.BBHandledException): d = bb.parse.handle(f.name, self.d)[''] + + at_sign_in_var_flag = """ +A[[email protected]] = "nonet" +B[[email protected]] = "ntb" + +unset A[[email protected]] +""" + def test_parse_at_sign_in_var_flag(self): + f = self.parsehelper(self.at_sign_in_var_flag) + d = bb.parse.handle(f.name, self.d)[''] + self.assertEqual(d.getVar("A"), None) + self.assertEqual(d.getVar("B"), None) + self.assertEqual(d.getVarFlag("A","[email protected]"), None) + self.assertEqual(d.getVarFlag("B","[email protected]"), "ntb") +
Signature · 1 line
2.39.2