#include <libintl.h>
#include <pakfire/arch.h>
+#include <pakfire/dependencies.h>
#include <pakfire/key.h>
#include "archive.h"
return NULL;
}
+static PyObject* _pakfire_version_compare(PyObject* self, PyObject* args) {
+ const char* evr1 = NULL;
+ const char* evr2 = NULL;
+ int r;
+
+ if (!PyArg_ParseTuple(args, "ss", &evr1, &evr2))
+ return NULL;
+
+ // Compare versions
+ r = pakfire_static_version_compare(evr1, evr2);
+
+ // Return the return code
+ return PyLong_FromLong(r);
+}
+
static PyMethodDef pakfireModuleMethods[] = {
{"native_arch", (PyCFunction)_pakfire_native_arch, METH_NOARGS, NULL },
{"supported_arches", (PyCFunction)_pakfire_supported_arches, METH_NOARGS, NULL },
+ {
+ "version_compare",
+ (PyCFunction)_pakfire_version_compare,
+ METH_VARARGS,
+ NULL,
+ },
{ NULL, NULL, 0, NULL }
};
#include <stdlib.h>
#include <string.h>
+#include <solv/evr.h>
#include <solv/pool.h>
#include <pakfire/dependencies.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
#include <pakfire/pakfire.h>
+#include <pakfire/private.h>
#include <pakfire/string.h>
#include <pakfire/util.h>
{ NULL, 0 },
};
+static Pool* __pool = NULL;
+
+/*
+ This function can compare package versions without a Pakfire instance initialized.
+*/
+PAKFIRE_EXPORT int pakfire_static_version_compare(const char* evr1, const char* evr2) {
+ // Initialize the pool (unless already done)
+ if (!__pool) {
+ __pool = pool_create();
+
+ if (!__pool)
+ return 0;
+
+ // Set to RPM mode
+ pool_setdisttype(__pool, DISTTYPE_RPM);
+ }
+
+ // Perform comparison
+ return pool_evrcmp_str(__pool, evr1, evr2, EVRCMP_COMPARE);
+}
+
const char* pakfire_dep2str(struct pakfire* pakfire, Id id) {
Pool* pool = pakfire_get_solv_pool(pakfire);
if (!pool)
#ifndef PAKFIRE_DEPENDENCIES_H
#define PAKFIRE_DEPENDENCIES_H
+int pakfire_static_version_compare(const char* evr1, const char* evr2);
+
#ifdef PAKFIRE_PRIVATE
#include <solv/pool.h>
pakfire_build_unref;
pakfire_shell;
+ # dependencies
+ pakfire_static_version_compare;
+
# digest
pakfire_digest_get_by_name;
pakfire_digest_name;