[OE-core] Bitbake class - how to escape special characters?

Peter Gejgus Peter.Gejgus at kistler.com
Mon Mar 2 11:49:16 UTC 2015


Hello,

This is the excerpt of my bitbake class:

data_migration_common() {
	if [ x"$D" = "x" ]; then
		if [[ ! ${CURRENT_DATA_VERSION} =~ ^[0-9]?[0-9].[0-9]?[0-9]$ ]]; then
			error-exit "Version information was provided in invalid format!"
		fi
	...
	fi
}

python populate_packages_append() {
    data_migration_pkgs = d.getVar('DATA_MIGRATION_PACKAGES', True).split()

    for pkg in data_migration_pkgs:
        bb.note("adding data migration postinst scripts to %s" % pkg)
        postinst = d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)
        if not postinst:
            postinst = '#!/bin/sh\n'
        postinst += d.getVar('data_migration_common', True)
        d.setVar('pkg_postinst_%s' % pkg, postinst)
}

This class generates post-install scriptlet for the packages inheriting from this bitbake class.

But bitbake is unable to parse the code in the data_migration_common function and claiming:
ERROR: ExpansionError during parsing .../xyz_0.1.0.bb: Failure expanding variable data_migration_common: ShellSyntaxError: Invalid token "%s"

This problem is because the regular expression in the function data_migration_common contains character '$'. Bitbake succeeds when I remove character '$' from this regular expression. Is there some way to escape this '$' character? Because I need '$' in my regex.

Best Regards,
Peter




More information about the Openembedded-core mailing list