2011-02-21 16:30:31 +01:00
|
|
|
/**************************************************************************
|
|
|
|
**
|
2011-11-28 17:03:44 +01:00
|
|
|
** This file is part of Installer Framework
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2012-01-31 12:45:40 +01:00
|
|
|
** Copyright (c) 2010-2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2012-02-06 11:30:37 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
**
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-11-28 17:03:44 +01:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** Other Usage
|
|
|
|
**
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
2011-11-28 17:03:44 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2012-02-06 11:30:37 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2011-02-21 16:30:31 +01:00
|
|
|
**
|
|
|
|
**************************************************************************/
|
2012-02-06 09:25:41 +01:00
|
|
|
|
2011-09-30 12:17:38 +02:00
|
|
|
#include "installerbase_p.h"
|
|
|
|
|
2011-03-03 16:03:57 +01:00
|
|
|
#include "installerbasecommons.h"
|
|
|
|
#include "tabcontroller.h"
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-09-30 12:17:38 +02:00
|
|
|
#include <common/binaryformat.h>
|
|
|
|
#include <common/errors.h>
|
|
|
|
#include <common/fileutils.h>
|
|
|
|
#include <common/utils.h>
|
|
|
|
#include <fsengineserver.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <lib7z_facade.h>
|
|
|
|
#include <operationrunner.h>
|
2011-06-15 12:39:03 +02:00
|
|
|
#include <packagemanagercore.h>
|
2011-09-30 12:17:38 +02:00
|
|
|
#include <packagemanagergui.h>
|
|
|
|
#include <qinstallerglobal.h>
|
2011-06-20 22:00:34 +02:00
|
|
|
#include <settings.h>
|
2011-09-30 12:17:38 +02:00
|
|
|
#include <updater.h>
|
2011-03-10 15:50:33 +01:00
|
|
|
|
2011-11-19 00:00:52 +01:00
|
|
|
#include <kdselfrestarter.h>
|
|
|
|
#include <kdrunoncechecker.h>
|
2011-11-25 14:35:32 +01:00
|
|
|
#include "kdupdaterfiledownloaderfactory.h"
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-09-30 12:17:38 +02:00
|
|
|
#include <QtCore/QTranslator>
|
2012-01-06 17:17:58 +01:00
|
|
|
#include <QtGui/QMessageBox>
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
#include <QtNetwork/QNetworkProxyFactory>
|
|
|
|
|
2011-11-23 15:26:28 +01:00
|
|
|
#include <iostream>
|
2011-12-09 14:38:47 +01:00
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include <string>
|
2011-11-23 15:26:28 +01:00
|
|
|
|
2011-09-30 12:24:57 +02:00
|
|
|
#define QUOTE_(x) #x
|
|
|
|
#define QUOTE(x) QUOTE_(x)
|
|
|
|
#define VERSION "Installerbase SHA1: \"" QUOTE(_GIT_SHA1_) "\" , Build date: " QUOTE(__DATE__) "."
|
2011-07-04 22:47:25 +02:00
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
using namespace QInstaller;
|
|
|
|
using namespace QInstallerCreator;
|
|
|
|
|
2011-11-15 12:37:01 +01:00
|
|
|
static QSet<Repository> repositories(const QStringList &arguments, const int index)
|
2011-05-10 11:53:36 +02:00
|
|
|
{
|
2011-11-15 12:37:01 +01:00
|
|
|
QSet<Repository> set;
|
2011-05-10 11:53:36 +02:00
|
|
|
if (index < arguments.size()) {
|
|
|
|
QStringList items = arguments.at(index).split(QLatin1Char(','));
|
2011-05-10 11:54:17 +02:00
|
|
|
foreach (const QString &item, items) {
|
2011-11-15 12:37:01 +01:00
|
|
|
set.insert(Repository(item, false));
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << "Adding custom repository:" << item;
|
2011-05-10 11:53:36 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
std::cerr << "No repository specified" << std::endl;
|
|
|
|
}
|
2011-11-15 12:37:01 +01:00
|
|
|
return set;
|
2011-05-10 11:53:36 +02:00
|
|
|
}
|
|
|
|
|
2012-01-06 17:17:58 +01:00
|
|
|
static bool allowMaintenanceTool()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Settings m_settings = Settings(Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
|
|
|
|
QLatin1String(":/metadata/installer-config/")));
|
|
|
|
|
|
|
|
if (m_settings.value(QLatin1String("AllowExecuteMaintenanceTool"), QLatin1String("true")).toString().toLower()
|
|
|
|
== QLatin1String("true"))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} catch (const Error &e) {
|
|
|
|
qWarning("Could not parse Config: %s", qPrintable(e.message()));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2011-11-22 17:52:59 +01:00
|
|
|
|
|
|
|
// -- main
|
2011-11-21 17:32:29 +01:00
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-12-15 13:28:30 +01:00
|
|
|
QStringList args = QInstaller::parseCommandLineArgs(argc, argv);
|
|
|
|
|
2011-12-09 14:38:47 +01:00
|
|
|
// hack to use cleanlooks if it is under Ubuntu 11.10
|
|
|
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
|
|
|
std::string standardString;
|
|
|
|
std::string cleanLooks ="-style=cleanlooks";
|
|
|
|
std::ifstream input("/etc/lsb-release");
|
|
|
|
bool isUbuntu = false;
|
|
|
|
bool is11_10 = false;
|
|
|
|
while (std::getline(input, standardString)) {
|
|
|
|
if (standardString == "DISTRIB_ID=Ubuntu")
|
|
|
|
isUbuntu = true;
|
|
|
|
else if (standardString == "DISTRIB_RELEASE=11.10")
|
|
|
|
is11_10 = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isUbuntu && is11_10) {
|
|
|
|
argc++;
|
2011-12-13 10:38:02 +01:00
|
|
|
char **newArgv = new char* [argc];
|
|
|
|
newArgv[0] = argv[0];
|
|
|
|
newArgv[1] = const_cast<char*>(cleanLooks.data());
|
|
|
|
for (int i = 1; i < argc-1; ++i) {
|
|
|
|
newArgv[i+1] = argv[i];
|
|
|
|
}
|
2011-12-09 14:38:47 +01:00
|
|
|
argv = newArgv;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
|
|
|
const KDSelfRestarter restarter(argc, argv);
|
|
|
|
KDRunOnceChecker runCheck(QLatin1String("lockmyApp1234865.lock"));
|
|
|
|
|
|
|
|
try {
|
2011-09-30 12:24:57 +02:00
|
|
|
if (args.contains(QLatin1String("--version"))) {
|
2011-11-22 17:52:59 +01:00
|
|
|
InstallerBase::showVersion(QLatin1String(VERSION));
|
2011-09-30 12:24:57 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-18 13:24:28 +02:00
|
|
|
// this is the FSEngineServer as an admin rights process upon request:
|
|
|
|
if (args.count() >= 3 && args[1] == QLatin1String("--startserver")) {
|
2011-07-29 16:10:54 +02:00
|
|
|
MyCoreApplication app(argc, argv);
|
2011-05-18 13:24:28 +02:00
|
|
|
FSEngineServer* const server = new FSEngineServer(args[2].toInt());
|
|
|
|
if (args.count() >= 4)
|
|
|
|
server->setAuthorizationKey(args[3]);
|
|
|
|
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()));
|
|
|
|
return app.exec();
|
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-05-18 13:24:28 +02:00
|
|
|
// Make sure we honor the system's proxy settings
|
|
|
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
|
|
|
QUrl proxyUrl(QString::fromLatin1(qgetenv("http_proxy")));
|
|
|
|
if (proxyUrl.isValid()) {
|
2011-05-18 13:31:39 +02:00
|
|
|
QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(),
|
|
|
|
proxyUrl.userName(), proxyUrl.password());
|
2011-05-18 13:24:28 +02:00
|
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (args.contains(QLatin1String("--proxy")))
|
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
|
|
|
#endif
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-05-18 13:24:28 +02:00
|
|
|
if (args.contains(QLatin1String("--checkupdates"))) {
|
2011-07-29 16:10:54 +02:00
|
|
|
MyCoreApplication app(argc, argv);
|
2011-05-18 13:24:28 +02:00
|
|
|
if (runCheck.isRunning(KDRunOnceChecker::ProcessList))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Updater u;
|
2012-02-22 15:09:55 +01:00
|
|
|
u.setVerbose(args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v")));
|
2011-05-18 13:31:39 +02:00
|
|
|
return u.checkForUpdates() ? 0 : 1;
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
|
2011-09-14 17:41:54 +02:00
|
|
|
if (args.contains(QLatin1String("--runoperation"))
|
2011-09-06 16:12:18 +02:00
|
|
|
|| args.contains(QLatin1String("--undooperation"))) {
|
2011-09-14 16:03:28 +02:00
|
|
|
MyCoreApplication app(argc, argv);
|
2011-09-06 16:12:18 +02:00
|
|
|
OperationRunner o;
|
2012-02-22 15:09:55 +01:00
|
|
|
o.setVerbose(args.contains(QLatin1String("--verbose"))
|
|
|
|
|| args.contains(QLatin1String("-v")));
|
2011-09-06 16:12:18 +02:00
|
|
|
return o.runOperation(args);
|
|
|
|
}
|
|
|
|
|
2011-10-04 12:46:04 +02:00
|
|
|
if (args.contains(QLatin1String("--update-installerbase"))) {
|
|
|
|
MyCoreApplication app(argc, argv);
|
|
|
|
if (runCheck.isRunning(KDRunOnceChecker::ProcessList))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return InstallerBase().replaceMaintenanceToolBinary(args);
|
|
|
|
}
|
|
|
|
|
2011-05-18 21:26:21 +02:00
|
|
|
// from here, the "normal" installer binary is running
|
2011-07-29 16:10:54 +02:00
|
|
|
MyApplication app(argc, argv);
|
2011-11-25 16:05:08 +01:00
|
|
|
args = app.arguments();
|
2011-05-18 21:26:21 +02:00
|
|
|
|
2011-02-21 16:30:31 +01:00
|
|
|
if (runCheck.isRunning(KDRunOnceChecker::ProcessList)) {
|
|
|
|
if (runCheck.isRunning(KDRunOnceChecker::Lockfile))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (runCheck.isRunning(KDRunOnceChecker::ProcessList))
|
|
|
|
Sleep::sleep(1);
|
|
|
|
}
|
|
|
|
|
2012-02-22 15:09:55 +01:00
|
|
|
if (args.contains(QLatin1String("--verbose")) || args.contains(QLatin1String("-v"))) {
|
2011-11-22 17:52:59 +01:00
|
|
|
app.setVerbose();
|
2011-02-21 16:30:31 +01:00
|
|
|
QInstaller::setVerbose(true);
|
2011-11-22 17:52:59 +01:00
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
// install the default translator
|
|
|
|
const QString localeFile =
|
|
|
|
QString::fromLatin1(":/translations/qt_%1").arg(QLocale::system().name());
|
|
|
|
{
|
|
|
|
QTranslator* const translator = new QTranslator(&app);
|
|
|
|
translator->load(localeFile);
|
|
|
|
app.installTranslator(translator);
|
|
|
|
}
|
|
|
|
|
|
|
|
// install "our" default translator
|
|
|
|
const QString ourLocaleFile =
|
|
|
|
QString::fromLatin1(":/translations/%1.qm").arg(QLocale().name().toLower());
|
2011-11-25 14:09:06 +01:00
|
|
|
if (QFile::exists(ourLocaleFile)) {
|
2011-02-21 16:30:31 +01:00
|
|
|
QTranslator* const translator = new QTranslator(&app);
|
|
|
|
translator->load(ourLocaleFile);
|
|
|
|
app.installTranslator(translator);
|
|
|
|
}
|
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
if (QInstaller::isVerbose()) {
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << VERSION;
|
|
|
|
qDebug() << "Arguments:" << args;
|
2012-02-07 13:15:13 +01:00
|
|
|
qDebug() << "Language: " << QLocale().name().toLower();
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << "Resource tree before loading the in-binary resource:";
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
QDir dir(QLatin1String(":/"));
|
|
|
|
foreach (const QString &i, dir.entryList()) {
|
|
|
|
const QByteArray ba = i.toUtf8();
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug().nospace() << " :/" << ba.constData();
|
2011-03-04 15:51:23 +01:00
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// register custom operations before reading the binary content cause they may used in
|
2011-03-04 15:51:23 +01:00
|
|
|
// the uninstaller for the recorded list of during the installation performed operations
|
2011-02-21 16:30:31 +01:00
|
|
|
QInstaller::init();
|
|
|
|
|
2012-02-27 17:05:10 +01:00
|
|
|
// load and map the embedded binary resource, registers operations
|
|
|
|
BinaryContent content = BinaryContent::readAndRegisterFromApplicationFile();
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
// instantiate the installer we are actually going to use
|
2012-02-27 14:16:52 +01:00
|
|
|
QInstaller::PackageManagerCore core(content.magicMarker(), content.performedOperations());
|
2012-02-27 17:06:13 +01:00
|
|
|
Settings m_settings =
|
|
|
|
Settings(Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
|
2012-01-06 17:17:58 +01:00
|
|
|
QLatin1String(":/metadata/installer-config/")));
|
|
|
|
|
2012-02-27 17:06:13 +01:00
|
|
|
// check execution rights for the maintenance tool
|
2012-01-06 17:17:58 +01:00
|
|
|
if (!core.isInstaller() && !allowMaintenanceTool() && !args.contains(QLatin1String("--script"))) {
|
|
|
|
QString reason = m_settings.value(QLatin1String("DisallowExecuteReason"),
|
|
|
|
QString::fromLatin1("You are not allowed to run %1.").arg(qAppName())).toString();
|
|
|
|
QMessageBox::information(0, QLatin1String("Update notification"), reason);
|
|
|
|
return 0;
|
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
if (QInstaller::isVerbose()) {
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << "Resource tree after loading the in-binary resource:";
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
QDir dir = QDir(QLatin1String(":/"));
|
|
|
|
foreach (const QString &i, dir.entryList())
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << QString::fromLatin1(" :/%1").arg(i);
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-03-04 15:51:23 +01:00
|
|
|
dir = QDir(QLatin1String(":/metadata/"));
|
|
|
|
foreach (const QString &i, dir.entryList())
|
2012-01-16 23:42:54 +01:00
|
|
|
qDebug() << QString::fromLatin1(" :/metadata/%1").arg(i);
|
2011-03-04 15:51:23 +01:00
|
|
|
}
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
QString controlScript;
|
|
|
|
QHash<QString, QString> params;
|
|
|
|
for (int i = 1; i < args.size(); ++i) {
|
|
|
|
const QString &argument = args.at(i);
|
|
|
|
if (argument.isEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (argument.contains(QLatin1Char('='))) {
|
|
|
|
const QString name = argument.section(QLatin1Char('='), 0, 0);
|
|
|
|
const QString value = argument.section(QLatin1Char('='), 1, 1);
|
|
|
|
params.insert(name, value);
|
2011-06-14 16:24:50 +02:00
|
|
|
core.setValue(name, value);
|
2011-02-21 16:30:31 +01:00
|
|
|
} else if (argument == QLatin1String("--script") || argument == QLatin1String("Script")) {
|
|
|
|
++i;
|
|
|
|
if (i < args.size()) {
|
|
|
|
controlScript = args.at(i);
|
|
|
|
if (!QFileInfo(controlScript).exists())
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
} else {
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
2012-02-22 15:09:55 +01:00
|
|
|
} else if (argument == QLatin1String("--verbose") || argument == QLatin1String("-v")) {
|
2011-06-14 16:24:50 +02:00
|
|
|
core.setVerbose(true);
|
2011-02-21 16:30:31 +01:00
|
|
|
} else if (argument == QLatin1String("--proxy")) {
|
2011-11-25 14:35:32 +01:00
|
|
|
core.settings().setProxyType(QInstaller::Settings::SystemProxy);
|
|
|
|
KDUpdater::FileDownloaderFactory::instance().setProxyFactory(core.proxyFactory());
|
2011-02-21 16:30:31 +01:00
|
|
|
} else if (argument == QLatin1String("--show-virtual-components")
|
|
|
|
|| argument == QLatin1String("ShowVirtualComponents")) {
|
|
|
|
QFont f;
|
|
|
|
f.setItalic(true);
|
2011-06-14 16:24:50 +02:00
|
|
|
PackageManagerCore::setVirtualComponentsFont(f);
|
|
|
|
PackageManagerCore::setVirtualComponentsVisible(true);
|
2011-03-03 16:03:57 +01:00
|
|
|
} else if ((argument == QLatin1String("--updater")
|
2011-06-14 16:24:50 +02:00
|
|
|
|| argument == QLatin1String("Updater")) && core.isUninstaller()) {
|
|
|
|
core.setUpdater();
|
2011-03-03 16:03:57 +01:00
|
|
|
} else if ((argument == QLatin1String("--manage-packages")
|
2011-06-14 16:24:50 +02:00
|
|
|
|| argument == QLatin1String("ManagePackages")) && core.isUninstaller()) {
|
|
|
|
core.setPackageManager();
|
2011-02-21 16:30:31 +01:00
|
|
|
} else if (argument == QLatin1String("--help") || argument == QLatin1String("-h")) {
|
2011-11-22 17:52:59 +01:00
|
|
|
InstallerBase::showUsage();
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Success;
|
2011-02-21 16:30:31 +01:00
|
|
|
} else if (argument == QLatin1String("--addTempRepository")
|
|
|
|
|| argument == QLatin1String("--setTempRepository")) {
|
|
|
|
++i;
|
2011-11-15 12:37:01 +01:00
|
|
|
QSet<Repository> repoList = repositories(args, i);
|
2011-05-10 11:53:36 +02:00
|
|
|
if (repoList.isEmpty())
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
// We cannot use setRemoteRepositories as that is a synchronous call which "
|
|
|
|
// tries to get the data from server and this isn't what we want at this point
|
|
|
|
const bool replace = (argument == QLatin1String("--setTempRepository"));
|
2011-06-14 16:24:50 +02:00
|
|
|
core.setTemporaryRepositories(repoList, replace);
|
2011-05-10 11:53:36 +02:00
|
|
|
} else if (argument == QLatin1String("--addRepository")) {
|
|
|
|
++i;
|
2011-11-15 12:37:01 +01:00
|
|
|
QSet<Repository> repoList = repositories(args, i);
|
2011-05-10 11:53:36 +02:00
|
|
|
if (repoList.isEmpty())
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-11-15 12:37:01 +01:00
|
|
|
core.addUserRepositories(repoList);
|
2011-03-15 20:19:14 +01:00
|
|
|
} else if (argument == QLatin1String("--no-force-installations")) {
|
2011-06-14 16:24:50 +02:00
|
|
|
PackageManagerCore::setNoForceInstallation(true);
|
2011-02-21 16:30:31 +01:00
|
|
|
} else {
|
2011-11-17 12:46:41 +01:00
|
|
|
std::cerr << "Unknown option: " << argument << std::endl;
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the wizard gui
|
|
|
|
TabController controller(0);
|
2011-06-14 16:24:50 +02:00
|
|
|
controller.setManager(&core);
|
|
|
|
controller.setManagerParams(params);
|
2011-02-21 16:30:31 +01:00
|
|
|
controller.setControlScript(controlScript);
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
if (core.isInstaller()) {
|
|
|
|
controller.setGui(new InstallerGui(&core));
|
2011-02-21 16:30:31 +01:00
|
|
|
} else {
|
2011-06-14 16:24:50 +02:00
|
|
|
controller.setGui(new MaintenanceGui(&core));
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
PackageManagerCore::Status status = PackageManagerCore::Status(controller.init());
|
|
|
|
if (status != PackageManagerCore::Success)
|
2011-03-14 17:42:15 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
const int result = app.exec();
|
|
|
|
if (result != 0)
|
|
|
|
return result;
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
if (core.finishedWithSuccess())
|
|
|
|
return PackageManagerCore::Success;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
status = core.status();
|
2011-02-21 16:30:31 +01:00
|
|
|
switch (status) {
|
2011-06-14 16:24:50 +02:00
|
|
|
case PackageManagerCore::Success:
|
2011-03-10 15:50:33 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
case PackageManagerCore::Canceled:
|
2011-03-10 15:50:33 +01:00
|
|
|
return status;
|
2011-02-21 16:30:31 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
} catch(const Error &e) {
|
|
|
|
std::cerr << qPrintable(e.message()) << std::endl;
|
|
|
|
} catch (const std::exception &e) {
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
} catch(...) {
|
|
|
|
std::cerr << "Unknown error, aborting." << std::endl;
|
|
|
|
}
|
|
|
|
|
2011-06-14 16:24:50 +02:00
|
|
|
return PackageManagerCore::Failure;
|
2011-02-21 16:30:31 +01:00
|
|
|
}
|