summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPasi Matilainen <pasi.matilainen@digia.com>2012-10-01 09:33:14 +0300
committerKarsten Heimrich <karsten.heimrich@digia.com>2012-10-22 15:09:17 +0200
commitf72207ed1ee99233aeff74c21ee313d827099ef4 (patch)
tree24c03237ad496ba771fcabfd65fb5467c4dd4165
parent63a37ecd2b60fa841f704a8b8b51a9ccfc400c7d (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>
-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 ba7299a46..98505bfd5 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -1038,10 +1038,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);
@@ -1264,6 +1288,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));
@@ -1271,6 +1313,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio
newBinaryWritten = true;
writeUninstallerBinary(&input, layout.endOfData - layout.dataBlockSize, true);
}
+#endif
}
try {