Commit bf4ffe1e authored by Lukas Appelhans's avatar Lukas Appelhans

Some hooks stuff and make the loading of groups easier

parent a05b6783
......@@ -17,13 +17,30 @@
#include <QDebug>
namespace Akabei {
class Hook
{
public:
Hook(Akabei::Database* database, const QString &string)
: db(database), name(string)
{}
~Hook() {}
bool operator==(const Hook &other) const { return ((other.db == db) && other.name == name);}
Akabei::Database * db;
QString name;
};
uint qHash(const Hook &hook) { return (qHash(hook.name) ^ qHash(hook.db->name()));}
class AkabeiPlainHookOperation::Private
{
public:
Private() {}
~Private() {}
QMap<Akabei::Database*, QSet<QString> > hooks;
//QMap<Akabei::Database*, QSet<QString> > hooks;
QSet<Hook> hooks;
};
class HookOpHelper
......@@ -67,7 +84,8 @@ AkabeiPlainHookOperation::~AkabeiPlainHookOperation()
void AkabeiPlainHookOperation::add(Database* db, const QString& hook)
{
d->hooks[db].insert(hook);
Hook h(db, hook);
d->hooks.insert(h);
}
void AkabeiPlainHookOperation::add(Database* db, const QStringList& hooks)
......
......@@ -81,10 +81,9 @@ bool performIntBind(sqlite3_stmt *stmt, const char *name, qint64 field)
return false;
}
CreateDb::CreateDb(const QString& db, const QString &groupDefinitions, const QStringList& targets, QObject* parent)
CreateDb::CreateDb(const QString& db, const QStringList& targets, QObject* parent)
: QObject(parent)
, m_db(db)
, m_groups(groupDefinitions)
, m_targets(targets)
, out(stdout)
, in(stdin, QFile::ReadOnly)
......@@ -284,13 +283,6 @@ void CreateDb::start()
out << "Succeeded! Will use " << path << " as temporary file." << endl;
out << endl;
m_groups = cleanPath(m_groups);
out << "Adding group definitions from " << m_groups << " to temporary akabei run" << endl;
QDir dir(m_groups);
foreach (const QString &path, dir.entryList())
Akabei::Backend::instance()->loadGroupFromFile(dir.absoluteFilePath(path));
// Ok, now load all the targets
QHash< QString, QList< Akabei::Package* > > packages;
QSet<Akabei::Group*> groups;
......@@ -309,6 +301,12 @@ void CreateDb::start()
foreach (const QString &target, cleanTargets) {
++idx;
//Is it a group?
if (target.endsWith(".group")) {
Akabei::Backend::instance()->loadGroupFromFile(target);
qDebug() << "Added group:" << target;
continue;
}
// Is it a delta?
if (target.endsWith(".delta.tar.xz")) {
// It is. Let's try loading it
......
......@@ -21,7 +21,7 @@ class CreateDb : public QObject
{
Q_OBJECT
public:
CreateDb(const QString &db, const QString &groupDefinitions, const QStringList &targets, QObject* parent = 0);
CreateDb(const QString &db, const QStringList &targets, QObject* parent = 0);
virtual ~CreateDb();
public slots:
......@@ -33,7 +33,6 @@ class CreateDb : public QObject
private:
QString m_db;
QString m_groups;
QStringList m_targets;
QTextStream out;
QTextStream in;
......
......@@ -28,13 +28,11 @@ int main(int argc, char **argv)
}
QString newDbPath = args.at(1);
QString groupDefinitions = args.at(2);
QStringList targets = args;
targets.removeAt(0);
targets.removeAt(0);
targets.removeAt(0);
CreateDb db(newDbPath, groupDefinitions, targets);
CreateDb db(newDbPath, targets);
QTimer::singleShot(0, &db, SLOT(start()));
......
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