diff options
-rw-r--r-- | src/libs/installer/binaryformat.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/fileutils.cpp | 19 | ||||
-rw-r--r-- | src/libs/installer/fileutils.h | 1 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 2 | ||||
-rw-r--r-- | tools/binarycreator/binarycreator.cpp | 2 |
6 files changed, 30 insertions, 8 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 28666f8e4..a734bc3fd 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -657,9 +657,11 @@ BinaryContent BinaryContent::readFromBinary(const QString &path) if (magicMarker != MagicInstallerMarker) { // We are not an installer, so we need to read the data from the .dat file. + QFileInfo fi(path); - if (QFileInfo(fi.absoluteFilePath() + QLatin1String("/../../..")).isBundle()) - fi.setFile(fi.absoluteFilePath()); // On OSX it's not inside the bundle, deserves TODO. + QString bundlePath; // On OSX it's not inside the bundle, deserves TODO. + if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath)) + fi.setFile(bundlePath); c.d->m_binaryDataFile.reset(new QFile(fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat"))); diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 2ec690f6d..4708e5602 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -570,3 +570,22 @@ quint64 QInstaller::fileSize(const QFileInfo &info) return symlinkSizeWin(info.absoluteFilePath()); #endif } + +bool QInstaller::isInBundle(const QString &path, QString *bundlePath) +{ +#ifdef Q_OS_OSX + QFileInfo fi = QFileInfo(path).absoluteFilePath(); + while (!fi.isRoot()) { + if (fi.isBundle()) { + if (bundlePath) + *bundlePath = fi.absoluteFilePath(); + return true; + } + fi.setFile(fi.path()); + } +#else + Q_UNUSED(path) + Q_UNUSED(bundlePath) +#endif + return false; +} diff --git a/src/libs/installer/fileutils.h b/src/libs/installer/fileutils.h index a8efefacd..077ab218b 100644 --- a/src/libs/installer/fileutils.h +++ b/src/libs/installer/fileutils.h @@ -105,6 +105,7 @@ private: void INSTALLER_EXPORT mkpath(const QString &path); quint64 INSTALLER_EXPORT fileSize(const QFileInfo &info); + bool INSTALLER_EXPORT isInBundle(const QString &path, QString *bundlePath = 0); #ifdef Q_OS_WIN QString INSTALLER_EXPORT getLongPathName(const QString &name); diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index ccc2dc930..190742d9c 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -737,7 +737,7 @@ QString PackageManagerCorePrivate::uninstallerName() const { QString filename = m_data.settings().uninstallerName(); #if defined(Q_OS_OSX) - if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle()) + if (QInstaller::isInBundle(QCoreApplication::applicationDirPath())) filename += QLatin1String(".app/Contents/MacOS/") + filename; #elif defined(Q_OS_WIN) filename += QLatin1String(".exe"); @@ -1186,7 +1186,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio #ifdef Q_OS_OSX // if it is a bundle, we need some stuff in it... const QString sourceAppDirPath = QCoreApplication::applicationDirPath(); - if (isInstaller() && QFileInfo(sourceAppDirPath + QLatin1String("/../..")).isBundle()) { + if (isInstaller() && QInstaller::isInBundle(sourceAppDirPath)) { Operation *op = createOwnedOperation(QLatin1String("Copy")); op->setArguments(QStringList() << (sourceAppDirPath + QLatin1String("/../PkgInfo")) << (targetAppDirPath + QLatin1String("/../PkgInfo"))); @@ -2005,8 +2005,8 @@ void PackageManagerCorePrivate::deleteUninstaller() QFile uninstaller(QFileInfo(installerBinaryPath()).absoluteFilePath()); uninstaller.remove(); # ifdef Q_OS_OSX - const QLatin1String cdUp("/../../.."); - if (QFileInfo(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath()).isBundle()) { + if (QInstaller::isInBundle(installerBinaryPath())) { + const QLatin1String cdUp("/../../.."); removeDirectoryThreaded(QFileInfo(installerBinaryPath() + cdUp).absoluteFilePath()); QFile::remove(QFileInfo(installerBinaryPath() + cdUp).absolutePath() + QLatin1String("/") + configurationFileName()); diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index c17364fd5..67c19de67 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -1715,7 +1715,7 @@ bool TargetDirectoryPage::validatePage() if (fi.isDir()) { QString fileName = packageManagerCore()->settings().uninstallerName(); #if defined(Q_OS_OSX) - if (QFileInfo(QCoreApplication::applicationDirPath() + QLatin1String("/../..")).isBundle()) + if (QInstaller::isInBundle(QCoreApplication::applicationDirPath())) fileName += QLatin1String(".app/Contents/MacOS/") + fileName; #elif defined(Q_OS_WIN) fileName += QLatin1String(".exe"); diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp index 84f5dfa42..3e8a651ef 100644 --- a/tools/binarycreator/binarycreator.cpp +++ b/tools/binarycreator/binarycreator.cpp @@ -117,7 +117,7 @@ static void chmod755(const QString &absolutFilePath) static int assemble(Input input, const QInstaller::Settings &settings) { #ifdef Q_OS_OSX - if (QFileInfo(input.installerExePath).isBundle()) { + if (QInstaller::isInBundle(input.installerExePath)) { const QString bundle = input.installerExePath; // if the input file was a bundle const QSettings s(QString::fromLatin1("%1/Contents/Info.plist").arg(input.installerExePath), |