#include <pakfire/file.h>
#include <pakfire/package.h>
#include <pakfire/relationlist.h>
+#include <pakfire/repo.h>
#include <pakfire/util.h>
#include "package.h"
const char* name = pakfire_repo_get_name(repo);
pakfire_repo_unref(repo);
- return new_repo(self->pool, name);
+ return new_repo(self->pakfire, name);
}
static int Package_set_repo(PackageObject* self, PyObject* value) {
#include <pakfire/package.h>
#include <solv/pooltypes.h>
+#include "pakfire.h"
#include "pool.h"
typedef struct {
PyObject_HEAD
+ PakfireObject* pakfire;
PoolObject* pool;
PakfirePackage package;
} PackageObject;
#include <pakfire/pakfire.h>
#include <pakfire/key.h>
+#include <pakfire/repo.h>
#include "key.h"
#include "pakfire.h"
+#include "repo.h"
static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
PakfireObject* self = (PakfireObject *)type->tp_alloc(type, 0);
return PyUnicode_FromString(arch);
}
+static PyObject* Pakfire_get_installed_repo(PakfireObject* self) {
+ PakfireRepo repo = pakfire_get_installed_repo(self->pakfire);
+ if (!repo)
+ Py_RETURN_NONE;
+
+ PyObject* obj = new_repo(self, pakfire_repo_get_name(repo));
+ Py_XINCREF(obj);
+
+ return obj;
+}
+
+static int Pakfire_set_installed_repo(PakfireObject* self, PyObject* value) {
+#if 0
+ if (PyObject_Not(value)) {
+ pakfire_pool_set_installed_repo(self->pool, NULL);
+ return 0;
+ }
+#endif
+
+ if (!PyObject_TypeCheck(value, &RepoType)) {
+ PyErr_SetString(PyExc_ValueError, "Argument must be a _pakfire.Repo object");
+ return -1;
+ }
+
+ RepoObject* repo = (RepoObject *)value;
+ pakfire_set_installed_repo(self->pakfire, repo->repo);
+
+ return 0;
+}
+
static PyObject* _import_keylist(PakfireObject* pakfire, PakfireKey* keys) {
PyObject* list = PyList_New(0);
NULL,
NULL
},
+ {
+ "installed_repo",
+ (getter)Pakfire_get_installed_repo,
+ (setter)Pakfire_set_installed_repo,
+ NULL,
+ NULL
+ },
{
"keys",
(getter)Pakfire_get_keys,
#include "pakfire.h"
#include "pool.h"
#include "relation.h"
-#include "repo.h"
#include "util.h"
static PyObject* Pool_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
return pakfire_pool_count(self->pool);
}
-static PyObject* Pool_get_installed_repo(PoolObject* self) {
- PakfireRepo repo = pakfire_pool_get_installed_repo(self->pool);
- if (!repo)
- Py_RETURN_NONE;
-
- PyObject* obj = new_repo(self, pakfire_repo_get_name(repo));
- Py_XINCREF(obj);
-
- return obj;
-}
-
-static int Pool_set_installed_repo(PoolObject* self, PyObject* value) {
-#if 0
- if (PyObject_Not(value)) {
- pakfire_pool_set_installed_repo(self->pool, NULL);
- return 0;
- }
-#endif
-
- if (!PyObject_TypeCheck(value, &RepoType)) {
- PyErr_SetString(PyExc_ValueError, "Argument must be a _pakfire.Repo object");
- return -1;
- }
-
- RepoObject* repo = (RepoObject *)value;
- pakfire_pool_set_installed_repo(self->pool, repo->repo);
-
- return 0;
-}
-
static PyObject* Pool_get_installonly(PoolObject* self) {
const char** installonly = pakfire_pool_get_installonly(self->pool);
NULL,
NULL
},
- {
- "installed_repo",
- (getter)Pool_get_installed_repo,
- (setter)Pool_set_installed_repo,
- NULL,
- NULL
- },
{
"installonly",
(getter)Pool_get_installonly,
typedef struct {
PyObject_HEAD
PakfirePool pool;
-
- // XXX COMPAT
- Pool* _pool;
} PoolObject;
extern PyTypeObject PoolType;
#include "package.h"
#include "repo.h"
-PyObject* new_repo(PoolObject* pool, const char* name) {
- PyObject* args = Py_BuildValue("Os", (PyObject *)pool, name);
+PyObject* new_repo(PakfireObject* pakfire, const char* name) {
+ PyObject* args = Py_BuildValue("Os", (PyObject *)pakfire, name);
PyObject* repo = PyObject_CallObject((PyObject *)&RepoType, args);
Py_DECREF(args);
static PyObject* Repo_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
RepoObject* self = (RepoObject *)type->tp_alloc(type, 0);
if (self) {
- self->pool = NULL;
+ self->pakfire = NULL;
self->repo = NULL;
}
static void Repo_dealloc(RepoObject* self) {
pakfire_repo_unref(self->repo);
- Py_XDECREF(self->pool);
+ Py_XDECREF(self->pakfire);
Py_TYPE(self)->tp_free((PyObject *)self);
}
static int Repo_init(RepoObject* self, PyObject* args, PyObject* kwds) {
- PyObject* pool;
+ PakfireObject* pakfire;
const char* name;
- if (!PyArg_ParseTuple(args, "O!s", &PoolType, &pool, &name))
+ if (!PyArg_ParseTuple(args, "O!s", &PakfireType, &pakfire, &name))
return -1;
- self->pool = (PoolObject *)pool;
- Py_INCREF(self->pool);
+ self->pakfire = pakfire;
+ Py_INCREF(self->pakfire);
- self->repo = pakfire_repo_create(self->pool->pool, name);
+ self->repo = pakfire_repo_create(self->pakfire->pakfire, name);
return 0;
}
if (!PyArg_ParseTuple(args, "sss", &name, &evr, &arch))
return NULL;
- PakfirePool pool = pakfire_repo_pool(self->repo);
+ PakfirePool pool = pakfire_repo_get_pool(self->repo);
PakfirePackage pkg = pakfire_package_create2(pool, self->repo, name, evr, arch);
- return new_package(self->pool, pakfire_package_id(pkg));
+ // XXX must be self->pakfire instead of NULL
+ return new_package(NULL /* self->pakfire */, pakfire_package_id(pkg));
}
static PyObject* Repo_cache_age(RepoObject* self, PyObject* args) {
#include <Python.h>
-#include <pakfire/pool.h>
-#include <pakfire/repo.h>
+#include <pakfire/types.h>
-#include "pool.h"
+#include "pakfire.h"
typedef struct {
PyObject_HEAD
- PoolObject* pool;
+ PakfireObject* pakfire;
PakfireRepo repo;
-
- // XXX COMPAT
- void* _repo;
} RepoObject;
extern PyTypeObject RepoType;
-PyObject* new_repo(PoolObject* pool, const char* name);
+PyObject* new_repo(PakfireObject* pakfire, const char* name);
#endif /* PYTHON_PAKFIRE_REPO_H */
PakfirePool pakfire_get_pool(Pakfire pakfire);
+PakfireRepo pakfire_get_installed_repo(Pakfire pakfire);
+void pakfire_set_installed_repo(Pakfire pakfire, PakfireRepo repo);
+
#endif /* PAKFIRE_PAKFIRE_H */
int pakfire_pool_version_compare(PakfirePool pool, const char* evr1, const char* evr2);
int pakfire_pool_count(PakfirePool pool);
-PakfireRepo pakfire_pool_get_installed_repo(PakfirePool pool);
-void pakfire_pool_set_installed_repo(PakfirePool pool, PakfireRepo repo);
-
const char** pakfire_pool_get_installonly(PakfirePool pool);
void pakfire_pool_set_installonly(PakfirePool pool, const char** installonly);
#include <pakfire/types.h>
-PakfireRepo pakfire_repo_create(PakfirePool pool, const char* name);
+PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name);
PakfireRepo pakfire_repo_ref(PakfireRepo repo);
PakfireRepo pakfire_repo_unref(PakfireRepo repo);
-PakfirePool pakfire_repo_pool(PakfireRepo repo);
+PakfirePool pakfire_repo_get_pool(PakfireRepo repo);
int pakfire_repo_identical(PakfireRepo repo1, PakfireRepo repo2);
int pakfire_repo_cmp(PakfireRepo repo1, PakfireRepo repo2);
#include <solv/repo.h>
-PakfireRepo pakfire_repo_create_from_repo(PakfirePool pool, Repo* r);
+PakfireRepo pakfire_repo_create_from_repo(Pakfire pakfire, Repo* r);
PakfirePackage pakfire_repo_add_package(PakfireRepo repo);
};
inline PakfirePool pakfire_repocache_pool(PakfireRepoCache repo_cache) {
- return pakfire_repo_pool(repo_cache->repo);
+ return pakfire_repo_get_pool(repo_cache->repo);
}
inline PakfireCache pakfire_repocache_cache(PakfireRepoCache repo_cache) {
pakfire_init;
pakfire_create;
pakfire_get_arch;
+ pakfire_get_installed_repo;
pakfire_get_path;
pakfire_get_pool;
pakfire_ref;
+ pakfire_set_installed_repo;
pakfire_unref;
# archive
pakfire_pool_count;
pakfire_pool_create;
pakfire_pool_get_cache_path;
- pakfire_pool_get_installed_repo;
pakfire_pool_get_installonly;
pakfire_pool_ref;
pakfire_pool_search;
pakfire_pool_set_cache_path;
- pakfire_pool_set_installed_repo;
pakfire_pool_set_installonly;
pakfire_pool_unref;
pakfire_pool_version_compare;
pakfire_repo_get_cache;
pakfire_repo_get_name;
pakfire_repo_get_enabled;
+ pakfire_repo_get_pool;
pakfire_repo_get_priority;
pakfire_repo_identical;
pakfire_repo_internalize;
# #
#############################################################################*/
+#include <solv/pool.h>
+
#include <pakfire/logging.h>
#include <pakfire/pakfire.h>
#include <pakfire/pool.h>
#include <pakfire/private.h>
+#include <pakfire/repo.h>
#include <pakfire/system.h>
#include <pakfire/types.h>
#include <pakfire/util.h>
PAKFIRE_EXPORT PakfirePool pakfire_get_pool(Pakfire pakfire) {
return pakfire_pool_ref(pakfire->pool);
}
+
+PAKFIRE_EXPORT PakfireRepo pakfire_get_installed_repo(Pakfire pakfire) {
+ Pool* p = pakfire_pool_get_solv_pool(pakfire->pool);
+ if (!p->installed)
+ return NULL;
+
+ return pakfire_repo_create_from_repo(pakfire, p->installed);
+}
+
+PAKFIRE_EXPORT void pakfire_set_installed_repo(Pakfire pakfire, PakfireRepo repo) {
+ Pool* p = pakfire_pool_get_solv_pool(pakfire->pool);
+
+ if (!repo) {
+ pool_set_installed(p, NULL);
+ return;
+ }
+
+ pool_set_installed(p, pakfire_repo_get_repo(repo));
+}
}
}
-PAKFIRE_EXPORT PakfireRepo pakfire_pool_get_installed_repo(PakfirePool pool) {
- Pool* p = pool->pool;
-
- if (!p->installed)
- return NULL;
-
- return pakfire_repo_create_from_repo(pool, p->installed);
-}
-
-PAKFIRE_EXPORT void pakfire_pool_set_installed_repo(PakfirePool pool, PakfireRepo repo) {
- if (!repo) {
- pool_set_installed(pool->pool, NULL);
- return;
- }
-
- pool_set_installed(pool->pool, pakfire_repo_get_repo(repo));
-}
-
PAKFIRE_EXPORT const char** pakfire_pool_get_installonly(PakfirePool pool) {
Queue q;
queue_init_clone(&q, &pool->installonly);
#include <pakfire/errno.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
+#include <pakfire/pakfire.h>
#include <pakfire/pool.h>
#include <pakfire/private.h>
#include <pakfire/repo.h>
const size_t XZ_HEADER_LENGTH = sizeof(XZ_HEADER_MAGIC);
struct _PakfireRepo {
- PakfirePool pool;
+ Pakfire pakfire;
Repo* repo;
PakfireRepoCache cache;
Repodata* filelist;
return NULL;
}
-PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(PakfirePool pool, const char* name) {
+PAKFIRE_EXPORT PakfireRepo pakfire_repo_create(Pakfire pakfire, const char* name) {
+ PakfirePool pool = pakfire_get_pool(pakfire);
+
PakfireRepo repo = get_pakfire_repo_by_name(pool, name);
if (repo) {
repo->nrefs++;
+
+ pakfire_pool_unref(pool);
+
return repo;
}
Pool* p = pakfire_pool_get_solv_pool(pool);
+ pakfire_pool_unref(pool);
Repo* r = get_repo_by_name(p, name);
if (!r)
r = repo_create(p, name);
- return pakfire_repo_create_from_repo(pool, r);
+ return pakfire_repo_create_from_repo(pakfire, r);
}
-PAKFIRE_EXPORT PakfireRepo pakfire_repo_create_from_repo(PakfirePool pool, Repo* r) {
+PAKFIRE_EXPORT PakfireRepo pakfire_repo_create_from_repo(Pakfire pakfire, Repo* r) {
// Return existing object if we have one
if (r->appdata)
return pakfire_repo_ref(r->appdata);
DEBUG("Allocated Repo at %p\n", repo);
repo->nrefs = 1;
- repo->pool = pakfire_pool_ref(pool);
+ repo->pakfire = pakfire_ref(pakfire);
repo->repo = r;
repo->cache = pakfire_repocache_create(repo);
if (repo->cache)
pakfire_repocache_free(repo->cache);
- pakfire_pool_unref(repo->pool);
+ pakfire_unref(repo->pakfire);
pakfire_free(repo);
DEBUG("Released Repo at %p\n", repo);
return repo->filelist;
}
-PAKFIRE_EXPORT PakfirePool pakfire_repo_pool(PakfireRepo repo) {
- return repo->pool;
+PAKFIRE_EXPORT PakfirePool pakfire_repo_get_pool(PakfireRepo repo) {
+ return pakfire_get_pool(repo->pakfire);
+}
+
+static Pool* pakfire_repo_get_solv_pool(PakfireRepo repo) {
+ PakfirePool pool = pakfire_repo_get_pool(repo);
+
+ Pool* p = pakfire_pool_get_solv_pool(pool);
+ pakfire_pool_unref(pool);
+
+ return p;
}
PAKFIRE_EXPORT int pakfire_repo_identical(PakfireRepo repo1, PakfireRepo repo2) {
}
PAKFIRE_EXPORT int pakfire_repo_count(PakfireRepo repo) {
- Pool* pool = pakfire_pool_get_solv_pool(repo->pool);
+ Pool* pool = pakfire_repo_get_solv_pool(repo);
int cnt = 0;
for (int i = 2; i < pool->nsolvables; i++) {
PAKFIRE_EXPORT void pakfire_repo_set_enabled(PakfireRepo repo, int enabled) {
repo->repo->disabled = !enabled;
- PakfirePool pool = pakfire_repo_pool(repo);
+ PakfirePool pool = pakfire_repo_get_pool(repo);
pakfire_pool_has_changed(pool);
+ pakfire_pool_unref(pool);
}
PAKFIRE_EXPORT int pakfire_repo_get_priority(PakfireRepo repo) {
}
PAKFIRE_EXPORT int pakfire_repo_is_installed_repo(PakfireRepo repo) {
- PakfirePool pool = pakfire_repo_pool(repo);
+ PakfireRepo installed_repo = pakfire_get_installed_repo(repo->pakfire);
+
+ int r = pakfire_repo_identical(repo, installed_repo);
- PakfireRepo installed_repo = pakfire_pool_get_installed_repo(pool);
+ pakfire_repo_unref(installed_repo);
- return pakfire_repo_identical(repo, installed_repo);
+ return r;
}
PAKFIRE_EXPORT int pakfire_repo_read_solv(PakfireRepo repo, const char* filename, int flags) {
return PAKFIRE_E_SOLV_CORRUPTED;
}
- pakfire_pool_has_changed(repo->pool);
+ PakfirePool pool = pakfire_get_pool(repo->pakfire);
+ pakfire_pool_has_changed(pool);
+ pakfire_pool_unref(pool);
return ret;
}
PAKFIRE_EXPORT PakfirePackage pakfire_repo_add_package(PakfireRepo repo) {
Id id = repo_add_solvable(repo->repo);
- return pakfire_package_create(repo->pool, id);
+ PakfirePool pool = pakfire_get_pool(repo->pakfire);
+ PakfirePackage pkg = pakfire_package_create(pool, id);
+ pakfire_pool_unref(pool);
+
+ return pkg;
}
PAKFIRE_EXPORT PakfireRepoCache pakfire_repo_get_cache(PakfireRepo repo) {
self.dummy = base.RepositoryDummy(self.pakfire)
# Create the local repository.
- self.local = self.pool.installed_repo = RepositorySystem(self.pakfire)
+ self.local = self.pakfire.installed_repo = RepositorySystem(self.pakfire)
self.add_repo(self.local)
# If we running in build mode, we include our local build repository.
self.pakfire = pakfire
# Inherit
- _pakfire.Repo.__init__(self, self.pakfire.pool, name)
+ _pakfire.Repo.__init__(self, self.pakfire, name)
# Save description
self.description = description