diff --git a/src/main.c b/src/main.c index eca164d..707d390 100644 --- a/src/main.c +++ b/src/main.c @@ -987,13 +987,10 @@ int bake_run_template( goto error; } - /* Check temporary path, remove if already exists */ - char *tmp_path = ut_envparse("$BAKE_HOME/temp/%s", path); - char ch, *ptr = tmp_path; - for (ptr = tmp_path; (ch = *ptr); ptr ++) { - if (ch == '.') *ptr = '-'; - } + const char *repo_id = ut_locate(path, NULL, UT_LOCATE_REPO_ID); + /* Check temporary path, remove if already exists */ + char *tmp_path = ut_envparse("$BAKE_HOME/temp/%s", repo_id); if (ut_file_test(tmp_path) == 1) { ut_rm(tmp_path); } diff --git a/util/include/load.h b/util/include/load.h index 3f0a9b0..176f0cc 100644 --- a/util/include/load.h +++ b/util/include/load.h @@ -124,7 +124,8 @@ typedef enum ut_locate_kind { UT_LOCATE_PROJECT, /* full path to project directory */ UT_LOCATE_SOURCE, /* full path to project source */ UT_LOCATE_DEVSRC, /* full path to project development source */ - UT_LOCATE_TEMPLATE /* full path to templates directory */ + UT_LOCATE_TEMPLATE,/* full path to templates directory */ + UT_LOCATE_REPO_ID /* project repository identifier ('-' instead of '.') */ } ut_locate_kind; /** Find project locations in the package hierarchy. diff --git a/util/src/load.c b/util/src/load.c index 7e7fc20..0d5128e 100644 --- a/util/src/load.c +++ b/util/src/load.c @@ -462,54 +462,51 @@ const char* ut_locate( } if (loaded && loaded->tried_locating) { - /* Templates don't occupy the same namespace as ordinary projects */ + if (!loaded->repo) { + ut_debug("locating project '%s' failed before", id); + goto error; + } + } + + /* Test whether project or template project exists */ + if (kind != UT_LOCATE_REPO_ID) { if (kind != UT_LOCATE_TEMPLATE) { if (!loaded->meta) { - ut_debug("locating project '%s' failed before", id); - goto error; + char *meta_path = ut_asprintf("%s"UT_OS_PS"%s", UT_META_PATH, id); + if (ut_file_test(meta_path) == 1) { + loaded->meta = meta_path; + } else { + ut_trace("project path '%s' not found", meta_path); + free(meta_path); + goto error; + } } } else { if (!loaded->template) { - ut_debug("locating template '%s' failed before", id); - goto error; + char *tmpl_path = ut_asprintf("%s"UT_OS_PS"%s", UT_TEMPLATE_PATH, id); + if (ut_file_test(tmpl_path) == 1) { + loaded->template = tmpl_path; + } else { + ut_trace("template path '%s' not found", tmpl_path); + free(tmpl_path); + goto error; + } } } } - /* Test whether project or template project exists */ - if (kind == UT_LOCATE_TEMPLATE) { - if (!loaded->template) { - char *tmpl_path = ut_asprintf("%s"UT_OS_PS"%s", UT_TEMPLATE_PATH, id); - if (ut_file_test(tmpl_path) == 1) { - loaded->template = tmpl_path; - } else { - ut_trace("template path '%s' not found", tmpl_path); - free(tmpl_path); - goto error; - } - } - } else { - if (!loaded->meta) { - char *meta_path = ut_asprintf("%s"UT_OS_PS"%s", UT_META_PATH, id); - if (ut_file_test(meta_path) == 1) { - loaded->meta = meta_path; - - /* Prepare repository identifier (replaces . with -) */ - loaded->repo = ut_strdup(id); - char *ptr, ch; - for (ptr = loaded->repo; (ch = *ptr); ptr ++) { - if (ch == '.') { - *ptr = '-'; - } - } - } else { - ut_trace("template path '%s' not found", meta_path); - free(meta_path); - goto error; + + if (!loaded->repo) { + /* Prepare repository identifier (replaces . with -) */ + loaded->repo = ut_strdup(id); + char *ptr, ch; + for (ptr = loaded->repo; (ch = *ptr); ptr ++) { + if (ch == '.') { + *ptr = '-'; } } } - + /* Only try to locate packages once (until reset is called) */ loaded->tried_locating = true; @@ -547,6 +544,9 @@ const char* ut_locate( } result = loaded->dev; break; + case UT_LOCATE_REPO_ID: + result = loaded->repo; + break; case UT_LOCATE_LIB: case UT_LOCATE_STATIC: case UT_LOCATE_APP: