Commit Graph

15 Commits

Author SHA1 Message Date
Konrad Weihmann
75c3ab048b bitbake: pyshyacc: allow double COMMA statements
this allows shell statements like '; ;' to pass the parser.
As it may be bad code but still valid enough to execute

(Bitbake rev: b7732b1b5085bea73e17d112e1bd9ac3d4dc34fb)

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-12 11:53:00 +01:00
Robert Yang
d6bc389e81 bitbake: bitbake: pysh: Improve error handling for shell code
The p_error() is used for printing errors when parse shell code, but it can't
the EOF error correctly

- Add the following lines to quilt.inc
  do_configure_prepend () {
      find ${s} -name "*.in" -exec sed -i -e "1s,^#\!.*@perl@ -w$,#\! @perl@\nuse warnings;," {} \;
      if [ hello ]; then
  }

- Before the patch:
  $ rm -fr cache/ tmp/cache/; bitbake -p
  [snip]
  WARNING: /path/to/quilt/quilt-native_0.65.bb: Error during finalise of /path/to/quilt/quilt-native_0.65.bb
  [snip]
  bb.pysh.sherrors.ShellSyntaxError: None
  followed by:

  We can see that this isn't easy to debug, let p_error() check wheter it is EOF
  and print appropriate errors can improve the error message. And don't let
  codeparser.py except pyshlex.NeedMore (in fact, it never worked since p_error()
  only raise ShellSyntaxError), but make it print the last 5 lines which might be
  useful for debuging.

- After the patch
  $ rm -fr cache/ tmp/cache/; bitbake -p
  [snip]
  ERROR: /path/to/quilt/quilt_0.65.bb: Error during parse shell code, the last 5 lines are:
      find /path/to/quilt/0.65-r0/quilt-0.65 -name "*.in" -exec sed -i -e "1s,^#\!.*@PERL@ -w$,#\! @PERL@\nuse warnings;," {} \;
      if [ hello ]; then
      autotools_do_configure
      sed -e 's,^COMPAT_SYMLINKS.*:=.*,COMPAT_SYMLINKS    :=,' -i /path/to/quilt/0.65-r0/quilt-0.65/Makefile
  [snip]
    File "/path/to/bb/pysh/pyshyacc.py", line 649, in p_error(p=None):
               w('Unexpected EOF')
      >    raise sherrors.ShellSyntaxError(''.join(msg))

  bb.pysh.sherrors.ShellSyntaxError: Unexpected EOF

(Bitbake rev: 44790597951638e32eb1672de2e40bd5a603326b)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-09 11:07:48 +00:00
Robert Yang
b3f0b96a25 bitbake: pysh/pyshlex.py: Set is not importable
>>> from Set import Set
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'Set'

So remove related code.

(Bitbake rev: 118e9d8894e64d102543562314b318676006e710)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-09 11:07:48 +00:00
Robert Yang
cbc102d8fc bitbake: pysh/sherrors.py: Remove unused classes
The only two that we need are ShellSyntaxError and ShellError, others are not
used, so remove them.

(Bitbake rev: abee2ff5ee71bf8c3221cd9d3cd4243ebb4ca273)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-09 11:07:48 +00:00
Robert Yang
54de2f5089 bitbake: pysh: Remove unused modules
We don't use these modules in bitbake, so remove them.

And pysh's author declared that pysh is no longer maintained:
http://pysh.sourceforge.net/

(Bitbake rev: 9cc4f12d2aef366a593c7977d3818a3002b1d8bf)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-09 11:07:48 +00:00
Richard Purdie
0f2c59367a bitbake: bitbake: Convert to python 3
Various misc changes to convert bitbake to python3 which don't warrant
separation into separate commits.

(Bitbake rev: d0f904d407f57998419bd9c305ce53e5eaa36b24)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02 08:24:02 +01:00
Robert Yang
053857479c bitbake: lib: fix no newline at end of file
Add a '\n' to the last line of the file to fix:

No newline at end of file

(Bitbake rev: 54f1359ed2e9d47980cd221b7b43ef56543fe06d)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-04 09:28:36 +01:00
Olof Johansson
88a7b041fb bitbake: pysh: Say what kind of token isn't implemented
When the shell lexer finds an unrecognized dollar token, the error
message should contain what kind of token it is having problems with.

(Bitbake rev: 1acb9c338018c612db519d2db823c66b567863b9)

Signed-off-by: Olof Johansson <olof.johansson@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-10 13:35:10 +01:00
Scott Garman
62d538fbe6 make exception handling syntax consistent
Update exception handling syntax to use the modern style:
except ExcType as localvar

(Bitbake rev: dbf5f42b06bef81749b13aa99945cc1292a6676d)

Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-06-15 11:13:13 +01:00
Richard Purdie
0090a798eb bitbake: Sync a load of whitespace and other non-functionality changes with bitbake uptream
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:54 +00:00
Chris Larson
8eee4221db pysh: add missing os.path import
(Bitbake rev: 6fb448a6cfb00aeb5dfc6c047915e0941e754348)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:53 +00:00
Chris Larson
32ea766871 Implement parallel parsing support
This utilizes python's multiprocessing module.  The default number of threads
to be used is the same as the number of available processor cores, however,
you can manually set this with the BB_NUMBER_PARSE_THREADS variable.

(Bitbake rev: c7b3ec819549e51e438d293969e205883fee725f)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:42 +00:00
Chris Larson
7e1b709231 bb.pysh: add Case support to format_commands
(Bitbake rev: 6e24f573a0e95068eb9237c1d264ad1148b2f690)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:39 +00:00
Chris Larson
32b4bd9224 bb.pysh: fix writing pyshtables all over the place
(Bitbake rev: ff4753e362714a3c4c759c2fad8a9e5b8fe5bef5)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:39 +00:00
Chris Larson
4addbd191d Move the pysh package into the bb package
The pysh we're using is modified, and we don't want to risk it conflicting
with one from elsewhere.

(Bitbake rev: 1cbf8a9403b4b60d59bfd90a51c3e4246ab834d6)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2011-01-04 14:46:39 +00:00