From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Peter Gejgus <Peter.Gejgus@kistler.com>
Cc: "openembedded-core@lists.openembedded.org"
<openembedded-core@lists.openembedded.org>
Subject: Re: Bitbake class - how to escape special characters?
Date: Mon, 02 Mar 2015 13:32:11 +0000 [thread overview]
Message-ID: <1425303131.26813.67.camel@linuxfoundation.org> (raw)
In-Reply-To: <672D6A2F0F2E8A43891580C45CE5D2E6013E3418@kihagwinex02.int.kistler.com>
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
prev parent reply other threads:[~2015-03-02 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-02 11:49 Bitbake class - how to escape special characters? Peter Gejgus
2015-03-02 13:32 ` Richard Purdie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425303131.26813.67.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=Peter.Gejgus@kistler.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox