]> git.ipfire.org Git - pakfire.git/commitdiff
Hard-code multiinstall and add them to pooljobs
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Jun 2021 14:08:45 +0000 (14:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Jun 2021 14:08:45 +0000 (14:08 +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
src/libpakfire/request.c

index bb89ac6470dbbbe98ef3393957ba96215d19a5e9..9df2ec0082426f40e6022ddd55514f5647aecf3c 100644 (file)
@@ -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,
index 248fd47e710ed5cc5ceddeef0e24a61b9800ea78..f241b6d7798848b292218d26f848011e6422bd94 100644 (file)
@@ -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);
 
index dea5b6fb5b4f0c5a43b7a0e886e719846e0f0863..f3ba009db04d2565c616098c5b8ef7afde903209 100644 (file)
@@ -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;
index f62adca0df921c9ae73fbf17a70bd173af0e865c..791905cd2e412a7ccb4cd697c03bf68d734f1ecf 100644 (file)
@@ -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);
index cd07088b3cd338b012d0226de651c4afbd03bab7..7867a3f92eee556a7cf9048c9ffc56a5b86f3a2a 100644 (file)
@@ -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);