Skip to content

Commit c916506

Browse files
committed
get x86 from server arch arg, install both if x86
1 parent f1a76d1 commit c916506

File tree

3 files changed

+65
-43
lines changed

3 files changed

+65
-43
lines changed

installation_and_upgrade/IBEX_upgrade.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
import sys
99

10+
import ibex_install_utils.default_args
1011
import semantic_version
1112
from ibex_install_utils.exceptions import ErrorInTask, UserStop
1213
from ibex_install_utils.file_utils import FileUtils
@@ -108,7 +109,10 @@ def _get_latest_existing_dir_path(release_dir, component):
108109
)
109110
parser.add_argument("--kits_icp_dir", default=None, help="Directory of kits/ICP")
110111
parser.add_argument(
111-
"--server_arch", default="x64", choices=["x64", "x86"], help="Server build architecture."
112+
"--server_arch",
113+
default=ibex_install_utils.default_args.SERVER_ARCH,
114+
choices=["x64", "x86"],
115+
help="Server build architecture.",
112116
)
113117

114118
deployment_types = [
@@ -122,6 +126,8 @@ def _get_latest_existing_dir_path(release_dir, component):
122126

123127
args = parser.parse_args()
124128

129+
ibex_install_utils.default_args.SERVER_ARCH = args.server_arch
130+
125131
if not args.no_log_to_var:
126132
Logger.set_up()
127133

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SERVER_ARCH = "x64"

installation_and_upgrade/ibex_install_utils/tasks/system_tasks.py

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -428,51 +428,66 @@ def install_or_upgrade_vc_redist(self) -> None:
428428
"""
429429
Install the latest visual studio redistributable files
430430
"""
431+
import ibex_install_utils.default_args
431432

432-
is_64_bit = platform.machine().endswith("64")
433-
exe_file = Path(EPICS_CRTL_PATH, f"vc_redist.{'x64' if is_64_bit else 'x86'}.exe")
434-
if exe_file.exists() and exe_file.is_file():
435-
log_file = Path(
436-
VAR_DIR, "logs", "deploy", f"vc_redist_log{time.strftime('%Y%m%d%H%M%S')}.txt"
437-
)
433+
arch = ibex_install_utils.default_args.SERVER_ARCH
438434

439-
# AdminRunner doesn't seem to work here, saying it can't find a handle, so just run as a
440-
# normal command as the process itself prompts for admin.
441-
RunProcess(
442-
working_dir=str(exe_file.parent),
443-
executable_file=exe_file.name,
444-
prog_args=["/install", "/norestart", "/passive", "/quiet", "/log", str(log_file)],
445-
expected_return_codes=[0],
446-
).run()
447-
448-
# vc_redist helpfully finishes with errorlevel 0 before actually copying the files over.
449-
# therefore we'll sleep for 5 seconds here
450-
print("waiting for install to finish")
451-
sleep(5)
452-
453-
last_line = ""
454-
with open(log_file, "r") as f:
455-
for line in f.readlines():
456-
print("vc_redist install output: {}".format(line.rstrip()))
457-
last_line = line
458-
459-
status = (
460-
"It looked like it installed correctly, but "
461-
if "Exit code: 0x0" in last_line
462-
else "it looked like the process errored,"
463-
)
435+
print(f"Installing vc_redist for arch: {arch}")
464436

465-
self.prompt.prompt_and_raise_if_not_yes(
466-
f"Installing vc redistributable files finished.\n"
467-
f"{status}"
468-
f"please check log output above for errors,\nor alternatively {log_file}",
469-
default="Y",
470-
)
471-
else:
472-
raise ErrorInTask(
473-
f"VC redistributable files not found in {exe_file.parent}, please check"
474-
f" and make sure {exe_file} is present. "
475-
)
437+
files_to_run = [f"vc_redist.x64.exe"]
438+
if arch == "x86":
439+
files_to_run.insert(0, "vc_redist.x86.exe")
440+
for file in files_to_run:
441+
exe_file = Path(EPICS_CRTL_PATH, file)
442+
if exe_file.exists() and exe_file.is_file():
443+
log_file = Path(
444+
VAR_DIR, "logs", "deploy", f"vc_redist_log{time.strftime('%Y%m%d%H%M%S')}.txt"
445+
)
446+
447+
# AdminRunner doesn't seem to work here, saying it can't find a handle, so just run as a
448+
# normal command as the process itself prompts for admin.
449+
RunProcess(
450+
working_dir=str(exe_file.parent),
451+
executable_file=exe_file.name,
452+
prog_args=[
453+
"/install",
454+
"/norestart",
455+
"/passive",
456+
"/quiet",
457+
"/log",
458+
str(log_file),
459+
],
460+
expected_return_codes=[0],
461+
).run()
462+
463+
# vc_redist helpfully finishes with errorlevel 0 before actually copying the files over.
464+
# therefore we'll sleep for 5 seconds here
465+
print("waiting for install to finish")
466+
sleep(5)
467+
468+
last_line = ""
469+
with open(log_file, "r") as f:
470+
for line in f.readlines():
471+
print("vc_redist install output: {}".format(line.rstrip()))
472+
last_line = line
473+
474+
status = (
475+
"It looked like it installed correctly, but "
476+
if "Exit code: 0x0" in last_line
477+
else "it looked like the process errored,"
478+
)
479+
480+
self.prompt.prompt_and_raise_if_not_yes(
481+
f"Installing vc redistributable files finished.\n"
482+
f"{status}"
483+
f"please check log output above for errors,\nor alternatively {log_file}",
484+
default="Y",
485+
)
486+
else:
487+
raise ErrorInTask(
488+
f"VC redistributable files not found in {exe_file.parent}, please check"
489+
f" and make sure {exe_file} is present. "
490+
)
476491

477492
def confirm(self, message: str) -> None:
478493
"""

0 commit comments

Comments
 (0)