]>
git.ipfire.org Git - pakfire.git/blob - python/src/util.c
1 /*#############################################################################
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2011 Pakfire development team #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 #############################################################################*/
29 #include <sys/personality.h>
35 PyObject
*_personality(PyObject
*self
, PyObject
*args
) {
36 unsigned long persona
;
39 if (!PyArg_ParseTuple(args
, "l", &persona
)) {
40 /* XXX raise exception */
44 /* Change personality here. */
45 ret
= personality(persona
);
48 PyErr_SetString(PyExc_RuntimeError
, "Could not set personality.");
52 return Py_BuildValue("i", ret
);
55 PyObject
*_sync(PyObject
*self
, PyObject
*args
) {
56 /* Just sync everything to disks. */
62 PyObject
*_unshare(PyObject
*self
, PyObject
*args
) {
65 if (!PyArg_ParseTuple(args
, "i", &flags
)) {
69 int ret
= unshare(flags
);
71 return PyErr_SetFromErrno(PyExc_RuntimeError
);
74 return Py_BuildValue("i", ret
);
77 PyObject
*version_compare(PyObject
*self
, PyObject
*args
) {
79 const char *evr1
, *evr2
;
81 if (!PyArg_ParseTuple(args
, "Oss", &pool
, &evr1
, &evr2
)) {
82 /* XXX raise exception */
86 int ret
= pool_evrcmp_str(pool
, evr1
, evr2
, EVRCMP_COMPARE
);
88 return Py_BuildValue("i", ret
);