diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-05-27 15:54:45 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2022-06-03 08:24:52 +0000 |
commit | b6e6ad4876ab6c2c2a20f6cce191e27411441921 (patch) | |
tree | 7dbe2671d16a5001dbee7d1a3a113fee42da6152 /src | |
parent | d279237a545cd0b38d8cc210f4e69648547f4d59 (diff) |
macOS: make creating maintenance tool alias optional
Currently the installer will create an alias file for maintenance tool
with the name defaulting to the file name of maintenance tool, if the
name is not explicitly declared in the installer's configuration file.
This can cause issues with installers that use the same maintenance tool
filename, as the alias would be overwritten on each install, and the
default name does not tell which installation the alias is associated
with. Make it so that the alias is only created if installer config
specifies a name for the alias.
Task-number: QTIFW-2665
Change-Id: I790ee376ec56cff16730189e513a194b8c610066
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 21 | ||||
-rw-r--r-- | src/libs/installer/settings.cpp | 2 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 9b574b3f8..66630b98d 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -782,12 +782,16 @@ QString PackageManagerCorePrivate::maintenanceToolName() const QString PackageManagerCorePrivate::maintenanceToolAliasPath() const { #ifdef Q_OS_MACOS + const QString aliasName = m_data.settings().maintenanceToolAlias(); + if (aliasName.isEmpty()) + return QString(); + const bool isRoot = (AdminAuthorization::hasAdminRights() || RemoteClient::instance().isActive()); const QString applicationsDir = m_core->value( isRoot ? QLatin1String("ApplicationsDir") : QLatin1String("ApplicationsDirUser") ); QString maintenanceToolAlias = QString::fromLatin1("%1/%2") - .arg(applicationsDir, m_data.settings().maintenanceToolAlias()); + .arg(applicationsDir, aliasName); if (!maintenanceToolAlias.endsWith(QLatin1String(".app"))) maintenanceToolAlias += QLatin1String(".app"); @@ -1511,9 +1515,12 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper if (newBinaryWritten) { // Remove old alias as the name may have changed. deleteMaintenanceToolAlias(); - // The new alias file is created after the maintenance too binary is renamed, - // but we need to set the value before the variables get written to disk. - m_core->setValue(QLatin1String("CreatedMaintenanceToolAlias"), maintenanceToolAliasPath()); + const QString aliasPath = maintenanceToolAliasPath(); + if (!aliasPath.isEmpty()) { + // The new alias file is created after the maintenance too binary is renamed, + // but we need to set the value before the variables get written to disk. + m_core->setValue(QLatin1String("CreatedMaintenanceToolAlias"), aliasPath); + } } #endif writeMaintenanceConfigFiles(); @@ -1602,14 +1609,16 @@ void PackageManagerCorePrivate::writeOfflineBaseBinary() void PackageManagerCorePrivate::writeMaintenanceToolAlias() { #ifdef Q_OS_MACOS + const QString aliasPath = maintenanceToolAliasPath(); + if (aliasPath.isEmpty()) + return; + QString maintenanceToolBundle = QString::fromLatin1("%1/%2") .arg(targetDir(), m_data.settings().maintenanceToolName()); if (!maintenanceToolBundle.endsWith(QLatin1String(".app"))) maintenanceToolBundle += QLatin1String(".app"); - const QString aliasPath = maintenanceToolAliasPath(); const QDir targetDir(QFileInfo(aliasPath).absolutePath()); - if (!targetDir.exists()) targetDir.mkpath(targetDir.absolutePath()); diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp index b0c6b9d31..108d68832 100644 --- a/src/libs/installer/settings.cpp +++ b/src/libs/installer/settings.cpp @@ -386,8 +386,6 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix, s.d->m_data.value(QLatin1String("UninstallerName"), QLatin1String("maintenancetool")) .toString()); } - if (s.d->m_data.value(scMaintenanceToolAlias).toString().isEmpty()) - s.d->m_data.replace(scMaintenanceToolAlias, s.d->m_data.value(scMaintenanceToolName)); if (s.d->m_data.value(scTargetConfigurationFile).toString().isEmpty()) s.d->m_data.replace(scTargetConfigurationFile, QLatin1String("components.xml")); |