* for further information
*/
+#define _GNU_SOURCE
+#define _XOPEN_SOURCE
+#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
*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)
{
queue_init(&prdq);
queue_init(&prdq2);
+ if (repo == pool->installed)
+ flags |= ADD_NO_AUTOPRODUCTS; /* no auto products for installed repos */
+
pattern_id = pool_str2id(pool, "pattern()", 9);
product_id = pool_str2id(pool, "product()", 9);
FOR_REPO_SOLVABLES(repo, p, s)
continue;
if (rd->name == pattern_id)
{
+ const char *evrstr = pool_id2str(pool, rd->evr);
+ if (evrstr[0] == '.') /* hack to allow provides that do not create a pattern */
+ continue;
+ if (patq2.count && patq2.elements[patq2.count - 2] == p)
+ {
+ /* hmm, two provides. choose by evrstr */
+ if (strcmp(evrstr, pool_id2str(pool, patq2.elements[patq2.count - 1])) >= 0)
+ continue;
+ patq2.count -= 2;
+ }
queue_push2(&patq2, p, rd->evr);
- break;
}
if (rd->name == product_id)
{
+ const char *evrstr = pool_id2str(pool, rd->evr);
+ if (prdq2.count && prdq2.elements[prdq2.count - 2] == p)
+ {
+ /* hmm, two provides. choose by evrstr */
+ if (strcmp(evrstr, pool_id2str(pool, prdq2.elements[prdq2.count - 1])) >= 0)
+ continue;
+ prdq2.count -= 2;
+ }
queue_push2(&prdq2, p, rd->evr);
- break;
}
}
}
queue_free(&patq);
queue_free(&patq2);
- if (repo == pool->installed)
- queue_empty(&prdq2); /* no auto products for installed repos */
+ if ((flags & ADD_NO_AUTOPRODUCTS) != 0)
+ queue_empty(&prdq2);
for (i = 0; i < prdq2.count; i += 2)
{
repodata_set_str(data, s2 - pool->solvables, SOLVABLE_CPEID, newname);
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)
+ {
+ 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];