Commit 9fb12d98 authored by Lisa's avatar Lisa

Print "Not found" message for all missing packages.

In case of installations and removals, find out the
packages that were not found among the given list,
and print an error.

In case nothing was found, we don't exit at
this stage, but the queue will be checked again
before starting the transaction.
parent a48a4126
......@@ -38,6 +38,7 @@ RemoveOperation::~RemoveOperation()
void RemoveOperation::start()
{
APM::OperationName operation = m_operations.takeFirst();
QTextStream err(stderr);
Akabei::Backend* backend = Akabei::Backend::instance();
Akabei::Database *localDatabase = backend->localDatabase();
......@@ -46,7 +47,13 @@ void RemoveOperation::start()
connect(backend, SIGNAL(queryOrphansCompleted(QUuid,QList<Akabei::Package*>)), SLOT(removeUnneeded(QUuid,QList<Akabei::Package*>)));
id = Akabei::Backend::instance()->orphanPackages();
} else if (operation == APM::Remove) {
remove(localDatabase->searchPackages(m_args, Akabei::SearchNameEqual));
Akabei::Package::List installed = localDatabase->searchPackages(m_args, Akabei::SearchNameEqual);
for (const QString& notFound : Utils::packagesNotFound(m_args, installed)) {
err << Akabei::errorPrefix << QObject::tr("Target not found: ") << notFound << endl;
}
remove(installed);
} else {
QTextStream err(stderr);
err << Akabei::errorPrefix << QObject::tr("Operation not supported.") << endl;
......@@ -84,4 +91,4 @@ void RemoveOperation::nextOperation()
return;
}
start();
}
\ No newline at end of file
}
......@@ -159,6 +159,8 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
return;
}
QTextStream err(stderr);
/*
* If the same package was returned more than once (i.e. it is present in more repos with different versions)
* choose the most recent one.
......@@ -191,6 +193,10 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
nonDuplicatedPackages << mostRecent;
}
for (const QString &notFound : Utils::packagesNotFound(m_args, nonDuplicatedPackages)) {
err << Akabei::errorPrefix << QObject::tr("Target not found: ") << notFound << endl;
}
QueueOperation *op = new QueueOperation(APM::Install, m_options, this);
connect(op, SIGNAL(finished()), SLOT(nextOperation()));
op->start(AkabeiClient::Install, nonDuplicatedPackages);
......
/* This file is part of the Chakra project
Copyright (C) 2012 Lukas Appelhans <l.appelhans@gmx.de>
Copyright (C) 2016 Lisa Vitolo <shainer@chakralinux.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -125,4 +126,16 @@ void printGroup(Akabei::Group const * group, QTextStream &out, bool showLess)
out << endl;
}
}
};
QStringList packagesNotFound(const QStringList &requested, const Akabei::Package::List &got) {
QStringList result( requested );
for (Akabei::Package* package : got) {
// We assume unique package names.
result.removeOne(package->name());
}
return result;
}
} // namespace Utils
/* This file is part of the Chakra project
Copyright (C) 2012 Lukas Appelhans <l.appelhans@gmx.de>
Copyright (C) 2016 Lisa Vitolo <shainer@chakralinux.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
......@@ -20,6 +21,14 @@ namespace Akabei {
namespace Utils {
void printPackageInformation(Akabei::Package * p, QTextStream &out, bool showLess = false, bool showMakeDeps = false);
void printGroup(Akabei::Group const * group, QTextStream &out, bool showLess = false);
/*
* Receives a list of requested package names (from command line), and
* a list of packages as retrieved in the databases. Returns the names of the
* packages that could be found, i.e. they were requested but they are not
* in the final list.
*/
QStringList packagesNotFound(const QStringList &requested, const QList<Akabei::Package *> &got);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment