fixed includes, cli interface for upgrade lookup
This commit is contained in:
parent
bf59a5746d
commit
98e565b8c3
|
@ -1,8 +1,8 @@
|
|||
#include "alpmdatabase.h"
|
||||
#include "group.h"
|
||||
#include "upgradelookup.h"
|
||||
#include "alpmpackage.h"
|
||||
#include "utilities.h"
|
||||
#include "./alpmdatabase.h"
|
||||
#include "./group.h"
|
||||
#include "./upgradelookup.h"
|
||||
#include "./alpmpackage.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ALPM_DATABASE_H
|
||||
#define ALPM_DATABASE_H
|
||||
|
||||
#include "repository.h"
|
||||
#include "list.h"
|
||||
#include "./repository.h"
|
||||
#include "./list.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QMutex>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "alpmpackage.h"
|
||||
#include "alpmdatabase.h"
|
||||
#include "utilities.h"
|
||||
#include "./alpmpackage.h"
|
||||
#include "./alpmdatabase.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PACKAGEMANAGEMENT_ALPMPACKAGE_H
|
||||
#define PACKAGEMANAGEMENT_ALPMPACKAGE_H
|
||||
|
||||
#include "package.h"
|
||||
#include "./package.h"
|
||||
|
||||
namespace RepoIndex {
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "aurpackage.h"
|
||||
#include "./aurpackage.h"
|
||||
|
||||
#include "repoindex/network/userrepository.h"
|
||||
#include "../network/userrepository.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PACKAGEMANAGEMENT_AURPACKAGE_H
|
||||
#define PACKAGEMANAGEMENT_AURPACKAGE_H
|
||||
|
||||
#include "package.h"
|
||||
#include "./package.h"
|
||||
|
||||
namespace RepoIndex {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "config.h"
|
||||
#include "manager.h"
|
||||
#include "./config.h"
|
||||
#include "./manager.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
||||
|
@ -59,6 +59,8 @@ ConfigArgs::ConfigArgs(ArgumentParser &parser) :
|
|||
buildOrderArg.setValueNames(pkgValueNames);
|
||||
serverArg.setDenotesOperation(true);
|
||||
upgradeLookupArg.setDenotesOperation(true);
|
||||
upgradeLookupArg.setRequiredValueCount(1);
|
||||
upgradeLookupArg.setValueNames({"repo"});
|
||||
mingwBundleArg.setDenotesOperation(true);
|
||||
mingwBundleArg.setRequiredValueCount(-1);
|
||||
mingwBundleArg.setValueNames(pkgValueNames);
|
||||
|
@ -112,10 +114,10 @@ ConfigArgs::ConfigArgs(ArgumentParser &parser) :
|
|||
repoArg.setRequiredValueCount(1);
|
||||
repoArg.setValueNames({"repo name"});
|
||||
serverArg.setSecondaryArguments({&rootdirArg, &dbpathArg, &pacmanConfArg, &certFileArg, &keyFileArg, &websocketAddrArg, &websocketPortArg, &insecureArg, &aurArg});
|
||||
upgradeLookupArg.setSecondaryArguments({&repoArg, &shSyntaxArg});
|
||||
upgradeLookupArg.setSecondaryArguments({&shSyntaxArg});
|
||||
buildOrderArg.setSecondaryArguments({&aurArg, &verboseArg, &shSyntaxArg});
|
||||
mingwBundleArg.setSecondaryArguments({&targetDirArg, &targetNameArg, &targetFormatArg, &iconThemesArg});
|
||||
parser.setMainArguments({&buildOrderArg, &serverArg, &mingwBundleArg, &repoindexConfArg, &repoindexConfArg, &helpArg});
|
||||
parser.setMainArguments({&buildOrderArg, &upgradeLookupArg, &serverArg, &mingwBundleArg, &repoindexConfArg, &repoindexConfArg, &helpArg});
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "group.h"
|
||||
#include "package.h"
|
||||
#include "./group.h"
|
||||
#include "./package.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ALPM_GROUP_H
|
||||
#define ALPM_GROUP_H
|
||||
|
||||
#include "list.h"
|
||||
#include "package.h"
|
||||
#include "./list.h"
|
||||
#include "./package.h"
|
||||
|
||||
#include <alpm.h>
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include "manager.h"
|
||||
#include "alpmdatabase.h"
|
||||
#include "utilities.h"
|
||||
#include "list.h"
|
||||
#include "config.h"
|
||||
#include "./manager.h"
|
||||
#include "./alpmdatabase.h"
|
||||
#include "./utilities.h"
|
||||
#include "./list.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include "repoindex/network/userrepository.h"
|
||||
#include "../network/userrepository.h"
|
||||
|
||||
#include <c++utilities/io/inifile.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ALPM_MANAGER_H
|
||||
#define ALPM_MANAGER_H
|
||||
|
||||
#include "upgradelookup.h"
|
||||
#include "alpmpackage.h"
|
||||
#include "./upgradelookup.h"
|
||||
#include "./alpmpackage.h"
|
||||
|
||||
#include <alpm.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "mingwbundle.h"
|
||||
#include "utilities.h"
|
||||
#include "manager.h"
|
||||
#include "config.h"
|
||||
#include "./mingwbundle.h"
|
||||
#include "./utilities.h"
|
||||
#include "./manager.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef PACKAGEMANAGEMENT_MINGWBUNDLE_H
|
||||
#define PACKAGEMANAGEMENT_MINGWBUNDLE_H
|
||||
|
||||
#include "package.h"
|
||||
#include "alpmdatabase.h"
|
||||
#include "./package.h"
|
||||
#include "./alpmdatabase.h"
|
||||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "package.h"
|
||||
#include "alpmdatabase.h"
|
||||
#include "utilities.h"
|
||||
#include "repository.h"
|
||||
#include "./package.h"
|
||||
#include "./alpmdatabase.h"
|
||||
#include "./utilities.h"
|
||||
#include "./repository.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ALPM_PACKAGE_H
|
||||
#define ALPM_PACKAGE_H
|
||||
|
||||
#include "list.h"
|
||||
#include "./list.h"
|
||||
|
||||
#include <c++utilities/chrono/datetime.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "repository.h"
|
||||
#include "upgradelookup.h"
|
||||
#include "utilities.h"
|
||||
#include "./repository.h"
|
||||
#include "./upgradelookup.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef PACKAGEMANAGEMENT_PACKAGESOURCE_H
|
||||
#define PACKAGEMANAGEMENT_PACKAGESOURCE_H
|
||||
|
||||
#include "package.h"
|
||||
#include "group.h"
|
||||
#include "./package.h"
|
||||
#include "./group.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "resolvebuildorder.h"
|
||||
#include "./resolvebuildorder.h"
|
||||
|
||||
#include "manager.h"
|
||||
#include "config.h"
|
||||
#include "./manager.h"
|
||||
#include "./config.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
|
@ -183,6 +184,15 @@ QStringList BuildOrderResolver::resolve(const StringVector &packages) const
|
|||
}
|
||||
}
|
||||
|
||||
void BuildOrderResolver::printResults(const QStringList &results)
|
||||
{
|
||||
if(useShSyntax) {
|
||||
Utilities::printBashArray(cout, "REPOINDEX_RESULTS", results);
|
||||
} else {
|
||||
Utilities::printValues(cout, "Results", results);
|
||||
}
|
||||
}
|
||||
|
||||
void BuildOrderResolver::addDeps(QList<TaskInfo *> &tasks, TaskInfo *task) const
|
||||
{
|
||||
if(const auto pkg = m_manager.packageProviding(Dependency(task->name()))) {
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
BuildOrderResolver(const Manager &manager);
|
||||
|
||||
QStringList resolve(const ApplicationUtilities::StringVector &packages) const;
|
||||
static void printResults(const QStringList &results);
|
||||
|
||||
private:
|
||||
void addDeps(QList<TaskInfo *> &tasks, TaskInfo *task) const;
|
||||
|
|
|
@ -1,24 +1,44 @@
|
|||
#include "upgradelookup.h"
|
||||
#include "manager.h"
|
||||
#include "alpmdatabase.h"
|
||||
#include "config.h"
|
||||
#include "./upgradelookup.h"
|
||||
#include "./manager.h"
|
||||
#include "./alpmdatabase.h"
|
||||
#include "./config.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace RepoIndex {
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
/*!
|
||||
* \class UpgradeResult
|
||||
* \brief The UpgradeResult class wraps and upgrade/downgrade package and the current version.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Returns a JSON object for the current instance.
|
||||
*/
|
||||
QJsonObject UpgradeResult::json() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj.insert(QStringLiteral("pkg"), package->basicInfo(true));
|
||||
obj.insert(QStringLiteral("prevVersion"), previousVersion);
|
||||
obj.insert(QStringLiteral("curVer"), currentVersion);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class UpgradeLookupProcess
|
||||
* \brief The UpgradeLookupProcess class performs an async upgrade lookup for a particular upgrade source.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new upgrade lookup process. The upgrade lookup process is started immediately.
|
||||
*/
|
||||
UpgradeLookupProcess::UpgradeLookupProcess(UpgradeLookup *upgradeLookup, const Repository *upgradeSource) :
|
||||
QObject(upgradeLookup),
|
||||
m_toCheck(upgradeLookup->toCheck()),
|
||||
|
@ -49,11 +69,17 @@ UpgradeLookupProcess::UpgradeLookupProcess(UpgradeLookup *upgradeLookup, const R
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns the results. Results are available, after the finished() signal has been emitted.
|
||||
*/
|
||||
const UpgradeLookupResults &UpgradeLookupProcess::results() const
|
||||
{
|
||||
return m_results;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Internally called when the upgrade source is ready.
|
||||
*/
|
||||
void UpgradeLookupProcess::sourceReady()
|
||||
{
|
||||
// if a request was required, check whether there occured an error
|
||||
|
@ -66,17 +92,78 @@ void UpgradeLookupProcess::sourceReady()
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Internally called to perform the upgrade lookup.
|
||||
*/
|
||||
void UpgradeLookupProcess::checkUpgrades()
|
||||
{
|
||||
m_toCheck->checkForUpgrades(m_results, QList<const Repository *>() << m_upgradeSource);
|
||||
}
|
||||
|
||||
UpgradeLookup::UpgradeLookup(const Manager &manager, const QJsonObject &request, QObject *parent) :
|
||||
/*!
|
||||
* \class UpgradeLookup
|
||||
* \brief The UpgradeLookup class performs an async upgrade lookup for using multiple upgrade sources.
|
||||
* \remarks The object deletes itself after the lookup is done.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new upgrade lookup (protected since this is a pure virtual class).
|
||||
*/
|
||||
UpgradeLookup::UpgradeLookup(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_request(request),
|
||||
m_toCheck(nullptr),
|
||||
m_remainingProcesses(0),
|
||||
m_firstFinished(false)
|
||||
{}
|
||||
|
||||
/*!
|
||||
* \fn UpgradeLookup::processFinished()
|
||||
* \brief Internally called when the finished() signal of an UpgradeLookupProcess instance is emitted.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \class UpgradeLookupJson
|
||||
* \brief The UpgradeLookupJson class performs an async upgrade lookup for using multiple upgrade sources.
|
||||
*
|
||||
* The request and the results are in JSON.
|
||||
*
|
||||
* Example request:
|
||||
* {
|
||||
* db: "repo", repository to be checked
|
||||
* syncdbs: ["extra", "community"] upgrade sources to be used
|
||||
* }
|
||||
*
|
||||
* Example result:
|
||||
* {
|
||||
* softwareUpdates: [ software upgrades
|
||||
* {pkg: ..., basic info of package providing upgrade
|
||||
* curVer: current version
|
||||
* ],
|
||||
* packageOnlyUpdates: [ package-only upgrades
|
||||
* {pkg: ..., basic info of package providing upgrade
|
||||
* curVer: current version
|
||||
* ],
|
||||
* downgrades: [ downgrades
|
||||
* {pkg: ..., basic info of package providing downgrade
|
||||
* curVer: current version
|
||||
* ]
|
||||
* orphanedPackages: [ ... ] basic info of orphaned packages
|
||||
* warnings: [ ... ] warnings
|
||||
* errors: [ ... ] errors
|
||||
* }
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \fn UpgradeLookupJson::resultsAvailable()
|
||||
* \brief Emitted when all results are availabe (also in the error case).
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new upgrade lookup for the specified \a request using the specified \a manager.
|
||||
*/
|
||||
UpgradeLookupJson::UpgradeLookupJson(const Manager &manager, const QJsonObject &request, QObject *parent) :
|
||||
UpgradeLookup(parent),
|
||||
m_request(request)
|
||||
{
|
||||
const auto toCheckName = request.value(QStringLiteral("db")).toString();
|
||||
if((m_toCheck = manager.repositoryByName(toCheckName))) {
|
||||
|
@ -114,19 +201,19 @@ UpgradeLookup::UpgradeLookup(const Manager &manager, const QJsonObject &request,
|
|||
deleteLater();
|
||||
}
|
||||
|
||||
void UpgradeLookup::processFinished()
|
||||
void UpgradeLookupJson::processFinished()
|
||||
{
|
||||
assert(m_remainingProcesses);
|
||||
// add results
|
||||
const auto &results = static_cast<UpgradeLookupProcess *>(sender())->results();
|
||||
for(const auto pkg : results.newVersions) {
|
||||
m_softwareUpdatesArray << pkg.json();
|
||||
for(const auto &res : results.newVersions) {
|
||||
m_softwareUpgradesArray << res.json();
|
||||
}
|
||||
for(const auto pkg : results.newReleases) {
|
||||
m_packageOnlyUpdatesArray << pkg.json();
|
||||
for(const auto &res : results.newReleases) {
|
||||
m_packageOnlyUpgradesArray << res.json();
|
||||
}
|
||||
for(const auto pkg : results.downgrades) {
|
||||
m_downgradesArray << pkg.json();
|
||||
for(const auto &res : results.downgrades) {
|
||||
m_downgradesArray << res.json();
|
||||
}
|
||||
for(const auto &warning : results.warnings) {
|
||||
m_warningsArray << warning;
|
||||
|
@ -148,8 +235,8 @@ void UpgradeLookup::processFinished()
|
|||
}
|
||||
// add results to results QJsonObject
|
||||
QJsonObject results;
|
||||
results.insert(QStringLiteral("softwareUpdates"), m_softwareUpdatesArray);
|
||||
results.insert(QStringLiteral("packageOnlyUpdates"), m_packageOnlyUpdatesArray);
|
||||
results.insert(QStringLiteral("softwareUpdates"), m_softwareUpgradesArray);
|
||||
results.insert(QStringLiteral("packageOnlyUpdates"), m_packageOnlyUpgradesArray);
|
||||
results.insert(QStringLiteral("downgrades"), m_downgradesArray);
|
||||
results.insert(QStringLiteral("orphanedPackages"), m_orphanedPackagesArray);
|
||||
if(!m_warningsArray.isEmpty()) {
|
||||
|
@ -164,4 +251,124 @@ void UpgradeLookup::processFinished()
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class UpgradeLookupCli
|
||||
* \brief The UpgradeLookupJson class performs an async upgrade lookup for using multiple upgrade sources.
|
||||
*
|
||||
* The repository to be checked is specified as string. Results are printed to cerr/cout.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new upgrade lookup for the specified \a db using the specified \a manager.
|
||||
*/
|
||||
UpgradeLookupCli::UpgradeLookupCli(const Manager &manager, const string &repo, QObject *parent) :
|
||||
UpgradeLookup(parent)
|
||||
{
|
||||
cerr << shchar << "Checking upgrades for \"" << repo << "\" ..." << endl;
|
||||
const auto toCheckName = qstr(repo);
|
||||
if((m_toCheck = manager.repositoryByName(toCheckName))) {
|
||||
// construct upgrade lookup processes
|
||||
for(const auto *src : m_toCheck->upgradeSources()) {
|
||||
new UpgradeLookupProcess(this, src);
|
||||
++m_remainingProcesses;
|
||||
}
|
||||
// check whether any processes could be constructed
|
||||
if(!m_remainingProcesses) {
|
||||
m_errorsArray << QStringLiteral("No upgrade sources associated for repository \"%1\".").arg(m_toCheck->name());
|
||||
} else {
|
||||
return; // no errors so far
|
||||
}
|
||||
} else {
|
||||
m_errorsArray << QStringLiteral("Repository \"%1\" can not be found.").arg(toCheckName);
|
||||
}
|
||||
printResults(); // print errors
|
||||
}
|
||||
|
||||
void UpgradeLookupCli::processFinished()
|
||||
{
|
||||
assert(m_remainingProcesses);
|
||||
// add results
|
||||
const auto &results = static_cast<UpgradeLookupProcess *>(sender())->results();
|
||||
m_softwareUpgradesArray.reserve(m_softwareUpgradesArray.size() + results.newVersions.size());
|
||||
m_packageOnlyUpgradesArray.reserve(m_packageOnlyUpgradesArray.size() + results.newReleases.size());
|
||||
m_downgradesArray.reserve(m_downgradesArray.size() + results.downgrades.size());
|
||||
m_warningsArray.reserve(m_warningsArray.size() + results.warnings.size());
|
||||
m_errorsArray.reserve(m_errorsArray.size() + results.errors.size());
|
||||
for(const auto &res : results.newVersions) {
|
||||
m_softwareUpgradesArray << res.package->name();
|
||||
}
|
||||
for(const auto &res : results.newReleases) {
|
||||
m_packageOnlyUpgradesArray << res.package->name();
|
||||
}
|
||||
for(const auto &res : results.downgrades) {
|
||||
m_downgradesArray << res.package->name();
|
||||
}
|
||||
for(const auto &warning : results.warnings) {
|
||||
m_warningsArray << warning;
|
||||
}
|
||||
for(const auto &error : results.errors) {
|
||||
m_errorsArray << error;
|
||||
}
|
||||
if(m_firstFinished) {
|
||||
m_orphanedPackages = m_orphanedPackages.intersect(results.orphaned);
|
||||
} else {
|
||||
m_firstFinished = true;
|
||||
m_orphanedPackages = results.orphaned;
|
||||
}
|
||||
// check whether all processes are finished
|
||||
if(--m_remainingProcesses == 0) {
|
||||
// finally make info for orphanded packages
|
||||
m_orphanedPackagesArray.reserve(m_orphanedPackages.size());
|
||||
for(const auto *pkg : m_orphanedPackages) {
|
||||
m_orphanedPackagesArray << pkg->name();
|
||||
}
|
||||
printResults();
|
||||
}
|
||||
}
|
||||
|
||||
void UpgradeLookupCli::printResults()
|
||||
{
|
||||
if(useShSyntax) {
|
||||
if(!m_errorsArray.isEmpty()) {
|
||||
Utilities::printBashArray(cerr, "REPOINDEX_ERRORS", m_errorsArray);
|
||||
}
|
||||
if(!m_warningsArray.isEmpty()) {
|
||||
Utilities::printBashArray(cerr, "REPOINDEX_WARNINGS", m_warningsArray);
|
||||
}
|
||||
if(!m_softwareUpgradesArray.isEmpty()) {
|
||||
Utilities::printBashArray(cout, "REPOINDEX_RESULTS_SOFTWARE_UPGRADES", m_softwareUpgradesArray);
|
||||
}
|
||||
if(!m_packageOnlyUpgradesArray.isEmpty()) {
|
||||
Utilities::printBashArray(cout, "REPOINDEX_RESULTS_PACKAGE_UPGRADES", m_packageOnlyUpgradesArray);
|
||||
}
|
||||
if(!m_downgradesArray.isEmpty()) {
|
||||
Utilities::printBashArray(cout, "REPOINDEX_RESULTS_DOWNGRADES", m_downgradesArray);
|
||||
}
|
||||
if(!m_orphanedPackagesArray.isEmpty()) {
|
||||
Utilities::printBashArray(cout, "REPOINDEX_RESULTS_ORPHANED", m_orphanedPackagesArray);
|
||||
}
|
||||
} else {
|
||||
if(!m_errorsArray.isEmpty()) {
|
||||
Utilities::printValues(cerr, "Errors", m_errorsArray);
|
||||
}
|
||||
if(!m_warningsArray.isEmpty()) {
|
||||
Utilities::printValues(cerr, "Warnings", m_warningsArray);
|
||||
}
|
||||
if(!m_softwareUpgradesArray.isEmpty()) {
|
||||
Utilities::printValues(cout, "Software upgrades", m_softwareUpgradesArray);
|
||||
}
|
||||
if(!m_packageOnlyUpgradesArray.isEmpty()) {
|
||||
Utilities::printValues(cout, "Package upgrades", m_packageOnlyUpgradesArray);
|
||||
}
|
||||
if(!m_downgradesArray.isEmpty()) {
|
||||
Utilities::printValues(cout, "Downgrades", m_downgradesArray);
|
||||
}
|
||||
if(!m_orphanedPackagesArray.isEmpty()) {
|
||||
Utilities::printValues(cout, "Orphaned packages", m_orphanedPackagesArray);
|
||||
}
|
||||
}
|
||||
// lookup done, delete this helper object
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
} // namespace PackageManagement
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef PACKAGEMANAGEMENT_UPDATELOOKUP_H
|
||||
#define PACKAGEMANAGEMENT_UPDATELOOKUP_H
|
||||
|
||||
#include "package.h"
|
||||
#include "./package.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QJsonObject>
|
||||
|
@ -18,15 +18,18 @@ class PackageReply;
|
|||
class UpgradeResult
|
||||
{
|
||||
public:
|
||||
UpgradeResult(const Package *package, const QString &previousVersion);
|
||||
UpgradeResult(const Package *package, const QString ¤tVersion);
|
||||
const Package *package;
|
||||
QString previousVersion;
|
||||
QString currentVersion;
|
||||
QJsonObject json() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Constructs a new upgrade result.
|
||||
*/
|
||||
inline UpgradeResult::UpgradeResult(const Package *package, const QString &previousVersion) :
|
||||
package(package),
|
||||
previousVersion(previousVersion)
|
||||
currentVersion(previousVersion)
|
||||
{}
|
||||
|
||||
class UpgradeLookupResults
|
||||
|
@ -103,35 +106,75 @@ class UpgradeLookup : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
friend class UpgradeLookupProcess;
|
||||
|
||||
public:
|
||||
explicit UpgradeLookup(const Manager &manager, const QJsonObject &request, QObject *parent = nullptr);
|
||||
const Repository *toCheck() const;
|
||||
|
||||
signals:
|
||||
void resultsAvailable(const QJsonValue &what, const QJsonValue &id, const QJsonValue &value);
|
||||
|
||||
private slots:
|
||||
void processFinished();
|
||||
virtual void processFinished() = 0;
|
||||
|
||||
protected:
|
||||
explicit UpgradeLookup(QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
const QJsonObject m_request;
|
||||
const Repository *m_toCheck;
|
||||
unsigned int m_remainingProcesses;
|
||||
bool m_firstFinished;
|
||||
QSet<const Package *> m_orphanedPackages;
|
||||
QJsonArray m_warningsArray;
|
||||
QJsonArray m_errorsArray;
|
||||
QJsonArray m_softwareUpdatesArray;
|
||||
QJsonArray m_packageOnlyUpdatesArray;
|
||||
QJsonArray m_downgradesArray;
|
||||
QJsonArray m_orphanedPackagesArray;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Returns the repository to be checked (if available; otherwise nullptr).
|
||||
*/
|
||||
inline const Repository *UpgradeLookup::toCheck() const
|
||||
{
|
||||
return m_toCheck;
|
||||
}
|
||||
|
||||
class UpgradeLookupJson : public UpgradeLookup
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UpgradeLookupJson(const Manager &manager, const QJsonObject &request, QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void resultsAvailable(const QJsonValue &what, const QJsonValue &id, const QJsonValue &value);
|
||||
|
||||
private slots:
|
||||
virtual void processFinished();
|
||||
|
||||
private:
|
||||
const QJsonObject m_request;
|
||||
QJsonArray m_warningsArray;
|
||||
QJsonArray m_errorsArray;
|
||||
QJsonArray m_softwareUpgradesArray;
|
||||
QJsonArray m_packageOnlyUpgradesArray;
|
||||
QJsonArray m_downgradesArray;
|
||||
QJsonArray m_orphanedPackagesArray;
|
||||
};
|
||||
|
||||
class UpgradeLookupCli : public UpgradeLookup
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class UpgradeLookupProcess;
|
||||
public:
|
||||
explicit UpgradeLookupCli(const Manager &manager, const std::string &repo, QObject *parent = nullptr);
|
||||
const Repository *toCheck() const;
|
||||
|
||||
private slots:
|
||||
void processFinished();
|
||||
|
||||
private:
|
||||
void printResults();
|
||||
|
||||
QStringList m_warningsArray;
|
||||
QStringList m_errorsArray;
|
||||
QStringList m_softwareUpgradesArray;
|
||||
QStringList m_packageOnlyUpgradesArray;
|
||||
QStringList m_downgradesArray;
|
||||
QStringList m_orphanedPackagesArray;
|
||||
};
|
||||
|
||||
|
||||
} // namespace PackageManagement
|
||||
|
||||
#endif // PACKAGEMANAGEMENT_UPDATELOOKUP_H
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include "utilities.h"
|
||||
#include "./utilities.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QStringList>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace RepoIndex {
|
||||
|
@ -202,6 +204,24 @@ QStringList qstrlist(StringList list)
|
|||
return strings;
|
||||
}
|
||||
|
||||
void printValues(ostream &output, const char *label, const QStringList &values)
|
||||
{
|
||||
output << label << ':';
|
||||
for(const auto &value : values) {
|
||||
output << ' ' << value.toLocal8Bit().data();
|
||||
}
|
||||
output << endl;
|
||||
}
|
||||
|
||||
void printBashArray(ostream &output, const char *name, const QStringList &values)
|
||||
{
|
||||
output << "export " << name << '=' << '(';
|
||||
for(const auto &value : values) {
|
||||
output << ' ' << '\'' << value.toLocal8Bit().data() << '\'';
|
||||
}
|
||||
output << ' ' << ')' << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace Alpm
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef ALPM_UTILITIES_H
|
||||
#define ALPM_UTILITIES_H
|
||||
|
||||
#include "list.h"
|
||||
#include "./list.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
@ -15,7 +15,6 @@ namespace RepoIndex {
|
|||
namespace Utilities {
|
||||
|
||||
std::list<std::string> getNames(DependencyList dependencyList);
|
||||
|
||||
QJsonArray sigLevelStrings(alpm_siglevel_t sigLevel);
|
||||
QJsonArray usageStrings(alpm_db_usage_t usage);
|
||||
QString sigStatusString(alpm_sigstatus_t sigStatus);
|
||||
|
@ -36,6 +35,10 @@ inline QString qstr(const std::string &str)
|
|||
return QString::fromLocal8Bit(str.data());
|
||||
}
|
||||
|
||||
void printValues(std::ostream &output, const char *label, const QStringList &values);
|
||||
|
||||
void printBashArray(std::ostream &output, const char *name, const QStringList &values);
|
||||
|
||||
}
|
||||
|
||||
} // namespace Alpm
|
||||
|
|
31
main.cpp
31
main.cpp
|
@ -1,10 +1,10 @@
|
|||
#include "repoindex/alpm/manager.h"
|
||||
#include "repoindex/alpm/utilities.h"
|
||||
#include "repoindex/alpm/config.h"
|
||||
#include "repoindex/alpm/resolvebuildorder.h"
|
||||
#include "repoindex/alpm/mingwbundle.h"
|
||||
#include "./alpm/manager.h"
|
||||
#include "./alpm/utilities.h"
|
||||
#include "./alpm/config.h"
|
||||
#include "./alpm/resolvebuildorder.h"
|
||||
#include "./alpm/mingwbundle.h"
|
||||
|
||||
#include "repoindex/network/server.h"
|
||||
#include "./network/server.h"
|
||||
|
||||
#include <c++utilities/application/argumentparser.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
|
@ -64,28 +64,15 @@ int main(int argc, char *argv[])
|
|||
return application.exec();
|
||||
} else if(configArgs.buildOrderArg.isPresent()) {
|
||||
BuildOrderResolver resolver(manager);
|
||||
const QStringList results = resolver.resolve(configArgs.buildOrderArg.values());
|
||||
// print results
|
||||
if(useShSyntax) {
|
||||
cout << "export REPOINDEX_RESULTS=(";
|
||||
for(const auto &pkgName : results) {
|
||||
cout << ' ' << '\'' << pkgName.toLocal8Bit().data() << '\'';
|
||||
}
|
||||
cout << ' ' << ')' << endl;
|
||||
} else {
|
||||
cout << "Results: ";
|
||||
for(const auto &pkgName : results) {
|
||||
cout << pkgName.toLocal8Bit().data() << ' ';
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
BuildOrderResolver::printResults(resolver.resolve(configArgs.buildOrderArg.values()));
|
||||
} else if(configArgs.mingwBundleArg.isPresent()) {
|
||||
MingwBundle bundle(manager, configArgs.mingwBundleArg.values(), configArgs.iconThemesArg.values());
|
||||
bundle.createBundle(configArgs.targetDirArg.isPresent() ? configArgs.targetDirArg.values().front() : string("."),
|
||||
configArgs.targetNameArg.values().front(),
|
||||
configArgs.targetFormatArg.isPresent() ? configArgs.targetFormatArg.values().front() : string("zip"));
|
||||
} else if(configArgs.upgradeLookupArg.isPresent()) {
|
||||
cerr << shchar << "TODO" << endl;
|
||||
QObject::connect(new UpgradeLookupCli(manager, configArgs.upgradeLookupArg.values().front()), &QObject::destroyed, &application, &QCoreApplication::quit);
|
||||
return application.exec();
|
||||
}
|
||||
} else if(!configArgs.helpArg.isPresent()) {
|
||||
if(useShSyntax) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "connection.h"
|
||||
#include "./connection.h"
|
||||
|
||||
#include "alpm/manager.h"
|
||||
#include "alpm/upgradelookup.h"
|
||||
#include "../alpm/manager.h"
|
||||
#include "../alpm/upgradelookup.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
@ -75,7 +75,7 @@ void Connection::handleQuery(const QJsonObject &obj)
|
|||
m_groupInfoUpdatesRequested = obj.value(QStringLiteral("updates")).toBool(m_groupInfoUpdatesRequested);
|
||||
sendResults(what, id, m_alpmManager.groupInfo());
|
||||
} else if(what == QLatin1String("checkforupdates")) {
|
||||
connect(new UpgradeLookup(m_alpmManager, obj), &UpgradeLookup::resultsAvailable, this, &Connection::sendResult);
|
||||
connect(new UpgradeLookupJson(m_alpmManager, obj), &UpgradeLookupJson::resultsAvailable, this, &Connection::sendResult);
|
||||
} else if(what == QLatin1String("ping")) {
|
||||
sendResult(what, id, QStringLiteral("pong"));
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "server.h"
|
||||
#include "connection.h"
|
||||
|
||||
#include "alpm/config.h"
|
||||
#include "../alpm/config.h"
|
||||
|
||||
#include <QWebSocketServer>
|
||||
#include <QSslCertificate>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "userrepository.h"
|
||||
|
||||
#include "alpm/aurpackage.h"
|
||||
#include "../alpm/aurpackage.h"
|
||||
|
||||
#include <c++utilities/misc/memory.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ALPM_USER_REPOSITORY_H
|
||||
#define ALPM_USER_REPOSITORY_H
|
||||
|
||||
#include "repoindex/alpm/package.h"
|
||||
#include "repoindex/alpm/repository.h"
|
||||
#include "./alpm/package.h"
|
||||
#include "./alpm/repository.h"
|
||||
|
||||
#include <QUrl>
|
||||
#include <QObject>
|
||||
|
|
|
@ -252,7 +252,7 @@
|
|||
newEntry.info.index = updateEntries.length;
|
||||
if(updates[i1].entries[i2].pkg) {
|
||||
newEntry.applyBasicInfo(updates[i1].entries[i2].pkg, true);
|
||||
if(updates[i1].entries[i2].prevVersion) {
|
||||
if(updates[i1].entries[i2].curVer) {
|
||||
newEntry.info.ver = updates[i1].entries[i2].prevVersion + " → " + (newEntry.info.ver ? newEntry.info.ver : "?");
|
||||
}
|
||||
// find associated repo entry
|
||||
|
|
Loading…
Reference in New Issue