From 159b082658ca69e49d32fddb4171f815d938ddad Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Sun, 9 Jun 2019 14:43:59 +0200 Subject: [PATCH 1/4] Remove recursion of ELF deployment since ldd already does that for us --- src/core/appdir.cpp | 47 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 7cffcb8..10cafd4 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -249,7 +249,7 @@ namespace linuxdeploy { } // search for copyright file for file and deploy it to AppDir - bool deployCopyrightFiles(const bf::path& from, const std::string& logPrefix = "") { + bool deployCopyrightFiles(const bf::path& from) { if (disableCopyrightFilesDeployment) return true; @@ -261,7 +261,7 @@ namespace linuxdeploy { if (copyrightFiles.empty()) return false; - ldLog() << logPrefix << LD_NO_SPACE << "Deploying copyright files for file" << from << std::endl; + ldLog() << "Deploying copyright files for file" << from << std::endl; for (const auto& file : copyrightFiles) { std::string targetDir = file.string(); @@ -293,22 +293,12 @@ namespace linuxdeploy { return to; } - std::string getLogPrefix(int recursionLevel) { - std::string logPrefix; - for (int i = 0; i < recursionLevel; i++) - logPrefix += " "; - return logPrefix; - } - - bool deployElfDependencies(const bf::path& path, int recursionLevel = 0) { - auto logPrefix = getLogPrefix(recursionLevel); - - ldLog() << logPrefix << LD_NO_SPACE << "Deploying dependencies for ELF file" << path << std::endl; + bool deployElfDependencies(const bf::path& path) { + ldLog() << "Deploying dependencies for ELF file" << path << std::endl; try { - for (const auto &dependencyPath : elf::ElfFile(path).traceDynamicDependencies()) { - if (!deployLibrary(dependencyPath, recursionLevel + 1)) + for (const auto &dependencyPath : elf::ElfFile(path).traceDynamicDependencies()) + if (!deployLibrary(dependencyPath)) return false; - } } catch (const elf::DependencyNotFoundError& e) { ldLog() << LD_ERROR << e.what() << std::endl; return false; @@ -333,20 +323,18 @@ namespace linuxdeploy { return stripPath; } - bool deployLibrary(const bf::path& path, int recursionLevel = 0, bool forceDeploy = false, const bf::path& destination = bf::path()) { - auto logPrefix = getLogPrefix(recursionLevel); - + bool deployLibrary(const bf::path& path, bool forceDeploy = false, const bf::path& destination = bf::path()) { if (!forceDeploy && hasBeenVisitedAlready(path)) { - ldLog() << LD_DEBUG << logPrefix << LD_NO_SPACE << "File has been visited already:" << path << std::endl; + ldLog() << LD_DEBUG << "File has been visited already:" << path << std::endl; return true; } if (!bf::exists(path)) { - ldLog() << LD_ERROR << logPrefix << LD_NO_SPACE << "Cannot deploy non-existing library file:" << path << std::endl; + ldLog() << LD_ERROR << "Cannot deploy non-existing library file:" << path << std::endl; return false; } - static auto isInExcludelist = [&logPrefix](const bf::path& fileName) { + static auto isInExcludelist = [](const bf::path& fileName) { for (const auto& excludePattern : generatedExcludelist) { // simple string match is faster than using fnmatch if (excludePattern == fileName) @@ -359,7 +347,7 @@ namespace linuxdeploy { case FNM_NOMATCH: break; default: - ldLog() << LD_ERROR << logPrefix << LD_NO_SPACE << "fnmatch() reported error:" << fnmatchResult << std::endl; + ldLog() << LD_ERROR << "fnmatch() reported error:" << fnmatchResult << std::endl; return false; } } @@ -368,7 +356,7 @@ namespace linuxdeploy { }; if (!forceDeploy && isInExcludelist(path.filename())) { - ldLog() << logPrefix << LD_NO_SPACE << "Skipping deployment of blacklisted library" << path << std::endl; + ldLog() << "Skipping deployment of blacklisted library" << path << std::endl; // mark file as visited visitedFiles.insert(path); @@ -380,7 +368,7 @@ namespace linuxdeploy { // create a directory bf::path libraryDir = appDirPath / "usr" / (getLibraryDirName(path) + "/"); - ldLog() << logPrefix << LD_NO_SPACE << "Deploying shared library" << path; + ldLog() << "Deploying shared library" << path; if (!destination.empty()) ldLog() << " (destination:" << destination << LD_NO_SPACE << ")"; ldLog() << std::endl; @@ -394,7 +382,7 @@ namespace linuxdeploy { // in case destinationPath is a directory, deployFile will give us the deployed file's path actualDestination = deployFile(path, actualDestination); - deployCopyrightFiles(path, logPrefix); + deployCopyrightFiles(path); std::string rpath = "$ORIGIN"; @@ -422,9 +410,6 @@ namespace linuxdeploy { stripOperations.insert(actualDestination); - if (!deployElfDependencies(path, recursionLevel)) - return false; - return true; } @@ -624,11 +609,11 @@ namespace linuxdeploy { } bool AppDir::deployLibrary(const bf::path& path, const bf::path& destination) { - return d->deployLibrary(path, 0, false, destination); + return d->deployLibrary(path, false, destination); } bool AppDir::forceDeployLibrary(const bf::path& path, const bf::path& destination) { - return d->deployLibrary(path, 0, true, destination); + return d->deployLibrary(path, true, destination); } bool AppDir::deployExecutable(const bf::path& path, const boost::filesystem::path& destination) { From 0e95f19a75ba318fae55b5281ac30c43ac5420b7 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Mon, 10 Jun 2019 20:07:58 +0200 Subject: [PATCH 2/4] Make deployLibrary deploy its dependencies by default, and avoid unnecessary recursion by making deployElfDependencies not deploy its deps of deps --- src/core/appdir.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/appdir.cpp b/src/core/appdir.cpp index 10cafd4..73f17cb 100644 --- a/src/core/appdir.cpp +++ b/src/core/appdir.cpp @@ -297,7 +297,7 @@ namespace linuxdeploy { ldLog() << "Deploying dependencies for ELF file" << path << std::endl; try { for (const auto &dependencyPath : elf::ElfFile(path).traceDynamicDependencies()) - if (!deployLibrary(dependencyPath)) + if (!deployLibrary(dependencyPath, false, false)) return false; } catch (const elf::DependencyNotFoundError& e) { ldLog() << LD_ERROR << e.what() << std::endl; @@ -323,7 +323,7 @@ namespace linuxdeploy { return stripPath; } - bool deployLibrary(const bf::path& path, bool forceDeploy = false, const bf::path& destination = bf::path()) { + bool deployLibrary(const bf::path& path, bool forceDeploy = false, bool deployDependencies = true, const bf::path& destination = bf::path()) { if (!forceDeploy && hasBeenVisitedAlready(path)) { ldLog() << LD_DEBUG << "File has been visited already:" << path << std::endl; return true; @@ -410,7 +410,10 @@ namespace linuxdeploy { stripOperations.insert(actualDestination); - return true; + if (!deployDependencies) + return true; + + return deployElfDependencies(path); } bool deployExecutable(const bf::path& path, const boost::filesystem::path& destination) { @@ -609,11 +612,11 @@ namespace linuxdeploy { } bool AppDir::deployLibrary(const bf::path& path, const bf::path& destination) { - return d->deployLibrary(path, false, destination); + return d->deployLibrary(path, false, true, destination); } bool AppDir::forceDeployLibrary(const bf::path& path, const bf::path& destination) { - return d->deployLibrary(path, true, destination); + return d->deployLibrary(path, true, true, destination); } bool AppDir::deployExecutable(const bf::path& path, const boost::filesystem::path& destination) { From ce5aecead596529bc1f84feed7ca56a61d76d0d6 Mon Sep 17 00:00:00 2001 From: darealshinji Date: Sat, 6 Jul 2019 20:21:16 +0200 Subject: [PATCH 3/4] remove all comments Otherwise the generated header contains entries like this: ``` c "libxcb-dri2.so.0", "#", "https://github.com/probonopd/linuxdeployqt/issues/331#issuecomment-442276277", "libxcb-dri3.so.0", "#", "https://github.com/AppImage/AppImages/issues/348", ``` --- src/core/generate-excludelist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/generate-excludelist.sh b/src/core/generate-excludelist.sh index 6c698b9..d92cb13 100644 --- a/src/core/generate-excludelist.sh +++ b/src/core/generate-excludelist.sh @@ -18,7 +18,7 @@ log_prefix="-- [$(basename $0)]" echo "$log_prefix downloading excludelist from GitHub" url="https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist" -blacklisted=($(wget --quiet "$url" -O - | sort | uniq | grep -v "^#.*" | grep "[^-\s]")) +blacklisted=($(wget --quiet "$url" -O - | sed 's|#.*||g' | sort | uniq)) # sanity check if [ "$blacklisted" == "" ]; then From 57dbdc6933ed043f2cff77e8ad0834413d85603d Mon Sep 17 00:00:00 2001 From: Alexis Lopez Zubieta Date: Thu, 25 Jul 2019 13:08:21 -0500 Subject: [PATCH 4/4] Update cpp-subprocess to ensure that the bug in util::read_all() is fixed --- lib/cpp-subprocess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cpp-subprocess b/lib/cpp-subprocess index 05c76a5..6931e3d 160000 --- a/lib/cpp-subprocess +++ b/lib/cpp-subprocess @@ -1 +1 @@ -Subproject commit 05c76a531180298a8404bdf5fccb71137c62cd76 +Subproject commit 6931e3d69fb36e6eae099585646e54ac644bf99c