.PHONY: po
po:
- find pakfire -name "*.py" | grep -v "__version__.py" | sort > po/POTFILES.in
+ find pakfire src -name "*.py" -or -name "*.c" | grep -v "__version__.py" | sort > po/POTFILES.in
import transaction
+from i18n import _
+
class Request(_pakfire.Request):
def install(self, what):
if isinstance(what, Solvable):
return transaction.Transaction.from_solver(self.pakfire, self, t)
+ # Do the problem handling...
+ problems = self._solver.get_problems(request)
+
+ logging.info("")
+ logging.info(_("The solver returned %s problems:") % len(problems))
+ logging.info("")
+
+ i = 0
+ for p in self._solver.get_problems(request):
+ i += 1
+
+ # Print information about the problem to the user.
+ logging.info(_(" Problem #%d:") % i)
+ logging.info(" %s" % p)
+ logging.info("")
+
return res
pakfire/server.py
pakfire/transaction.py
pakfire/util.py
+src/_pakfiremodule.c
+src/pool.c
+src/problem.c
+src/relation.c
+src/repo.c
+src/request.c
+src/solvable.c
+src/solver.c
+src/step.c
+src/test.py
+src/transaction.c
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-24 18:12+0200\n"
+"POT-Creation-Date: 2011-07-29 15:04+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "Build the package for the given architecture."
msgstr ""
-#: ../pakfire/cli.py:318 ../pakfire/cli.py:342
+#: ../pakfire/cli.py:318 ../pakfire/cli.py:344
msgid "Path were the output files should be copied to."
msgstr ""
-#: ../pakfire/cli.py:320
+#: ../pakfire/cli.py:320 ../pakfire/cli.py:333
msgid "Mode to run in. Is either 'release' or 'development' (default)."
msgstr ""
msgid "Emulated architecture in the shell."
msgstr ""
-#: ../pakfire/cli.py:336
+#: ../pakfire/cli.py:338
msgid "Generate a source package."
msgstr ""
-#: ../pakfire/cli.py:338
+#: ../pakfire/cli.py:340
msgid "Give name(s) of a package(s)."
msgstr ""
-#: ../pakfire/cli.py:413
+#: ../pakfire/cli.py:416
msgid "Pakfire repo command line interface."
msgstr ""
-#: ../pakfire/cli.py:438
+#: ../pakfire/cli.py:441
msgid "Repository management commands."
msgstr ""
-#: ../pakfire/cli.py:446
+#: ../pakfire/cli.py:449
msgid "Create a new repository index."
msgstr ""
-#: ../pakfire/cli.py:447
+#: ../pakfire/cli.py:450
msgid "Path to the packages."
msgstr ""
-#: ../pakfire/cli.py:448
+#: ../pakfire/cli.py:451
msgid "Path to input packages."
msgstr ""
-#: ../pakfire/cli.py:460
+#: ../pakfire/cli.py:463
msgid "Pakfire master command line interface."
msgstr ""
-#: ../pakfire/cli.py:488
+#: ../pakfire/cli.py:491
msgid "Update the sources."
msgstr ""
-#: ../pakfire/cli.py:498
+#: ../pakfire/cli.py:501
msgid "Pakfire server command line interface."
msgstr ""
-#: ../pakfire/cli.py:530
+#: ../pakfire/cli.py:533
msgid "Request a build job from the server."
msgstr ""
-#: ../pakfire/cli.py:536
+#: ../pakfire/cli.py:539
msgid "Send a keepalive to the server."
msgstr ""
-#: ../pakfire/cli.py:543
+#: ../pakfire/cli.py:546
msgid "Update all repositories."
msgstr ""
msgid "Loading installed packages"
msgstr ""
+#: ../pakfire/satsolver.py:105
+#, python-format
+msgid "The solver returned %s problems:"
+msgstr ""
+
+#. Print information about the problem to the user.
+#: ../pakfire/satsolver.py:113
+#, python-format
+msgid " Problem #%d:"
+msgstr ""
+
#: ../pakfire/transaction.py:89
msgid "Downloading packages:"
msgstr ""
#, python-format
msgid "%s [y/N]"
msgstr ""
+
+#: ../src/problem.c:126
+#, c-format
+msgid "%s does not belong to a distupgrade repository"
+msgstr ""
+
+#: ../src/problem.c:133
+#, c-format
+msgid "%s has inferior architecture"
+msgstr ""
+
+#: ../src/problem.c:140
+#, c-format
+msgid "problem with installed package %s"
+msgstr ""
+
+#: ../src/problem.c:146
+#, c-format
+msgid "conflicting requests"
+msgstr ""
+
+#: ../src/problem.c:151
+#, c-format
+msgid "nothing provides requested %s"
+msgstr ""
+
+#: ../src/problem.c:157
+#, c-format
+msgid "some dependency problem"
+msgstr ""
+
+#: ../src/problem.c:162
+#, c-format
+msgid "package %s is not installable"
+msgstr ""
+
+#: ../src/problem.c:169
+#, c-format
+msgid "nothing provides %s needed by %s"
+msgstr ""
+
+#: ../src/problem.c:176
+#, c-format
+msgid "cannot install both %s and %s"
+msgstr ""
+
+#: ../src/problem.c:183
+#, c-format
+msgid "package %s conflicts with %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:191
+#, c-format
+msgid "package %s obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:199
+#, c-format
+msgid "installed package %s obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:207
+#, c-format
+msgid "package %s implicitely obsoletes %s provided by %s"
+msgstr ""
+
+#: ../src/problem.c:215
+#, c-format
+msgid "package %s requires %s, but none of the providers can be installed"
+msgstr ""
+
+#: ../src/problem.c:222
+#, c-format
+msgid "package %s conflicts with %s provided by itself"
+msgstr ""
+
+#: ../src/problem.c:231
+#, c-format
+msgid "bad rule type"
+msgstr ""
#include <Python.h>
+#include "config.h"
#include "pool.h"
#include "problem.h"
#include "relation.h"
};
static PyMethodDef Problem_methods[] = {
+ {"get_rule", (PyCFunction)Problem_get_rule, METH_NOARGS, NULL},
+ {"get_source", (PyCFunction)Problem_get_source, METH_NOARGS, NULL},
+ {"get_target", (PyCFunction)Problem_get_target, METH_NOARGS, NULL},
+ {"get_dep", (PyCFunction)Problem_get_dep, METH_NOARGS, NULL},
{ NULL, NULL, 0, NULL }
};
};
void init_pakfire(void) {
+ /* Initialize locale */
+ setlocale(LC_ALL, "");
+ bindtextdomain(TEXTDOMAIN, "/usr/share/locale");
+ textdomain(TEXTDOMAIN);
+
+ /* Load the python module */
PyObject *m, *d;
m = Py_InitModule("_pakfire", pakfireModuleMethods);
PyDict_SetItemString(d, "REL_GE", Py_BuildValue("i", REL_GT|REL_EQ));
// Add constants for search
- PyDict_SetItemString(d, "SEARCH_STRING", Py_BuildValue("i", SEARCH_STRING));
+ PyDict_SetItemString(d, "SEARCH_STRING", Py_BuildValue("i", SEARCH_STRING));
PyDict_SetItemString(d, "SEARCH_STRINGSTART", Py_BuildValue("i", SEARCH_STRINGSTART));
- PyDict_SetItemString(d, "SEARCH_STRINGEND", Py_BuildValue("i", SEARCH_STRINGEND));
- PyDict_SetItemString(d, "SEARCH_SUBSTRING", Py_BuildValue("i", SEARCH_SUBSTRING));
- PyDict_SetItemString(d, "SEARCH_GLOB", Py_BuildValue("i", SEARCH_GLOB));
- PyDict_SetItemString(d, "SEARCH_REGEX", Py_BuildValue("i", SEARCH_REGEX));
- PyDict_SetItemString(d, "SEARCH_FILES", Py_BuildValue("i", SEARCH_FILES));
- PyDict_SetItemString(d, "SEARCH_CHECKSUMS", Py_BuildValue("i", SEARCH_CHECKSUMS));
+ PyDict_SetItemString(d, "SEARCH_STRINGEND", Py_BuildValue("i", SEARCH_STRINGEND));
+ PyDict_SetItemString(d, "SEARCH_SUBSTRING", Py_BuildValue("i", SEARCH_SUBSTRING));
+ PyDict_SetItemString(d, "SEARCH_GLOB", Py_BuildValue("i", SEARCH_GLOB));
+ PyDict_SetItemString(d, "SEARCH_REGEX", Py_BuildValue("i", SEARCH_REGEX));
+ PyDict_SetItemString(d, "SEARCH_FILES", Py_BuildValue("i", SEARCH_FILES));
+ PyDict_SetItemString(d, "SEARCH_CHECKSUMS", Py_BuildValue("i", SEARCH_CHECKSUMS));
+
+ // Add constants for rules
+ PyDict_SetItemString(d, "SOLVER_RULE_DISTUPGRADE", Py_BuildValue("i", SOLVER_RULE_DISTUPGRADE));
+ PyDict_SetItemString(d, "SOLVER_RULE_INFARCH", Py_BuildValue("i", SOLVER_RULE_INFARCH));
+ PyDict_SetItemString(d, "SOLVER_RULE_UPDATE", Py_BuildValue("i", SOLVER_RULE_UPDATE));
+ PyDict_SetItemString(d, "SOLVER_RULE_JOB", Py_BuildValue("i", SOLVER_RULE_JOB));
+ PyDict_SetItemString(d, "SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP", Py_BuildValue("i", SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM", Py_BuildValue("i", SOLVER_RULE_RPM));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_NOT_INSTALLABLE", Py_BuildValue("i", SOLVER_RULE_RPM_NOT_INSTALLABLE));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP", Py_BuildValue("i", SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_SAME_NAME", Py_BuildValue("i", SOLVER_RULE_RPM_SAME_NAME));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_CONFLICT", Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_CONFLICT));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_OBSOLETES", Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_OBSOLETES));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES", Py_BuildValue("i", SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_IMPLICIT_OBSOLETES", Py_BuildValue("i", SOLVER_RULE_RPM_IMPLICIT_OBSOLETES));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_PACKAGE_REQUIRES", Py_BuildValue("i", SOLVER_RULE_RPM_PACKAGE_REQUIRES));
+ PyDict_SetItemString(d, "SOLVER_RULE_RPM_SELF_CONFLICT", Py_BuildValue("i", SOLVER_RULE_RPM_SELF_CONFLICT));
+ PyDict_SetItemString(d, "SOLVER_RULE_UNKNOWN", Py_BuildValue("i", SOLVER_RULE_UNKNOWN));
+ PyDict_SetItemString(d, "SOLVER_RULE_FEATURE", Py_BuildValue("i", SOLVER_RULE_FEATURE));
+ PyDict_SetItemString(d, "SOLVER_RULE_LEARNT", Py_BuildValue("i", SOLVER_RULE_LEARNT));
+ PyDict_SetItemString(d, "SOLVER_RULE_CHOICE", Py_BuildValue("i", SOLVER_RULE_CHOICE));
}
of the satsolver module.
*/
-#define DEBUG
+//#define DEBUG
+
+
+#define STRING_SIZE 2048
+
+/*
+ Load all required modules for the translation.
+*/
+
+#include <libintl.h>
+
+#define TEXTDOMAIN "pakfire"
+#define _(x) gettext(x)
+#include <Python.h>
+
+#include "config.h"
#include "problem.h"
+#include "relation.h"
#include "request.h"
+#include "solvable.h"
#include "solver.h"
PyTypeObject ProblemType = {
tp_new : Problem_new,
tp_dealloc: (destructor) Problem_dealloc,
tp_doc: "Sat Problem objects",
+ tp_str: (reprfunc)Problem_string,
};
PyObject* Problem_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
ProblemObject *self;
-
SolverObject *solver;
RequestObject *request;
Id problem_id;
if (!PyArg_ParseTuple(args, "OOi", &solver, &request, &problem_id)) {
/* XXX raise exception */
+ return NULL;
}
self = (ProblemObject *)type->tp_alloc(type, 0);
if (self != NULL) {
+ self->_pool = request->_pool;
self->_solver = solver->_solver;
-// self->_request = request->_request;
self->_id = problem_id;
+
+ // Initialize problem information.
+ Problem_init(self);
}
return (PyObject *)self;
}
PyObject *Problem_dealloc(ProblemObject *self) {
- //self->ob_type->tp_free((PyObject *)self);
+ self->ob_type->tp_free((PyObject *)self);
Py_RETURN_NONE;
}
+
+PyObject *Problem_init(ProblemObject *self) {
+ Id id = solver_findproblemrule(self->_solver, self->_id);
+
+ self->rule = solver_ruleinfo(self->_solver, id, &self->source,
+ &self->target, &self->dep);
+
+ Py_RETURN_NONE;
+}
+
+PyObject *Problem_get_rule(ProblemObject *self) {
+ return Py_BuildValue("i", self->rule);
+}
+
+PyObject *Problem_get_source(ProblemObject *self) {
+ SolvableObject *solvable;
+
+ if (self->source == ID_NULL)
+ Py_RETURN_NONE;
+
+ solvable = PyObject_New(SolvableObject, &SolvableType);
+ if (solvable == NULL)
+ return NULL;
+
+ solvable->_pool = self->_pool;
+ solvable->_id = self->source;
+
+ return (PyObject *)solvable;
+}
+
+PyObject *Problem_get_target(ProblemObject *self) {
+ SolvableObject *solvable;
+
+ if (self->target == ID_NULL)
+ Py_RETURN_NONE;
+
+ solvable = PyObject_New(SolvableObject, &SolvableType);
+ if (solvable == NULL)
+ return NULL;
+
+ solvable->_pool = self->_pool;
+ solvable->_id = self->target;
+
+ return (PyObject *)solvable;
+}
+
+PyObject *Problem_get_dep(ProblemObject *self) {
+ RelationObject *relation;
+
+ if (self->dep == ID_NULL)
+ Py_RETURN_NONE;
+
+ relation = PyObject_New(RelationObject, &RelationType);
+ if (relation == NULL)
+ return NULL;
+
+ relation->_pool = self->_pool;
+ relation->_id = self->dep;
+
+ return (PyObject *)relation;
+}
+
+PyObject *Problem_get_solutions(ProblemObject *self) {
+ PyObject *list = PyList_New(0);
+
+ return list;
+}
+
+PyObject *Problem_string(ProblemObject *self) {
+ Pool *pool = self->_pool;
+ char s[STRING_SIZE];
+
+ switch (self->rule) {
+ case SOLVER_RULE_DISTUPGRADE:
+ snprintf(s, STRING_SIZE - 1,
+ _("%s does not belong to a distupgrade repository"),
+ pool_solvid2str(pool, self->source)
+ );
+ break;
+
+ case SOLVER_RULE_INFARCH:
+ snprintf(s, STRING_SIZE - 1,
+ _("%s has inferior architecture"),
+ pool_solvid2str(pool, self->source)
+ );
+ break;
+
+ case SOLVER_RULE_UPDATE:
+ snprintf(s, STRING_SIZE - 1,
+ _("problem with installed package %s"),
+ pool_solvid2str(pool, self->source)
+ );
+ break;
+
+ case SOLVER_RULE_JOB:
+ snprintf(s, STRING_SIZE - 1, _("conflicting requests"));
+ break;
+
+ case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
+ snprintf(s, STRING_SIZE - 1,
+ _("nothing provides requested %s"),
+ pool_dep2str(pool, self->dep)
+ );
+ break;
+
+ case SOLVER_RULE_RPM:
+ snprintf(s, STRING_SIZE - 1, _("some dependency problem"));
+ break;
+
+ case SOLVER_RULE_RPM_NOT_INSTALLABLE:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s is not installable"),
+ pool_solvid2str(pool, self->source)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
+ snprintf(s, STRING_SIZE - 1,
+ _("nothing provides %s needed by %s"),
+ pool_dep2str(pool, self->dep), pool_solvid2str(pool, self->source)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_SAME_NAME:
+ snprintf(s, STRING_SIZE - 1,
+ _("cannot install both %s and %s"),
+ pool_dep2str(pool, self->source), pool_solvid2str(pool, self->target)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s conflicts with %s provided by %s"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+ pool_solvid2str(pool, self->target)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s obsoletes %s provided by %s"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+ pool_solvid2str(pool, self->target)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
+ snprintf(s, STRING_SIZE - 1,
+ _("installed package %s obsoletes %s provided by %s"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+ pool_solvid2str(pool, self->target)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s implicitely obsoletes %s provided by %s"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep),
+ pool_solvid2str(pool, self->target)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s requires %s, but none of the providers can be installed"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep)
+ );
+ break;
+
+ case SOLVER_RULE_RPM_SELF_CONFLICT:
+ snprintf(s, STRING_SIZE - 1,
+ _("package %s conflicts with %s provided by itself"),
+ pool_solvid2str(pool, self->source), pool_dep2str(pool, self->dep)
+ );
+ break;
+
+ case SOLVER_RULE_UNKNOWN:
+ case SOLVER_RULE_FEATURE:
+ case SOLVER_RULE_LEARNT:
+ case SOLVER_RULE_CHOICE:
+ snprintf(s, STRING_SIZE - 1, _("bad rule type"));
+ break;
+
+ }
+
+ return Py_BuildValue("s", &s);
+}
#include <satsolver/pool.h>
#include <satsolver/solver.h>
-// Sat Step object
+// Sat Problem object
typedef struct {
PyObject_HEAD
+ Pool *_pool;
Solver *_solver;
-// Request *_request;
Id _id;
+
+ // problem information
+ Id rule;
+ Id source;
+ Id target;
+ Id dep;
} ProblemObject;
-extern PyObject* Problem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+extern PyObject *Problem_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
extern PyObject *Problem_dealloc(ProblemObject *self);
+extern PyObject *Problem_init(ProblemObject *self);
+extern PyObject *Problem_string(ProblemObject *self);
+
+extern PyObject *Problem_get_rule(ProblemObject *self);
+extern PyObject *Problem_get_source(ProblemObject *self);
+extern PyObject *Problem_get_target(ProblemObject *self);
+extern PyObject *Problem_get_dep(ProblemObject *self);
+
extern PyTypeObject ProblemType;
#endif
tp_new : Relation_new,
tp_dealloc: (destructor) Relation_dealloc,
tp_doc: "Sat Relation objects",
+ tp_str: (reprfunc)Relation_string,
};
PyObject* Relation_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
Py_RETURN_NONE;
}
+
+PyObject *Relation_string(RelationObject *self) {
+ return Py_BuildValue("s", pool_dep2str(self->_pool, self->_id));
+}
Id _id;
} RelationObject;
-extern PyObject* Relation_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
+extern PyObject *Relation_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
extern PyObject *Relation_dealloc(RelationObject *self);
+extern PyObject *Relation_string(RelationObject *self);
+
extern PyTypeObject RelationType;
#endif
+#include <Python.h>
+
+#include "config.h"
#include "relation.h"
#include "repo.h"
#include "solvable.h"
tp_new : Solvable_new,
tp_dealloc: (destructor) Solvable_dealloc,
tp_doc: "Sat Solvable objects",
+ tp_str: (reprfunc)Solvable_string,
};
// Solvable
Py_RETURN_NONE;
}
+PyObject *Solvable_string(SolvableObject *self) {
+ Solvable *solvable = pool_id2solvable(self->_pool, self->_id);
+
+ const char *str = pool_solvable2str(self->_pool, solvable);
+
+ return Py_BuildValue("s", str);
+}
+
PyObject *Solvable_get_name(SolvableObject *self) {
Solvable *solvable = pool_id2solvable(self->_pool, self->_id);
extern PyObject* Solvable_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
extern PyObject *Solvable_dealloc(SolvableObject *self);
+extern PyObject *Solvable_string(SolvableObject *self);
+
extern PyObject *Solvable_get_name(SolvableObject *self);
extern PyObject *Solvable_get_evr(SolvableObject *self);
extern PyObject *Solvable_get_arch(SolvableObject *self);
solver_solve(self->_solver, &request->_queue);
+#ifdef DEBUG
solver_printallsolutions(self->_solver);
+#endif
if (self->_solver->problems.count == 0) {
Py_RETURN_TRUE;
if (!PyArg_ParseTuple(args, "O", &request)) {
/* XXX raise exception */
+ return NULL;
}
PyObject *list = PyList_New(0);
ProblemObject *problem;
- int i = 0;
- for(; i < self->_solver->problems.count; i++) {
+ Id p = 0;
+ while ((p = solver_next_problem(self->_solver, p)) != 0) {
problem = PyObject_New(ProblemObject, &ProblemType);
+
+ problem->_pool = self->_solver->pool;
problem->_solver = self->_solver;
- //problem->_request = request->_request;
- problem->_id = self->_solver->problems.elements[i];
+ problem->_id = p;
+ Problem_init(problem);
PyList_Append(list, (PyObject *)problem);
}
- Py_INCREF(list); // XXX do we need this here?
- return (PyObject *)list;
+ return list;
}