cpb- / yocto-cooker

Meta buildtool for Yocto Project based Linux embedded systems
GNU General Public License v2.0
43 stars 22 forks source link

`cooker shell` failure #99

Closed cpb- closed 2 years ago

cpb- commented 2 years ago

When running $ cooker shell <build-name>, I got the following error:

Error: /home/user/oe-init-build-env doesn't exist!
Please run this script in oe-init-build-env's directory.

Other commands (show, cook, etc.) work as expected.

cooker --version gives # 1.1.0

pboettch commented 2 years ago

Are you sure you're not using your dev-branch which implements the support for different openembedded-distributions?

cpb- commented 2 years ago

When /bin/sh is a link to /bin/bash the shell sub-command runs as expected. The problem arises when /bin/sh is a link to /bin/dash. This was the case in my build container above.

Running manually the command that cooker tries to run gives the following results

With Bash:

$ /bin/bash -c ". /home/user/layers/poky/oe-init-build-env my-build; /bin/bash"

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'
[...]

$ which bitbake
/home/user/layers/poky/bitbake/bin/bitbake

$ exit
exit

With Dash:

$ /bin/dash -c ". /home/user/layers/poky/oe-init-build-env my-build; /bin/dash"
Error: /home/user/oe-init-build-env doesn't exist!
Please run this script in oe-init-build-env's directory.

The easier way to resolve this could be a direct call to /bin/bash. Note that we already have bash-dependencies. For example line 580 of current cooker.py version;

580      command_line = 'env bash -c "source {} {} && bitbake {} {}"'.format(init_script, directory, bb_task, bb_target)

So the question is: do we need to fight to remove Bash dependencies, or could we just replace

588      shell = os.environ.get('SHELL', '/bin/sh')

by

588      shell = os.environ.get('SHELL', '/bin/bash')

Any suggestion?

pboettch commented 2 years ago

Can't we use python-functions to do system-calls? Without bothering which shell is default?

cpb- commented 2 years ago

Not sure if we can source a shell script (oe-init-build-env for example) directly with python functions.

Maybe with subprocess library instead of os.system calls.

pboettch commented 2 years ago

Subprocess is a good candidate

RomainNaour commented 2 years ago

When /bin/sh is a link to /bin/bash the shell sub-command runs as expected. The problem arises when /bin/sh is a link to /bin/dash. This was the case in my build container above.

At least with Dunfell, dash is still an issue with Yocto and you have to reconfigure dash to use bash (dpkg-reconfigure dash). I had the issue recently.