]> git.ipfire.org Git - pakfire.git/commitdiff
parser: package: Set build host and time
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 17:03:17 +0000 (17:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Mar 2021 17:03:17 +0000 (17:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parser.c

index d9d43de53175314f9feeaf3b9e3b7645f75d4c0b..7b4c08e4b1e998dbb4fa70446010630d5c891fc7 100644 (file)
@@ -22,6 +22,8 @@
 #include <regex.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
+#include <unistd.h>
 
 #define PCRE2_CODE_UNIT_WIDTH 8
 #include <pcre2.h>
@@ -784,6 +786,21 @@ PAKFIRE_EXPORT int pakfire_parser_create_package(PakfireParser parser,
        pakfire_package_set_uuid(*pkg, uuid);
        free(uuid);
 
+       // Set build host
+       char hostname[HOST_NAME_MAX + 1];
+       r = gethostname(hostname, HOST_NAME_MAX + 1);
+       if (r) {
+               ERROR(parser->pakfire, "gethostname() failed: %s\n", strerror(errno));
+               goto CLEANUP;
+       }
+
+       pakfire_package_set_build_host(*pkg, hostname);
+
+       // Set build time
+       time_t now = time(NULL);
+
+       pakfire_package_set_build_time(*pkg, now);
+
        // Assign more attributes
        const struct attribute {
                const char* name;