Bug 15375 - Define what a valid layer name can contain (and what it cannot)
Summary: Define what a valid layer name can contain (and what it cannot)
Status: NEW
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: 5.0
Hardware: x86 Multiple
: Medium normal
Target Milestone: 6.2
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2024-01-30 21:52 UTC by Tim Orling
Modified: 2026-10-01 15:48 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Orling 2024-01-30 21:52:32 UTC
In working on #15373, I discovered that the original 2013 commit of layerindex-web had defined that a valid layer name could only contain alphanumeric characters and dashes:

https://git.yoctoproject.org/layerindex-web/commit/layerindex?id=2eb5f38b21396b6584f532f9bb763918f0860cdd

    def clean_name(self):
        name = self.cleaned_data['name'].strip()
        if re.compile(r'[^a-z0-9-]').search(name):
            raise forms.ValidationError("Name must only contain alphanumeric characters and dashes")
        if name.startswith('-'):
            raise forms.ValidationError("Name must not start with a dash")
        if name.endswith('-'):
            raise forms.ValidationError("Name must not end with a dash")
        if '--' in name:
            raise forms.ValidationError("Name cannot contain consecutive dashes")
        return name

But clearly nothing is preventing a layer from having a . in the name, it simply was not supported in layerindex. meta-luneos and friends have been successfully using -backports-2.8 and so on layers since zeus.

This led to me to a question of what might be possible?

underscore : an underscore works (we probably don't want it given overrides confusion) so you could create a layer with 'bitbake-layers create-layer meta-foo_bar-1.2' and the resulting example_1.0.bb recipe will build. The examples in the docs show an underscore... https://docs.yoctoproject.org/dev-manual/layers.html?highlight=_xyz#creating-your-own-layer
"meta-GUI_xyz".

non alphanumeric characters %:! These will not work with 'bitbake-layers create-layer' because they are invalid format characters for how Python is parsing the input (plus they probably cause other problems with bash/shell)
ValueError: unsupported format character ':' (0x3a) at index 44
To be sure, other characters like * & / \ are also probably not valid, but I only tested the three (%:!).

unicode, emojis. It turns out you can use the ":tada:" unicode character and 'bitbake-layers create-layer meta-<the :tada: emoji>' will happily create a layer. In this case it will fail to parse:
bb.parse.ParseError: ... unparsed line: 'BBFILE_PATTERN_meta-<the :tada: character> = "^${LAYERDIR}/"'

This then made me realize we probably need to actually define what is valid and put in checks to ensure the supported characters/pattern are being used.