for (const struct dependency* deps = dependencies; deps->field; deps++) {
const char* relations = (const char*)sqlite3_column_text(stmt, deps->field);
if (relations) {
- r = pakfire_str2deps(db->pakfire, pkg, deps->key, relations);
+ r = pakfire_str2deps(db->ctx, pkg, deps->key, relations);
if (r)
goto ERROR;
}
#include <solv/evr.h>
#include <solv/pool.h>
-// Enable legacy logging
-#define PAKFIRE_LEGACY_LOGGING
-
#include <pakfire/dependencies.h>
#include <pakfire/logging.h>
#include <pakfire/package.h>
return r;
}
-const char* pakfire_dep2str(struct pakfire* pakfire, Id id) {
- Pool* pool = pakfire_get_solv_pool(pakfire);
- if (!pool)
- return NULL;
-
+const char* pakfire_dep2str(struct pakfire_ctx* ctx, Pool* pool, Id id) {
return pool_dep2str(pool, id);
}
/*
This function parses a simple dependency like "foo = 1.2.3"
*/
-static Id pakfire_parse_dep(struct pakfire* pakfire, const char** s) {
+static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) {
Id id = ID_NULL;
if (!s) {
if (!p)
return ID_NULL;
- Pool* pool = pakfire_get_solv_pool(pakfire);
-
// Consume any leading space
while (isspace(*p))
p++;
/*
This function parses any rich dependencies
*/
-static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int flags) {
+static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx,
+ Pool* pool, const char** dep, int flags) {
const char* p = *dep;
Id id;
switch (*p) {
// A new rich dependency
case '(':
- id = pakfire_parse_rich_dep(pakfire, &p, 0);
+ id = pakfire_parse_rich_dep(ctx, pool, &p, 0);
if (!id)
return id;
break;
// Parse a regular dependency
default:
- id = pakfire_parse_dep(pakfire, &p);
+ id = pakfire_parse_dep(ctx, pool, &p);
if (!id)
return id;
break;
return ID_NULL;
// Parse the next bit
- Id evr = pakfire_parse_rich_dep(pakfire, &p, flags);
+ Id evr = pakfire_parse_rich_dep(ctx, pool, &p, flags);
// Abort if there was a problem
if (!evr)
// Store until where we have parsed the string
*dep = p;
- Pool* pool = pakfire_get_solv_pool(pakfire);
-
// Combine everything
return pool_rel2id(pool, id, evr, flags, 1);
}
-Id pakfire_str2dep(struct pakfire* pakfire, const char* dep) {
+Id pakfire_str2dep(struct pakfire_ctx* ctx, Pool* pool, const char* dep) {
Id id = ID_NULL;
// Invalid input
// Parse any rich dependencies
if (*s == '(')
- id = pakfire_parse_rich_dep(pakfire, &s, 0);
+ id = pakfire_parse_rich_dep(ctx, pool, &s, 0);
else
- id = pakfire_parse_dep(pakfire, &s);
+ id = pakfire_parse_dep(ctx, pool, &s);
// Return nothing if we could not parse the entire string
if (id && *s) {
- DEBUG(pakfire, "Invalid dependency: %s\n", dep);
+ CTX_DEBUG(ctx, "Invalid dependency: %s\n", dep);
id = ID_NULL;
}
return id;
}
-int pakfire_str2deps(struct pakfire* pakfire, struct pakfire_package* pkg,
+int pakfire_str2deps(struct pakfire_ctx* ctx, struct pakfire_package* pkg,
const enum pakfire_package_key key, const char* deps) {
char* p = NULL;
int r = 0;
#include <solv/pool.h>
+#include <pakfire/ctx.h>
#include <pakfire/package.h>
-#include <pakfire/pakfire.h>
extern const struct pakfire_dep {
const enum pakfire_package_key key;
const char* name;
} pakfire_deps[];
-const char* pakfire_dep2str(struct pakfire* pakfire, Id id);
-Id pakfire_str2dep(struct pakfire* pakfire, const char* s);
+const char* pakfire_dep2str(struct pakfire_ctx* ctx, Pool* pool, Id id);
+Id pakfire_str2dep(struct pakfire_ctx* ctx, Pool* pool, const char* s);
-int pakfire_str2deps(struct pakfire* pakfire, struct pakfire_package* pkg,
+int pakfire_str2deps(struct pakfire_ctx* ctx, struct pakfire_package* pkg,
const enum pakfire_package_key key, const char* deps);
#endif /* PAKFIRE_PRIVATE */
struct pakfire* pakfire;
int nrefs;
+ Pool* pool;
+
// Reference to this package in the SOLV pool
Id id;
struct pakfire_repo* repo;
pkg->pakfire = pakfire_ref(pakfire);
pkg->nrefs = 1;
+ // Store a reference to the pool
+ pkg->pool = pakfire_get_solv_pool(pkg->pakfire);
+
// Store the ID
pkg->id = id;
goto ERROR;
for (int i = 0; i < q.count; i++) {
- dep = pakfire_dep2str(pkg->pakfire, q.elements[i]);
+ dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]);
if (!dep)
goto ERROR;
int pakfire_package_add_dep(struct pakfire_package* pkg,
const enum pakfire_package_key key, const char* dep) {
// Parse the dependency
- Id id = pakfire_str2dep(pkg->pakfire, dep);
+ Id id = pakfire_str2dep(pkg->ctx, pkg->pool, dep);
// Silently ignore any invalid dependencies
if (!id)
goto ERROR;
for (int i = 0; i < q.count; i++) {
- const char* dep = pakfire_dep2str(pkg->pakfire, q.elements[i]);
+ const char* dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]);
// Is this a rich dependency?
if (dep && *dep == '(') {
return r;
// Get the dependency
- Id depid = pakfire_str2dep(pkg->pakfire, dep);
+ Id depid = pakfire_str2dep(pkg->ctx, pkg->pool, dep);
if (!depid)
return -1;
struct pakfire* pakfire = (struct pakfire*)data;
const char* namespace = pool_id2str(pool, ns);
- const char* name = pakfire_dep2str(pakfire, id);
+ const char* name = pakfire_dep2str(pakfire->ctx, pool, id);
CTX_DEBUG(pakfire->ctx, "Namespace callback called for %s(%s)\n", namespace, name);
};
for (const char** package = pakfire_multiinstall_packages; *package; package++) {
- Id id = pakfire_str2dep(pakfire, *package);
+ Id id = pakfire_str2dep(pakfire->ctx, pool, *package);
if (!id)
continue;
pakfire_pool_internalize(pakfire);
// Translate dependency to ID
- Id dep = pakfire_str2dep(pakfire, what);
+ Id dep = pakfire_str2dep(pakfire->ctx, pakfire->pool, what);
if (!dep) {
errno = EINVAL;
return 1;
if (is_source) {
deps = pakfire_parser_get(parser, "build", "requires");
if (deps) {
- r = pakfire_str2deps(parser->pakfire, *pkg, PAKFIRE_PKG_REQUIRES, deps);
+ r = pakfire_str2deps(parser->ctx, *pkg, PAKFIRE_PKG_REQUIRES, deps);
if (r)
goto CLEANUP;
}
for (const struct pakfire_dep* dep = pakfire_deps; dep->key; dep++) {
deps = pakfire_parser_get(parser, namespace, dep->name);
if (deps) {
- r = pakfire_str2deps(parser->pakfire, *pkg, dep->key, deps);
+ r = pakfire_str2deps(parser->ctx, *pkg, dep->key, deps);
if (r)
goto CLEANUP;
}
case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
r = asprintf(&s, _("nothing provides requested %s"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_JOB_UNKNOWN_PACKAGE:
r = asprintf(&s, _("package %s does not exist"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM:
r = asprintf(&s, _("%s is provided by the system"),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_RPM:
case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
r = asprintf(&s, _("nothing provides %s needed by %s"),
- pakfire_dep2str(problem->pakfire, dep), pool_solvid2str(pool, source));
+ pakfire_dep2str(problem->ctx, pool, dep), pool_solvid2str(pool, source));
break;
case SOLVER_RULE_RPM_SAME_NAME:
r = asprintf(&s, _("cannot install both %s and %s"),
- pool_solvid2str(pool, source), pool_solvid2str(pool, target));
+ pool_solvid2str(pool, source), pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_PACKAGE_CONFLICT:
r = asprintf(&s, _("package %s conflicts with %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
r = asprintf(&s, _("package %s obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_INSTALLEDPKG_OBSOLETES:
r = asprintf(&s, _("installed package %s obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
r = asprintf(&s, _("package %s implicitely obsoletes %s provided by %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
pool_solvid2str(pool, target));
break;
case SOLVER_RULE_RPM_PACKAGE_REQUIRES:
r = asprintf(&s, _("package %s requires %s, but none of the providers can be installed"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep));
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_RPM_SELF_CONFLICT:
r = asprintf(&s, _("package %s conflicts with %s provided by itself"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep));
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_YUMOBS:
r = asprintf(&s, _("both package %s and %s obsolete %s"),
pool_solvid2str(pool, source), pool_solvid2str(pool, target),
- pakfire_dep2str(problem->pakfire, dep));
+ pakfire_dep2str(problem->ctx, pool, dep));
break;
case SOLVER_RULE_BLACK:
case SOLVER_RULE_PKG_CONSTRAINS:
r = asprintf(&s, _("package %s has constraint %s conflicting with %s"),
- pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep),
+ pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
pool_solvid2str(pool, target));
break;
// Did we find anything?
if (jobs.count == 0) {
- Id id = pakfire_str2dep(transaction->pakfire, what);
+ Id id = pakfire_str2dep(transaction->ctx, pool, what);
if (!id) {
r = -errno;
goto ERROR;