From cc4df8d320bfe047243ebd03b16a87710e214b4d Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Wed, 17 Jan 2024 18:37:31 +0000 Subject: [PATCH] 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 --- meson.build | 5 ++++ src/bin/e_start_main.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/meson.build b/meson.build index e5b554b38..a7e42d414 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index 15ee63cd9..f1b23c161 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -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")))