1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#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;
}
|