@@ -670,7 +670,7 @@ QString copyDylib(const LibraryInfo &library, const QString path)
670
670
return dylibDestinationBinaryPath;
671
671
}
672
672
673
- void runPatchelf (QStringList options)
673
+ QString runPatchelf (QStringList options)
674
674
{
675
675
QProcess patchelftool;
676
676
patchelftool.start (" patchelf" , options);
@@ -690,6 +690,7 @@ void runPatchelf(QStringList options)
690
690
LogError () << " runPatchelf:" << patchelftool.readAllStandardOutput ();
691
691
// exit(1); // Do not exit because this could be a script that patchelf can't work on
692
692
}
693
+ return (patchelftool.readAllStandardOutput ().trimmed ());
693
694
}
694
695
695
696
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
742
743
743
744
void changeIdentification (const QString &id, const QString &binaryPath)
744
745
{
746
+ LogNormal () << " Checking rpath in" << binaryPath;
747
+ QString oldRpath = runPatchelf (QStringList () << " --get-rpath" << id << binaryPath);
748
+ if (oldRpath.startsWith (" /" )){
749
+ LogDebug () << " Old rpath in" << binaryPath << " starts with /, hence adding it to LD_LIBRARY_PATH" ;
750
+ // FIXME: Split along ":" characters, check each one, only append to LD_LIBRARY_PATH if not already there
751
+ QString oldPath = env.value (" LD_LIBRARY_PATH" );
752
+ QString newPath = oldRpath + " :" + oldPath; // FIXME: If we use a ldd replacement, we still need to observe this path
753
+ // FIXME: Directory layout might be different for system Qt; cannot assume lib/ to always be inside the Qt directory
754
+ LogDebug () << " Changed LD_LIBRARY_PATH:" << newPath;
755
+ setenv (" LD_LIBRARY_PATH" ,newPath.toUtf8 ().constData (),1 );
756
+ }
745
757
LogNormal () << " Changing rpath in" << binaryPath << " to" << id;
746
758
runPatchelf (QStringList () << " --set-rpath" << id << binaryPath);
747
759
0 commit comments