From 69e2c5aaa9f192eb70aad3e2a5e83268cb91cda3 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 1 Jul 2025 08:25:45 +0000 Subject: [PATCH] client: Send system information when connecting Signed-off-by: Michael Tremer --- src/pakfire/client.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/pakfire/client.c b/src/pakfire/client.c index 3f8dd3a0..e9afae02 100644 --- a/src/pakfire/client.c +++ b/src/pakfire/client.c @@ -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) -- 2.47.2