From fa3e51c7db91a8895260e8d37eb8033f6c813692 Mon Sep 17 00:00:00 2001 From: smarttowel Date: Tue, 11 Jan 2022 16:24:37 +0300 Subject: [PATCH 1/5] Possible fix for #149 --- src/core/appdir.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 9807e33..a896cc6 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -834,7 +834,11 @@ namespace linuxdeploy { if (!d->deployElfDependencies(sharedLibrary)) return false; - d->setElfRPathOperations[sharedLibrary] = "$ORIGIN"; + auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); + if(util::stringStartsWith(rpath, "$")) + d->setElfRPathOperations[sharedLibrary] = rpath; + else + d->setElfRPathOperations[sharedLibrary] = "$ORIGIN"; } // used to bundle dependencies of executables or libraries in the AppDir without moving them From ae8699854a9bfd9c3f82faff0e081c706586a9ef Mon Sep 17 00:00:00 2001 From: smarttowel Date: Tue, 11 Jan 2022 17:18:15 +0300 Subject: [PATCH 2/5] Append $ORIGIN to rpath if missed --- include/linuxdeploy/util/misc.h | 11 +++++++++++ src/core/appdir.cpp | 10 +++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linuxdeploy/util/misc.h b/include/linuxdeploy/util/misc.h index 1db862c..bf8e9c6 100644 --- a/include/linuxdeploy/util/misc.h +++ b/include/linuxdeploy/util/misc.h @@ -56,6 +56,17 @@ 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 a896cc6..abedc40 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -835,10 +835,14 @@ namespace linuxdeploy { return false; auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); - if(util::stringStartsWith(rpath, "$")) + 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; - else - d->setElfRPathOperations[sharedLibrary] = "$ORIGIN"; + } } // used to bundle dependencies of executables or libraries in the AppDir without moving them From f59f8f9512ed73c21ee6392e455a0e2d7d891750 Mon Sep 17 00:00:00 2001 From: smarttowel Date: Tue, 11 Jan 2022 17:33:27 +0300 Subject: [PATCH 3/5] Add const modifier to rpath var --- src/core/appdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index abedc40..b4f4fa6 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -834,7 +834,7 @@ namespace linuxdeploy { if (!d->deployElfDependencies(sharedLibrary)) return false; - auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); + const auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); auto rpathList = util::split(rpath, ':'); if (std::find(rpathList.begin(), rpathList.end(), "$ORIGIN") == rpathList.end()) { From fc27076843b0374da049a17abecec6a600f0e752 Mon Sep 17 00:00:00 2001 From: Pavel Mikhadzionak Date: Tue, 11 Jan 2022 17:47:05 +0300 Subject: [PATCH 4/5] Codestyle update Co-authored-by: TheAssassin --- src/core/appdir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index b4f4fa6..f7971f7 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -836,8 +836,7 @@ namespace linuxdeploy { const auto rpath = elf_file::ElfFile(sharedLibrary).getRPath(); auto rpathList = util::split(rpath, ':'); - if (std::find(rpathList.begin(), rpathList.end(), "$ORIGIN") == rpathList.end()) - { + if (std::find(rpathList.begin(), rpathList.end(), "$ORIGIN") == rpathList.end()) { rpathList.push_back("$ORIGIN"); d->setElfRPathOperations[sharedLibrary] = util::join(rpathList, ":"); } else { From 0f5361b457b1b6bfc4253570cd2e4049728c018e Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Tue, 11 Jan 2022 19:24:08 +0100 Subject: [PATCH 5/5] Code style fixes --- include/linuxdeploy/util/misc.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linuxdeploy/util/misc.h b/include/linuxdeploy/util/misc.h index bf8e9c6..0d7e5f6 100644 --- a/include/linuxdeploy/util/misc.h +++ b/include/linuxdeploy/util/misc.h @@ -56,13 +56,14 @@ namespace linuxdeploy { return split(s, '\n'); } - static std::string join(const std::vector &strings, const std::string &delimiter) - { + 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) + + if (i != strings.size() - 1) { result += delimiter; + } } return result; }