Commit fdfa265a authored by Lukas Appelhans's avatar Lukas Appelhans
Browse files

*better error message when updating dbs

*show requiredBy packages in the package information
*handle relative paths in "akabei owner"
*small fixes
parent 3aa1da66
......@@ -17,6 +17,7 @@
#include <akabeidatabase.h>
#include <akabeiconfig.h>
#include <akabeihelpers.h>
#include <akabeiquery.h>
#include <QTextStream>
#include <QDate>
......@@ -211,7 +212,7 @@ void QueryOperation::showInformation(Akabei::Package::List packages)
QTextStream out( stdout );
foreach (Akabei::Package const *pkg, packages) {
foreach (Akabei::Package *pkg, packages) {
Utils::printPackageInformation(pkg, out, m_options.contains(APM::ShowLess), m_options.contains(APM::ShowMakeDeps));
}
......@@ -363,24 +364,24 @@ void QueryOperation::showOwner(const QStringList &queries)
QTextStream err(stderr);
foreach (const QString& query, queries) {
if (!QFile::exists(query)) {
QString cleaned = QFileInfo(query).canonicalFilePath();
if (cleaned.isEmpty()) {
err << Akabei::errorPrefix << QObject::tr("File does not exists: %1").arg(query) << endl;
err.flush();
nextOperation();
return;
}
foreach (Akabei::Package * pkg, Akabei::Backend::instance()->localDatabase()->packages()) {
foreach (const QString &file, pkg->retrieveFiles()) {
if (Akabei::Config::instance()->rootDir().absoluteFilePath(file) == query) {
out << QObject::tr("%1 is owned by %2 %3").arg(query, pkg->name(), pkg->version().toByteArray()) << endl;
out.flush();
nextOperation();
return;
}
}
cleaned.remove(Akabei::Config::instance()->root());
//TODO: bash completition
qDebug() << "Cleaned is" << cleaned;
Akabei::Package::List result =
Akabei::Backend::instance()->localDatabase()->queryPackages("SELECT * FROM files JOIN packages ON files.package=packages.id WHERE files.file=\"" + cleaned + "\";");
if (result.isEmpty()) {
out << QObject::tr("No package owns %1").arg(query) << endl;
} else {
out << QObject::tr("%1 is owned by %2 %3!").arg(query, result.first()->name(), result.first()->version().toByteArray()) << endl;
}
out << QObject::tr("No package owns %1").arg(query) << endl;
}
out.flush();
......
......@@ -90,6 +90,7 @@ void QueueOperation::start(AkabeiClient::PackageAction action, QList<Akabei::Pac
foreach (Akabei::Package * pkg, packages) {
if (m_options.contains(APM::OnlyNeeded) && pkg->isInstalled())
continue;
qDebug() << "We have" << pkg->name() << pkg->database()->name();
AkabeiClient::Backend::instance()->queue()->addPackage(pkg, action);
}
......
......@@ -183,6 +183,8 @@ void SyncOperation::install(QUuid uuid, QList< Akabei::Package* > packages)
QList< Akabei::Package* >::iterator it2;
for (it1 = packages.begin(); it1 < packages.end(); it1++) {
if ((*it1)->database() == Akabei::Backend::instance()->localDatabase())
continue;
mostRecent = (*it1);
for (it2 = it1 + 1; it2 < packages.end(); it2++) {
......@@ -248,12 +250,12 @@ void SyncOperation::searchResult(QUuid , QList< Akabei::Package* > packages)
out << endl;
if (!m_options.contains(APM::ShowLess)) {
Akabei::Package::List result = Akabei::Backend::instance()->localDatabase()->searchPackages(p->name(), Akabei::SearchNameEqual);
out << "\t" << qSetFieldWidth(n) << fields["Available version:"] << qSetFieldWidth(0) << p->version().toByteArray().constData() << endl;
if (!result.isEmpty() && (!smallDetails || result.first()->version() > p->version())) {
out << "\t" << qSetFieldWidth(n) << fields["Installed version:"] << qSetFieldWidth(0) << result.first()->version().toByteArray().constData() << endl;
}
if (!smallDetails) {
Akabei::Package::List result = Akabei::Backend::instance()->localDatabase()->searchPackages(p->name(), Akabei::SearchNameEqual);
if (!result.isEmpty()) {
out << "\t" << qSetFieldWidth(n) << fields["Installed version:"] << qSetFieldWidth(0) << result.first()->version().toByteArray().constData() << endl;
}
out << "\t" << qSetFieldWidth(n) << fields["Homepage:"] << qSetFieldWidth(0) << p->url().toString() << endl;
}
out << "\t" << qSetFieldWidth(n) << fields["Description:"] << qSetFieldWidth(0) << p->description() << endl;
......@@ -408,9 +410,9 @@ void SyncOperation::updateNextDatabase()
void SyncOperation::databaseErrorTriggered(Akabei::Error::List errors)
{
QTextStream err(stderr);
QString message = Akabei::errorPrefix + QObject::tr("There has been an error while updating %1").arg( static_cast<AkabeiClient::DatabaseHandler*>(QObject::sender())->name() );
QString message = Akabei::errorPrefix + QObject::tr("There has been an error while updating %1:").arg( static_cast<AkabeiClient::DatabaseHandler*>(QObject::sender())->name() );
foreach (Akabei::Error error, errors)
message.append(error.description());
message.append(' ' + error.description());
err << m_bar.replaceMessage(message) << endl;
}
......
......@@ -22,7 +22,7 @@
#include <QStringList>
namespace Utils {
void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool showLess, bool showMakeDeps)
void printPackageInformation(Akabei::Package * p, QTextStream &out, bool showLess, bool showMakeDeps)
{
/* TODO: discover how to disable these features: reset() doesn't work */
out.setFieldAlignment(QTextStream::AlignLeft);
......@@ -77,6 +77,18 @@ void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool s
out << "\t" << qSetFieldWidth(n) << fields["Optional dependencies:"] << qSetFieldWidth(0) << (p->optionalDependencies().isEmpty() ? QObject::tr("None") : p->optionalDependencies().join(" ")) << endl;
out << "\t" << qSetFieldWidth(n) << fields["Replaces:"] << qSetFieldWidth(0) << (p->replaces().isEmpty() ? QObject::tr("None") : p->replaces().join(" ")) << endl;
Akabei::Package::List rb;
if (p->database() == Akabei::Backend::instance()->localDatabase()) {
rb = p->computeRequiredByInstalled();
} else {
rb = p->computeRequiredBy();
}
QString requiredBy;
foreach (Akabei::Package * p, rb) {
requiredBy.append(p->name() + ' ');
}
out << "\t" << qSetFieldWidth(n) << fields["Required by:"] << qSetFieldWidth(0) << (requiredBy.isEmpty() ? QObject::tr("None") : requiredBy) << endl;
out << "\t" << qSetFieldWidth(n) << fields["Packager:"] << qSetFieldWidth(0) << p->packager() << endl;
out << "\t" << qSetFieldWidth(n) << fields["Creation time:"] << qSetFieldWidth(0) << p->buildDate().toString() << endl;
if (p->database() == Akabei::Backend::instance()->localDatabase()) {
......
......@@ -18,7 +18,7 @@ namespace Akabei {
};
namespace Utils {
void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool showLess = false, bool showMakeDeps = false);
void printPackageInformation(Akabei::Package * p, QTextStream &out, bool showLess = false, bool showMakeDeps = false);
void printGroup(Akabei::Group const * group, QTextStream &out, bool showLess = false);
};
......
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