summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@theqtcompany.com>2016-05-05 15:18:34 +0300
committerKatja Marttila <katja.marttila@qt.io>2016-06-21 04:51:29 +0000
commit76fd6e8f2953347ea0bf7a57b643968784bc9acc (patch)
treeadc2ed4e61b4778c8995de6760bf514b8e3b3d37 /src
parente28bd0a98dd1a7ca0846cd406b23c6e5429ac82d (diff)
Allow signing maintenancetool in Windows
Signing was not possible for maintenancetool since metadata was added to binary. Separated metadata to installer.dat like in OS X. Task-number: QTIFW-667 Change-Id: I74ef307c51a2f43059475dd943d6f0910925fa86 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp13
-rw-r--r--src/sdk/sdkapp.h24
2 files changed, 25 insertions, 12 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index 642d7f5ae..76294ec69 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -995,12 +995,14 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q
QInstaller::appendData(&out, input, size);
if (writeBinaryLayout) {
-#ifdef Q_OS_OSX
+#if defined Q_OS_OSX || defined Q_OS_WIN
QDir resourcePath(QFileInfo(maintenanceToolRenamedName).dir());
+#ifdef Q_OS_OSX
if (!resourcePath.path().endsWith(QLatin1String("Contents/MacOS")))
throw Error(tr("Maintenance tool is not a bundle"));
resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources"));
+#endif
// 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)
QTemporaryFile dataOut;
@@ -1027,7 +1029,7 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q
dataOut.setAutoRemove(false);
dataOut.setPermissions(dataOut.permissions() | QFile::WriteUser | QFile::ReadGroup
| QFile::ReadOther);
-#else
+#elif defined(Q_OS_LINUX)
QInstaller::appendInt64(&out, 0); // operations start
QInstaller::appendInt64(&out, 0); // operations end
QInstaller::appendInt64(&out, 0); // resource count
@@ -1296,12 +1298,15 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper
QInstaller::openForRead(&input);
layout = BinaryContent::binaryLayout(&input, BinaryContent::MagicCookieDat);
} catch (const Error &/*error*/) {
-#ifdef Q_OS_OSX
- // On Mac, data is always in a separate file so that the binary can be signed
+#if defined Q_OS_OSX || defined Q_OS_WIN
+ // On Mac and Windows data is always in a separate file
+ // so that the binary can be signed
QString binaryName = isInstaller() ? installerBinaryPath() : maintenanceToolName();
QDir dataPath(QFileInfo(binaryName).dir());
+#ifdef Q_OS_OSX
dataPath.cdUp();
dataPath.cd(QLatin1String("Resources"));
+#endif
input.setFileName(dataPath.filePath(QLatin1String("installer.dat")));
QInstaller::openForRead(&input);
diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h
index c5cc4ca50..d06cd9eb3 100644
--- a/src/sdk/sdkapp.h
+++ b/src/sdk/sdkapp.h
@@ -76,21 +76,26 @@ public:
installer binary itself, which contains the binary layout and the binary content. In case
of an maintenance tool, it will return a binary that has just a binary layout append.
- Note on OS X: For compatibility reason this function will return the a .dat file located
- inside the resource folder in the application bundle, as on OS X the binary layout cannot
- be appended to the actual installer / maintenance tool binary itself because of signing.
+ Note on OS X and Windows: For compatibility reason this function will return the .dat file
+ as the binary layout cannot be appended to the actual installer / maintenance tool binary
+ itself because of signing. .dat file is located inside the resource folder in the application
+ bundle in OS X and next to maintenance tool in Windows.
*/
QString binaryFile() const
{
QString binaryFile = QCoreApplication::applicationFilePath();
-#ifdef Q_OS_OSX
- // The installer binary on OSX does not contain the binary content, it's put into
- // the resources folder as separate file. Adjust the actual binary path. No error
- // checking here since we will fail later while reading the binary content.
+#if defined Q_OS_OSX || defined Q_OS_WIN
+ // The installer binary on OSX and Windows does not contain the binary
+ // content, it's put into the resources folder as separate file.
+ // Adjust the actual binary path. No error checking here since we
+ // will fail later while reading the binary content.
QDir resourcePath(QFileInfo(binaryFile).dir());
+
+#ifdef Q_OS_OSX
resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources"));
- return resourcePath.filePath(QLatin1String("installer.dat"));
+#endif
+ binaryFile = resourcePath.filePath(QLatin1String("installer.dat"));
#endif
return binaryFile;
}
@@ -114,6 +119,9 @@ public:
QString bundlePath;
if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath))
fi.setFile(bundlePath);
+#ifdef Q_OS_WIN
+ return fi.absoluteDir().filePath(qApp->applicationName() + QLatin1String(".dat"));
+#endif
return fi.absoluteDir().filePath(fi.baseName() + QLatin1String(".dat"));
}
return QString();