paranoia for silly people - check efl version aty runtime via eina

enlightenment_start checks the efl version and complains if it's too
old. this shoulpd at runtime give some sensible output for shen
someone did somthing very silly. it'll write this to stderr AND to
~/.e-log.log
This commit is contained in:
Carsten Haitzler 2024-01-17 18:37:31 +00:00
parent 25640ae2fa
commit cc4df8d320
2 changed files with 58 additions and 0 deletions

View File

@ -83,6 +83,11 @@ config_h.set('_POSIX_PTHREAD_SEMANTICS', '1')
config_h.set('_TANDEM_SOURCE' , '1')
config_h.set('__EXTENSIONS__' , '1')
str_ver_split = efl_version.replace('>= ', '').split('.')
config_h.set('MIN_EFL_VERSION_MAJ', str_ver_split[0])
config_h.set('MIN_EFL_VERSION_MIN', str_ver_split[1])
config_h.set('MIN_EFL_VERSION_MIC', str_ver_split[2])
subdir('po')
darwin = host_machine.system().startswith('darwin')

View File

@ -524,6 +524,7 @@ main(int argc, char **argv)
struct sigaction action;
pid_t child = -1;
Eina_Bool restart = EINA_TRUE;
unsigned int provided_eina_version, required_eina_version;
unsetenv("NOTIFY_SOCKET");
@ -547,6 +548,58 @@ main(int argc, char **argv)
eina_init();
/* check eina version ... this should be the whole efl version */
/* check for sanity here in case someone has done something very silly */
provided_eina_version =
(eina_version->major * 1000 * 1000) +
(eina_version->minor * 1000 ) +
(eina_version->micro);
required_eina_version =
(MIN_EFL_VERSION_MAJ * 1000 * 1000) +
(MIN_EFL_VERSION_MIN * 1000) +
(MIN_EFL_VERSION_MIC);
printf("Enlightenment: EFL Version Check: %u >= %u\n",
provided_eina_version, required_eina_version);
if (provided_eina_version < required_eina_version)
{
char *logf = NULL, *logf_old = NULL;
FILE *fps[2];
FILE *outf;
home = getenv("HOME");
// rename old olg file
if (!home)
{
myasprintf(&logf, ".e-log.log");
myasprintf(&logf_old, ".e-log.log.old");
}
else
{
myasprintf(&logf, "%s/.e-log.log", home);
myasprintf(&logf_old, "%s/.e-log.log.old", home);
}
rename(logf, logf_old);
outf = fopen(logf, "w");
fps[0] = stderr;
fps[1] = outf;
for (i = 0; i < 2; i++)
{
if (fps[i])
fprintf(fps[i],
"ERROR: EFL version provided is %i.%i.%i\n"
"Enlightenment requires a minimum of %i.%i.%i\n"
"Abort\n",
eina_version->major,
eina_version->minor,
eina_version->micro,
MIN_EFL_VERSION_MAJ,
MIN_EFL_VERSION_MIN,
MIN_EFL_VERSION_MIC);
}
if (outf) fclose(outf);
exit(42); // exit 42 for this as life the universe and everything...
}
/* reexcute myself with dbus-launch if dbus-launch is not running yet */
if ((!getenv("DBUS_SESSION_BUS_ADDRESS")) &&
(!getenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET")))