Save the initial environment
cover Save the initial environment
Both Chris' terminal work and my reparse command will benefit from a saved copy of the initial enviornment. The Python docs indicate that the os.environ map is captured when the os module is first imported
http://docs.python.org/library/os.html#os.environ) so this patch adds a variable to the bb namespace (bb.initial_environ) that is an early copy of the environment.
I put the variable here so that a) it's easily accessible and b) we can take the copy pretty early on.
Any thoughts on this? Note the RFC prefix. :-)
Thanks,
Joshua
Please review the following changes for suitability for inclusion. If you have any objections or suggestions for improvement, please respond to the patches. If you agree with the changes, please provide your Acked-by.
The following changes since commit 5c8eeefc79455f058dda8f04cf4c12dc5418e00f:
cooker: only return *Found events if something was actually found (2011-07-14 15:12:40 +0100)
are available in the git repository at:
git://github.com/incandescant/bitbake initialenv
https://github.com/incandescant/bitbake/tree/initialenv
Joshua Lock (1):
lib/bb: preserve a copy of the initial environment variables
lib/bb/__init__.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.6
RFC PATCH 1/1 lib/bb: preserve a copy of the initial environment variables
We are gradually introducing code which wants to be able to modify the initial environment of BitBake. The os.environ map is created on first import of the os module so create a copy early on and store it for future use.
--- lib/bb/__init__.py | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
lib/bb/__init__.py +4 -0
@@ -30,6 +30,10 @@ if sys.version_info < (2, 6, 0): import os import logging +# The os.environ map of the environment is captured the first time the os +# module is imported. Take a copy so we can preserve the original environment +# for later use. +initial_environ = os.environ.copy() class NullHandler(logging.Handler): def emit(self, record):
Signature · 1 line
1.7.6
Quoted 11 lines · Joshua Lock
Both Chris' terminal work and my reparse command will benefit from a saved copy of the initial enviornment. The Python docs indicate that the os.environ map is captured when the os module is first imported
http://docs.python.org/library/os.html#os.environ) so this patch adds a variable to the bb namespace (bb.initial_environ) that is an early copy of the environment.I put the variable here so that a) it's easily accessible and b) we can take the copy pretty early on.
Any thoughts on this? Note the RFC prefix. :-)
Sorry I didn't reply earlier.
I'd really this the environment storage to be something we do explicitly in bin/bitbake alongside:
# Clear away any spurious environment variables. But don't wipe the # environment totally. This is necessary to ensure the correct operation # of the UIs (e.g. for DISPLAY, etc.) bb.utils.clean_environment()
I'd suggest we create a copy there, then pass it into cooker and its cooker which actually stores the copy for future reference. We may then need to find a way to get to that at the metadata level and from the UIs but what shouldn't be too difficult.
Cheers,
Richard
Quoted 8 lines · Richard Purdie
Quoted 7 lines · Joshua Lock
Both Chris' terminal work and my reparse command will benefit from a saved copy of the initial enviornment. The Python docs indicate that the os.environ map is captured when the os module is first imported
http://docs.python.org/library/os.html#os.environ) so this patch adds a variable to the bb namespace (bb.initial_environ) that is an early copy of the environment.
Quoted 6 lines
Quoted 4 lines
I put the variable here so that a) it's easily accessible and b) we can take the copy pretty early on.
Any thoughts on this? Note the RFC prefix. :-)
Sorry I didn't reply earlier.
No problem.
Quoted 8 lines
I'd really this the environment storage to be something we do explicitly in bin/bitbake alongside:
# Clear away any spurious environment variables. But don't wipe the # environment totally. This is necessary to ensure the correct operation # of the UIs (e.g. for DISPLAY, etc.)
bb.utils.clean_environment()
Quoted 4 lines
I'd suggest we create a copy there, then pass it into cooker and its cooker which actually stores the copy for future reference. We may then need to find a way to get to that at the metadata level and from the UIs but what shouldn't be too difficult.
Ah yes, that feels much nicer than doing it implicitly in the library. Expect a v2 RFC shortly (probably in your inbox tomorrow morning ;-))
Thanks,
Joshua
Signature · 3 lines
Joshua Lock
Yocto Project "Johannes Factotum"
Intel Open Source Technology Centre