Skip to content
Snippets Groups Projects
Commit f791e51c authored by Simon Rose's avatar Simon Rose
Browse files

Merge branch 'e3_518' into 'master'

E3-518: Cleaned up _DB/_TEMPLATES

See merge request e3/e3-require!58
parents 66d238e2 ba5d5357
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Removed duplicated entries from generated `.dep` files * Removed duplicated entries from generated `.dep` files
### Other changes ### Other changes
* Removed `<module>_TEMPLATES` in favour of `<module>_DB`
* Removed unnecessary code from `make init`. * Removed unnecessary code from `make init`.
* removed `e3.cfg`, `ess-env.conf` and `DEFINES_REQUIRE` files and associated codes in `RULES_REQUIRE`, `setE3Env.bash` and `.gitignore`. * removed `e3.cfg`, `ess-env.conf` and `DEFINES_REQUIRE` files and associated codes in `RULES_REQUIRE`, `setE3Env.bash` and `.gitignore`.
* removed legacy code from setE3Env.bash * removed legacy code from setE3Env.bash
......
/* /*
* ld - load code dynamically * ld - load code dynamically
* *
* $Author: zimoch $ * $Author: zimoch $
* $ID$ * $ID$
* $Date: 2015/06/29 09:47:30 $ * $Date: 2015/06/29 09:47:30 $
* *
* DISCLAIMER: Use at your own risc and so on. No warranty, no refund. * DISCLAIMER: Use at your own risc and so on. No warranty, no refund.
*/ */
#ifdef __unix #ifdef __unix
/* for vasprintf and dl_iterate_phdr */ /* for vasprintf and dl_iterate_phdr */
...@@ -351,9 +351,29 @@ void pathAdd(const char *varname, const char *dirname) ...@@ -351,9 +351,29 @@ void pathAdd(const char *varname, const char *dirname)
} }
} }
char *realpathSeparator(const char *location)
{
size_t ll;
char *buffer = malloc(PATH_MAX + strlen(OSI_PATH_SEPARATOR));
buffer = realpath(location, buffer);
if (!buffer)
{
if (requireDebug)
printf("require: realpath(%s) failed\n", location);
return NULL;
}
ll = strlen(buffer);
/* linux realpath removes trailing slash */
if (buffer[ll - strlen(OSI_PATH_SEPARATOR)] != OSI_PATH_SEPARATOR[0])
{
strcpy(buffer + ll + 1 - strlen(OSI_PATH_SEPARATOR), OSI_PATH_SEPARATOR);
}
return buffer;
}
static int setupDbPath(const char *module, const char *dbdir) static int setupDbPath(const char *module, const char *dbdir)
{ {
char *absdir = realpath(dbdir, NULL); /* so we can change directory later safely */ char *absdir = realpathSeparator(dbdir); /* so we can change directory later safely */
if (absdir == NULL) if (absdir == NULL)
{ {
if (requireDebug) if (requireDebug)
...@@ -365,14 +385,12 @@ static int setupDbPath(const char *module, const char *dbdir) ...@@ -365,14 +385,12 @@ static int setupDbPath(const char *module, const char *dbdir)
printf("require: found template directory %s\n", absdir); printf("require: found template directory %s\n", absdir);
/* set up db search path environment variables /* set up db search path environment variables
<module>_TEMPLATES template path of <module>
<module>_DB template path of <module> <module>_DB template path of <module>
TEMPLATES template path of the current module (overwritten) TEMPLATES template path of the current module (overwritten)
EPICS_DB_INCLUDE_PATH template path of all loaded modules (last in front after ".") EPICS_DB_INCLUDE_PATH template path of all loaded modules (last in front after ".")
*/ */
putenvprintf("%s_DB=%s", module, absdir); putenvprintf("%s_DB=%s", module, absdir);
putenvprintf("%s_TEMPLATES=%s", module, absdir);
putenvprintf("TEMPLATES=%s", absdir); putenvprintf("TEMPLATES=%s", absdir);
pathAdd("EPICS_DB_INCLUDE_PATH", absdir); pathAdd("EPICS_DB_INCLUDE_PATH", absdir);
free(absdir); free(absdir);
...@@ -502,7 +520,6 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -502,7 +520,6 @@ void registerModule(const char *module, const char *version, const char *locatio
size_t ll = 1; size_t ll = 1;
char *abslocation = NULL; char *abslocation = NULL;
char *argstring = NULL; char *argstring = NULL;
int addSlash = 0;
const char *mylocation; const char *mylocation;
static int firstTime = 1; static int firstTime = 1;
...@@ -522,17 +539,10 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -522,17 +539,10 @@ void registerModule(const char *module, const char *version, const char *locatio
if (location) if (location)
{ {
abslocation = realpath(location, NULL); abslocation = realpathSeparator(location);
if (!abslocation)
abslocation = (char *)location;
ll = strlen(abslocation) + 1; ll = strlen(abslocation) + 1;
/* linux realpath removes trailing slash */
if (abslocation[ll - 1 - strlen(OSI_PATH_SEPARATOR)] != OSI_PATH_SEPARATOR[0])
{
addSlash = strlen(OSI_PATH_SEPARATOR);
}
} }
m = (moduleitem *)malloc(sizeof(moduleitem) + lm + lv + ll + addSlash); m = (moduleitem *)malloc(sizeof(moduleitem) + lm + lv + ll);
if (m == NULL) if (m == NULL)
{ {
fprintf(stderr, "require: out of memory\n"); fprintf(stderr, "require: out of memory\n");
...@@ -545,10 +555,7 @@ void registerModule(const char *module, const char *version, const char *locatio ...@@ -545,10 +555,7 @@ void registerModule(const char *module, const char *version, const char *locatio
strcpy(m->content + lm, version); strcpy(m->content + lm, version);
strcpy(m->content + lm + lv, abslocation ? abslocation : ""); strcpy(m->content + lm + lv, abslocation ? abslocation : "");
if (addSlash) free(abslocation);
strcpy(m->content + lm + lv + ll - 1, OSI_PATH_SEPARATOR);
if (abslocation != location)
free(abslocation);
for (pm = &loadedModules; *pm != NULL; pm = &(*pm)->next) for (pm = &loadedModules; *pm != NULL; pm = &(*pm)->next)
; ;
*pm = m; *pm = m;
...@@ -842,7 +849,7 @@ static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int a ...@@ -842,7 +849,7 @@ static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int a
{ {
return match; return match;
} }
if (sv_request->build == -1) if (sv_request->build == -1)
{ {
if (already_matched) if (already_matched)
...@@ -855,7 +862,7 @@ static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int a ...@@ -855,7 +862,7 @@ static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int a
debug("require: compareVersions: No build number requested. Returning MATCH\n"); debug("require: compareVersions: No build number requested. Returning MATCH\n");
return MATCH; return MATCH;
} }
} }
return compareDigit(sv_found->build, sv_request->build, "build"); return compareDigit(sv_found->build, sv_request->build, "build");
} }
...@@ -898,19 +905,19 @@ static int compareVersions(const char *found, const char *request, int already_m ...@@ -898,19 +905,19 @@ static int compareVersions(const char *found, const char *request, int already_m
{ {
debug("require: compareVersions: Test versions requested and found, no match\n"); debug("require: compareVersions: Test versions requested and found, no match\n");
match = MISMATCH; match = MISMATCH;
} }
else else
{ {
debug("require: compareVersions: found numeric version, higher than test\n"); debug("require: compareVersions: found numeric version, higher than test\n");
match = HIGHER; match = HIGHER;
} }
} }
else if (strlen(sv_found->test_str) > 0) else if (strlen(sv_found->test_str) > 0)
{ {
debug("require: compareVersions: Numeric version requested, test version found\n"); debug("require: compareVersions: Numeric version requested, test version found\n");
match = MISMATCH; match = MISMATCH;
} }
else else
{ {
match = compareNumericVersion(sv_found, sv_request, already_matched); match = compareNumericVersion(sv_found, sv_request, already_matched);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment