]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
dependencies: Drop the legacy logger
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Jan 2024 17:46:09 +0000 (17:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 29 Jan 2024 17:46:09 +0000 (17:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/db.c
src/libpakfire/dependencies.c
src/libpakfire/include/pakfire/dependencies.h
src/libpakfire/package.c
src/libpakfire/pakfire.c
src/libpakfire/parser.c
src/libpakfire/problem.c
src/libpakfire/transaction.c

index bfc2b76ff53b35f6387cbceb12e8e73f8da3b808..1737a9304d9f01229530bad7ebd28c94194faaf2 100644 (file)
@@ -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->pakfire, pkg, deps->key, relations);
+                       r = pakfire_str2deps(db->ctx, pkg, deps->key, relations);
                        if (r)
                                goto ERROR;
                }
index 9064fb0f659041d2979243c0ef22d5b8d717cc55..fd24198fb7e18ef4ed1af4c1aec28af4f610493b 100644 (file)
@@ -26,9 +26,6 @@
 #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>
@@ -88,11 +85,7 @@ PAKFIRE_EXPORT int pakfire_static_version_compare(const char* evr1, const char*
        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);
 }
 
@@ -168,7 +161,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* pakfire, const char** s) {
+static Id pakfire_parse_dep(struct pakfire_ctx* ctx, Pool* pool, const char** s) {
        Id id = ID_NULL;
 
        if (!s) {
@@ -183,8 +176,6 @@ static Id pakfire_parse_dep(struct pakfire* pakfire, const char** s) {
        if (!p)
                return ID_NULL;
 
-       Pool* pool = pakfire_get_solv_pool(pakfire);
-
        // Consume any leading space
        while (isspace(*p))
                p++;
@@ -248,7 +239,8 @@ static Id pakfire_parse_dep(struct pakfire* pakfire, const char** s) {
 /*
        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;
 
@@ -263,7 +255,7 @@ static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int
        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;
@@ -274,7 +266,7 @@ static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int
 
                // Parse a regular dependency
                default:
-                       id = pakfire_parse_dep(pakfire, &p);
+                       id = pakfire_parse_dep(ctx, pool, &p);
                        if (!id)
                                return id;
                        break;
@@ -307,7 +299,7 @@ static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int
                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)
@@ -316,13 +308,11 @@ static Id pakfire_parse_rich_dep(struct pakfire* pakfire, const char** dep, int
        // 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
@@ -347,20 +337,20 @@ Id pakfire_str2dep(struct pakfire* pakfire, const char* dep) {
 
        // 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;
index 8dd58c3392f99fb8d5a16667564d4e179c1ed16c..8e8c1b988230443fdcf05baa82fd2cec5d84744b 100644 (file)
@@ -27,18 +27,18 @@ int pakfire_static_version_compare(const char* evr1, const char* evr2);
 
 #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 */
index e41f0a1a6c0a3d4fb41485d70bf65fc160288bff..173bb476aa36a58da4edd36e6416f8fd8cdaaee4 100644 (file)
@@ -58,6 +58,8 @@ struct pakfire_package {
        struct pakfire* pakfire;
        int nrefs;
 
+       Pool* pool;
+
        // Reference to this package in the SOLV pool
        Id id;
        struct pakfire_repo* repo;
@@ -171,6 +173,9 @@ 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;
 
@@ -1336,7 +1341,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->pakfire, q.elements[i]);
+               dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]);
                if (!dep)
                        goto ERROR;
 
@@ -1363,7 +1368,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->pakfire, dep);
+       Id id = pakfire_str2dep(pkg->ctx, pkg->pool, dep);
 
        // Silently ignore any invalid dependencies
        if (!id)
@@ -1413,7 +1418,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->pakfire, q.elements[i]);
+               const char* dep = pakfire_dep2str(pkg->ctx, pkg->pool, q.elements[i]);
 
                // Is this a rich dependency?
                if (dep && *dep == '(') {
@@ -1465,7 +1470,7 @@ int pakfire_package_matches_dep(struct pakfire_package* pkg,
                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;
 
index 2430c78979ff79a51cc0a752dcd9776b98992a84..8aab98aa1f20033a04d1c45bce7888b580765aaa 100644 (file)
@@ -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, id);
+       const char* name = pakfire_dep2str(pakfire->ctx, pool, 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, *package);
+               Id id = pakfire_str2dep(pakfire->ctx, pool, *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, what);
+       Id dep = pakfire_str2dep(pakfire->ctx, pakfire->pool, what);
        if (!dep) {
                errno = EINVAL;
                return 1;
index 263001b7d693ec0d14f97d991bc620989d5d649b..e686855e8cc1c9bebfc23c634d019447cebb7c96 100644 (file)
@@ -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->pakfire, *pkg, PAKFIRE_PKG_REQUIRES, deps);
+                       r = pakfire_str2deps(parser->ctx, *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->pakfire, *pkg, dep->key, deps);
+                               r = pakfire_str2deps(parser->ctx, *pkg, dep->key, deps);
                                if (r)
                                        goto CLEANUP;
                        }
index 5d696dd06897218df36bac4b0a2299b86f916a51..8fb63a933d3068be123bbd90763c582235032faf 100644 (file)
@@ -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->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:
@@ -123,52 +123,52 @@ 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->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:
@@ -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->pakfire, dep),
+                               pool_solvid2str(pool, source), pakfire_dep2str(problem->ctx, pool, dep),
                                pool_solvid2str(pool, target));
                        break;
 
index efd87e05f91eba39ebf22365376ee10a9137216d..ee27947032490b51624aabef51fb00b0f4c4c7ed 100644 (file)
@@ -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->pakfire, what);
+               Id id = pakfire_str2dep(transaction->ctx, pool, what);
                if (!id) {
                        r = -errno;
                        goto ERROR;