]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Export pakfire_make_cache_path to Python
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Apr 2021 10:57:09 +0000 (10:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Apr 2021 10:57:09 +0000 (10:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/include/pakfire/pakfire.h
src/libpakfire/libpakfire.sym
src/libpakfire/pakfire.c

index fb2aa491ee452a29f0a4ba5898347955b05fd58c..3f95ed0a23ce0959346a13fea2a004f7ebe0ff0f 100644 (file)
@@ -804,6 +804,23 @@ ERROR:
        return list;
 }
 
+static PyObject* Pakfire_make_cache_path(PakfireObject* self, PyObject* args) {
+       const char* path = NULL;
+
+       if (!PyArg_ParseTuple(args, "s", &path))
+               return NULL;
+
+       char cache_path[PATH_MAX];
+
+       int r = pakfire_make_cache_path(self->pakfire, cache_path, "%s", path);
+       if (r) {
+               PyErr_SetFromErrno(PyExc_OSError);
+               return NULL;
+       }
+
+       return PyUnicode_FromString(cache_path);
+}
+
 static struct PyMethodDef Pakfire_methods[] = {
        {
                "bind",
@@ -871,6 +888,12 @@ static struct PyMethodDef Pakfire_methods[] = {
                METH_VARARGS,
                NULL
        },
+       {
+               "make_cache_path",
+               (PyCFunction)Pakfire_make_cache_path,
+               METH_VARARGS,
+               NULL
+       },
        {
                "read_makefile",
                (PyCFunction)Pakfire_read_makefile,
index 7e4f915ea71db1623a71a0384e234967612c6c6c..29d2609be6bb711000e139deeb8ccdc140d24d51 100644 (file)
@@ -37,6 +37,12 @@ Pakfire pakfire_unref(Pakfire pakfire);
 
 const char* pakfire_get_path(Pakfire pakfire);
 
+#define pakfire_make_cache_path(pakfire, path, format, ...) \
+       __pakfire_make_cache_path(pakfire, path, sizeof(path) - 1, format, __VA_ARGS__)
+
+int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
+       const char* format, ...) __attribute__((format(printf, 4, 5)));
+
 int pakfire_bind(Pakfire pakfire, const char* src, const char* dst, int flags);
 
 int pakfire_copy_in(Pakfire pakfire, const char* src, const char* dst);
@@ -87,12 +93,6 @@ int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, const char* pa
        __pakfire_make_path(pakfire, dst, sizeof(dst) - 1, path)
 int __pakfire_make_path(Pakfire pakfire, char* dst, size_t length, const char* path);
 
-#define pakfire_make_cache_path(pakfire, path, format, ...) \
-       __pakfire_make_cache_path(pakfire, path, sizeof(path) - 1, format, __VA_ARGS__)
-
-int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
-       const char* format, ...) __attribute__((format(printf, 4, 5)));
-
 void pakfire_pool_has_changed(Pakfire pakfire);
 void pakfire_pool_apply_changes(Pakfire pakfire);
 
index 32aaba38a203ede2bc65255cb505fd6c2c382b33..3fd0fb6f9d9b707af9c6d991225d5dab202b5db1 100644 (file)
@@ -46,6 +46,7 @@ global:
        pakfire_unref;
        pakfire_version_compare;
        pakfire_whatprovides;
+       __pakfire_make_cache_path;
 
        # arch
        pakfire_arch_is_compatible;
index 8109cb8333a7f35b29bd8e5919fb8b8a935b7637..fa13961554c67123f49d074e9423ac85a14d8b67 100644 (file)
@@ -1145,7 +1145,7 @@ PAKFIRE_EXPORT PakfirePackageList pakfire_search(Pakfire pakfire, const char* wh
 
 // Cache
 
-int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
+PAKFIRE_EXPORT int __pakfire_make_cache_path(Pakfire pakfire, char* path, size_t length,
                const char* format, ...) {
        va_list args;