]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
client: Send system information when connecting
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 08:25:45 +0000 (08:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 08:25:45 +0000 (08:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/client.c

index 3f8dd3a095899dcf5313146ddd8c40563098e640..e9afae021b3d132a8afbb9d70c15c60a1c928799 100644 (file)
@@ -803,10 +803,27 @@ ERROR:
 }
 
 int pakfire_client_builder_connect(pakfire_client* self, pakfire_builder* builder) {
+       const pakfire_distro* distro = NULL;
+       pakfire_cpuinfo cpuinfo = {};
+       pakfire_sysinfo sysinfo = {};
        pakfire_xfer* xfer = NULL;
        const char* arch = NULL;
        int r;
 
+       // Fetch CPU info
+       r = pakfire_get_cpuinfo(&cpuinfo);
+       if (r < 0) {
+               ERROR(self->ctx, "Failed to fetch CPU info: %s\n", strerror(-r));
+               goto ERROR;
+       }
+
+       // Fetch system information
+       r = pakfire_get_sysinfo(&sysinfo);
+       if (r < 0) {
+               ERROR(self->ctx, "Failed to fetch system info: %s\n", strerror(-r));
+               goto ERROR;
+       }
+
        // Create a new xfer
        r = pakfire_client_xfer_create(&xfer, self, "/api/v1/builders/control");
        if (r < 0)
@@ -827,6 +844,42 @@ int pakfire_client_builder_connect(pakfire_client* self, pakfire_builder* builde
                        goto ERROR;
        }
 
+       // Fetch the distro that we are running on
+       distro = pakfire_ctx_get_distro(self->ctx);
+
+       // Send the distro information
+       if (distro) {
+               r = pakfire_xfer_add_query(xfer, "os_name", "%s", distro->pretty_name);
+               if (r < 0)
+                       goto ERROR;
+       }
+
+       // System Vendor
+       if (*sysinfo.vendor) {
+               r = pakfire_xfer_add_query(xfer, "sys_vendor", "%s", sysinfo.vendor);
+               if (r < 0)
+                       goto ERROR;
+       }
+
+       // System Model
+       if (*sysinfo.name) {
+               r = pakfire_xfer_add_query(xfer, "sys_name", "%s", sysinfo.name);
+               if (r < 0)
+                       goto ERROR;
+       }
+
+       // CPU Model
+       if (*cpuinfo.model) {
+               r = pakfire_xfer_add_query(xfer, "cpu_model", "%s", cpuinfo.model);
+               if (r < 0)
+                       goto ERROR;
+       }
+
+       // CPU Count
+       r = pakfire_xfer_add_query(xfer, "cpu_count", "%u", cpuinfo.count);
+       if (r < 0)
+               goto ERROR;
+
        // Enable authentication
        r = pakfire_client_xfer_auth(self, xfer);
        if (r < 0)