Commit 6d7e23e9 authored by Lukas Appelhans's avatar Lukas Appelhans

Merge branch 'master' of gitorious.org:chakra/akabei

parents 01b44c95 94d222fa
......@@ -37,6 +37,7 @@ enum OptionName
ShowLocal,
Local,
ShowLess,
ShowMakeDeps,
InstallAsDeps,
InstallAsExplicit,
SkipDependencyCheck,
......
......@@ -21,6 +21,7 @@ FieldNames::FieldNames()
insert("Groups:");
insert("Provides:");
insert("Depends on:");
insert("Make dependencies:");
insert("Optional dependencies:");
insert("Required by:");
insert("Replaces:");
......
......@@ -30,6 +30,7 @@ void initOptions(CommandLineParser *parser, bool isAkabei)
{
parser->addOption(APM::QueryPackageFile, "p", "file", ki18n("Queries a file instead of the database"), ki18n("package-file"));
parser->addOption(APM::ShowLess, "q", "quiet", ki18n("Shows less information in queries and searches"));
parser->addOption(APM::ShowMakeDeps, "m", "makedeps", ki18n("Shows make dependencies in a package's information"));
parser->addOption(APM::InstallAsDeps, "", "asdeps", ki18n("Install all packages as non-explicit"));
parser->addOption(APM::InstallAsExplicit, "", "asexplicit", ki18n("Install all packages as explicit"));
parser->addOption(APM::SkipDependencyCheck, "d", "nodeps", ki18n("Skip dependency check"));
......@@ -99,6 +100,7 @@ void initAkabeiOperations(CommandLineParser *parser)
AkabeiOperation info(APM::SyncOperationType, APM::ShowInformation, "", "info", ki18n("Shows package information"));
info.addConnectionWithOption(APM::Local);
info.addConnectionWithOption(APM::ShowLess);
info.addConnectionWithOption(APM::ShowMakeDeps);
info.addConnectionWithOption(APM::QueryPackageFile);
AkabeiOperation install(APM::SyncOperationType, APM::Install, "", "install", ki18n("Install packages"), true);
......@@ -241,6 +243,7 @@ void initPakabeiOperations(CommandLineParser *parser)
AkabeiOperation infol(APM::QueryOperationType, APM::ShowInformation, "i", "info", ki18n("Shows package information"));
infol.addConnectionWithOption(APM::ShowLess);
infol.addConnectionWithOption(APM::QueryPackageFile);
infol.addConnectionWithOption(APM::ShowMakeDeps);
AkabeiOperation searchl(APM::QueryOperationType, APM::Search, "s", "search", ki18n("Searches repositories for a word"), true);
searchl.addConnectionWithOption(APM::ShowLess);
......@@ -280,6 +283,7 @@ void initPakabeiOperations(CommandLineParser *parser)
AkabeiOperation info(APM::SyncOperationType, APM::ShowInformation, "i", "info", ki18n("Shows package information"));
info.addConnectionWithOption(APM::ShowLess);
info.addConnectionWithOption(APM::QueryPackageFile);
info.addConnectionWithOption(APM::ShowMakeDeps);
AkabeiOperation search(APM::SyncOperationType, APM::Search, "s", "search", ki18n("Searches repositories for a word"), true);
search.addConnectionWithOption(APM::ShowLess);
......
......@@ -141,7 +141,8 @@ void QueryOperation::start()
}
case APM::ShowNotRequired: {
showNotRequired();
connect(backend, SIGNAL(queryOrphansCompleted(QUuid,QList<Akabei::Package*>)), SLOT(showNotRequired(QUuid,QList<Akabei::Package*>)));
queryId = backend->orphanPackages();
break;
}
......@@ -208,7 +209,7 @@ void QueryOperation::showInformation(Akabei::Package::List packages)
QTextStream out( stdout );
foreach (Akabei::Package const *pkg, packages) {
Utils::printPackageInformation(pkg, out, m_options.contains(APM::ShowLess));
Utils::printPackageInformation(pkg, out, m_options.contains(APM::ShowLess), m_options.contains(APM::ShowMakeDeps));
}
nextOperation();
......@@ -387,34 +388,25 @@ void QueryOperation::showLocalQuery(Akabei::Package::List packages) //FIXME: Tra
nextOperation();
}
void QueryOperation::showNotRequired()
void QueryOperation::showNotRequired(QUuid uuid, QList< Akabei::Package* > orphans)
{
QTextStream out(stdout);
Akabei::Package::List packages = Akabei::Backend::instance()->localDatabase()->packages();
QMap<QString, Akabei::Package*> pkgs;
foreach (Akabei::Package* pkg, packages) {
pkgs[pkg->name()] = pkg;
if (queryId != uuid) {
nextOperation();
return;
}
foreach (Akabei::Package* pkg, packages) {
foreach (const QString &dep, pkg->dependencies())
pkgs.remove(dep);
if (pkg->installReason() != Akabei::Package::InstalledAsDependencyReason) {
pkgs.remove(pkg->name());
}
QTextStream out(stdout);
if (orphans.isEmpty()) {
out << "No packages found!" << endl;
}
foreach (Akabei::Package * pkg, pkgs.values()) {
if (!isIgnored(pkg)) {
out << pkg->name() << ' ' << pkg->version().toByteArray().data() << endl;
foreach (Akabei::Package* orphan, orphans) {
if (!isIgnored(orphan)) {
out << orphan->name() << ' ' << orphan->version().toByteArray().data() << endl;
}
}
if (pkgs.isEmpty()) {
out << i18n("No package found!") << endl;
}
out.flush();
nextOperation();
}
......
......@@ -31,6 +31,8 @@ private:
QList<APM::OperationName> m_operations;
QHash<APM::OptionName, QStringList> m_options;
QStringList m_args;
QUuid queryId;
void nextOperation();
......@@ -48,9 +50,11 @@ private:
void checkFiles(Akabei::Package::List);
void showOwner(const QStringList &queries);
void showLocalQuery(Akabei::Package::List);
void showNotRequired();
void showUpgradeable();
void printFiles(Akabei::Package::List packages);
private slots:
void showNotRequired(QUuid, QList<Akabei::Package*>);
signals:
void queryFinished();
......
......@@ -39,10 +39,13 @@ RemoveOperation::~RemoveOperation()
void RemoveOperation::start()
{
APM::OperationName operation = m_operations.takeFirst();
Akabei::Database *localDatabase = Akabei::Backend::instance()->localDatabase();
Akabei::Backend* backend = Akabei::Backend::instance();
Akabei::Database *localDatabase = backend->localDatabase();
if (operation == APM::Unneeded) {
removeUnneeded(localDatabase->packages());
connect(backend, SIGNAL(queryOrphansCompleted(QUuid,QList<Akabei::Package*>)), SLOT(removeUnneeded(QUuid,QList<Akabei::Package*>)));
id = Akabei::Backend::instance()->orphanPackages();
} else if (operation == APM::Remove) {
if (m_options.contains(APM::Recursive)) {
removeRecursive(localDatabase->searchPackages(m_args, Akabei::SearchNameEqual));
......@@ -81,28 +84,16 @@ void RemoveOperation::removeRecursive(QList<Akabei::Package*> packages)
operation->start(AkabeiClient::Remove, pkgs);
}
void RemoveOperation::removeUnneeded(Akabei::Package::List packages)
void RemoveOperation::removeUnneeded(QUuid uuid, QList< Akabei::Package* > orphans)
{
Akabei::Package::List unneeded( packages );
foreach (Akabei::Package* pkg, packages) {
foreach (Akabei::Package* dep, pkg->computeDependencies()) {
unneeded.removeOne(dep);
}
if (pkg->installReason() != Akabei::Package::InstalledAsDependencyReason) {
unneeded.removeOne(pkg);
}
}
if (unneeded.isEmpty()) {
if (id != uuid || orphans.isEmpty()) {
nextOperation();
return;
}
QueueOperation *operation = new QueueOperation(APM::Unneeded, m_options, this);
QueueOperation* operation = new QueueOperation(APM::Unneeded, m_options, this);
connect(operation, SIGNAL(finished()), SLOT(nextOperation()));
operation->start(AkabeiClient::Remove, unneeded);
operation->start(AkabeiClient::Remove, orphans);
}
void RemoveOperation::nextOperation()
......
......@@ -15,6 +15,7 @@
#include "apm.h"
#include <akabeierror.h>
#include <akabeipackage.h>
#include <QUuid>
class RemoveOperation : public QObject
{
......@@ -28,13 +29,15 @@ public:
public slots:
void remove(Akabei::Package::List packages);
void removeRecursive(Akabei::Package::List packages);
void removeUnneeded(Akabei::Package::List packages);
void removeUnneeded(QUuid, QList<Akabei::Package*>);
void nextOperation();
private:
QList<APM::OperationName> m_operations;
QHash<APM::OptionName, QStringList> m_options;
QStringList m_args;
QUuid id;
signals:
void removeFinished();
......
......@@ -298,7 +298,7 @@ void SyncOperation::showInformation(QUuid,QList<Akabei::Package*> packages)
/* Prints the information for every package */
foreach (Akabei::Package *pkg, packages) {
Utils::printPackageInformation(pkg, out, m_options.contains(APM::ShowLess));
Utils::printPackageInformation(pkg, out, m_options.contains(APM::ShowLess), m_options.contains(APM::ShowMakeDeps));
}
out.reset();
......
......@@ -17,11 +17,12 @@
#include <akabeigroup.h>
#include <klocale.h>
#include <QDateTime>
#include <QDebug>
#include <kio/global.h>
namespace Utils {
void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool showLess)
void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool showLess, bool showMakeDeps)
{
/* TODO: discover how to disable these features: reset() doesn't work */
out.setFieldAlignment(QTextStream::AlignLeft);
......@@ -69,6 +70,11 @@ void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool s
out << "\t" << qSetFieldWidth(n) << fields["Homepage:"] << qSetFieldWidth(0) << p->url().toString() << endl;
out << "\t" << qSetFieldWidth(n) << fields["Licenses:"] << qSetFieldWidth(0) << (p->licenses().isEmpty() ? i18n("None") : p->licenses().join(" ")) << endl;
out << "\t" << qSetFieldWidth(n) << fields["Depends on:"] << qSetFieldWidth(0) << (p->dependencies().isEmpty() ? i18n("None") : p->dependencies().join(" ")) << endl;
if (showMakeDeps) {
out << "\t" << qSetFieldWidth(n) << fields["Make dependencies:"] << qSetFieldWidth(0) << (p->makeDependencies().isEmpty() ? i18n("None") : p->makeDependencies().join(" ")) << endl;
}
out << "\t" << qSetFieldWidth(n) << fields["Optional dependencies:"] << qSetFieldWidth(0) << (p->optionalDependencies().isEmpty() ? i18n("None") : p->optionalDependencies().join(" ")) << endl;
out << "\t" << qSetFieldWidth(n) << fields["Replaces:"] << qSetFieldWidth(0) << (p->replaces().isEmpty() ? i18n("None") : p->replaces().join(" ")) << endl;
out << "\t" << qSetFieldWidth(n) << fields["Packager:"] << qSetFieldWidth(0) << p->packager() << endl;
......
......@@ -18,7 +18,7 @@ namespace Akabei {
};
namespace Utils {
void printPackageInformation(Akabei::Package const * p, QTextStream &out, bool showLess = false);
void printPackageInformation(Akabei::Package const * 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