@@ -670,26 +670,28 @@ 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
+ LogDebug () << " options:" << options;
676
677
patchelftool.start (" patchelf" , options);
677
678
if (!patchelftool.waitForStarted ()) {
678
- if (patchelftool.errorString ().contains (" execvp: No such file or directory" )){
679
+ if (patchelftool.errorString ().contains (" No such file or directory" )){
679
680
LogError () << " Could not start patchelf." ;
680
681
LogError () << " Make sure it is installed on your $PATH, e.g., in /usr/local/bin." ;
681
682
LogError () << " You can get it from https://nixos.org/patchelf.html." ;
682
683
} else {
683
- LogError () << " Could not start patchelftool . Process error is" << patchelftool.errorString ();
684
+ LogError () << " Could not start patchelf tool . Process error is" << patchelftool.errorString ();
684
685
}
685
686
exit (1 );
686
687
}
687
688
patchelftool.waitForFinished ();
688
689
if (patchelftool.exitCode () != 0 ) {
689
690
LogError () << " runPatchelf:" << patchelftool.readAllStandardError ();
690
- LogError () << " runPatchelf:" << patchelftool.readAllStandardOutput ();
691
+ // LogError() << "runPatchelf:" << patchelftool.readAllStandardOutput();
691
692
// exit(1); // Do not exit because this could be a script that patchelf can't work on
692
693
}
694
+ return (patchelftool.readAllStandardOutput ().trimmed ());
693
695
}
694
696
695
697
bool patchQtCore (const QString &path, const QString &variable, const QString &value)
@@ -742,6 +744,19 @@ bool patchQtCore(const QString &path, const QString &variable, const QString &va
742
744
743
745
void changeIdentification (const QString &id, const QString &binaryPath)
744
746
{
747
+ LogNormal () << " Checking rpath in" << binaryPath;
748
+ QString oldRpath = runPatchelf (QStringList () << " --print-rpath" << binaryPath);
749
+ LogDebug () << " oldRpath:" << oldRpath;
750
+ if (oldRpath.startsWith (" /" )){
751
+ LogDebug () << " Old rpath in" << binaryPath << " starts with /, hence adding it to LD_LIBRARY_PATH" ;
752
+ // FIXME: Split along ":" characters, check each one, only append to LD_LIBRARY_PATH if not already there
753
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
754
+ QString oldPath = env.value (" LD_LIBRARY_PATH" );
755
+ QString newPath = oldRpath + " :" + oldPath; // FIXME: If we use a ldd replacement, we still need to observe this path
756
+ // FIXME: Directory layout might be different for system Qt; cannot assume lib/ to always be inside the Qt directory
757
+ LogDebug () << " Added to LD_LIBRARY_PATH:" << newPath;
758
+ setenv (" LD_LIBRARY_PATH" ,newPath.toUtf8 ().constData (),1 );
759
+ }
745
760
LogNormal () << " Changing rpath in" << binaryPath << " to" << id;
746
761
runPatchelf (QStringList () << " --set-rpath" << id << binaryPath);
747
762
0 commit comments