From: Michael Tremer Date: Thu, 18 Jan 2018 18:25:12 +0000 (+0100) Subject: libpakfire: Drop pakfire_pool_[gs]et_installonly functions X-Git-Tag: 0.9.28~1285^2~1171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86671603756c720a7d2143ea8ad12737ff403499;p=pakfire.git libpakfire: Drop pakfire_pool_[gs]et_installonly functions Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 7bb283a8e..2a9a52bc9 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -217,6 +217,45 @@ static PyObject* Pakfire_version_compare(PakfireObject* self, PyObject* args) { return PyLong_FromLong(cmp); } +static PyObject* Pakfire_get_installonly(PakfireObject* self) { + const char** installonly = pakfire_get_installonly(self->pakfire); + + PyObject* list = PyList_New(0); + const char* name; + + while ((name = *installonly++) != NULL) { + PyObject* item = PyUnicode_FromString(name); + PyList_Append(list, item); + + Py_DECREF(item); + } + + Py_INCREF(list); + return list; +} + +static int Pakfire_set_installonly(PakfireObject* self, PyObject* value) { + if (!PySequence_Check(value)) { + PyErr_SetString(PyExc_AttributeError, "Expected a sequence."); + return -1; + } + + const int length = PySequence_Length(value); + const char* installonly[length + 1]; + + for (int i = 0; i < length; i++) { + PyObject* item = PySequence_GetItem(value, i); + + installonly[i] = PyUnicode_AsUTF8(item); + Py_DECREF(item); + } + installonly[length] = NULL; + + pakfire_set_installonly(self->pakfire, installonly); + + return 0; +} + static struct PyMethodDef Pakfire_methods[] = { { "generate_key", @@ -272,6 +311,13 @@ static struct PyGetSetDef Pakfire_getsetters[] = { NULL, NULL }, + { + "installonly", + (getter)Pakfire_get_installonly, + (setter)Pakfire_set_installonly, + NULL, + NULL + }, { "keys", (getter)Pakfire_get_keys, diff --git a/src/_pakfire/pool.c b/src/_pakfire/pool.c index 635d4c0c4..dcae7b6fb 100644 --- a/src/_pakfire/pool.c +++ b/src/_pakfire/pool.c @@ -67,44 +67,7 @@ static Py_ssize_t Pool_len(PoolObject* self) { return pakfire_pool_count(self->pool); } -static PyObject* Pool_get_installonly(PoolObject* self) { - const char** installonly = pakfire_pool_get_installonly(self->pool); - PyObject* list = PyList_New(0); - const char* name; - - while ((name = *installonly++) != NULL) { - PyObject* item = PyUnicode_FromString(name); - PyList_Append(list, item); - - Py_DECREF(item); - } - - Py_INCREF(list); - return list; -} - -static int Pool_set_installonly(PoolObject* self, PyObject* value) { - if (!PySequence_Check(value)) { - PyErr_SetString(PyExc_AttributeError, "Expected a sequence."); - return -1; - } - - const int length = PySequence_Length(value); - const char* installonly[length + 1]; - - for (int i = 0; i < length; i++) { - PyObject* item = PySequence_GetItem(value, i); - - installonly[i] = PyUnicode_AsUTF8(item); - Py_DECREF(item); - } - installonly[length] = NULL; - - pakfire_pool_set_installonly(self->pool, installonly); - - return 0; -} static PyObject* Pool_get_cache_path(PoolObject* self) { const char* path = pakfire_pool_get_cache_path(self->pool); @@ -130,13 +93,6 @@ static struct PyGetSetDef Pool_getsetters[] = { NULL, NULL }, - { - "installonly", - (getter)Pool_get_installonly, - (setter)Pool_set_installonly, - NULL, - NULL - }, { NULL } }; diff --git a/src/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index 5b917e7fa..5cf492dad 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -35,6 +35,9 @@ const char* pakfire_get_arch(Pakfire pakfire); PakfirePool pakfire_get_pool(Pakfire pakfire); +const char** pakfire_get_installonly(Pakfire pakfire); +void pakfire_set_installonly(Pakfire pakfire, const char** installonly); + int pakfire_version_compare(Pakfire pakfire, const char* evr1, const char* evr2); PakfireRepo pakfire_get_installed_repo(Pakfire pakfire); @@ -51,6 +54,7 @@ void pakfire_pool_has_changed(Pakfire pakfire); void pakfire_pool_apply_changes(Pakfire pakfire); Pool* pakfire_get_solv_pool(Pakfire pakfire); +Queue* pakfire_get_installonly_queue(Pakfire pakfire); #endif diff --git a/src/libpakfire/include/pakfire/pool.h b/src/libpakfire/include/pakfire/pool.h index fe22c5493..01a5df653 100644 --- a/src/libpakfire/include/pakfire/pool.h +++ b/src/libpakfire/include/pakfire/pool.h @@ -30,9 +30,6 @@ PakfirePool pakfire_pool_unref(PakfirePool pool); int pakfire_pool_count(PakfirePool pool); -const char** pakfire_pool_get_installonly(PakfirePool pool); -void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly); - const char* pakfire_pool_get_cache_path(PakfirePool pool); void pakfire_pool_set_cache_path(PakfirePool pool, const char* path); PakfireCache pakfire_pool_get_cache(PakfirePool pool); @@ -47,8 +44,6 @@ PakfirePackageList pakfire_pool_search(PakfirePool pool, const char* what, int f Pool* pakfire_pool_get_solv_pool(PakfirePool pool); char* pakfire_pool_tmpdup(Pool* pool, const char* s); -Queue* pakfire_pool_get_installonly_queue(PakfirePool pool); - #endif #endif /* PAKFIRE_POOL_H */ diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index 89ad676e5..8bebf05b0 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -25,11 +25,13 @@ global: pakfire_create; pakfire_get_arch; pakfire_get_installed_repo; + pakfire_get_installonly; pakfire_get_path; pakfire_get_pool; pakfire_ref; pakfire_search; pakfire_set_installed_repo; + pakfire_set_installonly; pakfire_unref; pakfire_version_compare; pakfire_whatprovides; @@ -203,11 +205,9 @@ global: pakfire_pool_count; pakfire_pool_create; pakfire_pool_get_cache_path; - pakfire_pool_get_installonly; pakfire_pool_ref; pakfire_pool_search; pakfire_pool_set_cache_path; - pakfire_pool_set_installonly; pakfire_pool_unref; pakfire_pool_whatprovides; diff --git a/src/libpakfire/pool.c b/src/libpakfire/pool.c index e4025bf17..8761214e3 100644 --- a/src/libpakfire/pool.c +++ b/src/libpakfire/pool.c @@ -96,18 +96,6 @@ PAKFIRE_EXPORT int pakfire_pool_count(PakfirePool pool) { return cnt; } -PAKFIRE_EXPORT const char** pakfire_pool_get_installonly(PakfirePool pool) { - return pakfire_get_installonly(pool->pakfire); -} - -Queue* pakfire_pool_get_installonly_queue(PakfirePool pool) { - return pakfire_get_installonly_queue(pool->pakfire); -} - -PAKFIRE_EXPORT void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly) { - pakfire_set_installonly(pool->pakfire, installonly); -} - PAKFIRE_EXPORT const char* pakfire_pool_get_cache_path(PakfirePool pool) { if (!pool->cache) return NULL; diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index 77408585c..2e8d797f4 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -178,10 +178,7 @@ PAKFIRE_EXPORT int pakfire_request_solve(PakfireRequest request, int flags) { } /* turn off implicit obsoletes for installonly packages */ - PakfirePool pool = pakfire_get_pool(request->pakfire); - Queue* installonly = pakfire_pool_get_installonly_queue(pool); - pakfire_pool_unref(pool); - + Queue* installonly = pakfire_get_installonly_queue(request->pakfire); for (int i = 0; i < installonly->count; i++) queue_push2(&queue, SOLVER_MULTIVERSION|SOLVER_SOLVABLE_PROVIDES, installonly->elements[i]);