Revert "Allow signing maintenancetool in Windows"

This reverts commit 76fd6e8f2953347ea0bf7a57b643968784bc9acc.
The change caused that two installation files were needed -
one executable and one dat file. Many users did not find it acceptable.
We need to figure out something else.

Change-Id: Ief12cd47f9897cee8a234d8611a5c18296d42b1c
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
This commit is contained in:
Katja Marttila 2016-09-14 13:15:05 +00:00
parent fc0b26f4d2
commit 49201fdb99
4 changed files with 15 additions and 42 deletions

View File

@ -995,14 +995,12 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q
QInstaller::appendData(&out, input, size); QInstaller::appendData(&out, input, size);
if (writeBinaryLayout) { if (writeBinaryLayout) {
#if defined Q_OS_OSX || defined Q_OS_WIN
QDir resourcePath(QFileInfo(maintenanceToolRenamedName).dir());
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
QDir resourcePath(QFileInfo(maintenanceToolRenamedName).dir());
if (!resourcePath.path().endsWith(QLatin1String("Contents/MacOS"))) if (!resourcePath.path().endsWith(QLatin1String("Contents/MacOS")))
throw Error(tr("Maintenance tool is not a bundle")); throw Error(tr("Maintenance tool is not a bundle"));
resourcePath.cdUp(); resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources")); resourcePath.cd(QLatin1String("Resources"));
#endif
// It's a bit odd to have only the magic in the data file, but this simplifies // 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) // other code a lot (since installers don't have any appended data either)
QTemporaryFile dataOut; QTemporaryFile dataOut;
@ -1029,7 +1027,7 @@ void PackageManagerCorePrivate::writeMaintenanceToolBinary(QFile *const input, q
dataOut.setAutoRemove(false); dataOut.setAutoRemove(false);
dataOut.setPermissions(dataOut.permissions() | QFile::WriteUser | QFile::ReadGroup dataOut.setPermissions(dataOut.permissions() | QFile::WriteUser | QFile::ReadGroup
| QFile::ReadOther); | QFile::ReadOther);
#elif defined(Q_OS_LINUX) #else
QInstaller::appendInt64(&out, 0); // operations start QInstaller::appendInt64(&out, 0); // operations start
QInstaller::appendInt64(&out, 0); // operations end QInstaller::appendInt64(&out, 0); // operations end
QInstaller::appendInt64(&out, 0); // resource count QInstaller::appendInt64(&out, 0); // resource count
@ -1298,15 +1296,12 @@ void PackageManagerCorePrivate::writeMaintenanceTool(OperationList performedOper
QInstaller::openForRead(&input); QInstaller::openForRead(&input);
layout = BinaryContent::binaryLayout(&input, BinaryContent::MagicCookieDat); layout = BinaryContent::binaryLayout(&input, BinaryContent::MagicCookieDat);
} catch (const Error &/*error*/) { } catch (const Error &/*error*/) {
#if defined Q_OS_OSX || defined Q_OS_WIN #ifdef Q_OS_OSX
// On Mac and Windows data is always in a separate file // On Mac, data is always in a separate file so that the binary can be signed
// so that the binary can be signed
QString binaryName = isInstaller() ? installerBinaryPath() : maintenanceToolName(); QString binaryName = isInstaller() ? installerBinaryPath() : maintenanceToolName();
QDir dataPath(QFileInfo(binaryName).dir()); QDir dataPath(QFileInfo(binaryName).dir());
#ifdef Q_OS_OSX
dataPath.cdUp(); dataPath.cdUp();
dataPath.cd(QLatin1String("Resources")); dataPath.cd(QLatin1String("Resources"));
#endif
input.setFileName(dataPath.filePath(QLatin1String("installer.dat"))); input.setFileName(dataPath.filePath(QLatin1String("installer.dat")));
QInstaller::openForRead(&input); QInstaller::openForRead(&input);

View File

@ -76,26 +76,21 @@ public:
installer binary itself, which contains the binary layout and the binary content. In case 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. of an maintenance tool, it will return a binary that has just a binary layout append.
Note on OS X and Windows: For compatibility reason this function will return the .dat file Note on OS X: For compatibility reason this function will return the a .dat file located
as the binary layout cannot be appended to the actual installer / maintenance tool binary inside the resource folder in the application bundle, as on OS X the binary layout cannot
itself because of signing. .dat file is located inside the resource folder in the application be appended to the actual installer / maintenance tool binary itself because of signing.
bundle in OS X and next to maintenance tool in Windows.
*/ */
QString binaryFile() const QString binaryFile() const
{ {
QString binaryFile = QCoreApplication::applicationFilePath(); QString binaryFile = QCoreApplication::applicationFilePath();
#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 #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.
QDir resourcePath(QFileInfo(binaryFile).dir());
resourcePath.cdUp(); resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources")); resourcePath.cd(QLatin1String("Resources"));
#endif return resourcePath.filePath(QLatin1String("installer.dat"));
binaryFile = resourcePath.filePath(QLatin1String("installer.dat"));
#endif #endif
return binaryFile; return binaryFile;
} }
@ -119,9 +114,6 @@ public:
QString bundlePath; QString bundlePath;
if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath)) if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath))
fi.setFile(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 fi.absoluteDir().filePath(fi.baseName() + QLatin1String(".dat"));
} }
return QString(); return QString();

