Commit 96cd834f authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Symbian: Warn when patching sis files

Wharn when qmake patches sis files to make them compatible with
self-signing.

Task-number: QTCREATORBUG-2403
Reviewed-by: Pawel Polanski
parent f2900951
......@@ -27,43 +27,91 @@
**
**************************************************************************/
#include "s60createpackageparser.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskwindow.h>
using namespace Qt4ProjectManager;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Constants;
using namespace Qt4ProjectManager::Internal;
S60CreatePackageParser::S60CreatePackageParser()
S60CreatePackageParser::S60CreatePackageParser(const QString &packageName) :
m_packageName(packageName),
m_needPassphrase(false)
{
m_signSis.setPattern("^(error):([A-Z\\d]+):(.+)$");
setObjectName(QLatin1String("S60CreatePackageParser"));
m_signSis.setPattern("^(error:\\s?)+(.+)$");
m_signSis.setMinimal(true);
}
void S60CreatePackageParser::stdOutput(const QString &line)
bool S60CreatePackageParser::parseLine(const QString &line)
{
QString lne = line.trimmed();
if (m_signSis.indexIn(lne) > -1) {
QString errorDescription(m_signSis.cap(3));
int index = errorDescription.indexOf(QLatin1String("error:"));
if (index >= 0) {
stdOutput(errorDescription.mid(index));
errorDescription = errorDescription.left(index);
}
Task task(Task::Error,
errorDescription /* description */,
QString(), -1,
TASK_CATEGORY_BUILDSYSTEM);
if (line.startsWith("Patching: ")) {
m_patchingLines.append(line.mid(10).trimmed());
return true;
}
if (!m_patchingLines.isEmpty()) {
emit packageWasPatched(m_packageName, m_patchingLines);
QString lines = m_patchingLines.join("\n");
m_patchingLines.clear();
//: %1 package name, %2 will be replaced by a list of patching lines.
QString message = tr("The binary package '%1' was patched to be installable after being self-signed!\n%2\n"
"Use a developer certificate or any other signing option to prevent "
"this patching from happening.").
arg(m_packageName, lines);
ProjectExplorer::Task task(ProjectExplorer::Task::Warning, message, QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
QTextLayout::FormatRange fr;
fr.start = message.indexOf(lines);
fr.length = lines.length();
fr.format.setFontItalic(true);
task.formats.append(fr);
emit addTask(task);
}
IOutputParser::stdOutput(line);
if (m_signSis.indexIn(line) > -1) {
if (m_signSis.cap(2).contains(QLatin1String("bad password"))
|| m_signSis.cap(2).contains(QLatin1String("bad decrypt")))
m_needPassphrase = true;
else
emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, m_signSis.cap(2), QString(), -1,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
return true;
}
return false;
}
void S60CreatePackageParser::stdOutput(const QString &line)
{
if (!parseLine(line))
IOutputParser::stdOutput(line);
}
void S60CreatePackageParser::stdError(const QString &line)
{
stdOutput(line);
IOutputParser::stdError(line);
if (!parseLine(line))
IOutputParser::stdError(line);
}
bool S60CreatePackageParser::needPassphrase() const
{
return m_needPassphrase;
}
/* STDOUT:
make[1]: Entering directory `C:/temp/test/untitled131'
createpackage.bat -g untitled131_template.pkg RELEASE-armv5
Auto-patching capabilities for self signed package.
Patching package file and relevant binaries...
Patching: Removed dependency to qt.sis (0x2001E61C) to avoid installation issues in case qt.sis is also patched.
NOTE: A patched package may not work as expected due to reduced capabilities and other modifications,
so it should not be used for any kind of Symbian signing or distribution!
Use a proper certificate to avoid the need to patch the package.
Processing untitled131_release-armv5.pkg...
*/
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef S60CREATEPACKAGEPARSER_H
#define S60CREATEPACKAGEPARSER_H
#ifndef SIGNSISPARSER_H
#define SIGNSISPARSER_H
#include <projectexplorer/ioutputparser.h>
#include <QtCore/QRegExp>
namespace Qt4ProjectManager {
namespace Internal {
class S60CreatePackageParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
public:
S60CreatePackageParser();
S60CreatePackageParser(const QString &packageName);
virtual void stdOutput(const QString & line);
virtual void stdError(const QString & line);
virtual void stdOutput(const QString &line);
virtual void stdError(const QString &line);
bool needPassphrase() const;
signals:
void packageWasPatched(const QString &, const QStringList &pachingLines);
private:
bool parseLine(const QString &line);
const QString m_packageName;
QRegExp m_signSis;
QStringList m_patchingLines;
bool m_needPassphrase;
};
} // namespace Internal
} // namespace Qt4ProjectExplorer
#endif // S60CREATEPACKAGEPARSER_H
#endif // SIGNSISPARSER_H
......@@ -42,9 +42,15 @@ QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace Utils {
class CheckableMessageBox;
} // namespace Utils
namespace Qt4ProjectManager {
namespace Internal {
class S60CreatePackageParser;
class S60CreatePackageStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
......@@ -71,6 +77,7 @@ class S60CreatePackageStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
friend class S60CreatePackageStepFactory;
public:
enum SigningMode {
SignSelf = 0,
......@@ -105,6 +112,7 @@ public:
signals:
void badPassphrase();
void warnAboutPatching();
protected:
S60CreatePackageStep(ProjectExplorer::BuildStepList *bsl, S60CreatePackageStep *bs);
......@@ -114,24 +122,22 @@ protected:
Qt4BuildConfiguration *qt4BuildConfiguration() const;
private slots:
void slotProcessFinished(int, QProcess::ExitStatus);
void packageWarningDialogDone();
void packageDone(int, QProcess::ExitStatus);
void processReadyReadStdOutput();
void processReadyReadStdError();
void taskAdded(const ProjectExplorer::Task &task);
void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format);
void checkForCancel();
void definePassphrase();
private:
enum ErrorType {
ErrorNone = 0,
ErrorUndefined,
ErrorBadPassphrase
};
void packageWasPatched(const QString &, const QStringList &);
void handleWarnAboutPatching();
private:
void stdOutput(const QString &line);
void stdError(const QString &line);
bool startProcess();
void setupProcess();
bool createOnePackage();
QString generateKeyId(const QString &keyPath) const;
QString loadPassphraseForKey(const QString &keyId);
......@@ -159,12 +165,18 @@ private:
QTimer *m_timer;
QEventLoop *m_eventLoop;
QFutureInterface<bool> *m_futureInterface;
ErrorType m_errorType;
QWaitCondition m_waitCondition;
QMutex m_mutex;
QSettings *m_settings;
bool m_cancel;
QSettings *m_passphrases;
S60CreatePackageParser *m_parser;
QList<QPair<QString, QStringList> > m_packageChanges;
bool m_suppressPatchWarningDialog;
Utils::CheckableMessageBox *m_patchWarningDialog;
};
class S60CreatePackageStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment