diff --git a/shared/shared.cpp b/shared/shared.cpp index 7332cb3..3d77b87 100644 --- a/shared/shared.cpp +++ b/shared/shared.cpp @@ -889,28 +889,42 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath // especially since stuff that is supposed to come from resources actually // seems to come in libexec in the upstream Qt binary distribution if (containsHowOften(deploymentInfo.deployedLibraries, "libQt5WebEngineCore")) { - QDir().mkpath(appDirInfo.path + "/resources"); - QDir().mkpath(appDirInfo.path + "/libexec"); - sourcePath = pluginSourcePath + "/../libexec/QtWebEngineProcess"; - destinationPath = pluginDestinationPath + "/../libexec/QtWebEngineProcess"; + // Find directories with needed files: + QString qtLibexecPath = qtToBeBundledInfo.value("QT_INSTALL_LIBEXECS"); + QString qtDataPath = qtToBeBundledInfo.value("QT_INSTALL_DATA"); + QString qtTranslationsPath = qtToBeBundledInfo.value("QT_INSTALL_TRANSLATIONS"); + // create destination directories: + QString dstLibexec = appDirInfo.path + "/libexec"; + QString dstResources = appDirInfo.path + "/resources"; + QString dstTranslations = appDirInfo.path + "/translations"; + QDir().mkpath(dstLibexec); + QDir().mkpath(dstResources); + QDir().mkpath(dstTranslations); + // WebEngine executable: + sourcePath = QDir::cleanPath(qtLibexecPath + "/QtWebEngineProcess"); + destinationPath = QDir::cleanPath(dstLibexec + "/QtWebEngineProcess"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/qtwebengine_resources.pak"; - destinationPath = pluginDestinationPath + "/../resources/qtwebengine_resources.pak"; + // put qt.conf file next to browser process so it can also make use of our local Qt resources + createQtConfForQtWebEngineProcess(dstLibexec); + // Resources: + sourcePath = QDir::cleanPath(qtDataPath + "/resources/qtwebengine_resources.pak"); + destinationPath = QDir::cleanPath(dstResources + "/qtwebengine_resources.pak"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/qtwebengine_devtools_resources.pak"; - destinationPath = pluginDestinationPath + "/../resources/qtwebengine_devtools_resources.pak"; + sourcePath = QDir::cleanPath(qtDataPath + "/resources/qtwebengine_devtools_resources.pak"); + destinationPath = QDir::cleanPath(dstResources + "/qtwebengine_devtools_resources.pak"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/qtwebengine_resources_100p.pak"; - destinationPath = pluginDestinationPath + "/../resources/qtwebengine_resources_100p.pak"; + sourcePath = QDir::cleanPath(qtDataPath + "/resources/qtwebengine_resources_100p.pak"); + destinationPath = QDir::cleanPath(dstResources + "/qtwebengine_resources_100p.pak"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/qtwebengine_resources_200p.pak"; - destinationPath = pluginDestinationPath + "/../resources/qtwebengine_resources_200p.pak"; + sourcePath = QDir::cleanPath(qtDataPath + "/resources/qtwebengine_resources_200p.pak"); + destinationPath = QDir::cleanPath(dstResources + "/qtwebengine_resources_200p.pak"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/icudtl.dat"; - destinationPath = pluginDestinationPath + "/../resources/icudtl.dat"; + sourcePath = QDir::cleanPath(qtDataPath + "/resources/icudtl.dat"); + destinationPath = QDir::cleanPath(dstResources + "/icudtl.dat"); copyFilePrintStatus(sourcePath, destinationPath); - sourcePath = pluginSourcePath + "/../libexec/qtwebengine_locales"; - destinationPath = pluginDestinationPath + "/../resources/"; + // Translations: + sourcePath = QDir::cleanPath(qtTranslationsPath + "/qtwebengine_locales"); + destinationPath = QDir::cleanPath(dstTranslations + "/qtwebengine_locales"); recursiveCopy(sourcePath, destinationPath); } @@ -964,6 +978,30 @@ void createQtConf(const QString &appDirPath) } } +void createQtConfForQtWebEngineProcess(const QString &appDirPath) +{ + QByteArray contents = "# Generated by linuxdeployqt\n" + "# https://github.com/probonopd/linuxdeployqt/\n" + "[Paths]\n" + "Prefix = ../\n"; + QString filePath = appDirPath + "/"; + QString fileName = filePath + "qt.conf"; + + QDir().mkpath(filePath); + + QFile qtconf(fileName); + if (qtconf.exists() && !alwaysOwerwriteEnabled) { + LogWarning() << fileName << "already exists, will not overwrite."; + return; + } + + qtconf.open(QIODevice::WriteOnly); + if (qtconf.write(contents) != -1) { + LogNormal() << "Created configuration file for Qt WebEngine process:" << fileName; + LogNormal() << "This file sets the prefix option to parent directory of browser process executable"; + } +} + void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo) { AppDirInfo applicationBundle; diff --git a/shared/shared.h b/shared/shared.h index 60c0fd9..736f920 100644 --- a/shared/shared.h +++ b/shared/shared.h @@ -112,6 +112,7 @@ QString copyLibrary(const LibraryInfo &library, const QString path); DeploymentInfo deployQtLibraries(const QString &appDirPath, const QStringList &additionalExecutables); DeploymentInfo deployQtLibraries(QList libraries,const QString &bundlePath, const QStringList &binaryPaths, bool useLoaderPath); void createQtConf(const QString &appDirPath); +void createQtConfForQtWebEngineProcess(const QString &appDirPath); void deployPlugins(const QString &appDirPath, DeploymentInfo deploymentInfo); bool deployQmlImports(const QString &appDirPath, DeploymentInfo deploymentInfo, QStringList &qmlDirs); void changeIdentification(const QString &id, const QString &binaryPath);