Unix build fixes.

Generally use 'available' instead of 'present'.
If dont_user_docker is set (or WSL, or vbox), we don't even check for it,
so we don't know if it's present.
'Available' means it's allowed and present.
This commit is contained in:
David Anderson 2024-08-21 00:40:50 -07:00
parent a5517209c5
commit 1a8477fac1
7 changed files with 28 additions and 27 deletions

View File

@ -292,19 +292,15 @@ void CLIENT_STATE::show_host_info() {
}
#ifndef _WIN64
if (host_info.docker_present && strlen(host_info.docker_version)) {
msg_printf(NULL, MSG_INFO, "Docker %s is present",
if (host_info.docker_available && strlen(host_info.docker_version)) {
msg_printf(NULL, MSG_INFO, "Docker version %s found",
host_info.docker_version
);
} else {
msg_printf(NULL, MSG_INFO, "Docker is not present");
}
if (host_info.docker_compose_present && strlen(host_info.docker_compose_version)) {
msg_printf(NULL, MSG_INFO, "Docker compose %s is present",
if (host_info.docker_compose_available && strlen(host_info.docker_compose_version)) {
msg_printf(NULL, MSG_INFO, "Docker compose version %s found",
host_info.docker_compose_version
);
} else {
msg_printf(NULL, MSG_INFO, "Docker compose is not present");
}
#endif
}

View File

@ -1242,7 +1242,7 @@ bool HOST_INFO::get_docker_compose_info(){
fgets(buf, 256, f);
std::string version;
if (get_docker_compose_version_string(buf, version)) {
docker_compose_present = true;
docker_compose_available = true;
safe_strcpy(docker_compose_version, version.c_str());
}
pclose(f);
@ -1261,7 +1261,7 @@ bool HOST_INFO::get_docker_info(){
fgets(buf, 256, f);
std::string version;
if (get_docker_version_string(buf, version)) {
docker_present = true;
docker_available = true;
safe_strcpy(docker_version, version.c_str());
}
pclose(f);

View File

@ -372,11 +372,11 @@ struct HOST {
bool p_vm_extensions_disabled;
int num_opencl_cpu_platforms;
OPENCL_CPU_PROP opencl_cpu_prop[MAX_OPENCL_CPU_PLATFORMS];
bool wsl_available;
WSLS wsls;
WSL_DISTROS wsl_distros;
//Docker available
// Docker info (non-Win only)
bool docker_available;
// present and allowed by config
bool docker_compose_available;
char docker_version[256];
char docker_compose_version[256];

View File

@ -74,8 +74,8 @@ void HOST_INFO::clear_host_info() {
#ifdef _WIN64
wsl_distros.clear();
#else
docker_present = false;
docker_compose_present = false;
docker_available = false;
docker_compose_available = false;
safe_strcpy(docker_version, "");
safe_strcpy(docker_compose_version, "");
#endif
@ -142,7 +142,8 @@ int HOST_INFO::parse(XML_PARSER& xp, bool static_items_only) {
continue;
}
#else
if (xp.parse_bool("docker_present", docker_present)) continue;
if (xp.parse_bool("docker_available", docker_available)) continue;
if (xp.parse_bool("docker_compose_available", docker_compose_available)) continue;
if (xp.parse_str("docker_version", docker_version, sizeof(docker_version))) continue;
if (xp.parse_str("docker_compose_version", docker_compose_version, sizeof(docker_compose_version))) continue;
#endif
@ -238,8 +239,12 @@ int HOST_INFO::write(
#else
out.printf(
" <docker_present>%d</docker_present>\n",
docker_present ? 1 : 0
" <docker_available>%d</docker_available>\n",
docker_available ? 1 : 0
);
out.printf(
" <docker_compose_available>%d</docker_compose_available>\n",
docker_compose_available ? 1 : 0
);
if (strlen(docker_version)) {
out.printf(

View File

@ -89,8 +89,9 @@ public:
// on Windows, Docker info is per WSL_DISTRO, not global
WSL_DISTROS wsl_distros;
#else
bool docker_present;
bool docker_compose_present;
bool docker_available;
// Docker is present and allowed by config
bool docker_compose_available;
char docker_version[256];
char docker_compose_version[256];
#endif

View File

@ -35,15 +35,15 @@ struct WSL_DISTRO {
int wsl_version;
// version of WSL (currently 1 or 2)
bool is_default;
// whether this is the default distro
// this is the default distro
bool is_docker_available;
// whether Docker is available in this distro
// Docker is present and allowed by config
bool is_docker_compose_available;
// whether Docker Compose is available in this distro
// Docker Compose is present and allowed by config
std::string docker_version;
// version of Docker in this distro
// version of Docker
std::string docker_compose_version;
// version of Docker Compose in this distro
// version of Docker Compose
WSL_DISTRO();
void clear();

View File

@ -1412,9 +1412,8 @@ int HOST::parse(XML_PARSER& xp) {
if (!retval) num_opencl_cpu_platforms++;
continue;
}
if (xp.parse_bool("wsl_available", wsl_available)) continue;
if (xp.match_tag("wsl")) {
wsls.parse(xp);
wsl_distros.parse(xp);
continue;
}