Py_RETURN_NONE;
}
+static PyObject* Pakfire_check(PakfireObject* self) {
+ int r = pakfire_check(self->pakfire);
+ if (r) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
static struct PyMethodDef Pakfire_methods[] = {
{
"bind",
METH_VARARGS|METH_KEYWORDS,
NULL
},
+ {
+ "check",
+ (PyCFunction)Pakfire_check,
+ METH_NOARGS,
+ NULL,
+ },
{
"clean",
(PyCFunction)Pakfire_clean,
int pakfire_erase(Pakfire pakfire, const char** packages, int flags, int* changed);
int pakfire_update(Pakfire pakfire, const char** packages, int flags, int* changed);
+// Check
+
+int pakfire_check(Pakfire pakfire);
+
#ifdef PAKFIRE_PRIVATE
#include <solv/pool.h>
global:
# pakfire
pakfire_bind;
+ pakfire_check;
pakfire_clean;
pakfire_copy_in;
pakfire_copy_out;
return pakfire_perform_transaction(pakfire, pakfire_request_upgrade, packages,
flags, changed);
}
+
+PAKFIRE_EXPORT int pakfire_check(Pakfire pakfire) {
+ struct pakfire_db* db = NULL;
+ int r;
+
+ // Open database in read-only mode and try to load all installed packages
+ r = pakfire_db_open(&db, pakfire, PAKFIRE_DB_READWRITE);
+ if (r)
+ goto ERROR;
+
+ // Perform a database integrity check
+ r = pakfire_db_check(db);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (db)
+ pakfire_db_unref(db);
+
+ return r;
+}
p.clean()
def handle_check(self, ns):
- with self.pakfire(ns) as p:
- # This will throw an exception when there are errors
- transaction = p.check()
-
- print(_("Everything okay"))
-
+ self.pakfire(ns).check()
class CliClient(Cli):