Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/tools/
Date: Fri, 02 Aug 2013 10:34:47
Message-Id: 1375438861.e7d0acb0f3de8345a6f84354f7c1a8fa58d245bc.dywi@gentoo
1 commit: e7d0acb0f3de8345a6f84354f7c1a8fa58d245bc
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Fri Aug 2 10:21:01 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Fri Aug 2 10:21:01 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=e7d0acb0
7
8 roverlay/tools/shenv: export HAS_CHANGES
9
10 ---
11 roverlay/tools/shenv.py | 56 +++++++++++++++++++++++++------------------------
12 1 file changed, 29 insertions(+), 27 deletions(-)
13
14 diff --git a/roverlay/tools/shenv.py b/roverlay/tools/shenv.py
15 index e9b1bad..9ee3af6 100644
16 --- a/roverlay/tools/shenv.py
17 +++ b/roverlay/tools/shenv.py
18 @@ -15,6 +15,7 @@ import time
19 import roverlay.config
20 import roverlay.strutil
21 import roverlay.util
22 +import roverlay.stats.collector
23
24
25 # _SHELL_ENV, _SHELL_INTPR are created when calling run_script()
26 @@ -94,6 +95,14 @@ NULL_PHASE = 'null'
27 # depends on log level
28 #
29
30 +# @typedef shbool is SH_TRUE|SH_FALSE, where:
31 +SH_TRUE = 'y'
32 +SH_FALSE = 'n'
33 +
34 +def shbool ( value ):
35 + """Converts value into a shbool."""
36 + return SH_TRUE if value else SH_FALSE
37 +# --- end of shbool (...) ---
38
39 def setup_env():
40 """Returns a 'well-defined' env dict for running scripts."""
41 @@ -102,15 +111,6 @@ def setup_env():
42 SHLIB_DIRNAME = 'shlib'
43 SHFUNC_FILENAME = 'functions.sh'
44
45 - # @typedef shbool is SH_TRUE|SH_FALSE, where:
46 - SH_TRUE = 'y'
47 - SH_FALSE = 'n'
48 -
49 - def shbool ( value ):
50 - """Converts value into a shbool."""
51 - return SH_TRUE if value else SH_FALSE
52 - # --- end of shbool (...) ---
53 -
54 # import os.environ
55 if roverlay.config.get ( "SHELL_ENV.filter_env", True ):
56 # (keepenv does not support wildcars)
57 @@ -307,7 +307,7 @@ def setup_env():
58 return env
59 # --- end of setup_env (...) ---
60
61 -def get_env ( copy=False ):
62 +def make_env ( copy=False ):
63 global _SHELL_ENV
64 if _SHELL_ENV is None:
65 _SHELL_ENV = setup_env()
66 @@ -316,23 +316,31 @@ def get_env ( copy=False ):
67 return dict ( _SHELL_ENV )
68 else:
69 return _SHELL_ENV
70 -# --- end of get_env (...) ---
71 +# --- end of make_env (...) ---
72
73 def update_env ( **info ):
74 - get_env().update ( info )
75 - return _SHELL_ENV
76 + env = make_env()
77 + env.update ( info )
78 + return env
79 # --- end of update_env (...) ---
80
81 +def get_env ( phase, copy=True ):
82 + env = make_env ( copy=copy )
83 + if phase:
84 + env ['ROVERLAY_PHASE'] = str ( phase ).lower()
85 +
86 + env ['HAS_CHANGES'] = shbool (
87 + roverlay.stats.collector.static.overlay_has_any_changes()
88 + )
89 +
90 + return env
91 +# --- end of get_env (...) ---
92 +
93 +
94 def run_script_exec (
95 script, phase, argv=(), initial_dir=None, use_path=True
96 ):
97 - if phase:
98 - my_env = get_env ( copy=True )
99 - my_env ['ROVERLAY_PHASE'] = str ( phase ).lower()
100 - else:
101 - # ref
102 - my_env = get_env()
103 - # -- end if phase;
104 + my_env = get_env ( phase )
105
106 if initial_dir:
107 os.chdir ( initial_dir )
108 @@ -354,13 +362,7 @@ def run_script (
109 # _SHELL_INTPR = roverlay.config.get ( 'SHELL_ENV.shell', '/bin/sh' )
110
111 my_logger = logger or LOGGER
112 - if phase:
113 - my_env = get_env ( copy=True )
114 - my_env ['ROVERLAY_PHASE'] = str ( phase ).lower()
115 - else:
116 - # ref
117 - my_env = get_env()
118 - # -- end if phase;
119 + my_env = get_env ( phase )
120
121 try:
122 script_call = subprocess.Popen (