From 69ee33c5927081c557674272ec50963adad554b9 Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Wed, 2 Sep 2015 14:56:40 +0200 Subject: [PATCH] xbps-rindex: set build-date from mtime in repository-index. --- bin/xbps-rindex/index-add.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bin/xbps-rindex/index-add.c b/bin/xbps-rindex/index-add.c index c2936718..03ea0d59 100644 --- a/bin/xbps-rindex/index-add.c +++ b/bin/xbps-rindex/index-add.c @@ -37,6 +37,24 @@ #include #include "defs.h" +static int +set_build_date(const xbps_dictionary_t pkgd, time_t timestamp) +{ + char outstr[64]; + struct tm tmp; + + if (!localtime_r(×tamp, &tmp)) + return -1; + + if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", &tmp) == 0) + return -1; + + if (!xbps_dictionary_set_cstring(pkgd, "build-date", outstr)) + return -1; + return 0; +} + + int index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force) { @@ -188,6 +206,12 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force rv = EINVAL; goto out; } + if (set_build_date(binpkgd, st.st_mtime) < 0) { + free(pkgver); + free(pkgname); + rv = EINVAL; + goto out; + } /* Remove unneeded objects */ xbps_dictionary_remove(binpkgd, "pkgname"); xbps_dictionary_remove(binpkgd, "version");