summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/packagemanagercore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/installer/packagemanagercore.cpp')
-rw-r--r--src/libs/installer/packagemanagercore.cpp74
1 files changed, 48 insertions, 26 deletions
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index 66220bd1d..0eae41ea3 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -146,6 +146,8 @@ using namespace QInstaller;
Installation has to be updated.
\value EssentialUpdated
Installation essential components were updated.
+ \value NoPackagesFound
+ No packages found from remote.
*/
/*!
@@ -1701,7 +1703,7 @@ bool PackageManagerCore::fetchPackagesWithFallbackRepositories(const QStringList
return false;
qCDebug(QInstaller::lcInstallerInstallLog).noquote()
- << "Components not found for installation with the current selection."
+ << "Components not found with the current selection."
<< "Searching from additional repositories";
if (!ProductKeyCheck::instance()->securityWarning().isEmpty()) {
qCWarning(QInstaller::lcInstallerInstallLog) << ProductKeyCheck::instance()->securityWarning();
@@ -1754,6 +1756,7 @@ bool PackageManagerCore::fetchRemotePackagesTree(const QStringList& components)
if (!d->installablePackagesFound(components))
return false;
+ d->m_componentsToBeInstalled = components;
return fetchPackagesTree(packages, installedPackages);
}
@@ -2681,6 +2684,7 @@ ComponentSortFilterProxyModel *PackageManagerCore::componentSortFilterProxyModel
bool PackageManagerCore::listAvailablePackages(const QString &regexp, const QHash<QString, QString> &filters)
{
setPackageViewer();
+ d->enableAllCategories();
qCDebug(QInstaller::lcInstallerInstallLog)
<< "Searching packages with regular expression:" << regexp;
@@ -2748,33 +2752,22 @@ bool PackageManagerCore::listAvailablePackages(const QString &regexp, const QHas
bool PackageManagerCore::listAvailableAliases(const QString &regexp)
{
setPackageViewer();
+ d->enableAllCategories();
qCDebug(QInstaller::lcInstallerInstallLog)
<< "Searching aliases with regular expression:" << regexp;
- ComponentModel *model = defaultComponentModel();
- Q_UNUSED(model);
-
- if (!d->m_updates) {
- d->fetchMetaInformationFromRepositories();
- d->addUpdateResourcesFromRepositories();
-
- const PackagesList &packages = d->remotePackages();
- if (!fetchAllPackages(packages, LocalPackagesMap())) {
- qCWarning(QInstaller::lcInstallerInstallLog)
- << "There was a problem with loading the package data.";
- return false;
- }
- }
+ if (!d->buildComponentAliases())
+ return false;
QRegularExpression re(regexp);
re.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
QList<ComponentAlias *> matchedAliases;
- for (auto *alias : qAsConst(d->m_componentAliases)) {
+ for (auto *alias : std::as_const(d->m_componentAliases)) {
if (!alias)
continue;
- if (re.match(alias->name()).hasMatch() && !alias->isUnstable()) {
+ if (re.match(alias->name()).hasMatch()) {
if (alias->isVirtual() && !virtualComponentsVisible())
continue;
@@ -2833,7 +2826,7 @@ bool PackageManagerCore::componentUninstallableFromCommandLine(const QString &co
eligible for installation, otherwise returns \c false. An error message can be retrieved
with \a errorMessage.
*/
-bool PackageManagerCore::checkComponentsForInstallation(const QStringList &names, QString &errorMessage, bool &unstableAliasFound)
+bool PackageManagerCore::checkComponentsForInstallation(const QStringList &names, QString &errorMessage, bool &unstableAliasFound, bool fallbackReposFetched)
{
bool installComponentsFound = false;
@@ -2847,11 +2840,16 @@ bool PackageManagerCore::checkComponentsForInstallation(const QStringList &names
errorMessage.append(tr("Cannot select alias %1. There was a problem loading this alias, "
"so it is marked unstable and cannot be selected.").arg(name) + QLatin1Char('\n'));
unstableAliasFound = true;
- continue;
+ setCanceled();
+ return false;
} else if (alias->isVirtual()) {
errorMessage.append(tr("Cannot select %1. Alias is marked virtual, meaning it cannot "
"be selected manually.").arg(name) + QLatin1Char('\n'));
continue;
+ } else if (alias->missingOptionalComponents() && !fallbackReposFetched) {
+ unstableAliasFound = true;
+ setCanceled();
+ return false;
}
alias->setSelected(true);
@@ -2934,6 +2932,25 @@ void PackageManagerCore::listInstalledPackages(const QString &regexp)
LoggingHandler::instance().printLocalPackageInformation(packages);
}
+PackageManagerCore::Status PackageManagerCore::searchAvailableUpdates()
+{
+ setUpdater();
+ d->enableAllCategories();
+ if (!fetchRemotePackagesTree()) {
+ qCWarning(QInstaller::lcInstallerInstallLog) << error();
+ return status();
+ }
+
+ const QList<QInstaller::Component *> availableUpdates =
+ components(QInstaller::PackageManagerCore::ComponentType::Root);
+ if (availableUpdates.isEmpty()) {
+ qCWarning(QInstaller::lcInstallerInstallLog) << "There are currently no updates available.";
+ return status();
+ }
+ QInstaller::LoggingHandler::instance().printUpdateInformation(availableUpdates);
+ return status();
+}
+
/*!
Updates the selected components \a componentsToUpdate without GUI.
If essential components are found, then only those will be updated.
@@ -2945,14 +2962,19 @@ PackageManagerCore::Status PackageManagerCore::updateComponentsSilently(const QS
ComponentModel *model = updaterComponentModel();
- bool fallbackReposFetched = false;
- bool packagesFound = fetchPackagesWithFallbackRepositories(componentsToUpdate, fallbackReposFetched);
+ if (componentsToUpdate.isEmpty()) {
+ d->enableAllCategories();
+ fetchRemotePackagesTree();
+ } else {
+ bool fallbackReposFetched = false;
+ bool packagesFound = fetchPackagesWithFallbackRepositories(componentsToUpdate, fallbackReposFetched);
- if (!packagesFound) {
- qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace()
- << "No components available for update with the current selection.";
- d->setStatus(Canceled);
- return status();
+ if (!packagesFound) {
+ qCDebug(QInstaller::lcInstallerInstallLog).noquote().nospace()
+ << "No components available for update with the current selection.";
+ d->setStatus(Canceled);
+ return status();
+ }
}
// List contains components containing update, if essential found contains only essential component