From: Michael Tremer Date: Sat, 10 Aug 2024 12:00:41 +0000 (+0000) Subject: deps: Revert all the braindead logging changes X-Git-Tag: 0.9.30~1223 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5204a39271b1614cae708a468454ab212b11e8a9;p=pakfire.git deps: Revert all the braindead logging changes Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index 1737a9304..bfc2b76ff 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -1985,7 +1985,7 @@ static int pakfire_db_load_package(struct pakfire_db* db, struct pakfire_repo* r 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->ctx, pkg, deps->key, relations); + r = pakfire_str2deps(db->pakfire, pkg, deps->key, relations); if (r) goto ERROR; } diff --git a/src/libpakfire/dependencies.c b/src/libpakfire/dependencies.c index fd24198fb..92811fa43 100644 --- a/src/libpakfire/dependencies.c +++ b/src/libpakfire/dependencies.c @@ -85,7 +85,9 @@ PAKFIRE_EXPORT int pakfire_static_version_compare(const char* evr1, const char* return r; } -const char* pakfire_dep2str(struct pakfire_ctx* ctx, Pool* pool, Id id) { +const char* pakfire_dep2str(struct pakfire* pakfire, Id id) { + Pool* pool = pakfire_get_solv_pool(pakfire); + return pool_dep2str(pool, id); } @@ -139,11 +141,14 @@ END: /* This function parses any namespaced dependencies */ -static Id pakfire_parse_namespace(Pool* pool, const char* s) { +static Id pakfire_parse_namespace(struct pakfire* pakfire, const char* s) { const char* p = strchr(s, '('); if (!p) return 0; + // Fetch the pool + Pool* pool = pakfire_get_solv_pool(pakfire); + // Store the namespace ID Id namespace = pool_strn2id(pool, s, p - s, 1); @@ -161,7 +166,7 @@ static Id pakfire_parse_namespace(Pool* pool, const char* s) { /* This function parses a simple dependency like "foo = 1.2.3" */ -static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) { +static Id pakfire_parse_dep(struct pakfire* pakfire, const char** s) { Id id = ID_NULL; if (!s) { @@ -176,6 +181,9 @@ static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) if (!p) return ID_NULL; + // Fetch the pool + Pool* pool = pakfire_get_solv_pool(pakfire); + // Consume any leading space while (isspace(*p)) p++; @@ -184,10 +192,11 @@ static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) size_t l = skip(&p, &n); // Add name to pool - if (pakfire_string_startswith(n, "pakfire(") || pakfire_string_startswith(n, "arch(")) - id = pakfire_parse_namespace(pool, n); - else + if (pakfire_string_startswith(n, "pakfire(") || pakfire_string_startswith(n, "arch(")) { + id = pakfire_parse_namespace(pakfire, n); + } else { id = pool_strn2id(pool, n, l, 1); + } // Consume any more space while (isspace(*p)) @@ -239,8 +248,7 @@ static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) /* This function parses any rich dependencies */ -static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx, - Pool* pool, const char** dep, int flags) { +static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int flags) { const char* p = *dep; Id id; @@ -255,7 +263,7 @@ static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx, switch (*p) { // A new rich dependency case '(': - id = pakfire_parse_rich_dep(ctx, pool, &p, 0); + id = pakfire_parse_rich_dep(pakfire, &p, 0); if (!id) return id; break; @@ -266,7 +274,7 @@ static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx, // Parse a regular dependency default: - id = pakfire_parse_dep(ctx, pool, &p); + id = pakfire_parse_dep(pakfire, &p); if (!id) return id; break; @@ -299,12 +307,15 @@ static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx, return ID_NULL; // Parse the next bit - Id evr = pakfire_parse_rich_dep(ctx, pool, &p, flags); + Id evr = pakfire_parse_rich_dep(pakfire, &p, flags); // Abort if there was a problem if (!evr) return ID_NULL; + // Fetch pool + Pool* pool = pakfire_get_solv_pool(pakfire); + // Store until where we have parsed the string *dep = p; @@ -312,7 +323,7 @@ static Id pakfire_parse_rich_dep(struct pakfire_ctx* ctx, return pool_rel2id(pool, id, evr, flags, 1); } -Id pakfire_str2dep(struct pakfire_ctx* ctx, Pool* pool, const char* dep) { +Id pakfire_str2dep(struct pakfire* pakfire, const char* dep) { Id id = ID_NULL; // Invalid input @@ -337,20 +348,20 @@ Id pakfire_str2dep(struct pakfire_ctx* ctx, Pool* pool, const char* dep) { // Parse any rich dependencies if (*s == '(') - id = pakfire_parse_rich_dep(ctx, pool, &s, 0); + id = pakfire_parse_rich_dep(pakfire, &s, 0); else - id = pakfire_parse_dep(ctx, pool, &s); + id = pakfire_parse_dep(pakfire, &s); // Return nothing if we could not parse the entire string if (id && *s) { - CTX_DEBUG(ctx, "Invalid dependency: %s\n", dep); + PAKFIRE_DEBUG(pakfire, "Invalid dependency: %s\n", dep); id = ID_NULL; } return id; } -int pakfire_str2deps(struct pakfire_ctx* ctx, struct pakfire_package* pkg, +int pakfire_str2deps(struct pakfire* pakfire, struct pakfire_package* pkg, const enum pakfire_package_key key, const char* deps) { char* p = NULL; int r = 0; diff --git a/src/libpakfire/include/pakfire/dependencies.h b/src/libpakfire/include/pakfire/dependencies.h index 8e8c1b988..3fb33f55f 100644 --- a/src/libpakfire/include/pakfire/dependencies.h +++ b/src/libpakfire/include/pakfire/dependencies.h @@ -25,8 +25,6 @@ int pakfire_static_version_compare(const char* evr1, const char* evr2); #ifdef PAKFIRE_PRIVATE -#include - #include #include @@ -35,10 +33,10 @@ extern const struct pakfire_dep { const char* name; } pakfire_deps[]; -const char* pakfire_dep2str(struct pakfire_ctx* ctx, Pool* pool, Id id); -Id pakfire_str2dep(struct pakfire_ctx* ctx, Pool* pool, const char* s); +const char* pakfire_dep2str(struct pakfire* pakfire, Id id); +Id pakfire_str2dep(struct pakfire* pakfire, const char* s); -int pakfire_str2deps(struct pakfire_ctx* ctx, struct pakfire_package* pkg, +int pakfire_str2deps(struct pakfire* pakfire, struct pakfire_package* pkg, const enum pakfire_package_key key, const char* deps); #endif /* PAKFIRE_PRIVATE */ diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 173bb476a..e41f0a1a6 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -58,8 +58,6 @@ struct pakfire_package { struct pakfire* pakfire; int nrefs; - Pool* pool; - // Reference to this package in the SOLV pool Id id; struct pakfire_repo* repo; @@ -173,9 +171,6 @@ int pakfire_package_create_from_solvable(struct pakfire_package** package, 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; @@ -1341,7 +1336,7 @@ PAKFIRE_EXPORT char** pakfire_package_get_deps(struct pakfire_package* pkg, goto ERROR; for (int i = 0; i < q.count; i++) { - dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]); + dep = pakfire_dep2str(pkg->pakfire, q.elements[i]); if (!dep) goto ERROR; @@ -1368,7 +1363,7 @@ SUCCESS: 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->ctx, pkg->pool, dep); + Id id = pakfire_str2dep(pkg->pakfire, dep); // Silently ignore any invalid dependencies if (!id) @@ -1418,7 +1413,7 @@ static int pakfire_package_has_rich_deps_in_deparray( goto ERROR; for (int i = 0; i < q.count; i++) { - const char* dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]); + const char* dep = pakfire_dep2str(pkg->pakfire, q.elements[i]); // Is this a rich dependency? if (dep && *dep == '(') { @@ -1470,7 +1465,7 @@ int pakfire_package_matches_dep(struct pakfire_package* pkg, return r; // Get the dependency - Id depid = pakfire_str2dep(pkg->ctx, pkg->pool, dep); + Id depid = pakfire_str2dep(pkg->pakfire, dep); if (!depid) return -1; diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 9478e4cb4..fd674e113 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -235,7 +235,7 @@ static Id pakfire_namespace_callback(Pool* pool, void* data, Id ns, Id id) { struct pakfire* pakfire = (struct pakfire*)data; const char* namespace = pool_id2str(pool, ns); - const char* name = pakfire_dep2str(pakfire->ctx, pool, id); + const char* name = pakfire_dep2str(pakfire, id); CTX_DEBUG(pakfire->ctx, "Namespace callback called for %s(%s)\n", namespace, name); @@ -315,7 +315,7 @@ static int pakfire_populate_pool(struct pakfire* pakfire) { }; for (const char** package = pakfire_multiinstall_packages; *package; package++) { - Id id = pakfire_str2dep(pakfire->ctx, pool, *package); + Id id = pakfire_str2dep(pakfire, *package); if (!id) continue; @@ -1373,7 +1373,7 @@ static int pakfire_search_dep(struct pakfire* pakfire, Id type, const char* what pakfire_pool_internalize(pakfire); // Translate dependency to ID - Id dep = pakfire_str2dep(pakfire->ctx, pakfire->pool, what); + Id dep = pakfire_str2dep(pakfire, what); if (!dep) { errno = EINVAL; return 1; diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index e686855e8..263001b7d 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -1082,7 +1082,7 @@ int pakfire_parser_create_package(struct pakfire_parser* parser, if (is_source) { deps = pakfire_parser_get(parser, "build", "requires"); if (deps) { - r = pakfire_str2deps(parser->ctx, *pkg, PAKFIRE_PKG_REQUIRES, deps); + r = pakfire_str2deps(parser->pakfire, *pkg, PAKFIRE_PKG_REQUIRES, deps); if (r) goto CLEANUP; } @@ -1090,7 +1090,7 @@ int pakfire_parser_create_package(struct pakfire_parser* parser, 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->ctx, *pkg, dep->key, deps); + r = pakfire_str2deps(parser->pakfire, *pkg, dep->key, deps); if (r) goto CLEANUP; } diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index e39202439..f9fd46042 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -91,17 +91,17 @@ static char* pakfire_problem_make_string(struct pakfire_problem* problem) { case SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP: r = asprintf(&s, _("nothing provides requested %s"), - pakfire_dep2str(problem->ctx, pool, dep)); + pakfire_dep2str(problem->pakfire, dep)); break; case SOLVER_RULE_JOB_UNKNOWN_PACKAGE: r = asprintf(&s, _("package %s does not exist"), - pakfire_dep2str(problem->ctx, pool, dep)); + pakfire_dep2str(problem->pakfire, dep)); break; case SOLVER_RULE_JOB_PROVIDED_BY_SYSTEM: r = asprintf(&s, _("%s is provided by the system"), - pakfire_dep2str(problem->ctx, pool, dep)); + pakfire_dep2str(problem->pakfire, dep)); break; case SOLVER_RULE_RPM: @@ -123,7 +123,7 @@ static char* pakfire_problem_make_string(struct pakfire_problem* problem) { case SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP: r = asprintf(&s, _("nothing provides %s needed by %s"), - pakfire_dep2str(problem->ctx, pool, dep), pool_solvid2str(pool, source)); + pakfire_dep2str(problem->pakfire, dep), pool_solvid2str(pool, source)); break; case SOLVER_RULE_RPM_SAME_NAME: @@ -133,42 +133,42 @@ static char* pakfire_problem_make_string(struct pakfire_problem* problem) { case SOLVER_RULE_RPM_PACKAGE_CONFLICT: r = asprintf(&s, _("package %s conflicts with %s provided by %s"), - pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep), + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep), + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep), + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep), + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep)); + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep)); + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, 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->ctx, pool, dep)); + pakfire_dep2str(problem->pakfire, dep)); break; case SOLVER_RULE_BLACK: @@ -178,7 +178,7 @@ static char* pakfire_problem_make_string(struct pakfire_problem* problem) { case SOLVER_RULE_PKG_CONSTRAINS: r = asprintf(&s, _("package %s has constraint %s conflicting with %s"), - pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep), + pool_solvid2str(pool, source), pakfire_dep2str(problem->pakfire, dep), pool_solvid2str(pool, target)); break; diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index 7d7415dfb..31b7e83f1 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -765,7 +765,7 @@ static int pakfire_transaction_add_job(struct pakfire_transaction* transaction, // Did we find anything? if (jobs.count == 0) { - Id id = pakfire_str2dep(transaction->ctx, pool, what); + Id id = pakfire_str2dep(transaction->pakfire, what); if (!id) { r = -errno; goto ERROR;