src/_pakfire/problem.h \
src/_pakfire/progressbar.c \
src/_pakfire/progressbar.h \
- src/_pakfire/relation.c \
- src/_pakfire/relation.h \
src/_pakfire/repo.c \
src/_pakfire/repo.h \
src/_pakfire/request.c \
src/libpakfire/problem.c \
src/libpakfire/progressbar.c \
src/libpakfire/pwd.c \
- src/libpakfire/relation.c \
- src/libpakfire/relationlist.c \
src/libpakfire/repo.c \
src/libpakfire/repolist.c \
src/libpakfire/request.c \
src/libpakfire/include/pakfire/problem.h \
src/libpakfire/include/pakfire/progressbar.h \
src/libpakfire/include/pakfire/pwd.h \
- src/libpakfire/include/pakfire/relation.h \
- src/libpakfire/include/pakfire/relationlist.h \
src/libpakfire/include/pakfire/repo.h \
src/libpakfire/include/pakfire/repolist.h \
src/libpakfire/include/pakfire/request.h \
#include "parser.h"
#include "problem.h"
#include "progressbar.h"
-#include "relation.h"
#include "repo.h"
#include "request.h"
#include "solution.h"
Py_INCREF(&RepoType);
PyModule_AddObject(module, "Repo", (PyObject *)&RepoType);
- // Relation
- if (PyType_Ready(&RelationType) < 0)
- return NULL;
-
- Py_INCREF(&RelationType);
- PyModule_AddObject(module, "Relation", (PyObject *)&RelationType);
-
// Request
if (PyType_Ready(&RequestType) < 0)
return NULL;
#include <pakfire/file.h>
#include <pakfire/filelist.h>
#include <pakfire/package.h>
-#include <pakfire/relationlist.h>
#include <pakfire/repo.h>
#include <pakfire/util.h>
#include "package.h"
#include "pakfire.h"
-#include "relation.h"
#include "repo.h"
PyObject* new_package(PyTypeObject* type, PakfirePackage pkg) {
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2011 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#include <Python.h>
-
-#include <pakfire/package.h>
-#include <pakfire/packagelist.h>
-#include <pakfire/relation.h>
-#include <pakfire/types.h>
-#include <pakfire/util.h>
-
-#include "package.h"
-#include "relation.h"
-
-PyObject* new_relation(PyTypeObject* type, PakfireRelation relation) {
- RelationObject* self = (RelationObject *)type->tp_alloc(type, 0);
- if (self) {
- self->relation = pakfire_relation_ref(relation);
- }
-
- return (PyObject*)self;
-}
-
-static PyObject* Relation_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
- RelationObject* self = (RelationObject *)type->tp_alloc(type, 0);
- if (self) {
- self->relation = NULL;
- }
-
- return (PyObject*)self;
-}
-
-static void Relation_dealloc(RelationObject* self) {
- pakfire_relation_unref(self->relation);
-
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-static int Relation_init(RelationObject* self, PyObject* args, PyObject* kwds) {
- PakfireObject* pakfire;
- const char* relation;
-
- if (!PyArg_ParseTuple(args, "O!s", &PakfireType, &pakfire, &relation))
- return -1;
-
- self->relation = pakfire_relation_create_from_string(pakfire->pakfire, relation);
- if (!self->relation) {
- PyErr_Format(PyExc_ValueError, "No such relation: %s", relation);
- return -1;
- }
-
- return 0;
-}
-
-static long Relation_hash(RelationObject* self) {
- return pakfire_relation_get_id(self->relation);
-}
-
-static PyObject* Relation_repr(RelationObject* self) {
- char* relation = pakfire_relation_str(self->relation);
-
- PyObject* repr = PyUnicode_FromFormat("<_pakfire.Relation %s>", relation);
- free(relation);
-
- return repr;
-}
-
-static PyObject* Relation_str(RelationObject* self) {
- char* relation = pakfire_relation_str(self->relation);
-
- PyObject* str = PyUnicode_FromString(relation);
- free(relation);
-
- return str;
-}
-
-static PyObject* Relation_get_providers(RelationObject* self) {
- PakfirePackageList packagelist = pakfire_relation_providers(self->relation);
-
- PyObject* list = PyList_New(0);
- for (unsigned int i = 0; i < pakfire_packagelist_count(packagelist); i++) {
- PakfirePackage package = pakfire_packagelist_get(packagelist, i);
-
- PyObject* obj = new_package(&PackageType, package);
- PyList_Append(list, obj);
-
- pakfire_package_unref(package);
- Py_DECREF(obj);
- }
-
- pakfire_packagelist_unref(packagelist);
-
- return list;
-}
-
-static struct PyGetSetDef Relation_getsetters[] = {
- {
- "providers",
- (getter)Relation_get_providers,
- NULL,
- NULL,
- NULL
- },
- { NULL },
-};
-
-PyTypeObject RelationType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- tp_name: "_pakfire.Relation",
- tp_basicsize: sizeof(RelationObject),
- tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- tp_new: Relation_new,
- tp_dealloc: (destructor)Relation_dealloc,
- tp_init: (initproc)Relation_init,
- tp_doc: "Relation object",
- tp_hash: (hashfunc)Relation_hash,
- tp_repr: (reprfunc)Relation_repr,
- tp_str: (reprfunc)Relation_str,
- tp_getset: Relation_getsetters,
-};
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2011 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#ifndef PYTHON_PAKFIRE_RELATION_H
-#define PYTHON_PAKFIRE_RELATION_H
-
-#include <Python.h>
-
-#include <pakfire/types.h>
-
-#include "pakfire.h"
-
-typedef struct {
- PyObject_HEAD
- PakfireRelation relation;
-} RelationObject;
-
-extern PyTypeObject RelationType;
-
-PyObject* new_relation(PyTypeObject* type, PakfireRelation relation);
-
-#endif /* PYTHON_PAKFIRE_RELATION_H */
#include "package.h"
#include "pakfire.h"
#include "problem.h"
-#include "relation.h"
#include "request.h"
#include "transaction.h"
#include <pakfire/package.h>
#include <pakfire/pakfire.h>
#include <pakfire/private.h>
-#include <pakfire/relationlist.h>
#include <pakfire/repo.h>
#include <pakfire/types.h>
#include <pakfire/util.h>
#include <time.h>
#include <pakfire/filelist.h>
-#include <pakfire/relation.h>
-#include <pakfire/relationlist.h>
#include <pakfire/types.h>
PakfirePackage pakfire_package_create(Pakfire pakfire, PakfireRepo repo,
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2013 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#ifndef PAKFIRE_RELATION_H
-#define PAKFIRE_RELATION_H
-
-#include <solv/pool.h>
-#include <solv/pooltypes.h>
-#include <solv/queue.h>
-
-#include <pakfire/types.h>
-
-PakfireRelation pakfire_relation_create(Pakfire pakfire, const char* name, int cmp_type, const char* evr);
-PakfireRelation pakfire_relation_create_from_id(Pakfire pakfire, Id id);
-PakfireRelation pakfire_relation_create_from_string(Pakfire pakfire, const char* s);
-
-PakfireRelation pakfire_relation_ref(PakfireRelation relation);
-PakfireRelation pakfire_relation_unref(PakfireRelation relation);
-
-Id pakfire_relation_get_id(PakfireRelation relation);
-char* pakfire_relation_str(PakfireRelation relation);
-
-PakfirePackageList pakfire_relation_providers(PakfireRelation relation);
-
-int pakfire_relation2queue(const PakfireRelation relation, Queue* queue, int solver_action);
-
-#endif /* PAKFIRE_RELATION_H */
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2013 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#ifndef PAKFIRE_RELATIONLIST_H
-#define PAKFIRE_RELATIONLIST_H
-
-#include <pakfire/types.h>
-
-int pakfire_relationlist_create(PakfireRelationList* list, Pakfire pakfire);
-int pakfire_relationlist_create_from_string(PakfireRelationList* list,
- Pakfire pakfire, const char* s);
-
-PakfireRelationList pakfire_relationlist_ref(PakfireRelationList relationlist);
-PakfireRelationList pakfire_relationlist_unref(PakfireRelationList relationlist);
-
-void pakfire_relationlist_add(PakfireRelationList relationlist, PakfireRelation relation);
-size_t pakfire_relationlist_size(PakfireRelationList relationlist);
-
-PakfireRelation pakfire_relationlist_get(PakfireRelationList relationlist, int index);
-
-void pakfire_relationlist_sort(PakfireRelationList list);
-
-#ifdef PAKFIRE_PRIVATE
-
-int pakfire_relationlist_from_queue(PakfireRelationList* list, Pakfire pakfire, Queue q);
-Queue* pakfire_relationlist_get_queue(PakfireRelationList list);
-
-#endif
-
-#endif /* PAKFIRE_RELATIONLIST_H */
typedef struct _PakfirePackageList* PakfirePackageList;
typedef struct _PakfireParser* PakfireParser;
typedef struct _PakfireProblem* PakfireProblem;
-typedef struct _PakfireRelation* PakfireRelation;
-typedef struct _PakfireRelationList* PakfireRelationList;
typedef struct _PakfireRepo* PakfireRepo;
typedef struct _PakfireSolution* PakfireSolution;
typedef struct _PakfireStep* PakfireStep;
#include <pakfire/package.h>
#include <pakfire/pakfire.h>
#include <pakfire/private.h>
-#include <pakfire/relation.h>
-#include <pakfire/relationlist.h>
#include <pakfire/repo.h>
#include <pakfire/util.h>
return array;
}
-static void pakfire_package_set_relationlist(PakfirePackage pkg, Id type,
- PakfireRelationList relationlist, Id marker) {
- Solvable* s = get_solvable(pkg);
- Queue* q = pakfire_relationlist_get_queue(relationlist);
-
-#if 0
- // This implemention should be the fastest, but unfortunately does not work.
- solvable_set_deparray(s, type, q, marker);
-#else
- for (int i = 0; i < q->count; i++)
- solvable_add_deparray(s, type, q->elements[i], marker);
-#endif
-}
-
static void pakfire_package_add_dep(PakfirePackage pkg, Id type,
const char* dep, Id marker) {
Solvable* s = get_solvable(pkg);
return pakfire_package_get_relationlist(pkg, SOLVABLE_PROVIDES, -SOLVABLE_FILEMARKER);
}
-PAKFIRE_EXPORT void pakfire_package_set_provides(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_PROVIDES, relationlist, -SOLVABLE_FILEMARKER);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_provides(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_provides(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_PROVIDES, dep, -SOLVABLE_FILEMARKER);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_REQUIRES, SOLVABLE_PREREQMARKER);
}
-PAKFIRE_EXPORT void pakfire_package_set_prerequires(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_REQUIRES, relationlist, SOLVABLE_PREREQMARKER);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_prerequires(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_prerequires(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_REQUIRES, dep, SOLVABLE_PREREQMARKER);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_REQUIRES, -SOLVABLE_PREREQMARKER);
}
-PAKFIRE_EXPORT void pakfire_package_set_requires(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_REQUIRES, relationlist, -SOLVABLE_PREREQMARKER);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_requires(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_requires(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_REQUIRES, dep, -SOLVABLE_PREREQMARKER);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_CONFLICTS, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_conflicts(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_CONFLICTS, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_conflicts(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_conflicts(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_CONFLICTS, dep, 0);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_OBSOLETES, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_obsoletes(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_OBSOLETES, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_obsoletes(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_obsoletes(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_OBSOLETES, dep, 0);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_RECOMMENDS, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_recommends(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_RECOMMENDS, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_recommends(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_recommends(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_RECOMMENDS, dep, 0);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_SUGGESTS, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_suggests(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_SUGGESTS, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_suggests(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_suggests(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_SUGGESTS, dep, 0);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_SUPPLEMENTS, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_supplements(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_SUPPLEMENTS, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_supplements(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_supplements(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_SUPPLEMENTS, dep, 0);
}
return pakfire_package_get_relationlist(pkg, SOLVABLE_ENHANCES, 0);
}
-PAKFIRE_EXPORT void pakfire_package_set_enhances(PakfirePackage pkg, PakfireRelationList relationlist) {
- pakfire_package_set_relationlist(pkg, SOLVABLE_ENHANCES, relationlist, 0);
-}
-
-PAKFIRE_EXPORT void pakfire_package_add_enhances(PakfirePackage pkg, const char* dep) {
+void pakfire_package_add_enhances(PakfirePackage pkg, const char* dep) {
pakfire_package_add_dep(pkg, SOLVABLE_ENHANCES, dep, 0);
}
}
if (is_source) {
- PakfireRelationList list;
-
// Fetch build dependencies
char* requires = pakfire_parser_get(parser, "build", "requires");
if (requires && *requires) {
- r = pakfire_relationlist_create_from_string(&list, parser->pakfire, requires);
- if (r) {
- pakfire_relationlist_unref(list);
- goto CLEANUP;
- }
+ char* p = requires;
+
+ while (*p) {
+ char* e = strchr(p, '\n');
- pakfire_package_set_requires(*pkg, list);
- pakfire_relationlist_unref(list);
+ // Terminate the string
+ if (e)
+ *e = '\0';
+
+ // Add the dependency
+ pakfire_package_add_requires(*pkg, p);
+
+ // End loop when we reached the end
+ if (!e)
+ break;
+
+ // Or continue at the next line
+ p = e + 1;
+ }
}
}
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2013 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#include <stdlib.h>
-
-#include <solv/pooltypes.h>
-#include <solv/queue.h>
-#include <solv/solver.h>
-
-#include <pakfire/logging.h>
-#include <pakfire/packagelist.h>
-#include <pakfire/pakfire.h>
-#include <pakfire/private.h>
-#include <pakfire/relation.h>
-#include <pakfire/types.h>
-#include <pakfire/util.h>
-
-struct _PakfireRelation {
- Pakfire pakfire;
- Id id;
- int nrefs;
-};
-
-const char* delimiters[] = {
- ">=", ">", "<=", "<", "=", NULL,
-};
-
-static int cmp2type(const char* s) {
- if (strcmp(s, ">=") == 0)
- return PAKFIRE_GE;
-
- if (strcmp(s, ">") == 0)
- return PAKFIRE_GT;
-
- if (strcmp(s, "<=") == 0)
- return PAKFIRE_LE;
-
- if (strcmp(s, "<") == 0)
- return PAKFIRE_LT;
-
- if (strcmp(s, "=") == 0)
- return PAKFIRE_EQ;
-
- return 0;
-}
-
-static int cmptype2relflags(int type) {
- int flags = 0;
-
- if (type & PAKFIRE_EQ)
- flags |= REL_EQ;
- if (type & PAKFIRE_LT)
- flags |= REL_LT;
- if (type & PAKFIRE_GT)
- flags |= REL_GT;
-
- return flags;
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relation_create(Pakfire pakfire, const char* name, int cmp_type, const char* evr) {
- Pool* p = pakfire_get_solv_pool(pakfire);
-
- Id id = pool_str2id(p, name, 1);
-
- if (id == STRID_NULL || id == STRID_EMPTY)
- return NULL;
-
- if (evr) {
- Id ievr = pool_str2id(p, evr, 1);
- int flags = cmptype2relflags(cmp_type);
- id = pool_rel2id(p, id, ievr, flags, 1);
- }
-
- return pakfire_relation_create_from_id(pakfire, id);
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relation_create_from_id(Pakfire pakfire, Id id) {
- PakfireRelation relation = calloc(1, sizeof(*relation));
- if (relation) {
- DEBUG(pakfire, "Allocated Relation at %p\n", relation);
- relation->nrefs = 1;
-
- relation->pakfire = pakfire_ref(pakfire);
- relation->id = id;
- }
-
- return relation;
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relation_create_from_string(Pakfire pakfire, const char* s) {
- DEBUG(pakfire, "Parsing relation from string: %s\n", s);
-
- char* name;
- char* evr;
-
- const char** delim = delimiters;
- while (*delim) {
- pakfire_string_partition(s, *delim, &name, &evr);
-
- // Nothing to do for no match
- if (!name && !evr) {
- delim++;
- continue;
- }
-
- // Create new relation object
- PakfireRelation rel = pakfire_relation_create(pakfire, name, cmp2type(*delim), evr);
-
- // Cleanup
- free(name);
- free(evr);
-
- return rel;
- }
-
- // No delimiter was found
- return pakfire_relation_create(pakfire, s, 0, NULL);
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relation_ref(PakfireRelation relation) {
- relation->nrefs++;
-
- return relation;
-}
-
-static void pakfire_relation_free(PakfireRelation relation) {
- DEBUG(relation->pakfire, "Releasing Relation at %p\n", relation);
-
- pakfire_unref(relation->pakfire);
- free(relation);
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relation_unref(PakfireRelation relation) {
- if (!relation)
- return NULL;
-
- if (--relation->nrefs > 0)
- return relation;
-
- pakfire_relation_free(relation);
- return NULL;
-}
-
-PAKFIRE_EXPORT Id pakfire_relation_get_id(PakfireRelation relation) {
- return relation->id;
-}
-
-PAKFIRE_EXPORT char* pakfire_relation_str(PakfireRelation relation) {
- Pool* pool = pakfire_get_solv_pool(relation->pakfire);
-
- const char* str = pool_dep2str(pool, relation->id);
-
- return strdup(str);
-}
-
-PAKFIRE_EXPORT int pakfire_relation2queue(const PakfireRelation relation, Queue* queue, int solver_action) {
- queue_push2(queue, SOLVER_SOLVABLE_PROVIDES|solver_action, relation->id);
-
- return 0;
-}
-
-PAKFIRE_EXPORT PakfirePackageList pakfire_relation_providers(PakfireRelation relation) {
- Queue q;
- queue_init(&q);
-
- pakfire_relation2queue(relation, &q, 0);
-
- PakfirePackageList list = pakfire_packagelist_from_queue(relation->pakfire, &q);
-
- queue_free(&q);
-
- return list;
-}
+++ /dev/null
-/*#############################################################################
-# #
-# Pakfire - The IPFire package management system #
-# Copyright (C) 2013 Pakfire development team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-#############################################################################*/
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <solv/pooltypes.h>
-#include <solv/queue.h>
-
-#include <pakfire/logging.h>
-#include <pakfire/pakfire.h>
-#include <pakfire/private.h>
-#include <pakfire/relation.h>
-#include <pakfire/relationlist.h>
-#include <pakfire/types.h>
-#include <pakfire/util.h>
-
-struct _PakfireRelationList {
- Pakfire pakfire;
- Queue queue;
- int nrefs;
-};
-
-PAKFIRE_EXPORT int pakfire_relationlist_create(PakfireRelationList* list, Pakfire pakfire) {
- PakfireRelationList l = calloc(1, sizeof(*l));
- if (!l)
- return ENOMEM;
-
- DEBUG(pakfire, "Allocated RelationList at %p\n", l);
- l->pakfire = pakfire_ref(pakfire);
- l->nrefs = 1;
-
- queue_init(&l->queue);
-
- *list = l;
- return 0;
-}
-
-PAKFIRE_EXPORT int pakfire_relationlist_create_from_string(PakfireRelationList* list, Pakfire pakfire, const char* s) {
- int r = pakfire_relationlist_create(list, pakfire);
- if (r)
- return r;
-
- // Split input by newline
- char** elements = pakfire_split_string(s, '\n');
- if (!elements)
- return 1;
-
- for (char** element = elements; *element; element++) {
- PakfireRelation rel = pakfire_relation_create_from_string(pakfire, *element);
- if (rel) {
- pakfire_relationlist_add(*list, rel);
- pakfire_relation_unref(rel);
- }
-
- free(*element);
- }
-
- free(elements);
-
- return 0;
-}
-
-PAKFIRE_EXPORT PakfireRelationList pakfire_relationlist_ref(PakfireRelationList relationlist) {
- relationlist->nrefs++;
-
- return relationlist;
-}
-
-static void pakfire_relationlist_free(PakfireRelationList relationlist) {
- DEBUG(relationlist->pakfire, "Releasing RelationList at %p\n", relationlist);
- pakfire_unref(relationlist->pakfire);
-
- queue_free(&relationlist->queue);
- free(relationlist);
-}
-
-PAKFIRE_EXPORT PakfireRelationList pakfire_relationlist_unref(PakfireRelationList relationlist) {
- if (!relationlist)
- return NULL;
-
- if (--relationlist->nrefs > 0)
- return relationlist;
-
- pakfire_relationlist_free(relationlist);
- return NULL;
-}
-
-PAKFIRE_EXPORT void pakfire_relationlist_add(PakfireRelationList relationlist, PakfireRelation relation) {
- queue_push(&relationlist->queue, pakfire_relation_get_id(relation));
-}
-
-PAKFIRE_EXPORT size_t pakfire_relationlist_size(PakfireRelationList relationlist) {
- return relationlist->queue.count;
-}
-
-PAKFIRE_EXPORT int pakfire_relationlist_from_queue(PakfireRelationList* list, Pakfire pakfire, Queue q) {
- int r = pakfire_relationlist_create(list, pakfire);
- if (r)
- return r;
-
- // Release old queue
- queue_free(&(*list)->queue);
-
- // Copy the queue
- queue_init_clone(&(*list)->queue, &q);
-
- return 0;
-}
-
-PAKFIRE_EXPORT PakfireRelation pakfire_relationlist_get(PakfireRelationList relationlist, int index) {
- if (index >= relationlist->queue.count)
- return NULL;
-
- Id id = relationlist->queue.elements[index];
-
- return pakfire_relation_create_from_id(relationlist->pakfire, id);
-}
-
-Queue* pakfire_relationlist_get_queue(PakfireRelationList list) {
- return &list->queue;
-}
-
-static int __sort(const void* _rel1, const void* _rel2, void* _pool) {
- const char* s1 = pool_dep2str((Pool*)_pool, *(Id*)_rel1);
- const char* s2 = pool_dep2str((Pool*)_pool, *(Id*)_rel2);
-
- return strcmp(s1, s2);
-}
-
-PAKFIRE_EXPORT void pakfire_relationlist_sort(PakfireRelationList list) {
- Pool* pool = pakfire_get_solv_pool(list->pakfire);
-
- qsort_r(list->queue.elements, list->queue.count, sizeof(*list->queue.elements),
- __sort, pool);
-}