|
|
844bdb |
From a610bc80c2b798d83737aaaa759f1799b24f3a57 Mon Sep 17 00:00:00 2001
|
|
|
844bdb |
From: Jaroslav Mracek <jmracek@redhat.com>
|
|
|
844bdb |
Date: Fri, 1 Feb 2019 14:37:35 +0100
|
|
|
844bdb |
Subject: [PATCH] Add setter of ModuleContainer for PySack
|
|
|
844bdb |
|
|
|
844bdb |
---
|
|
|
844bdb |
libdnf/dnf-sack-private.hpp | 3 ++-
|
|
|
844bdb |
libdnf/dnf-sack.cpp | 19 +++++++++++++++++++
|
|
|
844bdb |
python/hawkey/sack-py.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
844bdb |
3 files changed, 68 insertions(+), 2 deletions(-)
|
|
|
844bdb |
|
|
|
844bdb |
diff --git a/libdnf/dnf-sack-private.hpp b/libdnf/dnf-sack-private.hpp
|
|
|
844bdb |
index b058126..45241c4 100644
|
|
|
844bdb |
--- a/libdnf/dnf-sack-private.hpp
|
|
|
844bdb |
+++ b/libdnf/dnf-sack-private.hpp
|
|
|
844bdb |
@@ -57,7 +57,8 @@ int dnf_sack_get_pool_nsolvables(DnfSack *sack);
|
|
|
844bdb |
* @return Map*
|
|
|
844bdb |
*/
|
|
|
844bdb |
libdnf::PackageSet *dnf_sack_get_pkg_solvables(DnfSack *sack);
|
|
|
844bdb |
-
|
|
|
844bdb |
+ModulePackageContainer * dnf_sack_set_module_container(
|
|
|
844bdb |
+ DnfSack *sack, ModulePackageContainer * newConteiner);
|
|
|
844bdb |
ModulePackageContainer * dnf_sack_get_module_container(DnfSack *sack);
|
|
|
844bdb |
void dnf_sack_make_provides_ready (DnfSack *sack);
|
|
|
844bdb |
Id dnf_sack_running_kernel (DnfSack *sack);
|
|
|
844bdb |
diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
|
|
|
844bdb |
index fb56937..43bb977 100644
|
|
|
844bdb |
--- a/libdnf/dnf-sack.cpp
|
|
|
844bdb |
+++ b/libdnf/dnf-sack.cpp
|
|
|
844bdb |
@@ -2006,6 +2006,25 @@ dnf_sack_get_pool(DnfSack *sack)
|
|
|
844bdb |
}
|
|
|
844bdb |
|
|
|
844bdb |
/**
|
|
|
844bdb |
+ * dnf_sack_set_module_container: (skip)
|
|
|
844bdb |
+ * @sack: a #DnfSack instance.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * Setss the internal ModulePackageContainer.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * Returns: The old ModulePackageContainer, that has to be freed manually.
|
|
|
844bdb |
+ *
|
|
|
844bdb |
+ * Since: 0.25.0
|
|
|
844bdb |
+ */
|
|
|
844bdb |
+ModulePackageContainer *
|
|
|
844bdb |
+dnf_sack_set_module_container(DnfSack *sack, ModulePackageContainer * newConteiner)
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ DnfSackPrivate *priv = GET_PRIVATE(sack);
|
|
|
844bdb |
+ auto oldConteiner = priv->moduleContainer;
|
|
|
844bdb |
+ priv->moduleContainer = newConteiner;
|
|
|
844bdb |
+ return oldConteiner;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+/**
|
|
|
844bdb |
* dnf_sack_get_module_container: (skip)
|
|
|
844bdb |
* @sack: a #DnfSack instance.
|
|
|
844bdb |
*
|
|
|
844bdb |
diff --git a/python/hawkey/sack-py.cpp b/python/hawkey/sack-py.cpp
|
|
|
844bdb |
index e925346..7f97075 100644
|
|
|
844bdb |
--- a/python/hawkey/sack-py.cpp
|
|
|
844bdb |
+++ b/python/hawkey/sack-py.cpp
|
|
|
844bdb |
@@ -27,6 +27,7 @@
|
|
|
844bdb |
#include "hy-util.h"
|
|
|
844bdb |
#include "dnf-version.h"
|
|
|
844bdb |
#include "dnf-sack-private.hpp"
|
|
|
844bdb |
+#include "libdnf/module/ModulePackageContainer.hpp"
|
|
|
844bdb |
|
|
|
844bdb |
// pyhawkey
|
|
|
844bdb |
#include "exception-py.hpp"
|
|
|
844bdb |
@@ -47,6 +48,7 @@ typedef struct {
|
|
|
844bdb |
DnfSack *sack;
|
|
|
844bdb |
PyObject *custom_package_class;
|
|
|
844bdb |
PyObject *custom_package_val;
|
|
|
844bdb |
+ PyObject * ModulePackageContainerPy;
|
|
|
844bdb |
FILE *log_out;
|
|
|
844bdb |
} _SackObject;
|
|
|
844bdb |
|
|
|
844bdb |
@@ -119,8 +121,13 @@ sack_dealloc(_SackObject *o)
|
|
|
844bdb |
{
|
|
|
844bdb |
Py_XDECREF(o->custom_package_class);
|
|
|
844bdb |
Py_XDECREF(o->custom_package_val);
|
|
|
844bdb |
- if (o->sack)
|
|
|
844bdb |
+ if (o->sack) {
|
|
|
844bdb |
+ if (auto moduleContainer = o->ModulePackageContainerPy) {
|
|
|
844bdb |
+ dnf_sack_set_module_container(o->sack, NULL);
|
|
|
844bdb |
+ Py_DECREF(moduleContainer);
|
|
|
844bdb |
+ }
|
|
|
844bdb |
g_object_unref(o->sack);
|
|
|
844bdb |
+ }
|
|
|
844bdb |
if (o->log_out)
|
|
|
844bdb |
fclose(o->log_out);
|
|
|
844bdb |
Py_TYPE(o)->tp_free(o);
|
|
|
844bdb |
@@ -135,6 +142,7 @@ sack_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
|
844bdb |
self->sack = NULL;
|
|
|
844bdb |
self->custom_package_class = NULL;
|
|
|
844bdb |
self->custom_package_val = NULL;
|
|
|
844bdb |
+ self->ModulePackageContainerPy = NULL;
|
|
|
844bdb |
}
|
|
|
844bdb |
return (PyObject *)self;
|
|
|
844bdb |
}
|
|
|
844bdb |
@@ -324,10 +332,48 @@ set_installonly_limit(_SackObject *self, PyObject *obj, void *unused)
|
|
|
844bdb |
return 0;
|
|
|
844bdb |
}
|
|
|
844bdb |
|
|
|
844bdb |
+static int
|
|
|
844bdb |
+set_module_container(_SackObject *self, PyObject *obj, void *unused)
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ auto swigContainer = reinterpret_cast< ModulePackageContainerPyObject * >(
|
|
|
844bdb |
+ PyObject_GetAttrString(obj, "this"));
|
|
|
844bdb |
+ if (swigContainer == nullptr) {
|
|
|
844bdb |
+ PyErr_SetString(PyExc_SystemError, "Unable to parse ModuleContainer object");
|
|
|
844bdb |
+ return -1;
|
|
|
844bdb |
+ }
|
|
|
844bdb |
+ auto moduleContainer = swigContainer->ptr;
|
|
|
844bdb |
+ auto sack = self->sack;
|
|
|
844bdb |
+ if (auto oldConteynerPy = self->ModulePackageContainerPy) {
|
|
|
844bdb |
+ Py_XDECREF(oldConteynerPy);
|
|
|
844bdb |
+ auto oldContainer = dnf_sack_set_module_container(sack, moduleContainer);
|
|
|
844bdb |
+ } else {
|
|
|
844bdb |
+ auto oldContainer = dnf_sack_set_module_container(sack, moduleContainer);
|
|
|
844bdb |
+ if (oldContainer) {
|
|
|
844bdb |
+ delete oldContainer;
|
|
|
844bdb |
+ }
|
|
|
844bdb |
+ }
|
|
|
844bdb |
+ self->ModulePackageContainerPy = obj;
|
|
|
844bdb |
+ Py_INCREF(obj);
|
|
|
844bdb |
+
|
|
|
844bdb |
+ return 0;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
+static PyObject *
|
|
|
844bdb |
+get_module_container(_SackObject *self, void *unused)
|
|
|
844bdb |
+{
|
|
|
844bdb |
+ if (auto moduleConteinerPy = self->ModulePackageContainerPy) {
|
|
|
844bdb |
+ Py_INCREF(moduleConteinerPy);
|
|
|
844bdb |
+ return moduleConteinerPy;
|
|
|
844bdb |
+ }
|
|
|
844bdb |
+ Py_RETURN_NONE;
|
|
|
844bdb |
+}
|
|
|
844bdb |
+
|
|
|
844bdb |
static PyGetSetDef sack_getsetters[] = {
|
|
|
844bdb |
{(char*)"cache_dir", (getter)get_cache_dir, NULL, NULL, NULL},
|
|
|
844bdb |
{(char*)"installonly", NULL, (setter)set_installonly, NULL, NULL},
|
|
|
844bdb |
{(char*)"installonly_limit", NULL, (setter)set_installonly_limit, NULL, NULL},
|
|
|
844bdb |
+ {(char*)"_moduleContainer", (getter)get_module_container, (setter)set_module_container,
|
|
|
844bdb |
+ NULL, NULL},
|
|
|
844bdb |
{NULL} /* sentinel */
|
|
|
844bdb |
};
|
|
|
844bdb |
|
|
|
844bdb |
--
|
|
|
844bdb |
libgit2 0.27.7
|
|
|
844bdb |
|