diff options
68 files changed, 430 insertions, 2580 deletions
@@ -53,13 +53,13 @@ Adjust the qmake.conf to have a real stand alone working installer: Recommended configure options for Microsoft Windows: -configure.exe -opensource -release -static -no-multimedia -no-declarative -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -nomake examples -nomake demos +configure.exe -opensource -release -static -accessibility -no-multimedia -no-declarative -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -nomake examples -nomake demos ### Linux & Mac OS X Recommended configure options for Linux and Mac OS X: -configure -opensource -release -static -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -no-svg -nomake examples -nomake demos +configure -opensource -release -static -accessibility -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -no-svg -nomake examples -nomake demos Build the Framework diff --git a/doc/installerfw-getting-started.qdoc b/doc/installerfw-getting-started.qdoc index 1b21ac664..67dd4de14 100644 --- a/doc/installerfw-getting-started.qdoc +++ b/doc/installerfw-getting-started.qdoc @@ -81,7 +81,7 @@ Windows: \code - configure.exe -opensource -release -static -no-multimedia -no-declarative -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -nomake examples -nomake demos + configure.exe -opensource -release -static -accessibility -no-multimedia -no-declarative -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -nomake examples -nomake demos \endcode \section2 Configuring Qt for Linux and Mac OS X @@ -90,7 +90,7 @@ Mac OS X: \code - configure -opensource -release -static -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -no-svg -nomake examples -nomake demos + configure -opensource -release -static -accessibility -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-phonon -no-dbus -no-opengl -no-qt3support -no-webkit -no-xmlpatterns -no-svg -nomake examples -nomake demos \endcode \section1 Setting up Qt Installer Framework diff --git a/doc/scripting.qdoc b/doc/scripting.qdoc index 38fced90e..71ae92891 100644 --- a/doc/scripting.qdoc +++ b/doc/scripting.qdoc @@ -252,6 +252,10 @@ \row \o HomeDir \o Home directory of the current user. + \row + \o ApplicationsDir + \o Applications directory. For example, \c {C:\Program Files} on Windows, + \c {/opt} on Linux and \c {/Applications} on Mac OS X. \endtable The variables can be resolved by calls to \c installer.value(). If embedded @@ -263,5 +267,4 @@ component.addOperation("CreateShortcut", "@TargetDir@/MyApp.exe", "@StartMenuDir@/MyApp.lnk"); } \endcode - */ diff --git a/examples/componenterror/README b/examples/componenterror/README new file mode 100644 index 000000000..27fd4b3a4 --- /dev/null +++ b/examples/componenterror/README @@ -0,0 +1,5 @@ +Create an installer that shows how to react on errors set from a component. + +Generate installer with + +binarycreator --offline-only -c config/config.xml -p packages installer diff --git a/examples/componenterror/config/config.xml b/examples/componenterror/config/config.xml new file mode 100644 index 000000000..e9d6a9dd5 --- /dev/null +++ b/examples/componenterror/config/config.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Installer> + <Name>Component Error Installer Example</Name> + <Version>1.0.0</Version> + <Title>Component Error Installer Example</Title> + <Publisher>Qt-Project</Publisher> + <StartMenuDir>Qt Installer Framework Example</StartMenuDir> + <TargetDir>@HomeDir@/IFWComponentErrorInstallerExample</TargetDir> +</Installer> diff --git a/src/libs/installer/setpathonqtcoreoperation.h b/examples/componenterror/packages/root.component1/meta/installscript.js index 1b63c7ede..6d76437b2 100644 --- a/src/libs/installer/setpathonqtcoreoperation.h +++ b/examples/componenterror/packages/root.component1/meta/installscript.js @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,25 +39,12 @@ ** **************************************************************************/ -#ifndef SETPATHONQTCOREOPERATION_H -#define SETPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetPathOnQtCoreOperation : public Operation +function Component() { -public: - SetPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETPATHONQTCOREOPERATION_H + var error = true; + if (error) { + installer.setValue("component_errors", installer.value("component_errors") + ";;;" + + "error from component: " + component.name); + } + installer.setValue("ComponentError", true); +} diff --git a/examples/componenterror/packages/root.component1/meta/package.xml b/examples/componenterror/packages/root.component1/meta/package.xml new file mode 100644 index 000000000..eac36530b --- /dev/null +++ b/examples/componenterror/packages/root.component1/meta/package.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Package> + <DisplayName>component1</DisplayName> + <Version>1.0.1</Version> + <ReleaseDate>2013-08-21</ReleaseDate> + <Script>installscript.js</Script> +</Package> diff --git a/src/libs/installer/setdemospathonqtoperation.h b/examples/componenterror/packages/root.component2/meta/installscript.js index 27d25c9f9..6d76437b2 100644 --- a/src/libs/installer/setdemospathonqtoperation.h +++ b/examples/componenterror/packages/root.component2/meta/installscript.js @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,25 +39,12 @@ ** **************************************************************************/ -#ifndef SETDEMOSPATHONQTOPERATION_H -#define SETDEMOSPATHONQTOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetDemosPathOnQtOperation : public Operation +function Component() { -public: - SetDemosPathOnQtOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETDEMOSPATHONQTOPERATION_H + var error = true; + if (error) { + installer.setValue("component_errors", installer.value("component_errors") + ";;;" + + "error from component: " + component.name); + } + installer.setValue("ComponentError", true); +} diff --git a/examples/componenterror/packages/root.component2/meta/package.xml b/examples/componenterror/packages/root.component2/meta/package.xml new file mode 100644 index 000000000..4caad7ad6 --- /dev/null +++ b/examples/componenterror/packages/root.component2/meta/package.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Package> + <DisplayName>component2</DisplayName> + <Version>1.0.1</Version> + <ReleaseDate>2013-08-21</ReleaseDate> + <Script>installscript.js</Script> +</Package> diff --git a/src/libs/installer/qtcreatorpersistentsettings.h b/examples/componenterror/packages/root/meta/installscript.js index 4e299475a..7ddf7dab5 100644 --- a/src/libs/installer/qtcreatorpersistentsettings.h +++ b/examples/componenterror/packages/root/meta/installscript.js @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the Qt Installer Framework. @@ -39,50 +39,38 @@ ** **************************************************************************/ -#ifndef QTCREATORPERSISTENTSETTINGS_H -#define QTCREATORPERSISTENTSETTINGS_H +function abortInstaller() +{ + installer.setDefaultPageVisible(QInstaller.Introduction, false); + installer.setDefaultPageVisible(QInstaller.TargetDirectory, false); + installer.setDefaultPageVisible(QInstaller.ComponentSelection, false); + installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false); + installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false); + installer.setDefaultPageVisible(QInstaller.PerformInstallation, false); + installer.setDefaultPageVisible(QInstaller.LicenseCheck, false); -#include "persistentsettings.h" + var abortText = "<font color='red' size=6>" + qsTr("The installation has failed.") + "</font>"; -#include <QHash> -#include <QString> -#include <QVariantMap> + var error_list = installer.value("component_errors").split(";;;"); + abortText += "<ul>"; + // ignore the first empty one + for (var i = 0; i < error_list.length; ++i) { + if (error_list[i] !== "") { + print(error_list[i]); + abortText += "<li>" + error_list[i] + "</li>" + } + } + abortText += "</ul>"; + installer.setValue("FinishedText", abortText); +} -struct QtCreatorToolChain +function reactOnAbortInstallerChange() { - QString key; - QString type; - QString displayName; - QString abiString; - QString compilerPath; - QString debuggerPath; - QString armVersion; - QString force32Bit; -}; + if (installer.value("ComponentError") === "true") + abortInstaller(); +} -class QtCreatorPersistentSettings +function Component() { -public: - QtCreatorPersistentSettings(); - bool init(const QString &fileName); - bool addToolChain(const QtCreatorToolChain &toolChain); - bool removeToolChain(const QtCreatorToolChain &toolChain); - void addDefaultDebugger(const QString &abiString, const QString &debuggerPath); - void removeDefaultDebugger(const QString &abiString); - bool save(); - QHash<QString, QString> abiToDebuggerHash(); - -private: - QHash<QString, QVariantMap> readValidToolChains(); - QHash<QString, QString> readAbiToDebuggerHash(); - bool versionCheck(); - - QString m_fileName; - QHash<QString, QVariantMap> m_toolChains; - QHash<QString, QString> m_abiToDebuggerHash; - ProjectExplorer::PersistentSettingsReader m_reader; - ProjectExplorer::PersistentSettingsWriter m_writer; - -}; - -#endif // QTCREATORPERSISTENTSETTINGS_H + installer.finishAllComponentsReset.connect(reactOnAbortInstallerChange); +} diff --git a/examples/componenterror/packages/root/meta/package.xml b/examples/componenterror/packages/root/meta/package.xml new file mode 100644 index 000000000..ce9b55537 --- /dev/null +++ b/examples/componenterror/packages/root/meta/package.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Package> + <DisplayName>ROOT</DisplayName> + <Version>1.0.1</Version> + <ReleaseDate>2013-08-21</ReleaseDate> + <Script>installscript.js</Script> +</Package> diff --git a/installerfw.pri b/installerfw.pri index 0271433cd..83196c4bd 100644 --- a/installerfw.pri +++ b/installerfw.pri @@ -3,7 +3,7 @@ } IFW_PRI_INCLUDED = 1 -IFW_VERSION = 1.4.1 +IFW_VERSION = 1.5.0 IFW_REPOSITORY_FORMAT_VERSION = 1.0.0 @@ -87,14 +87,14 @@ macx:LIBS += -framework Carbon -framework Security isEqual(QT_MAJOR_VERSION, 4) { CONFIG += uitools CONFIG(static, static|shared) { - QTPLUGIN += qico + QTPLUGIN += qico qtaccessiblewidgets DEFINES += QT_STATIC QT += script network xml } } else { QT += uitools core-private CONFIG(static, static|shared) { - QTPLUGIN += qico + QTPLUGIN += qico qtaccessiblewidgets QT += concurrent network script xml } } diff --git a/src/libs/installer/addqtcreatorarrayvalueoperation.cpp b/src/libs/installer/addqtcreatorarrayvalueoperation.cpp index 7da24febe..23d160a9a 100644 --- a/src/libs/installer/addqtcreatorarrayvalueoperation.cpp +++ b/src/libs/installer/addqtcreatorarrayvalueoperation.cpp @@ -103,7 +103,7 @@ bool AddQtCreatorArrayValueOperation::performOperation() int arraySize = settings.beginReadArray(arrayName); for (int i = 0; i < arraySize; ++i) { settings.setArrayIndex(i); - //if it is already there we have nothing todo + //if it is already there we have nothing to do if (settings.value(key).toString() == value) return true; oldArrayValues.append(settings.value(key).toString()); @@ -121,7 +121,7 @@ bool AddQtCreatorArrayValueOperation::performOperation() settings.setValue(key, value); settings.endArray(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) setValue(QLatin1String("ArrayValueSet"), true); return true; } @@ -178,7 +178,7 @@ bool AddQtCreatorArrayValueOperation::undoOperation() } settings.endArray(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) return true; } diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 4fb390040..b7c4dfe3b 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -936,8 +936,9 @@ void Component::addOperation(Operation *operation) void Component::addElevatedOperation(Operation *operation) { if (value(scRequiresAdminRights, scFalse) != scTrue) { - qWarning() << QString::fromLatin1("component %1 uses addElevatedOperation in the script, but it doesn't" - "have the needed RequiresAdminRights tag").arg(name()); + qWarning() << QString::fromLatin1("Component %1 uses addElevatedOperation in the script, " + "but it does not have the needed RequiresAdminRights tag" + ).arg(name()); } addOperation(operation); operation->setValue(QLatin1String("admin"), true); @@ -1203,7 +1204,7 @@ bool Component::isAutoDependOn(const QSet<QString> &componentsToInstall) const QLatin1String("isAutoDependOn")); } catch (const Error &error) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("isAutoDependOnError"), tr("Can't resolve isAutoDependOn in %1" + QLatin1String("isAutoDependOnError"), tr("Cannot resolve isAutoDependOn in %1" ).arg(name()), error.message()); return false; } @@ -1253,7 +1254,7 @@ bool Component::isDefault() const QLatin1String("isDefault")); } catch (const Error &error) { MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("isDefaultError"), tr("Can't resolve isDefault in %1").arg(name()), + QLatin1String("isDefaultError"), tr("Cannot resolve isDefault in %1").arg(name()), error.message()); return false; } diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index 2d3bc1ec0..04d7c9a8c 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -134,7 +134,7 @@ bool ConsumeOutputOperation::performOperation() } if (executableOutput.isEmpty()) { - qWarning() << QString::fromLatin1("Can't get any query output from executable: '%1'").arg( + qWarning() << QString::fromLatin1("Cannot get any query output from executable: '%1'").arg( executable.absoluteFilePath()); } core->setValue(installerKeyName, QString::fromLatin1(executableOutput)); diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index 9f9084e05..963f0aaf8 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -250,7 +250,7 @@ bool CreateShortcutOperation::undoOperation() { const QString &linkLocation = arguments().at(1); if (!deleteFileNowOrLater(linkLocation) ) - qDebug() << "Can't delete:" << linkLocation; + qDebug() << "Cannot delete:" << linkLocation; QDir dir; // remove all directories we created const QStringList directoriesToDelete = value(QLatin1String("createddirs")).toStringList(); diff --git a/src/libs/installer/environmentvariablesoperation.cpp b/src/libs/installer/environmentvariablesoperation.cpp index 192272a8d..36b5d6273 100644 --- a/src/libs/installer/environmentvariablesoperation.cpp +++ b/src/libs/installer/environmentvariablesoperation.cpp @@ -67,19 +67,15 @@ void EnvironmentVariableOperation::backup() } #ifdef Q_OS_WIN -static bool broadcastChange() { +static void broadcastEnvironmentChange() +{ // Use SendMessageTimeout to Broadcast a message to the whole system to update settings of all // running applications. This is needed to activate the changes done above without logout+login. - // Note that cmd.exe does not respond to any WM_SETTINGCHANGE messages... - DWORD aResult = 0; - LRESULT sendresult = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, - 0, (LPARAM) "Environment", SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &aResult); - if (sendresult == 0 || aResult != 0) { - qWarning("Failed to broadcast a WM_SETTINGCHANGE message\n"); - return false; - } - - return true; + DWORD_PTR aResult = 0; + LRESULT sendresult = SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, + 0, (LPARAM) L"Environment", SMTO_BLOCK | SMTO_ABORTIFHUNG, 5000, &aResult); + if (sendresult == 0 || aResult != 0) + qWarning("Failed to broadcast the WM_SETTINGCHANGE message."); } #endif @@ -169,8 +165,9 @@ bool EnvironmentVariableOperation::performOperation() setErrorString(errorString); return false; } - const bool bret = broadcastChange(); - Q_UNUSED(bret); // this is not critical, so fall-through + + broadcastEnvironmentChange(); + setValue(QLatin1String("oldvalue"), oldvalue); return true; } diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 6f8c44622..c7c7436bb 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -49,6 +49,7 @@ #include <QtCore/QTemporaryFile> #include <QtCore/QThread> #include <QtCore/QUrl> +#include <QtCore/QCoreApplication> #include <QImageReader> #include <errno.h> @@ -141,9 +142,15 @@ QString QInstaller::humanReadableSize(const qint64 &size, int precision) double sizeAsDouble = size; static QStringList measures; if (measures.isEmpty()) - measures << QString::fromLatin1("bytes") << QString::fromLatin1("KiB") << QString::fromLatin1("MiB") - << QString::fromLatin1("GiB") << QString::fromLatin1("TiB") << QString::fromLatin1("PiB") - << QString::fromLatin1("EiB") << QString::fromLatin1("ZiB") << QString::fromLatin1("YiB"); + measures << QCoreApplication::translate("QInstaller", "bytes") + << QCoreApplication::translate("QInstaller", "KiB") + << QCoreApplication::translate("QInstaller", "MiB") + << QCoreApplication::translate("QInstaller", "GiB") + << QCoreApplication::translate("QInstaller", "TiB") + << QCoreApplication::translate("QInstaller", "PiB") + << QCoreApplication::translate("QInstaller", "EiB") + << QCoreApplication::translate("QInstaller", "ZiB") + << QCoreApplication::translate("QInstaller", "YiB"); QStringListIterator it(measures); QString measure(it.next()); diff --git a/src/libs/installer/fsengineclient.cpp b/src/libs/installer/fsengineclient.cpp index abc686fd9..2a7a8a5bd 100644 --- a/src/libs/installer/fsengineclient.cpp +++ b/src/libs/installer/fsengineclient.cpp @@ -797,8 +797,8 @@ void FSEngineClientHandler::Private::maybeStartServer() const QMessageBox::Button res = QInstaller::MessageBoxHandler::critical(QInstaller::MessageBoxHandler::currentBestSuitParent(), - QObject::tr("Authorization Error"), QObject::tr("Couldn't get authorization."), - QObject::tr("Couldn't get authorization that is needed for continuing the installation.\n" + QObject::tr("Authorization Error"), QObject::tr("Could not get authorization."), + QObject::tr("Could not get authorization that is needed for continuing the installation.\n" "Either abort the installation or use the fallback solution by running\n" "%1\nas root and then clicking ok.").arg(fallback), QMessageBox::Abort | QMessageBox::Ok, QMessageBox::Ok); diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp index a8a7f54d8..175ac98d5 100644 --- a/src/libs/installer/init.cpp +++ b/src/libs/installer/init.cpp @@ -63,16 +63,8 @@ // QtSDK specific #include "qtpatchoperation.h" #include "consumeoutputoperation.h" -#include "setdemospathonqtoperation.h" -#include "setexamplespathonqtoperation.h" -#include "setpluginpathonqtcoreoperation.h" -#include "setimportspathonqtcoreoperation.h" -#include "setpathonqtcoreoperation.h" -#include "registerqtincreatorqnxoperation.h" #include "setqtcreatorvalueoperation.h" #include "addqtcreatorarrayvalueoperation.h" -#include "registertoolchainoperation.h" -#include "registerdefaultdebuggeroperation.h" #ifdef Q_OS_MAC # include "macreplaceinstallnamesoperation.h" @@ -147,9 +139,12 @@ static void initResources() { Q_INIT_RESOURCE(patch_file_lists); Q_INIT_RESOURCE(installer); + // Qt5 or better qmake generates that automatically, so this is only needed on Qt4 # if QT_VERSION < 0x050000 Q_IMPORT_PLUGIN(qico) Q_UNUSED(qt_plugin_instance_qico()); + Q_IMPORT_PLUGIN(qtaccessiblewidgets) + Q_UNUSED(qt_plugin_instance_qtaccessiblewidgets()); # endif } #endif @@ -247,14 +242,6 @@ void QInstaller::init() factory.registerUpdateOperation<ConsumeOutputOperation>(QLatin1String("ConsumeOutput")); // QtSDK specific - factory.registerUpdateOperation<RegisterQtInCreatorQNXOperation>(QLatin1String("RegisterQtInCreatorQNX")); - factory.registerUpdateOperation<RegisterToolChainOperation>(QLatin1String("RegisterToolChain")); - factory.registerUpdateOperation<RegisterDefaultDebuggerOperation>(QLatin1String("RegisterDefaultDebugger")); - factory.registerUpdateOperation<SetDemosPathOnQtOperation>(QLatin1String("SetDemosPathOnQt")); - factory.registerUpdateOperation<SetExamplesPathOnQtOperation>(QLatin1String("SetExamplesPathOnQt")); - factory.registerUpdateOperation<SetPluginPathOnQtCoreOperation>(QLatin1String("SetPluginPathOnQtCore")); - factory.registerUpdateOperation<SetImportsPathOnQtCoreOperation>(QLatin1String("SetImportsPathOnQtCore")); - factory.registerUpdateOperation<SetPathOnQtCoreOperation>(QLatin1String("SetPathOnQtCore")); factory.registerUpdateOperation<SetQtCreatorValueOperation>(QLatin1String("SetQtCreatorValue")); factory.registerUpdateOperation<AddQtCreatorArrayValueOperation>(QLatin1String("AddQtCreatorArrayValue")); factory.registerUpdateOperation<QtPatchOperation>(QLatin1String("QtPatch")); diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index 653b65d6f..a1631c4a3 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -52,18 +52,10 @@ HEADERS += packagemanagercore.h \ componentmodel.h \ qinstallerglobal.h \ qtpatch.h \ - persistentsettings.h \ - projectexplorer_export.h \ qtpatchoperation.h \ consumeoutputoperation.h \ - setpathonqtcoreoperation.h \ - setdemospathonqtoperation.h \ - setexamplespathonqtoperation.h \ - setpluginpathonqtcoreoperation.h \ - setimportspathonqtcoreoperation.h \ replaceoperation.h \ linereplaceoperation.h \ - registertoolchainoperation.h \ setqtcreatorvalueoperation.h \ addqtcreatorarrayvalueoperation.h \ copydirectoryoperation.h \ @@ -98,8 +90,6 @@ HEADERS += packagemanagercore.h \ licenseoperation.h \ component_p.h \ qtcreator_constants.h \ - qtcreatorpersistentsettings.h \ - registerdefaultdebuggeroperation.h \ qprocesswrapper.h \ qsettingswrapper.h \ constants.h \ @@ -109,7 +99,6 @@ HEADERS += packagemanagercore.h \ link.h \ createlinkoperation.h \ packagemanagercoredata.h \ - registerqtincreatorqnxoperation.h \ applyproductkeyoperation.h \ globals.h \ graph.h @@ -128,17 +117,10 @@ HEADERS += packagemanagercore.h \ scriptengine.cpp \ componentmodel.cpp \ qtpatch.cpp \ - persistentsettings.cpp \ qtpatchoperation.cpp \ consumeoutputoperation.cpp \ - setpathonqtcoreoperation.cpp \ - setdemospathonqtoperation.cpp \ - setexamplespathonqtoperation.cpp \ - setpluginpathonqtcoreoperation.cpp \ - setimportspathonqtcoreoperation.cpp \ replaceoperation.cpp \ linereplaceoperation.cpp \ - registertoolchainoperation.cpp \ setqtcreatorvalueoperation.cpp \ addqtcreatorarrayvalueoperation.cpp \ copydirectoryoperation.cpp \ @@ -170,8 +152,6 @@ HEADERS += packagemanagercore.h \ getrepositoriesmetainfojob.cpp \ licenseoperation.cpp \ component_p.cpp \ - qtcreatorpersistentsettings.cpp \ - registerdefaultdebuggeroperation.cpp \ qprocesswrapper.cpp \ templates.cpp \ qsettingswrapper.cpp \ @@ -182,7 +162,6 @@ HEADERS += packagemanagercore.h \ link.cpp \ createlinkoperation.cpp \ packagemanagercoredata.cpp \ - registerqtincreatorqnxoperation.cpp \ applyproductkeyoperation.cpp \ globals.cpp diff --git a/src/libs/installer/macreplaceinstallnamesoperation.cpp b/src/libs/installer/macreplaceinstallnamesoperation.cpp index fa5e6139a..9ec553358 100644 --- a/src/libs/installer/macreplaceinstallnamesoperation.cpp +++ b/src/libs/installer/macreplaceinstallnamesoperation.cpp @@ -148,7 +148,7 @@ int MacReplaceInstallNamesOperation::updateExecutableInfo(MacBinaryInfo *binaryI QProcessWrapper otool; otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << binaryInfo->fileName); if (!otool.waitForStarted()) { - setError(UserDefinedError, tr("Can't invoke otool. Is Xcode installed?")); + setError(UserDefinedError, tr("Cannot invoke otool. Is Xcode installed?")); return -1; } otool.waitForFinished(); @@ -230,7 +230,7 @@ bool MacReplaceInstallNamesOperation::execCommand(const QString &cmd, const QStr QProcessWrapper process; process.start(cmd, args); if (!process.waitForStarted()) { - setError(UserDefinedError, tr("Can't start process %0.").arg(cmd)); + setError(UserDefinedError, tr("Cannot start process %0.").arg(cmd)); return false; } process.waitForFinished(); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index fc1ecff02..a7f5748d4 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -648,6 +648,19 @@ void PackageManagerCore::rollBackInstallation() const bool becameAdmin = !d->m_FSEngineClientHandler->isActive() && operation->value(QLatin1String("admin")).toBool() && gainAdminRights(); + if (operation->hasValue(QLatin1String("uninstall-only"))) { + // We know the mkdir operation which is creating the target path. If we do a + // full uninstall, prevent a forced remove of the full install path including the + // target , instead try to remove the target only and only if it is empty, + // otherwise fail silently. Note: we will ever experience this only -if- + // RemoveTargetDir is set, otherwise the operation does not exist at all. + const bool isMkDir = (operation->name() == QLatin1String("Mkdir")); + const bool removeTargetDir = QVariant(value(scRemoveTargetDir)).toBool(); + const bool uninstallOnly = operation->value(QLatin1String("uninstall-only")).toBool(); + if (isMkDir && uninstallOnly && removeTargetDir) + operation->setValue(QLatin1String("forceremoval"), false); + } + PackageManagerCorePrivate::performOperationThreaded(operation, PackageManagerCorePrivate::Undo); const QString componentName = operation->value(QLatin1String("component")).toString(); @@ -1681,15 +1694,23 @@ QString PackageManagerCore::findLibrary(const QString &name, const QStringList & #if defined(Q_OS_WIN) return findPath(QString::fromLatin1("%1.lib").arg(name), findPaths); #else +#if defined(Q_OS_MAC) if (findPaths.isEmpty()) { findPaths.push_back(QLatin1String("/lib")); findPaths.push_back(QLatin1String("/usr/lib")); findPaths.push_back(QLatin1String("/usr/local/lib")); findPaths.push_back(QLatin1String("/opt/local/lib")); } -#if defined(Q_OS_MAC) const QString dynamic = findPath(QString::fromLatin1("lib%1.dylib").arg(name), findPaths); #else + if (findPaths.isEmpty()) { + findPaths.push_back(QLatin1String("/lib")); + findPaths.push_back(QLatin1String("/usr/lib")); + findPaths.push_back(QLatin1String("/usr/local/lib")); + findPaths.push_back(QLatin1String("/lib64")); + findPaths.push_back(QLatin1String("/usr/lib64")); + findPaths.push_back(QLatin1String("/usr/local/lib64")); + } const QString dynamic = findPath(QString::fromLatin1("lib%1.so*").arg(name), findPaths); #endif if (!dynamic.isEmpty()) diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 2e5e3e369..884bc849d 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -554,7 +554,7 @@ bool PackageManagerCorePrivate::appendComponentToInstall(Component *component) if (dependencyComponent == 0) { QString errorMessage; if (!dependencyComponent) - errorMessage = QString::fromLatin1("Can't find missing dependency (%1) for %2."); + errorMessage = QString::fromLatin1("Cannot find missing dependency (%1) for %2."); errorMessage = errorMessage.arg(dependencyComponentName, component->name()); qDebug() << qPrintable(errorMessage); m_componentsToInstallError.append(errorMessage); diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index 65123efba..16fc6dc00 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -44,8 +44,14 @@ #include "fileutils.h" #include "qsettingswrapper.h" +#include <QDesktopServices> #include <QDir> +#ifdef Q_OS_WIN +# include <windows.h> +# include <shlobj.h> +#endif + namespace QInstaller { @@ -61,6 +67,20 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va m_variables.insert(QLatin1String("HomeDir"), QDir::homePath()); m_variables.insert(scTargetConfigurationFile, QLatin1String("components.xml")); + QString dir = QLatin1String("/opt"); +#ifdef Q_OS_WIN + TCHAR buffer[MAX_PATH + 1] = { 0 }; + SHGetFolderPath(0, CSIDL_PROGRAM_FILES, 0, 0, buffer); + dir = QString::fromWCharArray(buffer); +#elif defined (Q_OS_MAC) +# if QT_VERSION < 0x050000 + dir = QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation); +# else + dir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0); +# endif +#endif + m_variables.insert(QLatin1String("ApplicationsDir"), dir); + #ifdef Q_OS_WIN m_variables.insert(QLatin1String("os"), QLatin1String("win")); #elif defined(Q_OS_MAC) diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 98abefe75..e1e24c6e2 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -55,10 +55,8 @@ #include "kdsysinfo.h" #include <QtCore/QDir> -#include <QtCore/QDynamicPropertyChangeEvent> #include <QtCore/QPair> #include <QtCore/QProcess> -#include <QtCore/QRegExp> #include <QtCore/QSettings> #include <QtCore/QTimer> @@ -66,7 +64,6 @@ #include <QDesktopServices> #include <QFileDialog> #include <QGridLayout> -#include <QFormLayout> #include <QHBoxLayout> #include <QHeaderView> #include <QLabel> @@ -74,14 +71,11 @@ #include <QListWidget> #include <QListWidgetItem> #include <QMessageBox> -#include <QProgressBar> #include <QPushButton> #include <QRadioButton> #include <QTextBrowser> -#include <QTreeWidget> #include <QTreeView> #include <QVBoxLayout> -#include <QScrollBar> #include <QShowEvent> using namespace KDUpdater; @@ -531,7 +525,6 @@ void PackageManagerGui::cancelButtonClicked() void PackageManagerGui::rejectWithoutPrompt() { - m_core->setCanceled(); QDialog::reject(); } @@ -1725,7 +1718,7 @@ void PerformInstallationPage::entering() setCommitPage(true); if (packageManagerCore()->isUninstaller()) { - setButtonText(QWizard::CommitButton, tr("&Uninstall")); + setButtonText(QWizard::CommitButton, tr("U&ninstall")); setTitle(tr("Uninstalling %1").arg(productName())); QTimer::singleShot(30, packageManagerCore(), SLOT(runUninstaller())); diff --git a/src/libs/installer/persistentsettings.cpp b/src/libs/installer/persistentsettings.cpp deleted file mode 100644 index ecafe7682..000000000 --- a/src/libs/installer/persistentsettings.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "persistentsettings.h" - -#include <QtCore/QDebug> -#include <QtCore/QFile> -#include <QtCore/QVariant> -#include <QtXml/QDomDocument> -#include <QtXml/QDomCDATASection> -#include <QtXml/QDomElement> - - -using namespace ProjectExplorer; - -PersistentSettingsReader::PersistentSettingsReader() -{ -} - -QVariant PersistentSettingsReader::restoreValue(const QString &variable) const -{ - if (m_valueMap.contains(variable)) - return m_valueMap.value(variable); - return QVariant(); -} - -QVariantMap PersistentSettingsReader::restoreValues() const -{ - return m_valueMap; -} - -bool PersistentSettingsReader::load(const QString &fileName) -{ - m_valueMap.clear(); - - QFile file(fileName); - if (!file.open(QIODevice::ReadOnly)) - return false; - - QDomDocument doc; - if (!doc.setContent(&file)) - return false; - - QDomElement root = doc.documentElement(); - if (root.nodeName() != QLatin1String("qtcreator")) - return false; - - QDomElement child = root.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("data")) - readValues(child); - } - - file.close(); - return true; -} - -QVariant PersistentSettingsReader::readValue(const QDomElement &valElement) const -{ - QString name = valElement.nodeName(); - QString type = valElement.attribute(QLatin1String("type")); - QVariant v; - - if (name == QLatin1String("value")) { - if(type == QLatin1String("QChar")) { - //Workaround: QTBUG-12345 - v.setValue(QChar(valElement.text().at(0))); - } else { - v.setValue(valElement.text()); - v.convert(QVariant::nameToType(type.toLatin1().data())); - } - } else if (name == QLatin1String("valuelist")) { - QDomElement child = valElement.firstChildElement(); - QList<QVariant> valList; - for (; !child.isNull(); child = child.nextSiblingElement()) { - valList << readValue(child); - } - v.setValue(valList); - } else if (name == QLatin1String("valuemap")) { - QDomElement child = valElement.firstChildElement(); - QMap<QString, QVariant> valMap; - for (; !child.isNull(); child = child.nextSiblingElement()) { - QString key = child.attribute(QLatin1String("key")); - valMap.insert(key, readValue(child)); - } - v.setValue(valMap); - } - - return v; -} - -void PersistentSettingsReader::readValues(const QDomElement &data) -{ - QString variable; - QVariant v; - - QDomElement child = data.firstChildElement(); - for (; !child.isNull(); child = child.nextSiblingElement()) { - if (child.nodeName() == QLatin1String("variable")) - variable = child.text(); - else - v = readValue(child); - } - - m_valueMap.insert(variable, v); -} - -/// -/// PersistentSettingsWriter -/// - -PersistentSettingsWriter::PersistentSettingsWriter() -{ -} - -void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &variant) -{ - if (variant.type() == QVariant::StringList || variant.type() == QVariant::List) { - QDomElement values = ps.ownerDocument().createElement(QLatin1String("valuelist")); - values.setAttribute(QLatin1String("type"), QLatin1String(QVariant::typeToName(QVariant::List))); - QList<QVariant> varList = variant.toList(); - foreach (const QVariant &var, varList) { - writeValue(values, var); - } - ps.appendChild(values); - } else if (variant.type() == QVariant::Map) { - QDomElement values = ps.ownerDocument().createElement(QLatin1String("valuemap")); - values.setAttribute(QLatin1String("type"), QLatin1String(QVariant::typeToName(QVariant::Map))); - - QMap<QString, QVariant> varMap = variant.toMap(); - QMap<QString, QVariant>::const_iterator i = varMap.constBegin(); - while (i != varMap.constEnd()) { - writeValue(values, i.value()); - values.lastChild().toElement(). - setAttribute(QLatin1String("key"), i.key()); - ++i; - } - - ps.appendChild(values); - } else { - QDomElement value = ps.ownerDocument().createElement(QLatin1String("value")); - ps.appendChild(value); - QDomText valueText = ps.ownerDocument().createTextNode(variant.toString()); - value.appendChild(valueText); - value.setAttribute(QLatin1String("type"), QLatin1String(variant.typeName())); - ps.appendChild(value); - } -} - -void PersistentSettingsWriter::saveValue(const QString &variable, const QVariant &value) -{ - m_valueMap[variable] = value; -} - -bool PersistentSettingsWriter::save(const QString &fileName, const QString &docType) -{ - QFile file(fileName); - if (!file.open(QIODevice::WriteOnly)) - return false; - - QDomDocument doc(docType); - - QDomElement root = doc.createElement(QLatin1String("qtcreator")); - doc.appendChild(root); - - QMap<QString, QVariant>::const_iterator i = m_valueMap.constBegin(); - while (i != m_valueMap.constEnd()) { - QDomElement ps = doc.createElement(QLatin1String("data")); - root.appendChild(ps); - - QDomElement variable = doc.createElement(QLatin1String("variable")); - ps.appendChild(variable); - QDomText variableText = doc.createTextNode(i.key()); - variable.appendChild(variableText); - - writeValue(ps, i.value()); - ++i; - } - - file.write(doc.toByteArray()); - file.close(); - return true; -} diff --git a/src/libs/installer/persistentsettings.h b/src/libs/installer/persistentsettings.h deleted file mode 100644 index 71249cd70..000000000 --- a/src/libs/installer/persistentsettings.h +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef PERSISTENTSETTINGS_H -#define PERSISTENTSETTINGS_H - -#include "projectexplorer_export.h" - -#include <QtCore/QMap> -#include <QtCore/QVariant> - -QT_BEGIN_NAMESPACE -class QDomElement; -QT_END_NAMESPACE - -namespace ProjectExplorer { - -class PROJECTEXPLORER_EXPORT PersistentSettingsReader -{ -public: - PersistentSettingsReader(); - QVariant restoreValue(const QString &variable) const; - QVariantMap restoreValues() const; - bool load(const QString & fileName); - -private: - QVariant readValue(const QDomElement &valElement) const; - void readValues(const QDomElement &data); - QMap<QString, QVariant> m_valueMap; -}; - -class PROJECTEXPLORER_EXPORT PersistentSettingsWriter -{ -public: - PersistentSettingsWriter(); - void saveValue(const QString &variable, const QVariant &value); - bool save(const QString &fileName, const QString &docType); - -private: - void writeValue(QDomElement &ps, const QVariant &value); - QMap<QString, QVariant> m_valueMap; -}; - -} // namespace ProjectExplorer - -#endif // PERSISTENTSETTINGS_H diff --git a/src/libs/installer/progresscoordinator.h b/src/libs/installer/progresscoordinator.h index 263b25695..bdd154195 100644 --- a/src/libs/installer/progresscoordinator.h +++ b/src/libs/installer/progresscoordinator.h @@ -42,13 +42,15 @@ #ifndef PROGRESSCOORDINATOR_H #define PROGRESSCOORDINATOR_H +#include "installer_global.h" + #include <QtCore/QHash> #include <QtCore/QObject> #include <QtCore/QPointer> namespace QInstaller { -class ProgressCoordinator : public QObject +class INSTALLER_EXPORT ProgressCoordinator : public QObject { Q_OBJECT diff --git a/src/libs/installer/projectexplorer_export.h b/src/libs/installer/projectexplorer_export.h deleted file mode 100644 index 0e8cb470b..000000000 --- a/src/libs/installer/projectexplorer_export.h +++ /dev/null @@ -1 +0,0 @@ -#define PROJECTEXPLORER_EXPORT diff --git a/src/libs/installer/qtcreatorpersistentsettings.cpp b/src/libs/installer/qtcreatorpersistentsettings.cpp deleted file mode 100644 index bc035b422..000000000 --- a/src/libs/installer/qtcreatorpersistentsettings.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "qtcreatorpersistentsettings.h" -#include "qtcreator_constants.h" - -#include <QDebug> -#include <QStringList> -#include <QFile> -#include <QDir> - -QtCreatorPersistentSettings::QtCreatorPersistentSettings() -{ -} - -bool QtCreatorPersistentSettings::init(const QString &fileName) -{ - Q_ASSERT(!fileName.isEmpty()); - if (fileName.isEmpty()) - return false; - m_fileName = fileName; - if (m_reader.load(m_fileName) && !versionCheck()) - return false; - - m_toolChains = readValidToolChains(); - m_abiToDebuggerHash = readAbiToDebuggerHash(); - - return true; -} - -bool QtCreatorPersistentSettings::versionCheck() -{ - QVariantMap data = m_reader.restoreValues(); - - // Check version: - int version = data.value(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 0).toInt(); - if (version < 1) - return false; - return true; -} - - -QHash<QString, QVariantMap> QtCreatorPersistentSettings::readValidToolChains() -{ - if (m_fileName.isEmpty()) - return QHash<QString, QVariantMap>(); - - QHash<QString, QVariantMap> toolChainHash; - - QVariantMap data = m_reader.restoreValues(); - - int count = data.value(QLatin1String(TOOLCHAIN_COUNT_KEY), 0).toInt(); - for (int i = 0; i < count; ++i) { - const QString key = QLatin1String(TOOLCHAIN_DATA_KEY) + QString::number(i); - - const QVariantMap toolChainMap = data.value(key).toMap(); - - //gets the path variable, hope ".Path" will stay in QtCreator - QStringList pathContainingKeyList = QStringList(toolChainMap.keys()).filter(QLatin1String( - ".Path")); - foreach (const QString& pathKey, pathContainingKeyList) { - QString path = toolChainMap.value(pathKey).toString(); - if (!path.isEmpty() && QFile::exists(path)) { - toolChainHash.insert(path, toolChainMap); - } - } - } - return toolChainHash; -} - -QHash<QString, QString> QtCreatorPersistentSettings::abiToDebuggerHash() -{ - return m_abiToDebuggerHash; -} - -QHash<QString, QString> QtCreatorPersistentSettings::readAbiToDebuggerHash() -{ - if (m_fileName.isEmpty()) - return QHash<QString, QString>(); - - QHash<QString, QString> abiToDebuggerHash; - - QVariantMap data = m_reader.restoreValues(); - - // Read default debugger settings (if any) - int count = data.value(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY)).toInt(); - for (int i = 0; i < count; ++i) { - const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number(i); - if (!data.contains(abiKey)) - continue; - const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number(i); - if (!data.contains(pathKey)) - continue; - abiToDebuggerHash.insert(data.value(abiKey).toString(), data.value(pathKey).toString()); - } - return abiToDebuggerHash; -} - -bool QtCreatorPersistentSettings::addToolChain(const QtCreatorToolChain &toolChain) -{ - if (toolChain.key.isEmpty()) - return false; - if (toolChain.type.isEmpty()) - return false; - if (toolChain.displayName.isEmpty()) - return false; - if (toolChain.abiString.isEmpty()) - return false; - if (toolChain.compilerPath.isEmpty()) - return false; - - QVariantMap newToolChainVariantMap; - - newToolChainVariantMap.insert(QLatin1String(ID_KEY), - QString::fromLatin1("%1:%2.%3").arg(toolChain.type, QFileInfo(toolChain.compilerPath - ).absoluteFilePath(), toolChain.abiString)); - newToolChainVariantMap.insert(QLatin1String(DISPLAY_NAME_KEY), toolChain.displayName); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.Path").arg(toolChain.key), - QFileInfo(toolChain.compilerPath).absoluteFilePath()); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.TargetAbi").arg(toolChain.key), - toolChain.abiString); - newToolChainVariantMap.insert(QString::fromLatin1("ProjectExplorer.%1.Debugger").arg(toolChain.key), - QFileInfo(toolChain.debuggerPath).absoluteFilePath()); - - m_toolChains.insert(QFileInfo(toolChain.compilerPath).absoluteFilePath(), newToolChainVariantMap); - return true; -} - -bool QtCreatorPersistentSettings::removeToolChain(const QtCreatorToolChain &toolChain) -{ - m_toolChains.remove(QFileInfo(toolChain.compilerPath).absoluteFilePath()); - return true; -} - -void QtCreatorPersistentSettings::addDefaultDebugger(const QString &abiString, const QString &debuggerPath) -{ - m_abiToDebuggerHash.insert(abiString, debuggerPath); -} - -void QtCreatorPersistentSettings::removeDefaultDebugger(const QString &abiString) -{ - m_abiToDebuggerHash.remove(abiString); -} - -bool QtCreatorPersistentSettings::save() -{ - if (m_fileName.isEmpty()) - return false; - - m_writer.saveValue(QLatin1String(DEFAULT_DEBUGGER_COUNT_KEY), m_abiToDebuggerHash.count()); - - QHashIterator<QString, QString> it(m_abiToDebuggerHash); - int debuggerCounter = 0; - while (it.hasNext()) { - it.next(); - const QString abiKey = QString::fromLatin1(DEFAULT_DEBUGGER_ABI_KEY) + QString::number( - debuggerCounter); - const QString pathKey = QString::fromLatin1(DEFAULT_DEBUGGER_PATH_KEY) + QString::number( - debuggerCounter); - m_writer.saveValue(abiKey, it.key()); - m_writer.saveValue(pathKey, it.value()); - debuggerCounter++; - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_COUNT_KEY), m_toolChains.count()); - - int toolChainCounter = 0; - - foreach (QVariantMap toolChainMap, m_toolChains.values()) { - if (toolChainMap.isEmpty()) - continue; - - //if we added a new debugger we need to adjust the tool chains - QString abiString; - //find the abiString - foreach (const QString &key, toolChainMap.keys()) { - if (key.contains(QLatin1String(".TargetAbi"))) { - abiString = toolChainMap.value(key).toString(); - break; - } - } - //adjust debugger path - foreach (const QString &key, toolChainMap.keys()) { - if (key.contains(QLatin1String(".Debugger"))) { - toolChainMap.insert(key, m_abiToDebuggerHash.value(abiString)); - break; - } - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_DATA_KEY) + QString::number(toolChainCounter++), - toolChainMap); - } - - m_writer.saveValue(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 1); - - QDir().mkpath(QFileInfo(m_fileName).absolutePath()); - return m_writer.save(m_fileName, QLatin1String("QtCreatorToolChains")); -} diff --git a/src/libs/installer/qtpatch.cpp b/src/libs/installer/qtpatch.cpp index 6581815c2..7a1e18df3 100644 --- a/src/libs/installer/qtpatch.cpp +++ b/src/libs/installer/qtpatch.cpp @@ -113,7 +113,7 @@ QHash<QString, QByteArray> QtPatch::qmakeValues(const QString &qmakePath, QByteA } if (qmakeValueHash.isEmpty()) - qDebug() << "Can't get any query output from qmake."; + qDebug() << "Cannot get any query output from qmake."; return qmakeValueHash; } diff --git a/src/libs/installer/registerdefaultdebuggeroperation.cpp b/src/libs/installer/registerdefaultdebuggeroperation.cpp deleted file mode 100644 index d6cdac851..000000000 --- a/src/libs/installer/registerdefaultdebuggeroperation.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registerdefaultdebuggeroperation.h" - -#include "persistentsettings.h" -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "qtcreatorpersistentsettings.h" - -#include <QString> -#include <QFileInfo> -#include <QDir> -#include <QSettings> -#include <QDebug> - -using namespace QInstaller; - -using namespace ProjectExplorer; - -//TODO move this to a general location it is used on some classes -static QString fromNativeSeparatorsAllOS(const QString &pathName) -{ - QString n = pathName; - for (int i = 0; i < n.size(); ++i) { - if (n.at(i) == QLatin1Char('\\')) - n[i] = QLatin1Char('/'); - } - return n; -} - -RegisterDefaultDebuggerOperation::RegisterDefaultDebuggerOperation() -{ - setName(QLatin1String("RegisterDefaultDebugger")); -} - -void RegisterDefaultDebuggerOperation::backup() -{ -} - -/** application binary interface - this is an internal creator typ as a String CPU-OS-OS_FLAVOR-BINARY_FORMAT-WORD_WIDTH - * CPU: arm x86 mips ppc itanium - * OS: linux macos symbian unix windows - * OS_FLAVOR: generic maemo meego generic device emulator generic msvc2005 msvc2008 msvc2010 msys ce - * BINARY_FORMAT: elf pe mach_o qml_rt - * WORD_WIDTH: 8 16 32 64 - */ - -bool RegisterDefaultDebuggerOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - QString toolChainsXmlFilePath; - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - if (core->value(scQtCreatorInstallerToolchainsFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for %1 on the installer object.").arg( - scQtCreatorInstallerToolchainsFile)); - return false; - } - toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile); - - int argCounter = 0; - const QString &abiString = args.at(argCounter++); //for example x86-windows-msys-pe-32bit - const QString &debuggerPath = fromNativeSeparatorsAllOS(args.at(argCounter++)); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - creatorToolChainSettings.addDefaultDebugger(abiString, debuggerPath); - return creatorToolChainSettings.save(); -} - -bool RegisterDefaultDebuggerOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, 2 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/toolChains.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/toolChains.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - int argCounter = 0; - const QString &abiString = args.at(argCounter++); //for example x86-windows-msys-pe-32bit - const QString &debuggerPath = fromNativeSeparatorsAllOS(args.at(argCounter++)); - Q_UNUSED(debuggerPath) - - QtCreatorPersistentSettings creatorToolChainSettings; - - creatorToolChainSettings.init(toolChainsXmlFilePath); - creatorToolChainSettings.removeDefaultDebugger(abiString); - return creatorToolChainSettings.save(); -} - -bool RegisterDefaultDebuggerOperation::testOperation() -{ - return true; -} - -Operation *RegisterDefaultDebuggerOperation::clone() const -{ - return new RegisterDefaultDebuggerOperation(); -} diff --git a/src/libs/installer/registerdefaultdebuggeroperation.h b/src/libs/installer/registerdefaultdebuggeroperation.h deleted file mode 100644 index 87712e5d8..000000000 --- a/src/libs/installer/registerdefaultdebuggeroperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef REGISTERDEFAULTDEBUGGEROPERATION_H -#define REGISTERDEFAULTDEBUGGEROPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class RegisterDefaultDebuggerOperation : public Operation -{ -public: - RegisterDefaultDebuggerOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace QInstaller - -#endif // REGISTERDEFAULTDEBUGGEROPERATION_H diff --git a/src/libs/installer/registerqtincreatorqnxoperation.cpp b/src/libs/installer/registerqtincreatorqnxoperation.cpp deleted file mode 100644 index be99de4c7..000000000 --- a/src/libs/installer/registerqtincreatorqnxoperation.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registerqtincreatorqnxoperation.h" - -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "persistentsettings.h" - -#include <QString> -#include <QFileInfo> -#include <QDir> -#include <QSettings> -#include <QDebug> - - -using namespace QInstaller; - -// TODO: move this to a general location it is used on some classes -static QString fromNativeSeparatorsAllOS(const QString &pathName) -{ - QString n = pathName; - for (int i = 0; i < n.size(); ++i) { - if (n.at(i) == QLatin1Char('\\')) - n[i] = QLatin1Char('/'); - } - return n; -} - -static QString absoluteQmakePath(const QString &path) -{ - QString versionQmakePath = QDir(path).absolutePath(); - if (!versionQmakePath.endsWith(QLatin1String("qmake")) - && !versionQmakePath.endsWith(QLatin1String("qmake.exe"))) { -#if defined (Q_OS_WIN) - versionQmakePath.append(QLatin1String("/bin/qmake.exe")); -#elif defined(Q_OS_UNIX) - versionQmakePath.append(QLatin1String("/bin/qmake")); -#endif - } - return fromNativeSeparatorsAllOS(versionQmakePath); -} - -RegisterQtInCreatorQNXOperation::RegisterQtInCreatorQNXOperation() -{ - setName(QLatin1String("RegisterQtInCreatorQNX")); -} - -void RegisterQtInCreatorQNXOperation::backup() -{ -} - -// Parameter List: -// Name - String displayed as name in Qt Creator -// qmake path - location of the qmake binary -// Type identifier - Desktop, Simulator, Symbian, ... -// SDK identifier - unique string to identify Qt version inside of the SDK (eg. desk473, simu11, ...) -// System Root Path -// sbs path -bool RegisterQtInCreatorQNXOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 5) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("at least 5"), QLatin1String(""))); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - if (core->value(scQtCreatorInstallerQtVersionFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for %1 on the installer object.").arg( - scQtCreatorInstallerQtVersionFile)); - return false; - } - const QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile); - int argCounter = 0; - const QString &versionName = args.at(argCounter++); - const QString &path = QDir::toNativeSeparators(args.value(argCounter++)); - const QString versionQmakePath = absoluteQmakePath(path); - - const QString &sdkPath = args.at(argCounter++); - const QString &versionTypeIdentifier = args.at(argCounter++); - const QString &versionSDKIdentifier = args.at(argCounter++); - const QString &versionSystemRoot = fromNativeSeparatorsAllOS(args.value(argCounter++)); - const QString &versionSbsPath = fromNativeSeparatorsAllOS(args.value(argCounter++)); - - ProjectExplorer::PersistentSettingsReader reader; - int qtVersionCount = 0; - QVariantMap map; - if (reader.load(qtVersionsFileName)) { - map = reader.restoreValues(); - qtVersionCount = map.value(QLatin1String("QtVersion.Count")).toInt(); - map.remove(QLatin1String("QtVersion.Count")); - map.remove(QLatin1String("Version")); - } - - ProjectExplorer::PersistentSettingsWriter writer; - // Store old qt versions - if (!map.isEmpty()) { - for (int i = 0; i < qtVersionCount; ++i) { - writer.saveValue(QString::fromLatin1("QtVersion.%1").arg(i) - , map[QLatin1String("QtVersion.") + QString::number(i)].toMap()); - } - map.clear(); - } - // Enter new version - map.insert(QLatin1String("Id"), -1); - map.insert(QLatin1String("Arch"), 1); - map.insert(QLatin1String("Name"), versionName); - map.insert(QLatin1String("QMakePath"), versionQmakePath); - map.insert(QLatin1String("SDKPath"), sdkPath); - map.insert(QLatin1String("QtVersion.Type"), - QLatin1String("Qt4ProjectManager.QtVersion.") + versionTypeIdentifier); - map.insert(QLatin1String("isAutodetected"), true); - map.insert(QLatin1String("autodetectionSource"), - QLatin1String("SDK.") + versionSDKIdentifier); - if (!versionSystemRoot.isEmpty()) - map.insert(QLatin1String("SystemRoot"), versionSystemRoot); - if (!versionSbsPath.isEmpty()) - map.insert(QLatin1String("SBSv2Directory"), versionSbsPath); - - writer.saveValue(QLatin1String("QtVersion.") + QString::number(qtVersionCount), map); - - writer.saveValue(QLatin1String("Version"), 1); - writer.saveValue(QLatin1String("QtVersion.Count"), qtVersionCount + 1); - QDir().mkpath(QFileInfo(qtVersionsFileName).absolutePath()); - writer.save(qtVersionsFileName, QLatin1String("QtCreatorQtVersions")); - - return true; -} - -bool RegisterQtInCreatorQNXOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/qtversion.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString qtVersionsFileName = core->value(scQtCreatorInstallerQtVersionFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/qtversion.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - ProjectExplorer::PersistentSettingsReader reader; - // If no file, then it has been removed already - if (!reader.load(qtVersionsFileName)) - return true; - - const QVariantMap map = reader.restoreValues(); - - ProjectExplorer::PersistentSettingsWriter writer; - const int qtVersionCount = map.value(QLatin1String("QtVersion.Count")).toInt(); - - int currentVersionIndex = 0; - for (int i = 0; i < qtVersionCount; ++i) { - QVariantMap versionMap = map[QLatin1String("QtVersion.") + QString::number(i)].toMap(); - - const QString path = QDir::toNativeSeparators(args.value(1)); - const QString versionQmakePath = absoluteQmakePath(path); - - //use absoluteQmakePath function to normalize the path string, for example // - const QString existingQtQMakePath = absoluteQmakePath( - versionMap[QLatin1String("QMakePath")].toString()); - if (existingQtQMakePath == versionQmakePath) - continue; - writer.saveValue(QString::fromLatin1("QtVersion.%1").arg(currentVersionIndex++), versionMap); - } - - writer.saveValue(QLatin1String("QtVersion.Count"), currentVersionIndex); - writer.saveValue(QLatin1String("Version"), map[QLatin1String("Version")].toInt()); - - writer.save(qtVersionsFileName, QLatin1String("QtCreatorQtVersions")); - return true; -} - -bool RegisterQtInCreatorQNXOperation::testOperation() -{ - return true; -} - -Operation *RegisterQtInCreatorQNXOperation::clone() const -{ - return new RegisterQtInCreatorQNXOperation(); -} diff --git a/src/libs/installer/registerqtincreatorqnxoperation.h b/src/libs/installer/registerqtincreatorqnxoperation.h deleted file mode 100644 index 5b6a3c9b1..000000000 --- a/src/libs/installer/registerqtincreatorqnxoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef REGISTERQTINCREATORQNXOPERATION_H -#define REGISTERQTINCREATORQNXOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class RegisterQtInCreatorQNXOperation : public Operation -{ -public: - RegisterQtInCreatorQNXOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace QInstaller - -#endif // REGISTERQTINCREATORQNXOPERATION_H diff --git a/src/libs/installer/registertoolchainoperation.cpp b/src/libs/installer/registertoolchainoperation.cpp deleted file mode 100644 index 0caf1451b..000000000 --- a/src/libs/installer/registertoolchainoperation.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "registertoolchainoperation.h" - -#include "persistentsettings.h" -#include "packagemanagercore.h" -#include "qtcreator_constants.h" -#include "qtcreatorpersistentsettings.h" - -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtCore/QFileInfo> -#include <QtCore/QSettings> -#include <QtCore/QString> - -using namespace QInstaller; - -using namespace ProjectExplorer; - -RegisterToolChainOperation::RegisterToolChainOperation() -{ - setName(QLatin1String("RegisterToolChain")); -} - -void RegisterToolChainOperation::backup() -{ -} - -bool RegisterToolChainOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("at least 4"), QLatin1String(""))); - return false; - } - - QString toolChainsXmlFilePath; - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in '%1' operation is empty.").arg(name())); - return false; - } - if (core->value(scQtCreatorInstallerToolchainsFile).isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("There is no value set for '%1' on the installer object.").arg( - scQtCreatorInstallerToolchainsFile)); - return false; - } - toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile); - - QtCreatorToolChain toolChain; - - int argCounter = 0; - toolChain.key = args.at(argCounter++); //Qt SDK:gccPath - toolChain.type = args.at(argCounter++); //where this toolchain is defined in QtCreator - toolChain.displayName = args.at(argCounter++); //nice special Toolchain (Qt SDK) - toolChain.abiString = args.at(argCounter++); //x86-windows-msys-pe-32bit - toolChain.compilerPath = QDir::toNativeSeparators(args.at(argCounter++)); //gccPath - if (args.count() > argCounter) - toolChain.debuggerPath = QDir::toNativeSeparators(args.at(argCounter++)); - if (args.count() > argCounter) - toolChain.armVersion = args.at(argCounter++); - if (args.count() > argCounter) - toolChain.force32Bit = args.at(argCounter++); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - if (!creatorToolChainSettings.addToolChain(toolChain)) { - setError(InvalidArguments); - setErrorString(tr("Some arguments are not right in %1 operation.") - .arg(name()).arg(args.count())); - return false; - } - return creatorToolChainSettings.save(); -} - -bool RegisterToolChainOperation::undoOperation() -{ - const QStringList args = arguments(); - - if (args.count() < 4) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, minimum 4 expected.") - .arg(name()).arg(args.count())); - return false; - } - - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); - if (!core) { - setError(UserDefinedError); - setErrorString(tr("Needed installer object in \"%1\" operation is empty.").arg(name())); - return false; - } - - // default value is the old value to keep the possibility that old saved operations can run undo -#ifdef Q_OS_MAC - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/Qt Creator.app/Contents/Resources/QtProject/toolChains.xml").arg( - core->value(QLatin1String("TargetDir")))); -#else - QString toolChainsXmlFilePath = core->value(scQtCreatorInstallerToolchainsFile, - QString::fromLatin1("%1/QtCreator/share/qtcreator/QtProject/toolChains.xml").arg(core->value( - QLatin1String("TargetDir")))); -#endif - - QtCreatorToolChain toolChain; - - int argCounter = 0; - toolChain.key = args.at(argCounter++); //Qt SDK:gccPath - toolChain.type = args.at(argCounter++); //where this toolchain is defined in QtCreator - toolChain.displayName = args.at(argCounter++); //nice special Toolchain (Qt SDK) - toolChain.abiString = args.at(argCounter++); //x86-windows-msys-pe-32bit - toolChain.compilerPath = QDir::toNativeSeparators(args.at(argCounter++)); //gccPath - if (args.count() > argCounter) - toolChain.debuggerPath = QDir::toNativeSeparators(args.at(argCounter++)); - if (args.count() > argCounter) - toolChain.armVersion = args.at(argCounter++); - if (args.count() > argCounter) - toolChain.force32Bit = args.at(argCounter++); - - QtCreatorPersistentSettings creatorToolChainSettings; - - if (!creatorToolChainSettings.init(toolChainsXmlFilePath)) { - setError(UserDefinedError); - setErrorString(tr("Can't read from tool chains xml file(%1) correctly.") - .arg(toolChainsXmlFilePath)); - return false; - } - - if (!creatorToolChainSettings.removeToolChain(toolChain)) { - setError(InvalidArguments); - setErrorString(tr("Some arguments are not right in %1 operation.") - .arg(name()).arg(args.count())); - return false; - } - return creatorToolChainSettings.save(); -} - -bool RegisterToolChainOperation::testOperation() -{ - return true; -} - -Operation *RegisterToolChainOperation::clone() const -{ - return new RegisterToolChainOperation(); -} diff --git a/src/libs/installer/registertoolchainoperation.h b/src/libs/installer/registertoolchainoperation.h deleted file mode 100644 index bd745adfb..000000000 --- a/src/libs/installer/registertoolchainoperation.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef REGISTERTOOLCHAINOPERATION_H -#define REGISTERTOOLCHAINOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -/*! - Arguments: - * SDK Path - to find the QtCreator installation - * ToolChainKey - is the internal QtCreator settings key usually: GccToolChain - * toolchain type - where this toolchain is defined in QtCreator - * ProjectExplorer.ToolChain.Gcc ProjectExplorer.ToolChain.Mingw - * ProjectExplorer.ToolChain.LinuxIcc ProjectExplorer.ToolChain.Msvc - * Qt4ProjectManager.ToolChain.GCCE Qt4ProjectManager.ToolChain.Maemo - * display name - the name how it will be displayed in QtCreator - * application binary interface - this is an internal creator typ as a String CPU-OS-OS_FLAVOR-BINARY_FORMAT-WORD_WIDTH - * CPU: arm x86 mips ppc itanium - * OS: linux macos symbian unix windows - * OS_FLAVOR: generic maemo meego generic device emulator generic msvc2005 msvc2008 msvc2010 msys ce - * BINARY_FORMAT: elf pe mach_o qml_rt - * WORD_WIDTH: 8 16 32 64 - * compiler path - the binary which is used as the compiler - * debugger path - the binary which is used as the debugger -*/ -class RegisterToolChainOperation : public Operation -{ -public: - RegisterToolChainOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace QInstaller - -#endif // REGISTERTOOLCHAINOPERATION_H diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp index 9931d956e..a2fe9f049 100644 --- a/src/libs/installer/scriptengine.cpp +++ b/src/libs/installer/scriptengine.cpp @@ -162,16 +162,19 @@ QScriptValue qFileDialogGetExistingDirectory(QScriptContext *context, QScriptEng QScriptValue qFileDialogGetOpenFileName(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine); - const QScriptValue check = checkArguments(context, 0, 2); + const QScriptValue check = checkArguments(context, 0, 3); if (check.isError()) return check; QString caption; QString dir; + QString fileNameFilter; if (context->argumentCount() > 0) caption = context->argument(0).toString(); if (context->argumentCount() > 1) dir = context->argument(1).toString(); - return QFileDialog::getExistingDirectory(0, caption, dir); + if (context->argumentCount() > 2) + fileNameFilter = context->argument(2).toString(); + return QFileDialog::getOpenFileName(0, caption, dir, fileNameFilter); } } //namespace QInstaller @@ -201,6 +204,8 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core) QScriptValue fileDialog = newArray(); fileDialog.setProperty(QLatin1String("getExistingDirectory"), newFunction(qFileDialogGetExistingDirectory)); + fileDialog.setProperty(QLatin1String("getOpenFileName"), + newFunction(qFileDialogGetOpenFileName)); globalObject().setProperty(QLatin1String("QFileDialog"), fileDialog); const QList<Component*> components = m_core->availableComponents(); diff --git a/src/libs/installer/setdemospathonqtoperation.cpp b/src/libs/installer/setdemospathonqtoperation.cpp deleted file mode 100644 index d558b3e21..000000000 --- a/src/libs/installer/setdemospathonqtoperation.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setdemospathonqtoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QDir> -#include <QtCore/QSettings> -#include <QtCore/QDebug> - -using namespace QInstaller; - -SetDemosPathOnQtOperation::SetDemosPathOnQtOperation() -{ - setName(QLatin1String("SetDemosPathOnQt")); -} - -void SetDemosPathOnQtOperation::backup() -{ -} - -bool SetDemosPathOnQtOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtDir = args.at(0); - QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - QString qmakePath = qtDir + QLatin1String("/bin/qmake"); -#ifdef Q_OS_WIN - qmakePath = qmakePath + QLatin1String(".exe"); -#endif - - QByteArray qmakeOutput; - QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput); - - if (qmakeValueHash.isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("The output of \n'%1 -query'\nis not parseable. Please file a bugreport with this " - "dialog at https://bugreports.qt-project.org.\noutput: %2").arg(QDir::toNativeSeparators(qmakePath), - QString::fromUtf8(qmakeOutput))); - return false; - } - - QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_DEMOS")); - bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty(); - if (oldQtPathFromQMakeIsEmpty) { - qDebug() << "qpatch: warning: It was not possible to get the old values from" << qmakePath; - } - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt demo path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue)) ); - return false; - } - - QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf"); - if (QFile::exists(qtConfPath)) { - QSettings settings(qtConfPath, QSettings::IniFormat); - settings.setValue(QLatin1String("Paths/Demos"), QString::fromUtf8(newValue)); - } - - oldValue = QByteArray("qt_demopath=%1").replace("%1", oldValue); - newValue = QByteArray("qt_demopath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the demo path in" << qmakePath; - } - - return true; -} - -bool SetDemosPathOnQtOperation::undoOperation() -{ - return true; -} - -bool SetDemosPathOnQtOperation::testOperation() -{ - return true; -} - -Operation *SetDemosPathOnQtOperation::clone() const -{ - return new SetDemosPathOnQtOperation(); -} - diff --git a/src/libs/installer/setexamplespathonqtoperation.cpp b/src/libs/installer/setexamplespathonqtoperation.cpp deleted file mode 100644 index e73aed25a..000000000 --- a/src/libs/installer/setexamplespathonqtoperation.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setexamplespathonqtoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QDir> -#include <QtCore/QSettings> -#include <QtCore/QDebug> - -using namespace QInstaller; - -SetExamplesPathOnQtOperation::SetExamplesPathOnQtOperation() -{ - setName(QLatin1String("SetExamplesPathOnQt")); -} - -void SetExamplesPathOnQtOperation::backup() -{ -} - -bool SetExamplesPathOnQtOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtDir = args.at(0); - QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - QString qmakePath = qtDir + QLatin1String("/bin/qmake"); -#ifdef Q_OS_WIN - qmakePath = qmakePath + QLatin1String(".exe"); -#endif - - QByteArray qmakeOutput; - QHash<QString, QByteArray> qmakeValueHash = QtPatch::qmakeValues(qmakePath, &qmakeOutput); - - if (qmakeValueHash.isEmpty()) { - setError(UserDefinedError); - setErrorString(tr("The output of \n'%1 -query'\nis not parseable. Please file a bugreport with this " - "dialog at https://bugreports.qt-project.org.\noutput: %2").arg(QDir::toNativeSeparators(qmakePath), - QString::fromUtf8(qmakeOutput))); - return false; - } - - QByteArray oldValue = qmakeValueHash.value(QLatin1String("QT_INSTALL_EXAMPLES")); - bool oldQtPathFromQMakeIsEmpty = oldValue.isEmpty(); - if (oldQtPathFromQMakeIsEmpty) { - qDebug() << "qpatch: warning: It was not possible to get the old values from" << qmakePath; - } - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt example path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - - QString qtConfPath = qtDir + QLatin1String("/bin/qt.conf"); - - if (QFile::exists(qtConfPath)) { - QSettings settings(qtConfPath, QSettings::IniFormat); - settings.setValue( QLatin1String("Paths/Examples"), QString::fromUtf8(newValue)); - } - - oldValue = QByteArray("qt_xmplpath=%1").replace("%1", oldValue); - newValue = QByteArray("qt_xmplpath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(qmakePath, oldValue, newValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the example path in" << qmakePath; - } - - return true; -} - -bool SetExamplesPathOnQtOperation::undoOperation() -{ - return true; -} - -bool SetExamplesPathOnQtOperation::testOperation() -{ - return true; -} - -Operation *SetExamplesPathOnQtOperation::clone() const -{ - return new SetExamplesPathOnQtOperation(); -} - diff --git a/src/libs/installer/setexamplespathonqtoperation.h b/src/libs/installer/setexamplespathonqtoperation.h deleted file mode 100644 index 7f2df6b4e..000000000 --- a/src/libs/installer/setexamplespathonqtoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETEXAMPLESPATHONQTOPERATION_H -#define SETEXAMPLESPATHONQTOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetExamplesPathOnQtOperation : public Operation -{ -public: - SetExamplesPathOnQtOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETEXAMPLESPATHONQTOPERATION_H diff --git a/src/libs/installer/setimportspathonqtcoreoperation.cpp b/src/libs/installer/setimportspathonqtcoreoperation.cpp deleted file mode 100644 index 685aee846..000000000 --- a/src/libs/installer/setimportspathonqtcoreoperation.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setimportspathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found").arg(binaryPath); - return QByteArray(); - } - - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue("qt_impspath="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - while(source.at(stringEndPosition++) != '\0') {} - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetImportsPathOnQtCoreOperation::SetImportsPathOnQtCoreOperation() -{ - setName(QLatin1String("SetImportsPathOnQtCore")); -} - -void SetImportsPathOnQtCoreOperation::backup() -{ -} - -bool SetImportsPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt imports path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("qt_impspath=%1").replace("%1", oldValue); - QByteArray adjutedNewValue = QByteArray("qt_impspath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the imports path in" << coreLibrary; - } - } - } - - return true; -} - -bool SetImportsPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetImportsPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetImportsPathOnQtCoreOperation::clone() const -{ - return new SetImportsPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setimportspathonqtcoreoperation.h b/src/libs/installer/setimportspathonqtcoreoperation.h deleted file mode 100644 index 7dbb9c7d3..000000000 --- a/src/libs/installer/setimportspathonqtcoreoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETIMPORTSPATHONQTCOREOPERATION_H -#define SETIMPORTSPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetImportsPathOnQtCoreOperation : public Operation -{ -public: - SetImportsPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETIMPORTSPATHONQTCOREOPERATION_H diff --git a/src/libs/installer/setpathonqtcoreoperation.cpp b/src/libs/installer/setpathonqtcoreoperation.cpp deleted file mode 100644 index c6950246d..000000000 --- a/src/libs/installer/setpathonqtcoreoperation.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setpathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath, const QByteArray &typeValue) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found.").arg( - binaryPath); - return QByteArray(); - } - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue = typeValue; - searchValue.append("="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - - // go to the position where the other data starts - while (source.at(stringEndPosition++) != '\0') {} - - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetPathOnQtCoreOperation::SetPathOnQtCoreOperation() -{ - setName(QLatin1String("SetPathOnQtCore")); -} - -void SetPathOnQtCoreOperation::backup() -{ -} - -bool SetPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 3) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 3"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray typeValue(args.at(1).toUtf8()); - const QByteArray newValue = QDir::toNativeSeparators(args.at(2)).toUtf8(); - - QStringList possibleTypes; - possibleTypes << QLatin1String("qt_prfxpath") - << QLatin1String("qt_docspath") - << QLatin1String("qt_hdrspath") - << QLatin1String("qt_libspath") - << QLatin1String("qt_binspath") - << QLatin1String("qt_plugpath") - << QLatin1String("qt_impspath") - << QLatin1String("qt_datapath") - << QLatin1String("qt_trnspath") - << QLatin1String("qt_xmplpath") - << QLatin1String("qt_demopath"); - - if (!possibleTypes.contains(QString::fromUtf8(typeValue))) { - setError(InvalidArguments); - setErrorString(tr("The second type/value needs to be one of: %1").arg(possibleTypes.join( - QLatin1String(", ")))); - return false; - } - - if (newValue.size() >= 255) { - qDebug() << "qpatch: error: newQtDir needs to be less than 255 characters."; - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary, typeValue)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("%0=%1").replace("%0", typeValue).replace("%1", oldValue); - QByteArray adjutedNewValue = - QByteArray("%0=%1").replace("%0", typeValue).replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) { - qDebug() << "qpatch: warning: could not patch the plugin path in" << coreLibrary; - } - } - } - - return true; -} - -bool SetPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetPathOnQtCoreOperation::clone() const -{ - return new SetPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setpluginpathonqtcoreoperation.cpp b/src/libs/installer/setpluginpathonqtcoreoperation.cpp deleted file mode 100644 index cafdda24c..000000000 --- a/src/libs/installer/setpluginpathonqtcoreoperation.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#include "setpluginpathonqtcoreoperation.h" - -#include "qtpatch.h" - -#include <QtCore/QByteArrayMatcher> -#include <QtCore/QDir> -#include <QtCore/QDebug> - -using namespace QInstaller; - -namespace { - QByteArray getOldValue(const QString &binaryPath) - { - QFileInfo fileInfo(binaryPath); - - if (!fileInfo.exists()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' not found").arg(binaryPath); - return QByteArray(); - } - - QFile file(binaryPath); - int readOpenCount = 0; - while (!file.open(QFile::ReadOnly) && readOpenCount < 20000) { - ++readOpenCount; - qApp->processEvents(); - } - Q_ASSERT(file.isOpen()); - if (!file.isOpen()) { - qDebug() << QString::fromLatin1("qpatch: warning: file '%1' can not be opened as ReadOnly.").arg( - binaryPath); - qDebug() << file.errorString(); - return QByteArray(); - } - - const QByteArray source = file.readAll(); - file.close(); - - int offset = 0; - QByteArray searchValue("qt_plugpath="); - QByteArrayMatcher byteArrayMatcher(searchValue); - offset = byteArrayMatcher.indexIn(source, offset); - Q_ASSERT(offset > 0); - if (offset == -1) - return QByteArray(); - - int stringEndPosition = offset; - while(source.at(stringEndPosition++) != '\0') {} - // between the search string and the first \0 is the QByteArray we are looking for - return source.mid(offset + searchValue.size(), stringEndPosition - offset); - } -} - -SetPluginPathOnQtCoreOperation::SetPluginPathOnQtCoreOperation() -{ - setName(QLatin1String("SetPluginPathOnQtCore")); -} - -void SetPluginPathOnQtCoreOperation::backup() -{ -} - -bool SetPluginPathOnQtCoreOperation::performOperation() -{ - const QStringList args = arguments(); - - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); - return false; - } - - const QString qtCoreLibraryDir = args.at(0); - const QByteArray newValue = QDir::toNativeSeparators(args.at(1)).toUtf8(); - - if (newValue.size() >= 255) { - setError(UserDefinedError); - setErrorString(tr("Qt patch error: new Qt plugin path '%1'\nneeds to be less than 255 characters.") - .arg(QString::fromLocal8Bit(newValue))); - return false; - } - QStringList libraryFiles; -#ifdef Q_OS_WIN - libraryFiles << QString::fromLatin1("%1/QtCore4.dll").arg(qtCoreLibraryDir); - libraryFiles << QString::fromLatin1("%1/QtCore4d.dll").arg(qtCoreLibraryDir); -#else - libraryFiles << qtCoreLibraryDir + QLatin1String("/libQtCore.so"); -#endif - foreach (const QString &coreLibrary, libraryFiles) { - if (QFile::exists(coreLibrary)) { - QByteArray oldValue(getOldValue(coreLibrary)); - Q_ASSERT(!oldValue.isEmpty()); - oldValue = QByteArray("qt_plugpath=%1").replace("%1", oldValue); - QByteArray adjutedNewValue = QByteArray("qt_plugpath=%1").replace("%1", newValue); - - bool isPatched = QtPatch::patchBinaryFile(coreLibrary, oldValue, adjutedNewValue); - if (!isPatched) - qDebug() << "qpatch: warning: could not patch the plugin path in" << coreLibrary; - } - } - - return true; -} - -bool SetPluginPathOnQtCoreOperation::undoOperation() -{ - return true; -} - -bool SetPluginPathOnQtCoreOperation::testOperation() -{ - return true; -} - -Operation *SetPluginPathOnQtCoreOperation::clone() const -{ - return new SetPluginPathOnQtCoreOperation(); -} - diff --git a/src/libs/installer/setpluginpathonqtcoreoperation.h b/src/libs/installer/setpluginpathonqtcoreoperation.h deleted file mode 100644 index 99d9c4bfe..000000000 --- a/src/libs/installer/setpluginpathonqtcoreoperation.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef SETPLUGINPATHONQTCOREOPERATION_H -#define SETPLUGINPATHONQTCOREOPERATION_H - -#include "qinstallerglobal.h" - -namespace QInstaller { - -class SetPluginPathOnQtCoreOperation : public Operation -{ -public: - SetPluginPathOnQtCoreOperation(); - - void backup(); - bool performOperation(); - bool undoOperation(); - bool testOperation(); - Operation *clone() const; -}; - -} // namespace - -#endif // SETPLUGINPATHONQTCOREOPERATION_H diff --git a/src/libs/installer/setqtcreatorvalueoperation.cpp b/src/libs/installer/setqtcreatorvalueoperation.cpp index 28e0f9134..4f2bbfbc1 100644 --- a/src/libs/installer/setqtcreatorvalueoperation.cpp +++ b/src/libs/installer/setqtcreatorvalueoperation.cpp @@ -110,7 +110,7 @@ bool SetQtCreatorValueOperation::performOperation() if (!group.isEmpty()) settings.endGroup(); - settings.sync(); //be save ;) + settings.sync(); //be safe ;) return true; } diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp index 483f1b338..88b95f42e 100644 --- a/src/libs/kdtools/kdsavefile.cpp +++ b/src/libs/kdtools/kdsavefile.cpp @@ -299,7 +299,7 @@ bool KDSaveFile::open(OpenMode mode) return opened; } -bool KDSaveFile::atEnd() +bool KDSaveFile::atEnd() const { return d->tmpFile ? d->tmpFile->atEnd() : QIODevice::atEnd(); } diff --git a/src/libs/kdtools/kdsavefile.h b/src/libs/kdtools/kdsavefile.h index 24eee9870..7408892d0 100644 --- a/src/libs/kdtools/kdsavefile.h +++ b/src/libs/kdtools/kdsavefile.h @@ -76,7 +76,7 @@ public: bool resize(qint64 size); int handle() const; - bool atEnd(); + bool atEnd() const; qint64 bytesAvailable() const; qint64 bytesToWrite() const; bool canReadLine() const; diff --git a/src/libs/kdtools/kdupdaterfiledownloader.cpp b/src/libs/kdtools/kdupdaterfiledownloader.cpp index a7fbfe85b..95b574b2f 100644 --- a/src/libs/kdtools/kdupdaterfiledownloader.cpp +++ b/src/libs/kdtools/kdupdaterfiledownloader.cpp @@ -320,13 +320,13 @@ void KDUpdater::FileDownloader::emitDownloadStatus() if (bytesReceived.endsWith(tmp)) bytesReceived.chop(tmp.length()); - status = bytesReceived + tr(" of ") + bytesToReceive; + status = tr("%1 of %2").arg(bytesReceived).arg(bytesToReceive); } else { if (d->m_bytesReceived > 0) - status = humanReadableSize(d->m_bytesReceived) + tr(" downloaded."); + status = tr("%1 downloaded.").arg(humanReadableSize(d->m_bytesReceived)); } - status += QLatin1String(" (") + humanReadableSize(d->m_downloadSpeed) + tr("/sec") + QLatin1Char(')'); + status += QLatin1Char(' ') + tr("(%1/sec)").arg(humanReadableSize(d->m_downloadSpeed)); if (d->m_bytesToReceive > 0 && d->m_downloadSpeed > 0) { const qint64 time = (d->m_bytesToReceive - d->m_bytesReceived) / d->m_downloadSpeed; @@ -337,22 +337,22 @@ void KDUpdater::FileDownloader::emitDownloadStatus() QString days; if (d > 0) - days = QString::number(d) + (d < 2 ? tr(" day") : tr(" days")) + QLatin1String(", "); + days = tr("%n day(s), ", "", d); QString hours; if (h > 0) - hours = QString::number(h) + (h < 2 ? tr(" hour") : tr(" hours")) + QLatin1String(", "); + hours = tr("%n hour(s), ", "", h); QString minutes; if (m > 0) - minutes = QString::number(m) + (m < 2 ? tr(" minute") : tr(" minutes")); + minutes = tr("%n minute(s)", "", m); QString seconds; if (s >= 0 && minutes.isEmpty()) { s = (s <= 0 ? 1 : s); - seconds = QString::number(s) + (s < 2 ? tr(" second") : tr(" seconds")); + seconds = tr("%n second(s)", "", s); } - status += tr(" - ") + days + hours + minutes + seconds + tr(" remaining."); + status += tr(" - %1%2%3%4 remaining.").arg(days).arg(hours).arg(minutes).arg(seconds); } else { status += tr(" - unknown time remaining."); } diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp index f37fa9244..e53c47280 100644 --- a/src/libs/kdtools/kdupdaterupdatefinder.cpp +++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp @@ -227,7 +227,7 @@ void UpdateFinder::Private::computeUpdates() } // All done - q->reportProgress(100, tr("%1 updates found.").arg(updates.count())); + q->reportProgress(100, tr("%n update(s) found.", "", updates.count())); q->reportDone(); } diff --git a/src/sdk/translations/de_de.ts b/src/sdk/translations/de_de.ts index d832d8183..d6f033e69 100644 --- a/src/sdk/translations/de_de.ts +++ b/src/sdk/translations/de_de.ts @@ -2057,7 +2057,7 @@ Bitte kopieren Sie den Installer auf ein lokales Laufwerk</translation> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libs/installer/packagemanagergui.cpp" line="1733"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation>&Deinstallieren</translation> </message> <message> diff --git a/src/sdk/translations/en_us.ts b/src/sdk/translations/en_us.ts index 330f5f394..a5d636a2c 100644 --- a/src/sdk/translations/en_us.ts +++ b/src/sdk/translations/en_us.ts @@ -1902,7 +1902,7 @@ Please copy the installer to a local drive</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libs/installer/packagemanagergui.cpp" line="1733"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/sdk/translations/ru_ru.ts b/src/sdk/translations/ru_ru.ts index 65c35d62a..f7fcf2917 100644 --- a/src/sdk/translations/ru_ru.ts +++ b/src/sdk/translations/ru_ru.ts @@ -1921,7 +1921,7 @@ Please copy the installer to a local drive</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libs/installer/packagemanagergui.cpp" line="1733"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation>&Удалить</translation> </message> <message> diff --git a/src/sdk/translations/sv_se.ts b/src/sdk/translations/sv_se.ts index 4dafb0cac..c6557cdab 100644 --- a/src/sdk/translations/sv_se.ts +++ b/src/sdk/translations/sv_se.ts @@ -1815,7 +1815,7 @@ Installing component %1</source> <name>QInstaller::PerformInstallationPage</name> <message> <location filename="../../libinstaller/packagemanagergui.cpp" line="1776"/> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation type="unfinished"></translation> </message> <message> diff --git a/src/sdk/translations/zh_cn.ts b/src/sdk/translations/zh_cn.ts index 58acbd106..022d368ec 100644 --- a/src/sdk/translations/zh_cn.ts +++ b/src/sdk/translations/zh_cn.ts @@ -1606,7 +1606,7 @@ Please copy the installer to a local drive</source> <context> <name>QInstaller::PerformInstallationPage</name> <message> - <source>&Uninstall</source> + <source>U&ninstall</source> <translation>卸载(&U)</translation> </message> <message> diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro index 414c952d7..c405cf087 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -13,5 +13,6 @@ SUBDIRS += \ mkdiroperationtest \ copyoperationtest \ solver \ - binaryformat + binaryformat \ + packagemanagercore diff --git a/tests/auto/installer/packagemanagercore/installer-config/config.xml b/tests/auto/installer/packagemanagercore/installer-config/config.xml new file mode 100644 index 000000000..adc24631b --- /dev/null +++ b/tests/auto/installer/packagemanagercore/installer-config/config.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Installer> + <Name>test</Name> + <Version>1.0.0</Version> +</Installer> diff --git a/tests/auto/installer/packagemanagercore/packagemanagercore.pro b/tests/auto/installer/packagemanagercore/packagemanagercore.pro new file mode 100644 index 000000000..c78393540 --- /dev/null +++ b/tests/auto/installer/packagemanagercore/packagemanagercore.pro @@ -0,0 +1,10 @@ +include(../../qttest.pri) + +QT += script +lessThan(QT_MAJOR_VERSION, 5) { + QT -= gui +} +SOURCES += tst_packagemanagercore.cpp + +RESOURCES += \ + settings.qrc diff --git a/tests/auto/installer/packagemanagercore/settings.qrc b/tests/auto/installer/packagemanagercore/settings.qrc new file mode 100644 index 000000000..b25a589a3 --- /dev/null +++ b/tests/auto/installer/packagemanagercore/settings.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/metadata"> + <file>installer-config/config.xml</file> + </qresource> +</RCC> diff --git a/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp new file mode 100644 index 000000000..8a7af4a0b --- /dev/null +++ b/tests/auto/installer/packagemanagercore/tst_packagemanagercore.cpp @@ -0,0 +1,153 @@ +/************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Installer Framework. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** 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. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +**************************************************************************/ + +#include <binaryformat.h> +#include <component.h> +#include <errors.h> +#include <fileutils.h> +#include <packagemanagercore.h> +#include <progresscoordinator.h> + +#include <QDir> +#include <QTemporaryFile> +#include <QTest> + +using namespace QInstaller; + +class DummyComponent : public Component +{ +public: + DummyComponent(PackageManagerCore *core) + : Component(core) + { + setCheckState(Qt::Checked); + } + + void beginInstallation() + { + throw Error(tr("Force crash to test rollback!")); + } + + ~DummyComponent() + { + } +}; + +class tst_PackageManagerCore : public QObject +{ + Q_OBJECT + +private: + void setIgnoreMessage(const QString &testDirectory) + { + const QString message = "\"\t- arguments: %1\" "; + QTest::ignoreMessage(QtDebugMsg, "\"backup operation: Mkdir\" "); + QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory))); + QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory))); + QTest::ignoreMessage(QtDebugMsg, qPrintable(message.arg(testDirectory))); + QTest::ignoreMessage(QtDebugMsg, "\"perform operation: Mkdir\" "); + QTest::ignoreMessage(QtDebugMsg, "Install size: 1 components "); + QTest::ignoreMessage(QtDebugMsg, "create Error-Exception: \"Force crash to test rollback!\" "); + QTest::ignoreMessage(QtDebugMsg, "\"created critical message box installationError: 'Error" + "', Force crash to test rollback!\" "); + QTest::ignoreMessage(QtDebugMsg, "ROLLING BACK operations= 1 "); + QTest::ignoreMessage(QtDebugMsg, "\"undo operation: Mkdir\" "); + QTest::ignoreMessage(QtDebugMsg, "Done "); + QTest::ignoreMessage(QtDebugMsg, "Done "); + QTest::ignoreMessage(QtDebugMsg, "Done "); + } + +private slots: + void testRollBackInstallationKeepTarget() + { + + const QString testDirectory = QInstaller::generateTemporaryFileName(); + QVERIFY(QDir().mkpath(testDirectory)); + + setIgnoreMessage(testDirectory); + + PackageManagerCore core(MagicInstallerMarker); + // cancel the installer in error case + core.autoRejectMessageBoxes(); + core.appendRootComponent(new DummyComponent(&core)); + core.setValue(QLatin1String("TargetDir"), testDirectory); + core.setValue(QLatin1String("RemoveTargetDir"), QLatin1String("true")); + + QVERIFY(core.calculateComponentsToInstall()); + { + QTemporaryFile dummy(testDirectory + QLatin1String("/dummy")); + dummy.open(); + + core.runInstaller(); + + QVERIFY(QDir(testDirectory).exists()); + QVERIFY(QFileInfo(dummy.fileName()).exists()); + } + QDir().rmdir(testDirectory); + ProgressCoordinator::instance()->reset(); + } + + void testRollBackInstallationRemoveTarget() + { + const QString testDirectory = QInstaller::generateTemporaryFileName(); + QVERIFY(QDir().mkpath(testDirectory)); + + setIgnoreMessage(testDirectory); + + PackageManagerCore core(MagicInstallerMarker); + // cancel the installer in error case + core.autoRejectMessageBoxes(); + core.appendRootComponent(new DummyComponent(&core)); + core.setValue(QLatin1String("TargetDir"), testDirectory); + core.setValue(QLatin1String("RemoveTargetDir"), QLatin1String("true")); + + QVERIFY(core.calculateComponentsToInstall()); + + core.runInstaller(); + QVERIFY(!QDir(testDirectory).exists()); + ProgressCoordinator::instance()->reset(); + } +}; + + +QTEST_MAIN(tst_PackageManagerCore) + +#include "tst_packagemanagercore.moc" diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp index 8589192bb..3e1e755dd 100644 --- a/tools/binarycreator/binarycreator.cpp +++ b/tools/binarycreator/binarycreator.cpp @@ -463,7 +463,7 @@ static void printUsage() std::cout << " -c|--config file The file containing the installer configuration" << std::endl; - std::cout << " -n|--online-only Don't add any package into the installer" << std::endl; + std::cout << " -n|--online-only Do not add any package into the installer" << std::endl; std::cout << " (for online only installers)" << std::endl; std::cout << " -f|--offline-only Forces the installer to act as an offline installer, " << std::endl; @@ -583,7 +583,7 @@ int main(int argc, char **argv) QString target; QString configFile; - QString packagesDirectory = QDir::currentPath(); + QStringList packagesDirectories; bool onlineOnly = false; bool offlineOnly = false; QStringList resources; @@ -605,7 +605,7 @@ int main(int argc, char **argv) return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package directory not found at the " "specified location.")); } - packagesDirectory = *it; + packagesDirectories.append(*it); } else if (*it == QLatin1String("-e") || *it == QLatin1String("--exclude")) { ++it; if (!filteredPackages.isEmpty()) @@ -711,15 +711,18 @@ int main(int argc, char **argv) if (configFile.isEmpty()) return printErrorAndUsageAndExit(QString::fromLatin1("Error: No configuration file selected.")); + if (packagesDirectories.isEmpty()) + return printErrorAndUsageAndExit(QString::fromLatin1("Error: Package directory parameter missing.")); + qDebug() << "Parsed arguments, ok."; int exitCode = EXIT_FAILURE; const QString tmpMetaDir = QInstaller::createTemporaryDirectory(); try { const Settings settings = Settings::fromFileAndPrefix(configFile, QFileInfo(configFile).absolutePath()); - QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDirectory, + QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDirectories, &filteredPackages, ftype); - QInstallerTools::copyMetaData(tmpMetaDir, packagesDirectory, packages, settings.applicationName(), + QInstallerTools::copyMetaData(tmpMetaDir, packagesDirectories.first(), packages, settings.applicationName(), settings.applicationVersion()); copyConfigData(configFile, tmpMetaDir + QLatin1String("/installer-config")); @@ -743,7 +746,7 @@ int main(int argc, char **argv) input.binaryResourcePath = createBinaryResourceFile(tmpMetaDir, generateTemporaryFileName()); input.binaryResources = createBinaryResourceFiles(resources); - QInstallerTools::copyComponentData(packagesDirectory, tmpMetaDir, &packages); + QInstallerTools::copyComponentData(packagesDirectories, tmpMetaDir, &packages); // now put the packages into the components section of the binary foreach (const QInstallerTools::PackageInfo &info, packages) { diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index 2af72f0cb..609844829 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -62,13 +62,13 @@ using namespace QInstallerTools; void QInstallerTools::printRepositoryGenOptions() { std::cout << " -p|--packages dir The directory containing the available packages." << std::endl; - std::cout << " Defaults to the current working directory." << std::endl; + std::cout << " This entry can be given multiple times." << std::endl; std::cout << " -e|--exclude p1,...,pn Exclude the given packages." << std::endl; std::cout << " -i|--include p1,...,pn Include the given packages and their dependencies" << std::endl; std::cout << " from the repository." << std::endl; - std::cout << " --ignore-translations Don't use any translation" << std::endl; + std::cout << " --ignore-translations Do not use any translation" << std::endl; std::cout << " --ignore-invalid-packages Ignore all invalid packages instead of aborting." << std::endl; } @@ -120,7 +120,7 @@ static QStringList copyFilesFromNode(const QString &parentNode, const QString &c const QString filter = attr.isEmpty() ? node.toElement().text() : node.toElement().attribute(attr); const QStringList files = dir.entryList(QStringList(filter), QDir::Files); if (files.isEmpty()) { - throw QInstaller::Error(QString::fromLatin1("Couldn't find any %1 matching '%2' " + throw QInstaller::Error(QString::fromLatin1("Could not find any %1 matching '%2' " "while copying %1 of '%3'.").arg(kind, filter, info.name)); } @@ -382,7 +382,7 @@ void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &met QInstaller::blockingWrite(&targetUpdatesXml, doc.toByteArray()); } -PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesDirectory, +PackageInfoVector QInstallerTools::createListOfPackages(const QStringList &packagesDirectories, QStringList *packagesToFilter, FilterType filterType) { qDebug() << "\nCollecting information about available packages..."; @@ -390,7 +390,9 @@ PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesD bool ignoreInvalidPackages = qApp->arguments().contains(QString::fromLatin1("--ignore-invalid-packages")); PackageInfoVector dict; - const QFileInfoList entries = QDir(packagesDirectory).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + QFileInfoList entries; + foreach (const QString &packagesDirectory, packagesDirectories) + entries.append(QDir(packagesDirectory).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)); for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) { if (filterType == Exclude) { // Check for current file in exclude list, if found, skip it and remove it from exclude list @@ -409,7 +411,7 @@ PackageInfoVector QInstallerTools::createListOfPackages(const QString &packagesD if (it->fileName().contains(QLatin1Char('-'))) { if (ignoreInvalidPackages) continue; - throw QInstaller::Error(QString::fromLatin1("Component '%1' mustn't contain '-'. This is not " + throw QInstaller::Error(QString::fromLatin1("Component '%1' must not contain '-'. This is not " "allowed, because dashes are used as the separator between the component name and the " "version number internally.").arg(it->fileName())); } @@ -551,7 +553,7 @@ void QInstallerTools::compressMetaDirectories(const QString &repoDir, const QStr existingUpdatesXml.close(); } -void QInstallerTools::copyComponentData(const QString &packageDir, const QString &repoDir, +void QInstallerTools::copyComponentData(const QStringList &packageDirs, const QString &repoDir, PackageInfoVector *const infos) { for (int i = 0; i < infos->count(); ++i) { @@ -567,31 +569,33 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString QStringList compressedFiles; QStringList filesToCompress; - const QDir dataDir(QString::fromLatin1("%1/%2/data").arg(packageDir, name)); - foreach (const QString &entry, dataDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files)) { - QFileInfo fileInfo(dataDir.absoluteFilePath(entry)); - if (fileInfo.isFile() && !fileInfo.isSymLink()) { - const QString absoluteEntryFilePath = dataDir.absoluteFilePath(entry); - if (Lib7z::isSupportedArchive(absoluteEntryFilePath)) { - QFile tmp(absoluteEntryFilePath); - QString target = QString::fromLatin1("%1/%3%2").arg(namedRepoDir, entry, info.version); - qDebug() << QString::fromLatin1("Copying archive from '%1' to '%2'").arg(tmp.fileName(), - target); - if (!tmp.copy(target)) { - throw QInstaller::Error(QString::fromLatin1("Could not copy '%1' to '%2': %3") - .arg(tmp.fileName(), target, tmp.errorString())); + foreach (const QString &packageDir, packageDirs) { + const QDir dataDir(QString::fromLatin1("%1/%2/data").arg(packageDir, name)); + foreach (const QString &entry, dataDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files)) { + QFileInfo fileInfo(dataDir.absoluteFilePath(entry)); + if (fileInfo.isFile() && !fileInfo.isSymLink()) { + const QString absoluteEntryFilePath = dataDir.absoluteFilePath(entry); + if (Lib7z::isSupportedArchive(absoluteEntryFilePath)) { + QFile tmp(absoluteEntryFilePath); + QString target = QString::fromLatin1("%1/%3%2").arg(namedRepoDir, entry, info.version); + qDebug() << QString::fromLatin1("Copying archive from '%1' to '%2'").arg(tmp.fileName(), + target); + if (!tmp.copy(target)) { + throw QInstaller::Error(QString::fromLatin1("Could not copy '%1' to '%2': %3") + .arg(tmp.fileName(), target, tmp.errorString())); + } + compressedFiles.append(target); + } else { + filesToCompress.append(absoluteEntryFilePath); } + } else if (fileInfo.isDir()) { + qDebug() << "Compressing data directory" << entry; + QString target = QString::fromLatin1("%1/%3%2.7z").arg(namedRepoDir, entry, info.version); + QInstallerTools::compressPaths(QStringList() << dataDir.absoluteFilePath(entry), target); compressedFiles.append(target); - } else { - filesToCompress.append(absoluteEntryFilePath); + } else if (fileInfo.isSymLink()) { + filesToCompress.append(dataDir.absoluteFilePath(entry)); } - } else if (fileInfo.isDir()) { - qDebug() << "Compressing data directory" << entry; - QString target = QString::fromLatin1("%1/%3%2.7z").arg(namedRepoDir, entry, info.version); - QInstallerTools::compressPaths(QStringList() << dataDir.absoluteFilePath(entry), target); - compressedFiles.append(target); - } else if (fileInfo.isSymLink()) { - filesToCompress.append(dataDir.absoluteFilePath(entry)); } } diff --git a/tools/common/repositorygen.h b/tools/common/repositorygen.h index b415bd561..c7bdfa457 100644 --- a/tools/common/repositorygen.h +++ b/tools/common/repositorygen.h @@ -68,7 +68,7 @@ void printRepositoryGenOptions(); QString makePathAbsolute(const QString &path); void copyWithException(const QString &source, const QString &target, const QString &kind = QString()); -PackageInfoVector createListOfPackages(const QString &packagesDirectory, QStringList *packagesToFilter, +PackageInfoVector createListOfPackages(const QStringList &packagesDirectories, QStringList *packagesToFilter, FilterType ftype); QHash<QString, QString> buildPathToVersionMapping(const PackageInfoVector &info); @@ -78,7 +78,7 @@ void compressMetaDirectories(const QString &repoDir, const QString &baseDir, void copyMetaData(const QString &outDir, const QString &dataDir, const PackageInfoVector &packages, const QString &appName, const QString& appVersion); -void copyComponentData(const QString &packageDir, const QString &repoDir, PackageInfoVector *const infos); +void copyComponentData(const QStringList &packageDir, const QString &repoDir, PackageInfoVector *const infos); } // namespace QInstallerTools diff --git a/tools/extractbinarydata/main.cpp b/tools/extractbinarydata/main.cpp index a87f3a222..de7acd9af 100644 --- a/tools/extractbinarydata/main.cpp +++ b/tools/extractbinarydata/main.cpp @@ -181,7 +181,7 @@ int main(int argc, char **argv) file.setPermissions(file.permissions() | QFile::WriteUser | QFile::ReadGroup | QFile::ReadOther); if (!file.commit(KDSaveFile::OverwriteExistingFile)) { - throw Error(QString::fromLatin1("Couldn't write binary data to %1. Reason: %2").arg(file + throw Error(QString::fromLatin1("Could not write binary data to %1. Reason: %2").arg(file .fileName(), file.errorString())); } file.close(); diff --git a/tools/getrepositorycontent/main.cpp b/tools/getrepositorycontent/main.cpp index 66a2ec43f..c84826359 100644 --- a/tools/getrepositorycontent/main.cpp +++ b/tools/getrepositorycontent/main.cpp @@ -221,7 +221,7 @@ QHash<QString, ComponentData> downLoadRepository(const QString &repositoryUrl, c itComponentData.next(); QString componentDirectory = QDir(repositoryTarget).filePath(itComponentData.key()); if (!QDir().mkpath(componentDirectory)) - qWarning() << "couldn't create:" << componentDirectory; + qWarning() << "could not create:" << componentDirectory; foreach (const QString &download, itComponentData.value().m_downloadDownloadableArchives) { const QString fileTarget(componentDirectory + QDir::separator() + download); @@ -377,7 +377,7 @@ int main(int argc, char *argv[]) QDir().mkpath(pathToTarget); QFile file; if (!file.copy(absoluteSourceFilePath, target)) { - qWarning() << QString::fromLatin1("copy file %1 to %2 wasn't working %3").arg( + qWarning() << QString::fromLatin1("copy file %1 to %2 was not working %3").arg( absoluteSourceFilePath, target, file.errorString()); } } diff --git a/tools/repogen/repogen.cpp b/tools/repogen/repogen.cpp index e0e0a88c0..4273837d2 100644 --- a/tools/repogen/repogen.cpp +++ b/tools/repogen/repogen.cpp @@ -107,7 +107,7 @@ int main(int argc, char** argv) QStringList filteredPackages; bool updateExistingRepository = false; - QString packagesDir; + QStringList packagesDirectories; QInstallerTools::FilterType filterType = QInstallerTools::Exclude; bool remove = false; bool updateExistingRepositoryWithNewComponents = false; @@ -153,7 +153,7 @@ int main(int argc, char** argv) return printErrorAndUsageAndExit(QObject::tr("Error: Package directory not found " "at the specified location")); } - packagesDir = args.first(); + packagesDirectories.append(args.first()); args.removeFirst(); } else if (args.first() == QLatin1String("-c") || args.first() == QLatin1String("--config")) { args.removeFirst(); @@ -173,7 +173,7 @@ int main(int argc, char** argv) } } - if (packagesDir.isEmpty() || (args.count() != 1)) { + if (packagesDirectories.isEmpty() || (args.count() != 1)) { printUsage(); return 1; } @@ -195,7 +195,7 @@ int main(int argc, char** argv) .arg(repositoryDir)); } - QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDir, + QInstallerTools::PackageInfoVector packages = QInstallerTools::createListOfPackages(packagesDirectories, &filteredPackages, filterType); if (updateExistingRepositoryWithNewComponents) { @@ -252,7 +252,7 @@ int main(int argc, char** argv) } tmpMetaDir = QInstaller::createTemporaryDirectory(); - QInstallerTools::copyComponentData(packagesDir, repositoryDir, &packages); + QInstallerTools::copyComponentData(packagesDirectories, repositoryDir, &packages); QInstallerTools::copyMetaData(tmpMetaDir, repositoryDir, packages, QLatin1String("{AnyApplication}"), QLatin1String(QUOTE(IFW_REPOSITORY_FORMAT_VERSION))); QInstallerTools::compressMetaDirectories(tmpMetaDir, tmpMetaDir, pathToVersionMapping); |