Skip to content

Commit 24d3eab

Browse files
Wei Liuwenlingz
authored andcommitted
acrn-config: skip git environment check when not do git commit
Check git environment only when '--enable_commit' option was set. Tracked-On: #3854 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com>
1 parent fbd8597 commit 24d3eab

File tree

7 files changed

+42
-35
lines changed

7 files changed

+42
-35
lines changed

misc/acrn-config/board_config/board_cfg_gen.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def main(args):
3535
if err_dic:
3636
return err_dic
3737

38+
# check env
39+
err_dic = board_cfg_lib.prepare(enable_commit)
40+
if err_dic:
41+
return err_dic
42+
3843
board_cfg_lib.BOARD_INFO_FILE = board_info_file
3944
board_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
4045
board_cfg_lib.get_vm_count(scenario_info_file)
@@ -124,11 +129,13 @@ def main(args):
124129

125130
def ui_entry_api(board_info,scenario_info, enable_commit=False):
126131

132+
git_env_check = False
127133
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
128134
if enable_commit:
129135
arg_list.append('--enable_commit')
136+
git_env_check = True
130137

131-
err_dic = board_cfg_lib.prepare()
138+
err_dic = board_cfg_lib.prepare(git_env_check)
132139
if err_dic:
133140
return err_dic
134141

@@ -139,12 +146,6 @@ def ui_entry_api(board_info,scenario_info, enable_commit=False):
139146

140147
if __name__ == '__main__':
141148

142-
err_dic = board_cfg_lib.prepare()
143-
if err_dic:
144-
for err_k, err_v in err_dic.items():
145-
board_cfg_lib.print_red("{}: {}".format(err_k, err_v), err=True)
146-
sys.exit(1)
147-
148149
ARGS = sys.argv
149150
err_dic = main(ARGS)
150151
if err_dic:

misc/acrn-config/launch_config/launch_cfg_gen.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ def validate_launch_setting(board_info, scenario_info, launch_info):
8484
def ui_entry_api(board_info, scenario_info, launch_info, enable_commit=False):
8585

8686
err_dic = {}
87-
87+
git_env_check = False
8888
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info, '--launch', launch_info, '--uosid', '0']
8989

9090
if enable_commit:
9191
arg_list.append('--enable_commit')
92+
git_env_check = True
9293

93-
err_dic = launch_cfg_lib.prepare()
94+
err_dic = launch_cfg_lib.prepare(git_env_check)
9495
if err_dic:
9596
return err_dic
9697

@@ -148,6 +149,12 @@ def main(args):
148149
(err_dic, board_info_file, scenario_info_file, launch_info_file, vm_th, enable_commit) = launch_cfg_lib.get_param(args)
149150
if err_dic:
150151
return err_dic
152+
153+
# check env
154+
err_dic = launch_cfg_lib.prepare(enable_commit)
155+
if err_dic:
156+
return err_dic
157+
151158
# vm_th =[0..post_vm_max]
152159
# 0: generate all launch script for all post vm launch script
153160
# 1: generate launch script for 1st post vm launch script
@@ -236,12 +243,6 @@ def main(args):
236243

237244
if __name__ == '__main__':
238245

239-
err_dic = launch_cfg_lib.prepare()
240-
if err_dic:
241-
for err_k, err_v in err_dic.items():
242-
launch_cfg_lib.print_red("{}: {}".format(err_k, err_v), err=True)
243-
sys.exit(1)
244-
245246
ARGS = sys.argv
246247
err_dic = main(ARGS)
247248
if err_dic:

misc/acrn-config/library/board_cfg_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
HEADER_LICENSE = common.open_license() + "\n"
3535

3636

37-
def prepare():
37+
def prepare(check_git):
3838
""" check environment """
39-
return common.check_env()
39+
return common.check_env(check_git)
4040

4141

4242
def print_yel(msg, warn=False):

