Skip to content

Commit 854c511

Browse files
authored
Update script to detect Podman in the system (#287)
* Add support for podman * [Automated Commit] Format Codebase [skip ci] * Container tool name made dynamic
1 parent cfa5519 commit 854c511

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

script/get-docker/customize.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ def preprocess(i):
1212

1313
recursion_spaces = i['recursion_spaces']
1414

15-
file_name = 'docker.exe' if os_info['platform'] == 'windows' else 'docker'
16-
env['FILE_NAME'] = file_name
15+
file_name_docker = 'docker.exe' if os_info['platform'] == 'windows' else 'docker'
16+
file_name_podman = 'podman.exe' if os_info['platform'] == 'windows' else 'podman'
1717

1818
if 'MLC_DOCKER_BIN_WITH_PATH' not in env:
19-
r = i['automation'].find_artifact({'file_name': file_name,
19+
# check for docker
20+
# if docker is not found, podman is checked
21+
env['FILE_NAME'] = file_name_docker
22+
env['CONTAINER_TOOL_NAME'] = "docker"
23+
r = i['automation'].find_artifact({'file_name': file_name_docker,
2024
'env': env,
2125
'os_info': os_info,
2226
'default_path_env_key': 'PATH',
@@ -26,11 +30,26 @@ def preprocess(i):
2630
'recursion_spaces': recursion_spaces})
2731
if r['return'] > 0:
2832
if r['return'] == 16:
29-
run_file_name = "install"
30-
r = automation.run_native_script(
31-
{'run_script_input': i['run_script_input'], 'env': env, 'script_name': run_file_name})
33+
# check for podman
34+
# if podman is also absent, the script will try to
35+
# automatically install docker in the system
36+
env['FILE_NAME'] = file_name_podman
37+
env['CONTAINER_TOOL_NAME'] = "podman"
38+
r = i['automation'].find_artifact({'file_name': file_name_podman,
39+
'env': env,
40+
'os_info': os_info,
41+
'default_path_env_key': 'PATH',
42+
'detect_version': True,
43+
'env_path_key': 'MLC_DOCKER_BIN_WITH_PATH',
44+
'run_script_input': i['run_script_input'],
45+
'recursion_spaces': recursion_spaces})
3246
if r['return'] > 0:
33-
return r
47+
if r['return'] == 16:
48+
run_file_name = "install"
49+
r = automation.run_native_script(
50+
{'run_script_input': i['run_script_input'], 'env': env, 'script_name': run_file_name})
51+
if r['return'] > 0:
52+
return r
3453
else:
3554
return r
3655

script/get-docker/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
2-
docker --version > tmp-ver.out
2+
${CONTAINER_TOOL_NAME} --version > tmp-ver.out
33
test $? -eq 0 || exit 1

0 commit comments

Comments
 (0)