diff options
| -rw-r--r-- | src/lib/core/include/recipe.h | 28 | ||||
| -rw-r--r-- | src/lib/core/recipe.c | 32 |
2 files changed, 43 insertions, 17 deletions
diff --git a/src/lib/core/include/recipe.h b/src/lib/core/include/recipe.h index 4dea248..ddcbabf 100644 --- a/src/lib/core/include/recipe.h +++ b/src/lib/core/include/recipe.h @@ -6,13 +6,20 @@ #include "utils.h" //! Unable to determine recipe repo type -#define RECIPE_TYPE_UNKNOWN 0 +#define RECIPE_STYLE_UNKNOWN 0 //! Recipe repo is from conda-forge -#define RECIPE_TYPE_CONDA_FORGE 1 +#define RECIPE_STYLE_CONDA_FORGE 1 //! Recipe repo is from astroconda -#define RECIPE_TYPE_ASTROCONDA 2 +#define RECIPE_STYLE_ASTROCONDA 2 //! Recipe repo provides the required build configurations but doesn't match conda-forge or astroconda's signature -#define RECIPE_TYPE_GENERIC 3 +#define RECIPE_STYLE_GENERIC 3 + +//! Unable to determine required build system +#define RECIPE_BUILD_UNKNOWN 0 +//! Build uses meta.yaml +#define RECIPE_BUILD_CONDA_BUILD 1 +//! Build uses recipe.yaml +#define RECIPE_BUILD_RATTLER 2 /** * Download a Conda package recipe @@ -46,18 +53,18 @@ int recipe_clone(char *recipe_dir, char *url, char *gitref, char **result); * } * * int recipe_type; - * recipe_type = recipe_get_type(recipe); + * recipe_type = recipe_get_style(recipe); * switch (recipe_type) { - * case RECIPE_TYPE_CONDA_FORGE: + * case RECIPE_STYLE_CONDA_FORGE: * // do something specific for conda-forge directory structure * break; - * case RECIPE_TYPE_ASTROCONDA: + * case RECIPE_STYLE_ASTROCONDA: * // do something specific for astroconda directory structure * break; - * case RECIPE_TYPE_GENERIC: + * case RECIPE_STYLE_GENERIC: * // do something specific for a directory containing a meta.yaml config * break; - * case RECIPE_TYPE_UNKNOWN: + * case RECIPE_STYLE_UNKNOWN: * default: * // the structure is foreign or the path doesn't contain a conda recipe * break; @@ -67,6 +74,7 @@ int recipe_clone(char *recipe_dir, char *url, char *gitref, char **result); * @param repopath path to git repository containing conda recipe(s) * @return One of RECIPE_TYPE_UNKNOWN, RECIPE_TYPE_CONDA_FORGE, RECIPE_TYPE_ASTROCONDA, RECIPE_TYPE_GENERIC */ -int recipe_get_type(char *repopath); +int recipe_get_style(char *repopath); +int recipe_get_build_system(const char *repopath, int style); #endif //STASIS_RECIPE_H diff --git a/src/lib/core/recipe.c b/src/lib/core/recipe.c index 8cc8e21..2e18492 100644 --- a/src/lib/core/recipe.c +++ b/src/lib/core/recipe.c @@ -34,8 +34,26 @@ int recipe_clone(char *recipe_dir, char *url, char *gitref, char **result) { return git_clone(&proc, url, destdir, gitref); } +int recipe_get_build_system(const char *repopath, const int style) { + char filename[PATH_MAX] = {0}; + safe_strncat(filename, repopath, sizeof(filename)); -int recipe_get_type(char *repopath) { + if (style == RECIPE_STYLE_CONDA_FORGE) { + safe_strncat(filename, "/recipe/recipe.yaml", sizeof(filename)); + if (!access(filename, F_OK)) { + return RECIPE_BUILD_RATTLER; + } + return RECIPE_BUILD_CONDA_BUILD; + } + + if (style == RECIPE_STYLE_ASTROCONDA || style == RECIPE_STYLE_GENERIC) { + return RECIPE_BUILD_CONDA_BUILD; + } + + return RECIPE_BUILD_UNKNOWN; +} + +int recipe_get_style(char *repopath) { // conda-forge is a collection of repositories // "conda-forge.yml" is guaranteed to exist const char *marker[] = { @@ -44,10 +62,10 @@ int recipe_get_type(char *repopath) { "meta.yaml", NULL }; - const int type[] = { - RECIPE_TYPE_CONDA_FORGE, - RECIPE_TYPE_ASTROCONDA, - RECIPE_TYPE_GENERIC + const int style[] = { + RECIPE_STYLE_CONDA_FORGE, + RECIPE_STYLE_ASTROCONDA, + RECIPE_STYLE_GENERIC }; for (size_t i = 0; marker[i] != NULL; i++) { @@ -55,9 +73,9 @@ int recipe_get_type(char *repopath) { snprintf(path, sizeof(path), "%s/%s", repopath, marker[i]); int result = access(path, F_OK); if (!result) { - return type[i]; + return style[i]; } } - return RECIPE_TYPE_UNKNOWN; + return RECIPE_STYLE_UNKNOWN; }
\ No newline at end of file |