misc/acrn-config/library/common.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
PY_CACHES = ["__pycache__", "../board_config/__pycache__", "../scenario_config/__pycache__"]
18-
BIN_LIST = ['git']
1918
GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTHROUGH",
2019
"GUEST_FLAG_IO_COMPLETION_POLLING", "GUEST_FLAG_CLOS_REQUIRED",
2120
"GUEST_FLAG_HIDE_MTRR", "GUEST_FLAG_RT", "GUEST_FLAG_HIGHEST_SEVERITY"]
@@ -105,10 +104,19 @@ def get_param(args):
105104
return (err_dic, board_info_file, scenario_info_file, enable_commit)
106105

107106

108-
def check_env():
107+
def check_env(check_git=False):
109108
""" Prepare to check the environment """
110109
err_dic = {}
111-
for excute in BIN_LIST:
110+
bin_list = []
111+
112+
if check_git:
113+
bin_list.append('git')
114+
115+
usr_dir = os.environ['HOME']
116+
if not os.path.isfile("{}/.gitconfig".format(usr_dir)):
117+
err_dic['commn error: check env failed'] = "git not configured!"
118+
119+
for excute in bin_list:
112120
res = subprocess.Popen("which {}".format(excute), shell=True, stdout=subprocess.PIPE,
113121
stderr=subprocess.PIPE, close_fds=True)
114122

@@ -125,10 +133,6 @@ def check_env():
125133
if "acrn" not in line:
126134
err_dic['commn error: check env failed'] = "Run this tool in acrn-hypervisor mainline source code!"
127135

128-
usr_dir = os.environ['HOME']
129-
if not os.path.isfile("{}/.gitconfig".format(usr_dir)):
130-
err_dic['commn error: check env failed'] = "git not configured!"
131-
132136
for py_cache in PY_CACHES:
133137
if os.path.exists(py_cache):
134138
shutil.rmtree(py_cache)

misc/acrn-config/library/launch_cfg_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
POST_UUID_DIC = {}
5555

5656

57-
def prepare():
57+
def prepare(check_git):
5858
""" Check environment """
59-
return common.check_env()
59+
return common.check_env(check_git)
6060

6161

6262
def print_yel(msg, warn=False):

misc/acrn-config/library/scenario_cfg_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535

3636
ERR_LIST = {}
3737

38-
def prepare():
38+
def prepare(check_git):
3939
""" Check environment """
40-
return common.check_env()
40+
return common.check_env(check_git)
4141

4242

4343
def print_yel(msg, warn=False):

misc/acrn-config/scenario_config/scenario_cfg_gen.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ def main(args):
8282
if err_dic:
8383
return err_dic
8484

85+
# check env
86+
err_dic = scenario_cfg_lib.prepare(enable_commit)
87+
if err_dic:
88+
return err_dic
89+
8590
scenario_cfg_lib.BOARD_INFO_FILE = board_info_file
8691
scenario_cfg_lib.SCENARIO_INFO_FILE = scenario_info_file
8792

@@ -145,11 +150,13 @@ def main(args):
145150

146151
def ui_entry_api(board_info, scenario_info, enable_commit=False):
147152

153+
git_env_check = False
148154
arg_list = ['board_cfg_gen.py', '--board', board_info, '--scenario', scenario_info]
149155
if enable_commit:
150156
arg_list.append('--enable_commit')
157+
git_env_check = True
151158

152-
err_dic = scenario_cfg_lib.prepare()
159+
err_dic = scenario_cfg_lib.prepare(git_env_check)
153160
if err_dic:
154161
return err_dic
155162

@@ -160,12 +167,6 @@ def ui_entry_api(board_info, scenario_info, enable_commit=False):
160167

161168
if __name__ == '__main__':
162169

163-
err_dic = scenario_cfg_lib.prepare()
164-
if err_dic:
165-
for err_k, err_v in err_dic.items():
166-
scenario_cfg_lib.print_red("{}: {}".format(err_k, err_v), err=True)
167-
sys.exit(1)
168-
169170
ARGS = sys.argv
170171
err_dic = main(ARGS)
171172
if err_dic:

0 commit comments

Comments
 (0)