All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] Save the initial environment
@ 2011-07-18 22:33 Joshua Lock
  2011-07-18 22:33 ` [RFC PATCH 1/1] lib/bb: preserve a copy of the initial environment variables Joshua Lock
  2011-07-21 21:22 ` [RFC PATCH 0/1] Save the initial environment Richard Purdie
  0 siblings, 2 replies; 4+ messages in thread
From: Joshua Lock @ 2011-07-18 22:33 UTC (permalink / raw)
  To: bitbake-devel

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(-)

-- 
1.7.6




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC PATCH 1/1] lib/bb: preserve a copy of the initial environment variables
  2011-07-18 22:33 [RFC PATCH 0/1] Save the initial environment Joshua Lock
@ 2011-07-18 22:33 ` Joshua Lock
  2011-07-21 21:22 ` [RFC PATCH 0/1] Save the initial environment Richard Purdie
  1 sibling, 0 replies; 4+ messages in thread
From: Joshua Lock @ 2011-07-18 22:33 UTC (permalink / raw)
  To: bitbake-devel

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.

Signed-off-by: Joshua Lock <josh@linux.intel.com>
---
 lib/bb/__init__.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py
index d20267b..414e836 100644
--- a/lib/bb/__init__.py
+++ b/lib/bb/__init__.py
@@ -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):
-- 
1.7.6




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 0/1] Save the initial environment
  2011-07-18 22:33 [RFC PATCH 0/1] Save the initial environment Joshua Lock
  2011-07-18 22:33 ` [RFC PATCH 1/1] lib/bb: preserve a copy of the initial environment variables Joshua Lock
@ 2011-07-21 21:22 ` Richard Purdie
  2011-07-21 22:12   ` Joshua Lock
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2011-07-21 21:22 UTC (permalink / raw)
  To: Joshua Lock; +Cc: bitbake-devel

On Mon, 2011-07-18 at 15:33 -0700, Joshua Lock wrote:
> 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH 0/1] Save the initial environment
  2011-07-21 21:22 ` [RFC PATCH 0/1] Save the initial environment Richard Purdie
@ 2011-07-21 22:12   ` Joshua Lock
  0 siblings, 0 replies; 4+ messages in thread
From: Joshua Lock @ 2011-07-21 22:12 UTC (permalink / raw)
  To: Richard Purdie; +Cc: bitbake-devel

On Thu, 2011-07-21 at 22:22 +0100, Richard Purdie wrote:
> On Mon, 2011-07-18 at 15:33 -0700, Joshua Lock wrote:
> > 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.

No problem.

> 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.

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
-- 
Joshua Lock
        Yocto Project "Johannes Factotum"
        Intel Open Source Technology Centre




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-21 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18 22:33 [RFC PATCH 0/1] Save the initial environment Joshua Lock
2011-07-18 22:33 ` [RFC PATCH 1/1] lib/bb: preserve a copy of the initial environment variables Joshua Lock
2011-07-21 21:22 ` [RFC PATCH 0/1] Save the initial environment Richard Purdie
2011-07-21 22:12   ` Joshua Lock

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.