diff --git a/include/linuxdeploy/util/misc.h b/include/linuxdeploy/util/misc.h index 1db862c..0d7e5f6 100644 --- a/include/linuxdeploy/util/misc.h +++ b/include/linuxdeploy/util/misc.h @@ -56,6 +56,18 @@ namespace linuxdeploy { return split(s, '\n'); } + static std::string join(const std::vector &strings, const std::string &delimiter) { + std::string result; + for (size_t i = 0; i < strings.size(); i++) { + result += strings[i]; + + if (i != strings.size() - 1) { + result += delimiter; + } + } + return result; + } + static inline std::string strLower(std::string s) { std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::tolower(c); }); return s; diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 9807e33..f7971f7 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -834,7 +834,14 @@ namespace linuxdeploy { if (!d->deployElfDependencies(sharedLibrary)) return false; - d->setElfRPathOperations[sharedLibrary] = "$ORIGIN"; + const auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); + auto rpathList = util::split(rpath, ':'); + if (std::find(rpathList.begin(), rpathList.end(), "$ORIGIN") == rpathList.end()) { + rpathList.push_back("$ORIGIN"); + d->setElfRPathOperations[sharedLibrary] = util::join(rpathList, ":"); + } else { + d->setElfRPathOperations[sharedLibrary] = rpath; + } } // used to bundle dependencies of executables or libraries in the AppDir without moving them