]> git.ipfire.org Git - pakfire.git/commitdiff
buildservice: Send the host distribution info
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 Oct 2023 11:35:52 +0000 (11:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 31 Oct 2023 11:35:52 +0000 (11:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/buildservice.c
src/libpakfire/ctx.c
src/libpakfire/include/pakfire/ctx.h

index 3043e0e510d0402fcc74580bad3d5e4af9dc03f8..66d9816af2d9cfe3ec5d95e8c421636f424ebd64 100644 (file)
@@ -990,6 +990,9 @@ PAKFIRE_EXPORT int pakfire_buildservice_submit_stats(struct pakfire_buildservice
        char* buffer = NULL;
        size_t length = 0;
 
+       // Fetch the distro
+       const struct pakfire_distro* distro = pakfire_ctx_get_distro(service->ctx);
+
        // Fetch CPU info
        r = pakfire_cpuinfo(&cpuinfo);
        if (r) {
@@ -1057,7 +1060,7 @@ PAKFIRE_EXPORT int pakfire_buildservice_submit_stats(struct pakfire_buildservice
                goto ERROR;
 
        // OS
-       r = pakfire_xfer_add_param(xfer, "os_name", "%s", "???");
+       r = pakfire_xfer_add_param(xfer, "os_name", "%s", distro->pretty_name);
        if (r)
                goto ERROR;
 
index 83ddb409371c403c4f802654ac34146121cd8fdc..aff3a02a30771ed954b6343bf603590a099acfc8 100644 (file)
@@ -28,6 +28,7 @@
 #include <pakfire/config.h>
 #include <pakfire/ctx.h>
 #include <pakfire/logging.h>
+#include <pakfire/os.h>
 #include <pakfire/private.h>
 
 struct pakfire_ctx {
@@ -40,6 +41,9 @@ struct pakfire_ctx {
        // Config
        struct pakfire_config* config;
 
+       // Distro
+       struct pakfire_distro distro;
+
        // Logging
        struct pakfire_ctx_log {
                int level;
@@ -181,6 +185,11 @@ PAKFIRE_EXPORT int pakfire_ctx_create(struct pakfire_ctx** ctx, const char* path
        if (r)
                goto ERROR;
 
+       // Load the distribution information
+       r = pakfire_distro(&c->distro, NULL);
+       if (r)
+               goto ERROR;
+
        // Set the default confirm callback
        pakfire_ctx_set_confirm_callback(c, pakfire_ctx_default_confirm_callback, NULL);
 
@@ -231,6 +240,12 @@ struct pakfire_config* pakfire_ctx_get_config(struct pakfire_ctx* ctx) {
        return pakfire_config_ref(ctx->config);
 }
 
+// Distro
+
+const struct pakfire_distro* pakfire_ctx_get_distro(struct pakfire_ctx* ctx) {
+       return &ctx->distro;
+}
+
 // Logging
 
 PAKFIRE_EXPORT int pakfire_ctx_get_log_level(struct pakfire_ctx* ctx) {
index 92a5acc876cd1b84c09f52f636e8b85250126add..b72c8cd624154551aab773fde7f313bdd2c682da 100644 (file)
@@ -81,6 +81,13 @@ void pakfire_ctx_set_pick_solution_callback(struct pakfire_ctx* ctx,
 
 #ifdef PAKFIRE_PRIVATE
 
+#include <pakfire/os.h>
+
+// Distro
+const struct pakfire_distro* pakfire_ctx_get_distro(struct pakfire_ctx* ctx);
+
+// Logging
+
 void pakfire_ctx_log(struct pakfire_ctx* ctx, int level, const char* file, int line,
        const char* fn, const char* format, ...) __attribute__((format(printf, 6, 7)));