diff options
author | kh1 <karsten.heimrich@nokia.com> | 2012-03-27 13:55:25 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@nokia.com> | 2012-03-27 14:57:48 +0200 |
commit | 564ef626886496ea5e6685f0fc4f96c283245123 (patch) | |
tree | 032ca464485a74b7e3b1e0e52d905fdaf6d69f6e /tools/common/repositorygen.cpp | |
parent | 5ba980c17e07ee6078a5b419642bf7f0599a1e24 (diff) |
let repogen validate install scripts
Change-Id: I4d08e4c33c3d967d4cf45ef5cdb5f3c3e066cf67
Reviewed-by: Niels Weber <niels.2.weber@nokia.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@nokia.com>
Diffstat (limited to 'tools/common/repositorygen.cpp')
-rw-r--r-- | tools/common/repositorygen.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index cd5996b76..68fe09b28 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -35,12 +35,15 @@ #include <errors.h> #include <lib7z_facade.h> #include <settings.h> +#include <qinstallerglobal.h> #include <kdupdater.h> #include <QtCore/QCryptographicHash> #include <QtCore/QDirIterator> +#include <QtScript/QScriptEngine> + #include <QtXml/QDomDocument> #include <iostream> @@ -240,13 +243,20 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt // copy scripts const QString script = package.firstChildElement(QLatin1String("Script")).text(); if (!script.isEmpty()) { + const QString fromLocation(QString::fromLatin1("%1/meta/%2").arg(it->directory, script)); - QFile scriptFile(script); QString scriptContent; + QFile scriptFile(fromLocation); if (scriptFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&scriptFile); scriptContent = in.readAll(); } + static QScriptEngine testScriptEngine; + testScriptEngine.evaluate(scriptContent, scriptFile.fileName()); + if (testScriptEngine.hasUncaughtException()) { + throw QInstaller::Error(QObject::tr("Exception while loading the component script: %1") + .arg(QInstaller::uncaughtExceptionString(&testScriptEngine, scriptFile.fileName()))); + } // added the xml tag RequiresAdminRights to the xml if somewhere addElevatedOperation is used if (scriptContent.contains(QLatin1String("addElevatedOperation"))) { @@ -256,9 +266,8 @@ void QInstallerTools::generateMetaDataDirectory(const QString &outDir, const QSt } qDebug() << "\tCopying associated script" << script << "into the meta package..."; - QString fromLocation(QString::fromLatin1("%1/meta/%2").arg(it->directory, script)); QString toLocation(QString::fromLatin1("%1/%2/%3").arg(metapath, it->name, script)); - if (!QFile::copy(fromLocation, toLocation)) { + if (!scriptFile.copy(toLocation)) { qDebug() << "failed!"; throw QInstaller::Error(QObject::tr("Could not copy the script %1 to its target location %2.") .arg(fromLocation, toLocation)); |