diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-10 09:20:18 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-10 09:20:18 -0400 |
commit | 6cab5d431e8de192af156efef21ef97efc3a8830 (patch) | |
tree | 2a4fb956628c4aee869a1a96b9beac89d67b200b | |
parent | 8c69a18b82be2e8179883b1d48cfb2fc0520b6f2 (diff) | |
download | stasis-6cab5d431e8de192af156efef21ef97efc3a8830.tar.gz |
Add check_system_requirements() helper
* Fail out early on error to avoid user frustration
-rw-r--r-- | src/main.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -143,6 +143,44 @@ void globals_free() { guard_free(globals.workaround.tox_posargs); } +static void check_system_requirements() { + const char *tools_required[] = { + "rsync", + NULL, + }; + + msg(OMC_MSG_L1, "Checking system requirements\n"); + for (size_t i = 0; tools_required[i] != NULL; i++) { + if (!find_program(tools_required[i])) { + msg(OMC_MSG_L2 | OMC_MSG_ERROR, "'%s' must be installed.\n", tools_required[i]); + exit(1); + } + } + + struct DockerCapabilities dcap; + if (!docker_capable(&dcap)) { + msg(OMC_MSG_L2 | OMC_MSG_WARN, "Docker is broken\n"); + msg(OMC_MSG_L3, "Available: %s\n", dcap.available ? "Yes" : "No"); + msg(OMC_MSG_L3, "Usable: %s\n", dcap.usable ? "Yes" : "No"); + msg(OMC_MSG_L3, "Podman [Docker Emulation]: %s\n", dcap.podman ? "Yes" : "No"); + msg(OMC_MSG_L3, "Build plugin(s): "); + if (dcap.usable) { + if (dcap.build & OMC_DOCKER_BUILD) { + printf("build "); + } + if (dcap.build & OMC_DOCKER_BUILD_X) { + printf("buildx "); + } + puts(""); + } else { + printf("N/A\n"); + } + + // disable docker builds + globals.enable_docker = false; + } +} + int main(int argc, char *argv[]) { struct INIFILE *cfg = NULL; struct INIFILE *ini = NULL; @@ -230,6 +268,7 @@ int main(int argc, char *argv[]) { printf(BANNER, VERSION, AUTHOR); + check_system_requirements(); msg(OMC_MSG_L1, "Setup\n"); // Expose variables for use with the template engine |