src/_pakfire/progressbar.h \
src/_pakfire/repo.c \
src/_pakfire/repo.h \
- src/_pakfire/request.c \
- src/_pakfire/request.h \
src/_pakfire/solution.c \
src/_pakfire/solution.h \
- src/_pakfire/transaction.c \
- src/_pakfire/transaction.h \
src/_pakfire/util.c \
src/_pakfire/util.h
#include "problem.h"
#include "progressbar.h"
#include "repo.h"
-#include "request.h"
#include "solution.h"
-#include "transaction.h"
#include "util.h"
PyObject* PyExc_BadSignatureError;
Py_INCREF(&RepoType);
PyModule_AddObject(module, "Repo", (PyObject *)&RepoType);
- // Request
- if (PyType_Ready(&RequestType) < 0)
- return NULL;
-
- Py_INCREF(&RequestType);
- PyModule_AddObject(module, "Request", (PyObject *)&RequestType);
-
// Solution
if (PyType_Ready(&SolutionType) < 0)
return NULL;
Py_INCREF(&SolutionType);
PyModule_AddObject(module, "Solution", (PyObject *)&SolutionType);
- // Transaction
- if (PyType_Ready(&TransactionType) < 0)
- return NULL;
-
- Py_INCREF(&TransactionType);
- PyModule_AddObject(module, "Transaction", (PyObject *)&TransactionType);
-
return module;
}
+++ /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/request.h>
-
-#include "errors.h"
-#include "package.h"
-#include "pakfire.h"
-#include "problem.h"
-#include "request.h"
-#include "transaction.h"
-
-static PyObject* Request_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
- RequestObject* self = (RequestObject *)type->tp_alloc(type, 0);
- if (self) {
- self->request = NULL;
- }
-
- return (PyObject *)self;
-}
-
-static void Request_dealloc(RequestObject* self) {
- pakfire_request_unref(self->request);
-
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-static int Request_init(RequestObject* self, PyObject* args, PyObject* kwds) {
- PakfireObject* pakfire;
-
- if (!PyArg_ParseTuple(args, "O!", &PakfireType, &pakfire))
- return -1;
-
- int r = pakfire_request_create(&self->request, pakfire->pakfire, 0);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return -1;
- }
-
- return 0;
-}
-
-static PyObject* Request_install(RequestObject* self, PyObject* args) {
- const char* what = NULL;
-
- if (!PyArg_ParseTuple(args, "s", &what))
- return NULL;
-
- int r = pakfire_request_install(self->request, what, 0);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_erase(RequestObject* self, PyObject* args) {
- const char* what = NULL;
- int flags = 0;
-
- if (!PyArg_ParseTuple(args, "s|i", &what, &flags))
- return NULL;
-
- int r = pakfire_request_erase(self->request, what, flags);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_upgrade(RequestObject* self, PyObject* args) {
- const char* what = NULL;
-
- if (!PyArg_ParseTuple(args, "s", &what))
- return NULL;
-
- int r = pakfire_request_upgrade(self->request, what, 0);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_upgrade_all(RequestObject* self) {
- int r = pakfire_request_upgrade_all(self->request);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_sync(RequestObject* self) {
- int r = pakfire_request_sync(self->request);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_verify(RequestObject* self) {
- int r = pakfire_request_verify(self->request);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Request_get_problems(RequestObject* self) {
- PyObject* list = PyList_New(0);
-
- PakfireProblem problem = pakfire_request_get_problems(self->request);
- while (problem) {
- PyObject* p = new_problem(problem);
- PyList_Append(list, p);
-
- Py_DECREF(p);
-
- // Move on to next problem
- problem = pakfire_problem_next(problem);
- }
-
- return list;
-}
-
-static PyObject* Request_solve(RequestObject* self, PyObject* args, PyObject *kwds) {
- char* kwlist[] = {"allow_archchange", "allow_downgrade", "allow_uninstall",
- "allow_vendorchange", "without_recommends", NULL};
-
- int allow_archchange = 0;
- int allow_downgrade = 0;
- int allow_uninstall = 0;
- int allow_vendorchange = 0;
- int without_recommends = 0;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ppppp", kwlist,
- &allow_archchange, &allow_downgrade, &allow_uninstall,
- &allow_vendorchange, &without_recommends))
- return NULL;
-
- int flags = 0;
- if (allow_archchange)
- flags |= PAKFIRE_SOLVER_ALLOW_ARCHCHANGE;
-
- if (allow_downgrade)
- flags |= PAKFIRE_SOLVER_ALLOW_DOWNGRADE;
-
- if (allow_uninstall)
- flags |= PAKFIRE_SOLVER_ALLOW_UNINSTALL;
-
- if (allow_vendorchange)
- flags |= PAKFIRE_SOLVER_ALLOW_VENDORCHANGE;
-
- if (without_recommends)
- flags |= PAKFIRE_SOLVER_WITHOUT_RECOMMENDS;
-
- int ret = pakfire_request_solve(self->request, flags);
-
- // Raise a DependencyError with all problems
- // if the request could not be solved
- if (ret) {
- PyObject* problems = Request_get_problems(self);
- PyErr_SetObject(PyExc_DependencyError, problems);
-
- Py_DECREF(problems);
- return NULL;
- }
-
- // Allocate the transaction and return it
- struct pakfire_transaction* transaction = pakfire_request_get_transaction(self->request);
- assert(transaction);
-
- return new_transaction(self, transaction);
-}
-
-static struct PyMethodDef Request_methods[] = {
- {
- "install",
- (PyCFunction)Request_install,
- METH_VARARGS,
- NULL
- },
- {
- "erase",
- (PyCFunction)Request_erase,
- METH_VARARGS,
- NULL
- },
- {
- "upgrade",
- (PyCFunction)Request_upgrade,
- METH_VARARGS,
- NULL
- },
- {
- "upgrade_all",
- (PyCFunction)Request_upgrade_all,
- METH_NOARGS,
- NULL
- },
- {
- "sync",
- (PyCFunction)Request_sync,
- METH_NOARGS,
- NULL
- },
- {
- "verify",
- (PyCFunction)Request_verify,
- METH_NOARGS,
- NULL
- },
- {
- "solve",
- (PyCFunction)Request_solve,
- METH_VARARGS|METH_KEYWORDS,
- NULL
- },
- { NULL }
-};
-
-static struct PyGetSetDef Request_getsetters[] = {
- {
- "problems",
- (getter)Request_get_problems,
- NULL,
- NULL,
- NULL
- },
- { NULL },
-};
-
-PyTypeObject RequestType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- tp_name: "_pakfire.Request",
- tp_basicsize: sizeof(RequestObject),
- tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- tp_new: Request_new,
- tp_dealloc: (destructor)Request_dealloc,
- tp_init: (initproc)Request_init,
- tp_doc: "Request object",
- tp_methods: Request_methods,
- tp_getset: Request_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_REQUEST_H
-#define PYTHON_PAKFIRE_REQUEST_H
-
-#include <Python.h>
-
-#include <pakfire/request.h>
-
-typedef struct {
- PyObject_HEAD
- struct pakfire_request* request;
-} RequestObject;
-
-extern PyTypeObject RequestType;
-
-#endif /* PYTHON_PAKFIRE_REQUEST_H */
+++ /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/request.h>
-#include <pakfire/transaction.h>
-
-#include "package.h"
-#include "transaction.h"
-#include "util.h"
-
-static TransactionObject* Transaction_new_core(PyTypeObject* type, RequestObject* request) {
- TransactionObject* self = (TransactionObject *)type->tp_alloc(type, 0);
- if (!self)
- return NULL;
-
- if (request) {
- self->request = request;
- Py_INCREF(self->request);
- }
-
- self->transaction = NULL;
-
- return self;
-}
-
-PyObject* new_transaction(RequestObject* request, struct pakfire_transaction* trans) {
- TransactionObject* transaction = Transaction_new_core(&TransactionType, request);
- transaction->transaction = trans;
-
- return (PyObject *)transaction;
-}
-
-static PyObject* Transaction_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
- TransactionObject* self = Transaction_new_core(type, NULL);
-
- return (PyObject *)self;
-}
-
-static void Transaction_dealloc(TransactionObject* self) {
- if (self->transaction)
- pakfire_transaction_unref(self->transaction);
-
- Py_XDECREF(self->request);
- Py_TYPE(self)->tp_free((PyObject *)self);
-}
-
-static int Transaction_init(TransactionObject* self, PyObject* args, PyObject* kwds) {
- RequestObject* request;
-
- if (!PyArg_ParseTuple(args, "O!", &RequestType, &request))
- return -1;
-
- self->request = request;
- Py_INCREF(self->request);
-
- self->transaction = pakfire_request_get_transaction(request->request);
-
- // Fail on empty transaction
- if (!self->transaction)
- return -1;
-
- return 0;
-}
-
-static PyObject* Transaction_dump(TransactionObject* self) {
- char* string = pakfire_transaction_dump(self->transaction, 80);
- assert(string);
-
- return PyUnicode_FromString(string);
-}
-
-static PyObject* Transaction_run(TransactionObject* self) {
- int r = pakfire_transaction_run(self->transaction);
-
- if (r) {
- PyErr_SetString(PyExc_RuntimeError, "Could not run transaction");
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static PyObject* Transaction_download(TransactionObject* self) {
- int r = pakfire_transaction_download(self->transaction);
- if (r) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- Py_RETURN_NONE;
-}
-
-static Py_ssize_t Transaction_len(TransactionObject* self) {
- return pakfire_transaction_count(self->transaction);
-}
-
-static struct PyMethodDef Transaction_methods[] = {
- {
- "download",
- (PyCFunction)Transaction_download,
- METH_NOARGS,
- NULL,
- },
- {
- "dump",
- (PyCFunction)Transaction_dump,
- METH_NOARGS,
- NULL,
- },
- {
- "run",
- (PyCFunction)Transaction_run,
- METH_NOARGS,
- NULL,
- },
- { NULL },
-};
-
-static PySequenceMethods Transaction_sequence = {
- sq_length: (lenfunc)Transaction_len,
-};
-
-PyTypeObject TransactionType = {
- PyVarObject_HEAD_INIT(NULL, 0)
- tp_name: "_pakfire.Transaction",
- tp_basicsize: sizeof(TransactionObject),
- tp_flags: Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
- tp_new: Transaction_new,
- tp_dealloc: (destructor)Transaction_dealloc,
- tp_init: (initproc)Transaction_init,
- tp_doc: "Transaction object",
- tp_methods: Transaction_methods,
- tp_as_sequence: &Transaction_sequence,
-};
+++ /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_TRANSACTION_H
-#define PYTHON_PAKFIRE_TRANSACTION_H
-
-#include <Python.h>
-
-#include <pakfire/transaction.h>
-
-#include "request.h"
-
-typedef struct {
- PyObject_HEAD
- RequestObject* request;
- struct pakfire_transaction* transaction;
-} TransactionObject;
-
-extern PyTypeObject TransactionType;
-
-PyObject* new_transaction(RequestObject* request, struct pakfire_transaction* trans);
-
-#endif /* PYTHON_PAKFIRE_TRANSACTION_H */