summaryrefslogtreecommitdiffstats
path: root/src/libs/installer
diff options
context:
space:
mode:
authorPasi Matilainen <pasi.matilainen@digia.com>2012-10-01 09:33:14 +0300
committerTim Jenssen <tim.jenssen@digia.com>2012-10-15 07:59:55 +0200
commit2215e67d2c5e8bdefd9f9fcbe455706139bb2df9 (patch)
tree98ad32c66699dafab87a214d895a60d91e1206a7 /src/libs/installer
parentbc15c2d4b68d77adf8929417311b36ad217d773f (diff)
Update uninstaller creation on Mac to work with separate installer data
Installer data is stored in a separate file on Mac, and writeUninstaller must be updated to understand that fact. To simplify code, the uninstaller magic marker is also stored in a separate data file. Also fixed writeUninstallerBinary to write the operations start and end values that are part of the data header. Change-Id: I3ee5d1eaa0542d6187a587fb72165c3a5b7306ec Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/libs/installer')
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 6a3e30cc5..3a31f54fe 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -1036,10 +1036,34 @@ void PackageManagerCorePrivate::writeUninstallerBinary(QFile *const input, qint6
appendData(&out, input, size);
if (writeBinaryLayout) {
+#ifdef Q_WS_MAC
+ QDir resourcePath(QFileInfo(uninstallerRenamedName).dir());
+ if (!resourcePath.path().endsWith(QLatin1String("Contents/MacOS")))
+ throw Error(tr("Uninstaller is not a bundle"));
+ resourcePath.cdUp();
+ resourcePath.cd(QLatin1String("Resources"));
+ // It's a bit odd to have only the magic in the data file, but this simplifies
+ // other code a lot (since installers don't have any appended data either)
+ QString outPath = resourcePath.filePath(QLatin1String("installer.dat"));
+ KDSaveFile dataOut(outPath);
+ openForWrite(&dataOut, dataOut.fileName());
+ appendInt64(&dataOut, 0); // operations start
+ appendInt64(&dataOut, 0); // operations end
+ appendInt64(&dataOut, 0); // resource count
+ appendInt64(&dataOut, 4 * sizeof(qint64)); // data block size
+ appendInt64(&dataOut, QInstaller::MagicUninstallerMarker);
+ appendInt64(&dataOut, QInstaller::MagicCookie);
+ dataOut.setPermissions(dataOut.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther);
+ if (!dataOut.commit(KDSaveFile::OverwriteExistingFile))
+ throw Error(tr("Could not write uninstaller data to %1: %2").arg(out.fileName(), out.errorString()));
+#else
+ appendInt64(&out, 0); // operations start
+ appendInt64(&out, 0); // operations end
appendInt64(&out, 0); // resource count
appendInt64(&out, 4 * sizeof(qint64)); // data block size
appendInt64(&out, QInstaller::MagicUninstallerMarker);
appendInt64(&out, QInstaller::MagicCookie);
+#endif
}
out.setPermissions(out.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther
| QFile::ExeOther | QFile::ExeGroup | QFile::ExeUser);
@@ -1262,6 +1286,24 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
openForRead(&input, input.fileName());
layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookieDat));
} catch (const Error &/*error*/) {
+#ifdef Q_OS_MAC
+ // On Mac, data is always in a separate file so that the binary can be signed
+ QString binaryName = isInstaller() ? installerBinaryPath() : uninstallerName();
+ QDir dataPath(QFileInfo(binaryName).dir());
+ dataPath.cdUp();
+ dataPath.cd(QLatin1String("Resources"));
+ input.setFileName(dataPath.filePath(QLatin1String("installer.dat")));
+
+ openForRead(&input, input.fileName());
+ layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookie));
+
+ if (!newBinaryWritten) {
+ newBinaryWritten = true;
+ QFile tmp(binaryName);
+ openForRead(&tmp, tmp.fileName());
+ writeUninstallerBinary(&tmp, tmp.size(), true);
+ }
+#else
input.setFileName(isInstaller() ? installerBinaryPath() : uninstallerName());
openForRead(&input, input.fileName());
layout = BinaryContent::readBinaryLayout(&input, findMagicCookie(&input, MagicCookie));
@@ -1269,6 +1311,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
newBinaryWritten = true;
writeUninstallerBinary(&input, layout.endOfData - layout.dataBlockSize, true);
}
+#endif
}
try {