aboutsummaryrefslogtreecommitdiff
path: root/src/cli/stasis/stasis_main.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-11-14 00:36:06 -0500
committerGitHub <noreply@github.com>2024-11-14 00:36:06 -0500
commit613bfff7ffae94b76c9d3bd46b50b42ea4ceb164 (patch)
tree7adbd4a95963d61b02c652a27de855a0d538a9bd /src/cli/stasis/stasis_main.c
parent52e6d0f495023c0aa939bf6b2170ca5ea853202b (diff)
parent836cc753ea22fd8a3d152f2b00dae971ee3dc943 (diff)
downloadstasis-613bfff7ffae94b76c9d3bd46b50b42ea4ceb164.tar.gz
Merge pull request #69 from jhunkeler/workaround-shebang-nightmare
Workaround for shebang nightmare
Diffstat (limited to 'src/cli/stasis/stasis_main.c')
-rw-r--r--src/cli/stasis/stasis_main.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/cli/stasis/stasis_main.c b/src/cli/stasis/stasis_main.c
index e188b2e..093e32e 100644
--- a/src/cli/stasis/stasis_main.c
+++ b/src/cli/stasis/stasis_main.c
@@ -225,14 +225,6 @@ int main(int argc, char *argv[]) {
exit(1);
}
- msg(STASIS_MSG_L1, "Conda setup\n");
- delivery_get_conda_installer_url(&ctx, installer_url);
- msg(STASIS_MSG_L2, "Downloading: %s\n", installer_url);
- if (delivery_get_conda_installer(&ctx, installer_url)) {
- msg(STASIS_MSG_ERROR, "download failed: %s\n", installer_url);
- exit(1);
- }
-
// Unlikely to occur: this should help prevent rmtree() from destroying your entire filesystem
// if path is "/" then, die
// or if empty string, die
@@ -241,6 +233,30 @@ int main(int argc, char *argv[]) {
exit(1);
}
+ // 2 = #!
+ // 5 = /bin\n
+ const size_t prefix_len = strlen(ctx.storage.conda_install_prefix) + 2 + 5;
+ const size_t prefix_len_max = 127;
+ msg(STASIS_MSG_L1, "Checking length of conda installation prefix\n");
+ if (!strcmp(ctx.system.platform[DELIVERY_PLATFORM], "Linux") && prefix_len > prefix_len_max) {
+ msg(STASIS_MSG_L2 | STASIS_MSG_ERROR,
+ "The shebang, '#!%s/bin/python\\n' is too long (%zu > %zu).\n",
+ ctx.storage.conda_install_prefix, prefix_len, prefix_len_max);
+ msg(STASIS_MSG_L2 | STASIS_MSG_ERROR,
+ "Conda's workaround to handle long path names does not work consistently within STASIS.\n");
+ msg(STASIS_MSG_L2 | STASIS_MSG_ERROR,
+ "Please try again from a different, \"shorter\", directory.\n");
+ exit(1);
+ }
+
+ msg(STASIS_MSG_L1, "Conda setup\n");
+ delivery_get_conda_installer_url(&ctx, installer_url);
+ msg(STASIS_MSG_L2, "Downloading: %s\n", installer_url);
+ if (delivery_get_conda_installer(&ctx, installer_url)) {
+ msg(STASIS_MSG_ERROR, "download failed: %s\n", installer_url);
+ exit(1);
+ }
+
msg(STASIS_MSG_L2, "Installing: %s\n", ctx.conda.installer_name);
delivery_install_conda(ctx.conda.installer_path, ctx.storage.conda_install_prefix);
@@ -294,7 +310,7 @@ int main(int argc, char *argv[]) {
}
if (!isempty(ctx.meta.based_on)) {
- if (conda_env_remove(env_name)) {
+ if (conda_env_exists(ctx.storage.conda_install_prefix, env_name) && conda_env_remove(env_name)) {
msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove release environment: %s\n", env_name);
exit(1);
}
@@ -305,7 +321,7 @@ int main(int argc, char *argv[]) {
exit(1);
}
- if (conda_env_remove(env_name_testing)) {
+ if (conda_env_exists(ctx.storage.conda_install_prefix, env_name_testing) && conda_env_remove(env_name_testing)) {
msg(STASIS_MSG_ERROR | STASIS_MSG_L2, "failed to remove testing environment %s\n", env_name_testing);
exit(1);
}