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);
}
NULL,
NULL
},
- {
- "installonly",
- (getter)Pakfire_get_installonly,
- (setter)Pakfire_set_installonly,
- NULL,
- NULL
- },
{
"keys",
(getter)Pakfire_get_keys,
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);
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);
pakfire_execute_command;
pakfire_execute_script;
pakfire_get_arch;
- pakfire_get_installonly;
pakfire_get_path;
pakfire_get_repo;
pakfire_get_repos;
pakfire_ref;
pakfire_refresh;
pakfire_search;
- pakfire_set_installonly;
pakfire_sync;
pakfire_unref;
pakfire_update;
// Pool stuff
Pool* pool;
int pool_ready;
- Queue installonly;
// Logging
pakfire_log_function_t log_function;
{ 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;
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;
// 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)
if (pakfire->pool)
pool_free(pakfire->pool);
- queue_free(&pakfire->installonly);
-
if (pakfire->config)
pakfire_config_unref(pakfire->config);
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);
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);