View File

@ -241,12 +241,10 @@ static int assemble(Input input, const QInstaller::Settings &settings, const QSt
QTemporaryFile out; QTemporaryFile out;
QString targetName = input.outputPath; QString targetName = input.outputPath;
#if defined Q_OS_OSX || defined Q_OS_WIN
QDir resourcePath(QFileInfo(input.outputPath).dir());
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
QDir resourcePath(QFileInfo(input.outputPath).dir());
resourcePath.cdUp(); resourcePath.cdUp();
resourcePath.cd(QLatin1String("Resources")); resourcePath.cd(QLatin1String("Resources"));
#endif
targetName = resourcePath.filePath(QLatin1String("installer.dat")); targetName = resourcePath.filePath(QLatin1String("installer.dat"));
#endif #endif
@ -264,10 +262,7 @@ static int assemble(Input input, const QInstaller::Settings &settings, const QSt
QInstaller::openForWrite(&out); QInstaller::openForWrite(&out);
QFile exe(input.installerExePath); QFile exe(input.installerExePath);
#if defined Q_OS_OSX || defined Q_OS_WIN #ifdef Q_OS_OSX
// remove the target
if (QFile::exists(input.outputPath))
QFile::remove(input.outputPath);
if (!exe.copy(input.outputPath)) { if (!exe.copy(input.outputPath)) {
throw Error(QString::fromLatin1("Cannot copy %1 to %2: %3").arg(exe.fileName(), throw Error(QString::fromLatin1("Cannot copy %1 to %2: %3").arg(exe.fileName(),
input.outputPath, exe.errorString())); input.outputPath, exe.errorString()));

View File

@ -173,11 +173,6 @@ int main(int argc, char *argv[])
if (QInstaller::isInBundle(path, &bundlePath)) if (QInstaller::isInBundle(path, &bundlePath))
path = QDir(bundlePath).filePath(QLatin1String("Contents/Resources/installer.dat")); path = QDir(bundlePath).filePath(QLatin1String("Contents/Resources/installer.dat"));
#ifdef Q_OS_WIN
QDir resourcePath(path);
resourcePath.cdUp();
path = resourcePath.filePath(QLatin1String("installer.dat"));
#endif
int result = EXIT_FAILURE; int result = EXIT_FAILURE;
QVector<QByteArray> resourceMappings; QVector<QByteArray> resourceMappings;
quint64 cookie = QInstaller::BinaryContent::MagicCookie; quint64 cookie = QInstaller::BinaryContent::MagicCookie;
@ -196,12 +191,8 @@ int main(int argc, char *argv[])
QFileInfo fi(path); QFileInfo fi(path);
if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath)) if (QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath))
fi.setFile(bundlePath); fi.setFile(bundlePath);
#ifdef Q_OS_WIN
QFileInfo appName = arguments.first();
path = fi.absoluteDir().filePath(appName.baseName() + QLatin1String(".dat"));
#else
path = fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat"); path = fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat");
#endif
tmp.close(); tmp.close();
tmp.setFileName(path); tmp.setFileName(path);
QInstaller::openForRead(&tmp); QInstaller::openForRead(&tmp);