const char* arch = pakfire_archive_metadata_get(archive, "arch", NULL);
// Create a new package object
- r = pakfire_package_create(&pkg, archive->root, repo, name, evr, arch);
+ r = pakfire_package_create(&pkg, archive->ctx, archive->root, repo, name, evr, arch);
if (r)
return r;
}
// Create package
- r = pakfire_package_create(&pkg, db->root, repo, name, evr, arch);
+ r = pakfire_package_create(&pkg, db->ctx, db->root, repo, name, evr, arch);
if (r) {
ERROR(db->ctx, "Could not create package '%s-%s.%s': %m\n", name, evr, arch);
goto ERROR;
}
int pakfire_package_create_from_solvable(pakfire_package** package,
- pakfire_root* root, pakfire_repo* repo, Id id) {
+ pakfire_ctx* ctx, pakfire_root* root, pakfire_repo* repo, Id id) {
pakfire_package* pkg = NULL;
// Allocate some memory
return -errno;
// Store a reference to the context
- pkg->ctx = pakfire_root_get_ctx(root);
+ pkg->ctx = pakfire_ctx_ref(ctx);
// Store a reference to the root
pkg->root = pakfire_root_ref(root);
return 0;
}
-int pakfire_package_create(pakfire_package** package, pakfire_root* root,
+int pakfire_package_create(pakfire_package** package, pakfire_ctx* ctx, pakfire_root* root,
pakfire_repo* repo, const char* name, const char* evr, const char* arch) {
pakfire_repo* dummy = NULL;
int r;
repo = dummy;
}
- // Fetch the context
- pakfire_ctx* ctx = pakfire_root_get_ctx(root);
-
// Allocate a new solvable
Id id = pakfire_repo_add_solvable(repo);
if (!id) {
}
// Create a new package object
- r = pakfire_package_create_from_solvable(package, root, repo, id);
+ r = pakfire_package_create_from_solvable(package, ctx, root, repo, id);
if (r)
goto ERROR;
ERROR:
if (dummy)
pakfire_repo_unref(dummy);
- if (ctx)
- pakfire_ctx_unref(ctx);
return r;
}
typedef struct pakfire_package pakfire_package;
+#include <pakfire/ctx.h>
#include <pakfire/filelist.h>
#include <pakfire/hashes.h>
#include <pakfire/packagelist.h>
PAKFIRE_PKG_ENHANCES,
};
-int pakfire_package_create(pakfire_package** package, pakfire_root* root,
+int pakfire_package_create(pakfire_package** package, pakfire_ctx* ctx, pakfire_root* root,
pakfire_repo* repo, const char* name, const char* evr, const char* arch);
pakfire_package* pakfire_package_ref(pakfire_package* pkg);
int pakfire_package_installcheck(pakfire_package* pkg, char** problem, int flags);
int pakfire_package_create_from_solvable(pakfire_package** package,
- pakfire_root* root, pakfire_repo* repo, Id id);
+ pakfire_ctx* ctx, pakfire_root* root, pakfire_repo* repo, Id id);
int pakfire_package_set_strings_from_string(pakfire_package* pkg,
const enum pakfire_package_key key, const char* value);
// Walk through all elements on the queue
for (int i = 0; i < q->count; i++) {
- r = pakfire_package_create_from_solvable(&pkg, root, NULL, q->elements[i]);
+ r = pakfire_package_create_from_solvable(&pkg, self->ctx, root, NULL, q->elements[i]);
if (r)
return r;
}
// Create a new package object
- r = pakfire_package_create(pkg, parser->root, repo, name, evr, (arch) ? arch : default_arch);
+ r = pakfire_package_create(pkg, parser->ctx, parser->root,
+ repo, name, evr, (arch) ? arch : default_arch);
if (r < 0) {
ERROR(parser->ctx, "Could not create package: %m\n");
goto CLEANUP;
id = pool_solvable2id(self->repo->pool, s);
// Create a new package
- r = pakfire_package_create_from_solvable(&pkg, self->root, self, id);
+ r = pakfire_package_create_from_solvable(&pkg, self->ctx, self->root, self, id);
if (r < 0)
goto ERROR;
Id id = pool_solvable2id(pool, s);
// Allocate package
- r = pakfire_package_create_from_solvable(&pkg, repo->root, repo, id);
+ r = pakfire_package_create_from_solvable(&pkg, repo->ctx, repo->root, repo, id);
if (r)
return 1;
// Create all packages
for (unsigned int i = 0; i < transaction->num; i++) {
- r = pakfire_package_create_from_solvable(&transaction->packages[i],
+ r = pakfire_package_create_from_solvable(&transaction->packages[i], transaction->ctx,
transaction->root, NULL, transaction->transaction->steps.elements[i]);
if (r < 0)
goto ERROR;
// Store all newly installed and overall all installed packages
for (int i = 0; i < pkgs.count; i++) {
- r = pakfire_package_create_from_solvable(&pkg,
+ r = pakfire_package_create_from_solvable(&pkg, transaction->ctx,
transaction->root, NULL, pkgs.elements[i]);
if (r < 0)
goto ERROR;
pakfire_package* old_pkg = NULL;
pakfire_package* new_pkg = NULL;
- r = pakfire_package_create_from_solvable(&old_pkg, transaction->root,
- NULL, pkgs.elements[j]);
+ r = pakfire_package_create_from_solvable(&old_pkg, transaction->ctx,
+ transaction->root, NULL, pkgs.elements[j]);
if (r)
continue;
switch (class) {
case SOLVER_TRANSACTION_UPGRADED:
case SOLVER_TRANSACTION_DOWNGRADED:
- r = pakfire_package_create_from_solvable(&new_pkg, transaction->root,
- NULL, transaction_obs_pkg(transaction->transaction, pkgs.elements[j]));
+ r = pakfire_package_create_from_solvable(&new_pkg, transaction->ctx,
+ transaction->root, NULL, transaction_obs_pkg(transaction->transaction, pkgs.elements[j]));
if (r)
continue;
return -1;
// Create the package object
- r = pakfire_package_create(&self->package, root->root, repo->repo, name, evr, arch);
+ r = pakfire_package_create(&self->package, root->ctx->ctx, root->root,
+ repo->repo, name, evr, arch);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
pakfire_package* pkg = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
"test", "1.0-1", "x86_64"));
// Check if the package matches itself
char** groups = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "x86_64"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", "1.0-1", "x86_64"));
ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_NAME), "test");
ASSERT_STRING_EQUALS(pakfire_package_get_string(pkg, PAKFIRE_PKG_EVR), "1.0-1");
int r = EXIT_FAILURE;
// Try to create a package with some values missing
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, NULL, "1.0-1", "src"), EINVAL);
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, "test", NULL, "src"), EINVAL);
- ASSERT_ERRNO(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", NULL), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ NULL, "1.0-1", "src"), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", NULL, "src"), EINVAL);
+ ASSERT_ERRNO(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", "1.0-1", NULL), EINVAL);
// Finally create a package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "x86_64"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", "1.0-1", "x86_64"));
// Try to set non-sense for strings
ASSERT_ERRNO(pakfire_package_set_string(pkg, PAKFIRE_PKG_INSTALLTIME, "today"), EINVAL);
uuid_unparse(uuid, uuid_string);
// Create a new package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", "1.0-1", "src"));
// Set the UUID
ASSERT_SUCCESS(pakfire_package_set_uuid(pkg, PAKFIRE_PKG_UUID, uuid));
char** deps = NULL;
int r = EXIT_FAILURE;
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
+ "test", "1.0-1", "src"));
// Add a "provides"
ASSERT_SUCCESS(pakfire_package_add_dep(pkg, PAKFIRE_PKG_PROVIDES, "a"));
ASSERT_EQUALS(pakfire_filelist_length(filelist), 1);
// Create a new package
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, NULL,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, NULL,
"bash", "1.0-1", "i386"));
// Set filelist
ASSERT_SUCCESS(pakfire_repo_create(&repo, t->root, "test"));
ASSERT(repo);
- ASSERT_SUCCESS(pakfire_package_create(&pkg, t->root, repo, "test", "1.0-1", "src"));
+ ASSERT_SUCCESS(pakfire_package_create(&pkg, t->ctx, t->root, repo,
+ "test", "1.0-1", "src"));
// Create packager
ASSERT_SUCCESS(pakfire_packager_create(&packager, t->root, pkg));
pakfire_repo* repo = pakfire_root_get_repo(t->root, PAKFIRE_REPO_DUMMY);
ASSERT(repo);
- ASSERT_SUCCESS(pakfire_package_create(&pkg1, t->root, repo,
+ ASSERT_SUCCESS(pakfire_package_create(&pkg1, t->ctx, t->root, repo,
"test", "1.0-1", "x86_64"));
// Set all metadata