From fd8bd3053487ab4d1ed61755b076a423283949dc Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 10 Jun 2017 15:35:01 +0200 Subject: [PATCH] Create shared.cpp --- shared/shared.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/shared/shared.cpp b/shared/shared.cpp index 87cfe42..97bd933 100644 --- a/shared/shared.cpp +++ b/shared/shared.cpp @@ -670,7 +670,7 @@ QString copyDylib(const LibraryInfo &library, const QString path) return dylibDestinationBinaryPath; } -void runPatchelf(QStringList options) +QString runPatchelf(QStringList options) { QProcess patchelftool; patchelftool.start("patchelf", options); @@ -690,6 +690,7 @@ void runPatchelf(QStringList options) LogError() << "runPatchelf:" << patchelftool.readAllStandardOutput(); // exit(1); // Do not exit because this could be a script that patchelf can't work on } + return(patchelftool.readAllStandardOutput().trimmed()); } bool patchQtCore(const QString &path, const QString &variable, const QString &value) @@ -742,6 +743,17 @@ bool patchQtCore(const QString &path, const QString &variable, const QString &va void changeIdentification(const QString &id, const QString &binaryPath) { + LogNormal() << "Checking rpath in" << binaryPath; + QString oldRpath = runPatchelf(QStringList() << "--get-rpath" << id << binaryPath); + if (oldRpath.startsWith("/")){ + LogDebug() << "Old rpath in" << binaryPath << "starts with /, hence adding it to LD_LIBRARY_PATH"; + // FIXME: Split along ":" characters, check each one, only append to LD_LIBRARY_PATH if not already there + QString oldPath = env.value("LD_LIBRARY_PATH"); + QString newPath = oldRpath + ":" + oldPath; // FIXME: If we use a ldd replacement, we still need to observe this path + // FIXME: Directory layout might be different for system Qt; cannot assume lib/ to always be inside the Qt directory + LogDebug() << "Changed LD_LIBRARY_PATH:" << newPath; + setenv("LD_LIBRARY_PATH",newPath.toUtf8().constData(),1); + } LogNormal() << "Changing rpath in" << binaryPath << "to" << id; runPatchelf(QStringList() << "--set-rpath" << id << binaryPath);