diff --git a/include/linuxdeploy/core/elf_file.h b/include/linuxdeploy/core/elf_file.h index 3ced6a2..9ffebc4 100644 --- a/include/linuxdeploy/core/elf_file.h +++ b/include/linuxdeploy/core/elf_file.h @@ -46,7 +46,7 @@ namespace linuxdeploy { // this works for both libraries and executables // the resulting vector consists of absolute paths to the libraries determined by the same methods a system's // linker would use - std::vector traceDynamicDependencies(const std::vector& excludeLibraryPatterns={}); + std::vector traceDynamicDependencies(); // fetch rpath stored in binary // it appears that according to the ELF standard, the rpath is ignored in libraries, therefore if the path diff --git a/include/linuxdeploy/util/misc.h b/include/linuxdeploy/util/misc.h index eceac1f..7ac7d94 100644 --- a/include/linuxdeploy/util/misc.h +++ b/include/linuxdeploy/util/misc.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -147,26 +146,6 @@ namespace linuxdeploy { } return result; } - - static bool isInExcludelist(const std::filesystem::path& fileName, const std::vector &excludeList) { - for (const auto& excludePattern : excludeList) { - // simple string match is faster than using fnmatch - if (excludePattern == fileName) - return true; - - auto fnmatchResult = fnmatch(excludePattern.c_str(), fileName.string().c_str(), FNM_PATHNAME); - switch (fnmatchResult) { - case 0: - return true; - case FNM_NOMATCH: - break; - default: - return false; - } - } - - return false; - } } } } diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 8f31102..6f918e5 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -8,6 +8,7 @@ // library headers #include +#include // local headers @@ -365,7 +366,7 @@ namespace linuxdeploy { ldLog() << "Deploying dependencies for ELF file" << path << std::endl; try { - for (const auto &dependencyPath : elfFile.traceDynamicDependencies(excludeLibraryPatterns)) + for (const auto &dependencyPath : elfFile.traceDynamicDependencies()) if (!deployLibrary(dependencyPath, false, false)) return false; } catch (const elf_file::DependencyNotFoundError& e) { @@ -409,7 +410,28 @@ namespace linuxdeploy { return false; } - if (!forceDeploy && (util::isInExcludelist(path.filename(), generatedExcludelist) || util::isInExcludelist(path.filename(), excludeLibraryPatterns))) { + static auto isInExcludelist = [](const fs::path& fileName, const std::vector &excludeList) { + for (const auto& excludePattern : excludeList) { + // simple string match is faster than using fnmatch + if (excludePattern == fileName) + return true; + + auto fnmatchResult = fnmatch(excludePattern.c_str(), fileName.string().c_str(), FNM_PATHNAME); + switch (fnmatchResult) { + case 0: + return true; + case FNM_NOMATCH: + break; + default: + ldLog() << LD_ERROR << "fnmatch() reported error:" << fnmatchResult << std::endl; + return false; + } + } + + return false; + }; + + if (!forceDeploy && (isInExcludelist(path.filename(), generatedExcludelist) || isInExcludelist(path.filename(), excludeLibraryPatterns))) { ldLog() << "Skipping deployment of blacklisted library" << path << std::endl; // mark file as visited diff --git a/src/core/elf_file.cpp b/src/core/elf_file.cpp index c8772ac..f199b21 100644 --- a/src/core/elf_file.cpp +++ b/src/core/elf_file.cpp @@ -183,7 +183,7 @@ namespace linuxdeploy { delete d; } - std::vector ElfFile::traceDynamicDependencies(const std::vector& excludeLibraryPatterns) { + std::vector ElfFile::traceDynamicDependencies() { // this method's purpose is to abstract this process // the caller doesn't care _how_ it's done, after all @@ -247,10 +247,7 @@ namespace linuxdeploy { missingLib.erase(missingLib.find(pattern), pattern.size()); util::trim(missingLib); util::trim(missingLib, '\t'); - if (!util::isInExcludelist(missingLib, excludeLibraryPatterns)) { - throw DependencyNotFoundError("Could not find dependency: " + missingLib); - } - ldLog() << LD_WARNING << resolvedPath.string() << "depends on excluded library:" << missingLib << std::endl; + throw DependencyNotFoundError("Could not find dependency: " + missingLib); } else { ldLog() << LD_DEBUG << "Invalid ldd output: " << line << std::endl; }