Skip to content

Commit ad1a0a0

Browse files
committed
ab3cfg,main: also accept specifying stage2 mode ...
* ... via environment variables * also print out a message when running in stage2 mode
1 parent f59d66a commit ad1a0a0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

acbs/ab3cfg.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
from pyparsing import ParseException # type: ignore
66

77

8+
def is_in_stage2_file(ab3cfg_path: str) -> bool:
9+
with open(ab3cfg_path) as f:
10+
vars = bashvar.eval_bashvar(f.read(), filename=ab3cfg_path)
11+
stage2_val: str = vars.get('ABSTAGE2')
12+
return stage2_val == '1'
13+
return False
14+
15+
16+
def is_in_stage2_env() -> bool:
17+
return os.environ.get('ABSTAGE2', '') == '1'
18+
19+
820
def is_in_stage2() -> bool:
21+
"""
22+
Return whether the current environment is in a stage2 development phase.
23+
"""
924
ab3cfg_path: str = os.path.join(AUTOBUILD_CONF_DIR, 'ab3cfg.sh')
1025
try:
11-
with open(ab3cfg_path) as f:
12-
vars = bashvar.eval_bashvar(f.read(), filename=ab3cfg_path)
13-
stage2_val: str = vars.get('ABSTAGE2')
14-
return stage2_val == '1'
26+
return is_in_stage2_env() or is_in_stage2_file(ab3cfg_path)
1527
except OSError as e:
1628
raise RuntimeError(f'Unable to read Autobuild config file {ab3cfg_path}.') from e
1729
except ParseException as e:

acbs/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ def build(self) -> None:
9494
build_timings: List[Tuple[str, float]] = []
9595
acbs.fetch.generate_mode = self.generate
9696
acbs.parser.generate_mode = self.generate
97+
if self.stage2:
98+
logging.info("Life-cycle: currently running in stage2 mode.")
9799
# begin finding and resolving dependencies
98100
logging.info('Searching and resolving dependencies...')
99101
acbs.pm.reorder_mode = self.reorder

0 commit comments

Comments
 (0)