Commit 838882b7 authored by Lisa's avatar Lisa

Makedepends added to packages.

parent cb1ad6cc
......@@ -69,6 +69,15 @@ CREATE TABLE IF NOT EXISTS `depends` (
REFERENCES `packages` (`id` )
ON UPDATE CASCADE);
CREATE TABLE IF NOT EXISTS `makedepends` (
`id` INTEGER PRIMARY KEY ASC ,
`package` INTEGER NOT NULL ,
`dependency` TEXT NOT NULL,
CONSTRAINT `fk_requires_package`
FOREIGN KEY (`package` )
REFERENCES `packages` (`id` )
ON UPDATE CASCADE);
CREATE TABLE IF NOT EXISTS `conflicts` (
`id` INTEGER PRIMARY KEY ASC ,
`package` INTEGER NOT NULL ,
......
......@@ -633,7 +633,7 @@ OperationRunner* Backend::operationRunner()
Package* Backend::loadPackageFromFile(const QString& path)
{
Q_D(Backend);
if (!QFile::exists(path)) {
return 0;
}
......@@ -665,6 +665,7 @@ Package* Backend::loadPackageFromFile(const QString& path)
// Recheck if it's commented over
if (key.startsWith('#')) {
// Pass by
continue;
}
// Strip whitespaces here instead
......@@ -693,6 +694,8 @@ Package* Backend::loadPackageFromFile(const QString& path)
retpackage->d_func()->setSize(value.toInt());
} else if (key == "depend") {
retpackage->d_func()->addDependency(value);
} else if (key == "makedepend") {
retpackage->d_func()->addMakeDependency(value);
} else if (key == "optdepend") {
retpackage->d_func()->addOptDependency(value);
} else if (key == "conflict") {
......
......@@ -126,43 +126,48 @@ Package* DatabasePrivate::packageFromRow(SQLiteResource& table, int row)
// Fetch the provided package names
SQLiteResource res = dbConnection.query(QString("SELECT provides FROM provides WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("provides")) {
foreach (const QVariant& v, res.getColumn("provides")) {
package->d_func()->addProvider(v.toString());
}
// Fetch the conflicting package names
res = dbConnection.query(QString("SELECT conflict FROM conflicts WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("conflict")) {
foreach (const QVariant& v, res.getColumn("conflict")) {
package->d_func()->addConflict(v.toString());
}
// Fetch the package names to which we depend on
res = dbConnection.query(QString("SELECT dependency FROM depends WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("dependency")) {
foreach (const QVariant& v, res.getColumn("dependency")) {
package->d_func()->addDependency(v.toString());
}
res = dbConnection.query(QString("SELECT dependency FROM makedepends WHERE package=%1").arg(id));
foreach (const QVariant& v, res.getColumn("dependency")) {
package->d_func()->addMakeDependency(v.toString());
}
// Fetch the package names to which we optionally dependend on
res = dbConnection.query(QString("SELECT dependency FROM optional WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("dependency")) {
foreach (const QVariant& v, res.getColumn("dependency")) {
package->d_func()->addOptDependency(v.toString());
}
// Fetch the packages names that we replace
res = dbConnection.query(QString("SELECT replaces FROM replaces WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("replaces")) {
foreach (const QVariant& v, res.getColumn("replaces")) {
package->d_func()->addReplaces(v.toString());
}
// Fetch the mimetypes which we provide
res = dbConnection.query(QString("SELECT mimetype FROM providesmimetype WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("mimetype")) {
foreach (const QVariant& v, res.getColumn("mimetype")) {
package->d_func()->addMimetype(v.toString());
}
// Fetch the licenses of this package
res = dbConnection.query(QString("SELECT license FROM licensed WHERE package=%1").arg(id));
foreach (QVariant v, res.getColumn("license")) {
foreach (const QVariant& v, res.getColumn("license")) {
package->d_func()->addLicense(v.toString());
}
......
......@@ -419,6 +419,13 @@ int QueryPerformer::insertPackage(SQLiteConnection &dbConnection, Package* p)
dbConnection.bind(":Depend", dependency);
dbConnection.query(sqlQuery);
}
foreach (const QString& makedep, p->makeDependencies()) {
sqlQuery = "INSERT INTO makedepends ('package', 'dependency') VALUES (:Package, :MakeDepend);";
dbConnection.bind(":Package", id);
dbConnection.bind(":MakeDepend", makedep);
dbConnection.query(sqlQuery);
}
foreach (const QString& opt, p->optionalDependencies()) {
sqlQuery = "INSERT INTO optional ('package', 'dependency') VALUES (:Package, :OptDepend);";
......
......@@ -112,6 +112,12 @@ void PackagePrivate::addDependency(const QString &d)
deps << d;
}
void PackagePrivate::addMakeDependency(const QString &d)
{
QWriteLocker locker(mutex);
makedeps << d;
}
void PackagePrivate::addConflict(const QString &c)
{
QWriteLocker locker(mutex);
......@@ -755,6 +761,13 @@ QStringList Package::dependencies() const
return d->deps;
}
QStringList Package::makeDependencies() const
{
Q_D(const Package);
QReadLocker locker(d->mutex);
return d->makedeps;
}
QString Package::retrieveScriptlet()
{
Q_D(Package);
......
......@@ -227,6 +227,7 @@ public:
* @see dependencies()
*/
List computeDependencies();
/**
* @returns a list of packages which have the current package as dependency
* This method is expensive on first call, because it needs to resolve a list of package names to a list of packages.
......@@ -251,6 +252,10 @@ public:
* @see computeDependencies
*/
QStringList dependencies() const;
/**
* @returns a list of package names that are make dependencies of this one.
*/
QStringList makeDependencies() const;
/**
* @returns a list of package names which conflict with the current package
*/
......
......@@ -69,6 +69,7 @@ public:
void setInstalledSize(qint32 is);
void addFile(const QString &f);
void addDependency(const QString &d);
void addMakeDependency(const QString &d);
void addConflict(const QString &c);
void addOptDependency(const QString &od);
void addReplaces(const QString &r);
......@@ -109,6 +110,7 @@ private:
qint32 isize;
QStringList files;
QStringList deps;
QStringList makedeps;
QStringList conflicts;
QStringList optdepends;
QStringList replaces;
......
......@@ -61,9 +61,7 @@ DatabaseWorker::DatabaseWorker(QObject * parent)
: QObject(parent),
db(0),
out(stdout)
{
}
{}
DatabaseWorker::~DatabaseWorker()
{
......
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