From: Michael Tremer Date: Tue, 22 Jun 2021 14:08:45 +0000 (+0000) Subject: Hard-code multiinstall and add them to pooljobs X-Git-Tag: 0.9.28~1198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42bf25ad3c47fbaddfe0d91c015f6ef129925622;p=pakfire.git Hard-code multiinstall and add them to pooljobs Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index bb89ac647..9df2ec008 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -498,45 +498,6 @@ 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 Py_ssize_t Pakfire_len(PakfireObject* self) { return pakfire_count_packages(self->pakfire); } @@ -1062,13 +1023,6 @@ 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/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index 248fd47e7..f241b6d77 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -57,9 +57,6 @@ int pakfire_copy_out(Pakfire pakfire, const char* src, const char* dst); const char* pakfire_get_arch(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); size_t pakfire_count_packages(Pakfire pakfire); @@ -127,7 +124,6 @@ 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); PakfireRepo pakfire_get_installed_repo(Pakfire pakfire); diff --git a/src/libpakfire/libpakfire.sym b/src/libpakfire/libpakfire.sym index dea5b6fb5..f3ba009db 100644 --- a/src/libpakfire/libpakfire.sym +++ b/src/libpakfire/libpakfire.sym @@ -33,7 +33,6 @@ global: pakfire_execute_command; pakfire_execute_script; pakfire_get_arch; - pakfire_get_installonly; pakfire_get_path; pakfire_get_repo; pakfire_get_repos; @@ -41,7 +40,6 @@ global: pakfire_ref; pakfire_refresh; pakfire_search; - pakfire_set_installonly; pakfire_sync; pakfire_unref; pakfire_update; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index f62adca0d..791905cd2 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -73,7 +73,6 @@ struct _Pakfire { // Pool stuff Pool* pool; int pool_ready; - Queue installonly; // Logging pakfire_log_function_t log_function; @@ -117,6 +116,15 @@ static const struct pakfire_feature { { NULL }, }; +/* + These packages can be installed multiple times simultaneously +*/ +const char* pakfire_multiinstall_packages[] = { + "kernel", + "kernel-devel", + NULL, +}; + static const struct pakfire_mountpoint { const char* source; const char* target; @@ -386,6 +394,13 @@ static Id pakfire_namespace_callback(Pool* pool, void* data, Id ns, Id id) { return 0; } +static void pakfire_pool_add_multiinstall(Pool* pool) { + for (const char** package = pakfire_multiinstall_packages; *package; package++) { + Id id = pool_str2id(pool, *package, 1); + queue_push2(&pool->pooljobs, SOLVER_MULTIVERSION|SOLVER_SOLVABLE_PROVIDES, id); + } +} + static int pakfire_populate_pool(Pakfire pakfire) { struct pakfire_db* db; PakfireRepo repo = NULL; @@ -413,6 +428,9 @@ static int pakfire_populate_pool(Pakfire pakfire) { // Install namespace callback pool_setnamespacecallback(pool, pakfire_namespace_callback, pakfire); + // Add multiinstall packages + pakfire_pool_add_multiinstall(pool); + // Open database in read-only mode and try to load all installed packages r = pakfire_db_open(&db, pakfire, PAKFIRE_DB_READWRITE); if (r) @@ -501,8 +519,6 @@ static void pakfire_free(Pakfire pakfire) { if (pakfire->pool) pool_free(pakfire->pool); - queue_free(&pakfire->installonly); - if (pakfire->config) pakfire_config_unref(pakfire->config); @@ -1295,38 +1311,6 @@ PakfireRepo pakfire_get_installed_repo(Pakfire pakfire) { return pakfire_repo_create_from_repo(pakfire, pakfire->pool->installed); } -PAKFIRE_EXPORT const char** pakfire_get_installonly(Pakfire pakfire) { - Queue q; - queue_init_clone(&q, &pakfire->installonly); - - const char** installonly = malloc(sizeof(const char*) * (q.count + 1)); - - int i = 0; - while (q.count) { - installonly[i++] = pool_id2str(pakfire->pool, queue_shift(&q)); - } - installonly[i] = NULL; - - queue_free(&q); - - return installonly; -} - -Queue* pakfire_get_installonly_queue(Pakfire pakfire) { - return &pakfire->installonly; -} - -PAKFIRE_EXPORT void pakfire_set_installonly(Pakfire pakfire, const char** installonly) { - queue_empty(&pakfire->installonly); - - if (installonly == NULL) - return; - - const char* name; - while ((name = *installonly++) != NULL) - queue_pushunique(&pakfire->installonly, pool_str2id(pakfire->pool, name, 1)); -} - static PakfirePackageList pakfire_pool_dataiterator(Pakfire pakfire, const char* what, int key, int flags) { PakfirePackageList list = pakfire_packagelist_create(pakfire); pakfire_pool_apply_changes(pakfire); diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index cd07088b3..7867a3f92 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -202,14 +202,6 @@ PAKFIRE_EXPORT int pakfire_request_solve(struct pakfire_request* request, int fl Queue queue; queue_init_clone(&queue, &request->jobs); - /* turn off implicit obsoletes for installonly packages */ - 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]); - - // XXX EXCLUDES - r = solve(request, &queue); queue_free(&queue);