diff options
author | Tim Jenssen <tim.jenssen@nokia.com> | 2011-10-05 17:49:52 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@nokia.com> | 2011-10-05 18:14:30 +0200 |
commit | ce7ffebf0702fcee50e96e2f7f33d3ab347c758a (patch) | |
tree | 3fa51e91162c711afb3ff17e05ef094469782518 | |
parent | 53432722c736b47c68af48bff2d6cf37b526df40 (diff) |
show dependency calculation errors in the installer
- renamed missingDependenciesReasons -> calculateComponentsToInstallError
- abort adding components if a recursion is detected
Change-Id: Ie9c3bda0b8482eb0e54a9eff6bb8a5868d3d9ee8
Reviewed-on: http://codereview.qt-project.org/6082
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
5 files changed, 38 insertions, 28 deletions
diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp index 3f658207b..24e453660 100644 --- a/installerbuilder/libinstaller/packagemanagercore.cpp +++ b/installerbuilder/libinstaller/packagemanagercore.cpp @@ -929,9 +929,9 @@ QList<Component*> PackageManagerCore::componentsToUninstall() const return d->m_componentsToUninstall.toList(); } -QStringList PackageManagerCore::missingDependenciesReasons() const +QString PackageManagerCore::componentsToInstallError() const { - return d->m_missingDependenciesReasons; + return d->m_componentsToInstallError; } /*! diff --git a/installerbuilder/libinstaller/packagemanagercore.h b/installerbuilder/libinstaller/packagemanagercore.h index 0995cac79..e769b47fc 100644 --- a/installerbuilder/libinstaller/packagemanagercore.h +++ b/installerbuilder/libinstaller/packagemanagercore.h @@ -158,7 +158,7 @@ public: bool calculateComponentsToUninstall() const; QList<Component*> componentsToUninstall() const; - QStringList missingDependenciesReasons() const; + QString componentsToInstallError() const; QString installReason(Component *component) const; QList<Component*> dependees(const Component *component) const; diff --git a/installerbuilder/libinstaller/packagemanagercore_p.cpp b/installerbuilder/libinstaller/packagemanagercore_p.cpp index 375b48f2b..6af2ffeb1 100644 --- a/installerbuilder/libinstaller/packagemanagercore_p.cpp +++ b/installerbuilder/libinstaller/packagemanagercore_p.cpp @@ -310,7 +310,7 @@ void PackageManagerCorePrivate::clearComponentsToInstall() { m_visitedComponents.clear(); m_toInstallComponentIds.clear(); - m_missingDependenciesReasons.clear(); + m_componentsToInstallError.clear(); m_orderedComponentsToInstall.clear(); m_toInstallComponentIdReasonHash.clear(); } @@ -339,9 +339,10 @@ bool PackageManagerCorePrivate::appendComponentsToInstall(const QList<Component* QList<Component*> notAppendedComponents; // for example components with unresolved dependencies foreach (Component *component, components){ if (m_toInstallComponentIds.contains(component->name())) { - const QString errorMessage = QString::fromLatin1("Recursion detected component(%1) already added " - "with reason: %2.").arg(component->name(), installReason(component)); + QString errorMessage = QString::fromLatin1("Recursion detected component(%1) already added with " + "reason: \"%2\"").arg(component->name(), installReason(component)); verbose() << qPrintable(errorMessage) << std::endl; + m_componentsToInstallError.append(errorMessage); Q_ASSERT_X(!m_toInstallComponentIds.contains(component->name()), Q_FUNC_INFO, qPrintable(errorMessage)); return false; @@ -353,31 +354,30 @@ bool PackageManagerCorePrivate::appendComponentsToInstall(const QList<Component* notAppendedComponents.append(component); } - bool allComponentsAdded = true; - foreach (Component *component, notAppendedComponents) - allComponentsAdded &= appendComponentToInstall(component); + foreach (Component *component, notAppendedComponents) { + if (!appendComponentToInstall(component)) + return false; + } QList<Component*> foundAutoDependOnList; - if (allComponentsAdded) { - // All regular dependencies are resolved. Now we are looking for auto depend on components. - foreach (Component *component, m_core->availableComponents()) { - // If a components is already installed or is scheduled for installation, no need to check for - // auto depend installation. - if ((!component->isInstalled() || component->updateRequested()) - && !m_toInstallComponentIds.contains(component->name())) { - // If we figure out a component requests auto installation, keep it to resolve their deps as - // well. - if (component->isAutoDependOn(m_toInstallComponentIds)) { - foundAutoDependOnList.append(component); - insertInstallReason(component, tr("Component(s) added as automatic dependencies")); - } + // All regular dependencies are resolved. Now we are looking for auto depend on components. + foreach (Component *component, m_core->availableComponents()) { + // If a components is already installed or is scheduled for installation, no need to check for + // auto depend installation. + if ((!component->isInstalled() || component->updateRequested()) + && !m_toInstallComponentIds.contains(component->name())) { + // If we figure out a component requests auto installation, keep it to resolve their deps as + // well. + if (component->isAutoDependOn(m_toInstallComponentIds)) { + foundAutoDependOnList.append(component); + insertInstallReason(component, tr("Component(s) added as automatic dependencies")); } } } if (!foundAutoDependOnList.isEmpty()) return appendComponentsToInstall(foundAutoDependOnList); - return allComponentsAdded; + return true; } bool PackageManagerCorePrivate::appendComponentToInstall(Component *component) @@ -397,15 +397,22 @@ bool PackageManagerCorePrivate::appendComponentToInstall(Component *component) " %2."); errorMessage = errorMessage.arg(dependencyComponentName, component->name()); verbose() << qPrintable(errorMessage) << std::endl; - m_missingDependenciesReasons.append(errorMessage); + m_componentsToInstallError.append(errorMessage); Q_ASSERT_X(false, Q_FUNC_INFO, qPrintable(errorMessage)); return false; } if ((!dependencyComponent->isInstalled() || dependencyComponent->updateRequested()) && !m_toInstallComponentIds.contains(dependencyComponent->name())) { - if (m_visitedComponents.value(component).contains(dependencyComponent)) + if (m_visitedComponents.value(component).contains(dependencyComponent)) { + QString errorMessage = QString::fromLatin1("Recursion detected component(%1) already " + "added with reason: \"%2\"").arg(component->name(), installReason(component)); + verbose() << qPrintable(errorMessage) << std::endl; + m_componentsToInstallError = errorMessage; + Q_ASSERT_X(!m_visitedComponents.value(component).contains(dependencyComponent), Q_FUNC_INFO, + qPrintable(errorMessage)); return false; + } m_visitedComponents[component].insert(dependencyComponent); // add needed dependency components to the next run diff --git a/installerbuilder/libinstaller/packagemanagercore_p.h b/installerbuilder/libinstaller/packagemanagercore_p.h index 3fc87a81a..952a5fa6d 100644 --- a/installerbuilder/libinstaller/packagemanagercore_p.h +++ b/installerbuilder/libinstaller/packagemanagercore_p.h @@ -239,7 +239,7 @@ private: QHash<QString, QString> m_toInstallComponentIdReasonHash; QSet<Component*> m_componentsToUninstall; - QStringList m_missingDependenciesReasons; + QString m_componentsToInstallError; QHash<Component*, QSet<QString> > m_autoDependOnDependencies; private: diff --git a/installerbuilder/libinstaller/packagemanagergui.cpp b/installerbuilder/libinstaller/packagemanagergui.cpp index d0b53434c..0c079e709 100644 --- a/installerbuilder/libinstaller/packagemanagergui.cpp +++ b/installerbuilder/libinstaller/packagemanagergui.cpp @@ -1570,8 +1570,11 @@ void ReadyForInstallationPage::refreshTaskDetailsBrowser() !packageManagerCore()->calculateComponentsToInstall()) { htmlOutput.append(QString::fromLatin1("<h2><font color=\"red\">%1</font></h2><ul>") .arg(tr("Can not resolve all dependencies!"))); - foreach (const QString &reason, packageManagerCore()->missingDependenciesReasons()) - htmlOutput.append(QString::fromLatin1("<li> %1 </li>").arg(reason)); + //if we have a missing dependency or a recursion we can display it + if (!packageManagerCore()->componentsToInstallError().isEmpty()) { + htmlOutput.append(QString::fromLatin1("<li> %1 </li>").arg( + packageManagerCore()->componentsToInstallError())); + } htmlOutput.append(QLatin1String("</ul>")); m_taskDetailsBrowser->setHtml(htmlOutput); if (!m_taskDetailsBrowser->isVisible()) |