diff --git a/.gitignore b/.gitignore index 54dcf66f..83966328 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ react/package-lock.json src/dbus/bluez_adaptor.h src/dbus/bluez_proxy.h + +CMakeFiles \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 325ee997..dfe17419 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -658,9 +658,6 @@ add_executable(pipedalconfig ) target_link_libraries(pipedalconfig PRIVATE PiPedalCommon pthread atomic uuid stdc++fs asound - icui18n - icuuc - icudata ) diff --git a/src/Locale.cpp b/src/Locale.cpp index 97121505..08fbf38e 100644 --- a/src/Locale.cpp +++ b/src/Locale.cpp @@ -34,6 +34,7 @@ #include "ss.hpp" #include #include "Utf8Utils.hpp" +#include #define U_SHOW_CPLUSPLUS_API 0 @@ -50,9 +51,46 @@ using namespace pipedal; using namespace std; +namespace fs = std::filesystem; +static inline bool isDigit(char c) +{ + return c >= '0' && c <= '9'; +} +static bool getSoVersionNumber(const std::string&fileName, int *version) +{ + auto fnamePos = fileName.find_last_of('/'); + if (fnamePos == std::string::npos) + { + fnamePos = 0; + } + auto extensionPos = fileName.find(".so.",fnamePos); + if (extensionPos == std::string::npos) + { + return false; + } + + + const char *p = fileName.c_str() + extensionPos + 4; + + if (!isDigit(*p)) { + return false; + } + int n = 0; + while (isDigit(*p)) + { + n = n*10 + *p-'0'; + ++p; + } + if (*p != '\0' && *p != '.') + { + return false; + } + *version = n; + return true; +} // Function to get ICU version dynamically -int getICUVersion(void* libHandle) { +static int getICUVersion(void* libHandle) { // pares the dlerror to get the version number. :-/ dlerror(); // clear the error. @@ -61,22 +99,35 @@ int getICUVersion(void* libHandle) { std::string error = dlerror(); // "/lib/aarch64-linux-gnu/libicui18n.so.74: undefined symbol: nonExistentFunction" - auto nPos = error.find(".so."); + auto nPos = error.find(":"); if (nPos == std::string::npos) { - throw std::runtime_error("Unable to determine version of libicui18n.so"); + return false; } - const char *p = error.c_str() + nPos + 4; + std::string fileName = error.substr(nPos); - int version = 0; - while (*p >= '0' && *p <= '9') - { - version = version*10 + *p-'0'; - ++p; - } - if (*p != ':' && *p != '.') + int version = -1; + + if (!getSoVersionNumber(fileName,&version)) { - throw std::runtime_error("Unable to determine version of libicui18n.so"); + fs::path basePath = fileName; + fs::path parentDirectory = basePath.parent_path(); + auto fileName = basePath.filename().string(); + for (auto&entry: fs::directory_iterator(parentDirectory)) + { + if (entry. path().filename().string().starts_with(fileName)) + { + if (getSoVersionNumber(entry.path().string(),&version)) + { + break; + } + + } + } + if (version == -1) + { + throw std::runtime_error(SS("Unable to determine libicui18n.so version: " << error)); + } } return version; } diff --git a/src/templates/pipedald.service.template b/src/templates/pipedald.service.template index 8b93a571..aafd6f01 100644 --- a/src/templates/pipedald.service.template +++ b/src/templates/pipedald.service.template @@ -11,6 +11,7 @@ Restart=on-failure Type=notify LimitMEMLOCK=infinity LimitRTPRIO=95 +Nice=-9 ExecStart=${COMMAND} User=pipedal_d Group=pipedal_d