summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2014-01-30 17:08:52 +0100
committerMichael Schroeder <mls@suse.de>2014-01-30 17:08:52 +0100
commit448c573a2272f27f51467eef2dd32026d24ef842 (patch)
treef1870e3c7c2d4ccb6f92d617b3307d0dac27cb59 /ext
parent56140dc8cacd341dc5b30f411057a507a11715ed (diff)
downloadlibsolv-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')
-rw-r--r--ext/repo_autopattern.c39
-rw-r--r--ext/repo_products.c44
2 files changed, 81 insertions, 2 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];
diff --git a/ext/repo_products.c b/ext/repo_products.c
index 7a164d8..0294ff2 100644
--- a/ext/repo_products.c
+++ b/ext/repo_products.c
@@ -11,6 +11,9 @@
* for further information
*/
+#define _GNU_SOURCE
+#define _XOPEN_SOURCE
+#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -60,6 +63,7 @@ enum state {
STATE_PRODUCTLINE,
STATE_REGUPDATES,
STATE_REGUPDREPO,
+ STATE_ENDOFLIFE,
NUMSTATES
};
@@ -88,6 +92,7 @@ static struct stateswitch stateswitches[] = {
{ STATE_PRODUCT, "linguas", STATE_LINGUAS, 0 },
{ STATE_PRODUCT, "updaterepokey", STATE_UPDATEREPOKEY, 1 },
{ STATE_PRODUCT, "cpeid", STATE_CPEID, 1 },
+ { STATE_PRODUCT, "endoflife", STATE_ENDOFLIFE, 1 },
{ STATE_URLS, "url", STATE_URL, 1 },
{ STATE_LINGUAS, "lang", STATE_LANG, 0 },
{ STATE_REGISTER, "target", STATE_TARGET, 1 },
@@ -152,6 +157,29 @@ find_attr(const char *txt, const char **atts)
return 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);
+}
/*
* XML callback: startElement
@@ -226,7 +254,12 @@ startElement(void *userData, const char *name, const char **atts)
{
const char *repoid = find_attr("repoid", atts);
if (repoid && *repoid)
- repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_UPDATES_REPOID, repoid);
+ {
+ Id h = repodata_new_handle(pd->data);
+ repodata_set_str(pd->data, h, PRODUCT_UPDATES_REPOID, repoid);
+ repodata_add_flexarray(pd->data, pd->handle, PRODUCT_UPDATES, h);
+ }
+ break;
}
default:
break;
@@ -336,6 +369,15 @@ endElement(void *userData, const char *name)
case STATE_CPEID:
if (*pd->content)
repodata_set_str(pd->data, pd->handle, SOLVABLE_CPEID, pd->content);
+ break;
+ case STATE_ENDOFLIFE:
+ if (*pd->content)
+ {
+ time_t t = datestr2timestamp(pd->content);
+ if (t)
+ repodata_set_num(pd->data, pd->handle, PRODUCT_ENDOFLIFE, (unsigned long long)t);
+ }
+ break;
default:
break;
}