diff options
author | Michael Schroeder <mls@suse.de> | 2014-01-30 17:08:52 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-01-30 17:08:52 +0100 |
commit | 448c573a2272f27f51467eef2dd32026d24ef842 (patch) | |
tree | f1870e3c7c2d4ccb6f92d617b3307d0dac27cb59 /ext/repo_autopattern.c | |
parent | 56140dc8cacd341dc5b30f411057a507a11715ed (diff) | |
download | libsolv-448c573a2272f27f51467eef2dd32026d24ef842.tar.gz libsolv-448c573a2272f27f51467eef2dd32026d24ef842.tar.bz2 libsolv-448c573a2272f27f51467eef2dd32026d24ef842.zip |
support PRODUCT_ENDOFLIFE, store repoid as flexarray so we can add a lable later
Diffstat (limited to 'ext/repo_autopattern.c')
-rw-r--r-- | ext/repo_autopattern.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/ext/repo_autopattern.c b/ext/repo_autopattern.c index 1028947..4335382 100644 --- a/ext/repo_autopattern.c +++ b/ext/repo_autopattern.c @@ -5,6 +5,9 @@ * for further information */ +#define _GNU_SOURCE +#define _XOPEN_SOURCE +#include <time.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> @@ -55,6 +58,30 @@ unescape(char *p) *q = 0; } +static time_t +datestr2timestamp(const char *date) +{ + const char *p; + struct tm tm; + + if (!date || !*date) + return 0; + for (p = date; *p >= '0' && *p <= '9'; p++) + ; + if (!*p) + return atoi(date); + memset(&tm, 0, sizeof(tm)); + p = strptime(date, "%F%T", &tm); + if (!p) + { + memset(&tm, 0, sizeof(tm)); + p = strptime(date, "%F", &tm); + if (!p || *p) + return 0; + } + return timegm(&tm); +} + int repo_add_autopattern(Repo *repo, int flags) { @@ -339,7 +366,17 @@ repo_add_autopattern(Repo *repo, int flags) else if (!strcmp(pn, "product-flags()") && evr) repodata_add_poolstr_array(data, s2 - pool->solvables, PRODUCT_FLAGS, newname); else if (!strcmp(pn, "product-updates-repoid()") && evr) - repodata_add_poolstr_array(data, s2 - pool->solvables, PRODUCT_UPDATES_REPOID, newname); + { + Id h = repodata_new_handle(data); + repodata_set_str(data, h, PRODUCT_UPDATES_REPOID, newname); + repodata_add_flexarray(data, s2 - pool->solvables, PRODUCT_UPDATES, h); + } + else if (!strcmp(pn, "product-endoflife()") && evr) + { + time_t t = datestr2timestamp(newname); + if (t) + repodata_set_num(data, s2 - pool->solvables, PRODUCT_ENDOFLIFE, t); + } else if (!strncmp(pn, "product-url(", 12) && evr && pn[12] && pn[13] && strlen(pn + 12) < 32) { char type[34]; |