aboutsummaryrefslogtreecommitdiff
path: root/src/recipe.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-10-14 09:32:03 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-10-14 09:43:31 -0400
commit5a9688e9e78a25a42bddfc4388fb4ce3311ded74 (patch)
treebcc1b54c3f8a7f1eab0d6b3e129f098721a41537 /src/recipe.c
parentb98088f7b7cfe4b08eb39fa1b6b86210cb6c08b8 (diff)
downloadstasis-5a9688e9e78a25a42bddfc4388fb4ce3311ded74.tar.gz
Refactor directory structure
* Move core library sources into src/lib/core * Move command-line programs into src/cli
Diffstat (limited to 'src/recipe.c')
-rw-r--r--src/recipe.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/recipe.c b/src/recipe.c
deleted file mode 100644
index 833908c..0000000
--- a/src/recipe.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include "recipe.h"
-
-int recipe_clone(char *recipe_dir, char *url, char *gitref, char **result) {
- struct Process proc;
- char destdir[PATH_MAX];
- char *reponame = NULL;
-
- memset(&proc, 0, sizeof(proc));
- memset(destdir, 0, sizeof(destdir));
- reponame = path_basename(url);
-
- sprintf(destdir, "%s/%s", recipe_dir, reponame);
- if (!*result) {
- *result = calloc(PATH_MAX, sizeof(*result));
- if (!*result) {
- return -1;
- }
- }
- strncpy(*result, destdir, PATH_MAX);
-
- if (!access(destdir, F_OK)) {
- if (!strcmp(destdir, "/")) {
- fprintf(stderr, "STASIS is misconfigured. Please check your output path(s) immediately.\n");
- fprintf(stderr, "recipe_dir = '%s'\nreponame = '%s'\ndestdir = '%s'\n",
- recipe_dir, reponame, destdir);
- exit(1);
- }
- if (rmtree(destdir)) {
- guard_free(*result);
- *result = NULL;
- return -1;
- }
- }
- return git_clone(&proc, url, destdir, gitref);
-}
-
-
-int recipe_get_type(char *repopath) {
- int result;
- char path[PATH_MAX];
- // conda-forge is a collection of repositories
- // "conda-forge.yml" is guaranteed to exist
- const char *marker[] = {
- "conda-forge.yml",
- "stsci",
- "meta.yaml",
- NULL
- };
- const int type[] = {
- RECIPE_TYPE_CONDA_FORGE,
- RECIPE_TYPE_ASTROCONDA,
- RECIPE_TYPE_GENERIC
- };
-
- for (size_t i = 0; marker[i] != NULL; i++) {
- sprintf(path, "%s/%s", repopath, marker[i]);
- result = access(path, F_OK);
- if (!result) {
- return type[i];
- }
- }
-
- return RECIPE_TYPE_UNKNOWN;
-} \ No newline at end of file