efl/eina: fix debian multilib detection without magic file.

The algorithm will now consider valid bin, data orlocale as well if
magic file was not provided.



SVN revision: 82429
This commit is contained in:
Gustavo Sverzut Barbieri 2013-01-08 23:57:14 +00:00
parent f57968f158
commit 65aae8f181
3 changed files with 49 additions and 23 deletions

View File

@ -1,8 +1,12 @@
2013-01-08 Mike Blumenkrantz
2013-01-08 Gustavo Sverzut Barbieri (k-s)
* Fix eina_prefix_new() with debian multilib without magic check file.
2013-01-08 Mike Blumenkrantz
* Fix efreet desktop command parsing of https
2013-01-07 Sung W. Park (sung_)
2013-01-07 Sung W. Park (sung_)
* Pulled out evas gl backend binary shader file caching code from
evas_gl_shader.c file and made an internal generic caching api in

1
NEWS
View File

@ -104,3 +104,4 @@ Fixes:
* Fix ecore_con case where freeing server double-frees clients
* Fix build of Evas XCB backend
* Fix efreet desktop command parsing of https
* Fix eina_prefix_new() with debian multilib without magic check file.

View File

@ -376,6 +376,7 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
const char *libdir = "lib";
const char *datadir = "share";
const char *localedir = "share";
Eina_Bool from_lib = EINA_FALSE, from_bin = EINA_FALSE;
DBG("EINA PREFIX: argv0=%s, symbol=%p, magicsharefile=%s, envprefix=%s",
argv0, symbol, magicsharefile, envprefix);
@ -524,6 +525,7 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
{
INF("Dlsym gave full path = %s", info_dl.dli_fname);
STRDUP_REP(pfx->exe_path, info_dl.dli_fname);
from_lib = EINA_TRUE;
}
}
}
@ -542,6 +544,7 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
envprefix);
return pfx;
}
from_bin = EINA_TRUE;
#ifndef _WIN32
}
#endif
@ -579,6 +582,9 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
pfx->prefix_path = malloc(p - pfx->exe_path + 1);
if (pfx->prefix_path)
{
Eina_Bool magic_found = EINA_FALSE;
int checks_passed = 0;
strncpy(pfx->prefix_path, pfx->exe_path,
p - pfx->exe_path);
pfx->prefix_path[p - pfx->exe_path] = 0;
@ -589,55 +595,70 @@ eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
pfx->prefix_path, bindir);
STRDUP_REP(pfx->prefix_path_bin, buf);
DBG("Have bin = %s", pfx->prefix_path_bin);
if ((!from_bin) && (stat(buf, &st) == 0))
checks_passed++;
/* lib */
snprintf(buf, sizeof(buf), "%s" DSEP_S "%s",
pfx->prefix_path, libdir);
STRDUP_REP(pfx->prefix_path_lib, buf);
DBG("Have lib = %s", pfx->prefix_path_lib);
if ((!from_lib) && (stat(buf, &st) == 0))
checks_passed++;
/* locale */
snprintf(buf, sizeof(buf), "%s" DSEP_S "%s",
pfx->prefix_path, localedir);
STRDUP_REP(pfx->prefix_path_locale, buf);
DBG("Have locale = %s", pfx->prefix_path_locale);
if (stat(buf, &st) == 0)
checks_passed++;
/* check if magic file is there - then our guess is right */
if (magic)
if (!magic)
DBG("No magic file");
else
{
DBG("Magic = %s", magic);
snprintf(buf, sizeof(buf),
"%s" DSEP_S "%s" DSEP_S "%s",
pfx->prefix_path, datadir, magic);
DBG("Check in %s", buf);
}
if ((!magic) || (stat(buf, &st) == 0))
{
if (buf[0])
DBG("Magic path %s stat passed", buf);
if (stat(buf, &st) == 0)
{
checks_passed++;
magic_found = EINA_TRUE;
DBG("Magic path %s stat passed", buf);
}
else
DBG("No magic file");
WRN("Missing magic path %s", buf);
}
if (((!magic) && (checks_passed > 0)) ||
((magic) && (magic_found)))
{
snprintf(buf, sizeof(buf), "%s" DSEP_S "%s",
pfx->prefix_path, datadir);
STRDUP_REP(pfx->prefix_path_data, buf);
}
/* magic file not there. time to start hunting! */
else
{
if (buf[0])
for (;p > pfx->exe_path; p--)
{
for (;p > pfx->exe_path; p--)
if (*p == DSEP_C)
{
if (*p == DSEP_C)
{
p--;
break;
}
}
if (p > pfx->exe_path)
{
continue;
DBG("Go back one directory");
p--;
break;
}
}
WRN("Magic failed");
if (p > pfx->exe_path)
{
int newlen = p - pfx->exe_path;
DBG("Go back one directory (%.*s)", newlen, pfx->exe_path);
continue;
}
WRN("No Prefix path (exhausted search depth)");
_fallback(pfx, pkg_bin, pkg_lib, pkg_data,
pkg_locale, envprefix);
}