* Bitbake class - how to escape special characters?
@ 2015-03-02 11:49 Peter Gejgus
2015-03-02 13:32 ` Richard Purdie
0 siblings, 1 reply; 2+ messages in thread
From: Peter Gejgus @ 2015-03-02 11:49 UTC (permalink / raw)
To: openembedded-core@lists.openembedded.org
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Bitbake class - how to escape special characters?
2015-03-02 11:49 Bitbake class - how to escape special characters? Peter Gejgus
@ 2015-03-02 13:32 ` Richard Purdie
0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2015-03-02 13:32 UTC (permalink / raw)
To: Peter Gejgus; +Cc: openembedded-core@lists.openembedded.org
On Mon, 2015-03-02 at 11:49 +0000, Peter Gejgus wrote:
> 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.
The problem is in the shell parser that bitbake uses (lib/bb/pysh)
doesn't like that syntax. The expression you have above is bash specific
and we tend to support /bin/dash as /bin/sh so the function you have
there isn't portable.
Cheers,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-02 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02 11:49 Bitbake class - how to escape special characters? Peter Gejgus
2015-03-02 13:32 ` Richard Purdie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox