summaryrefslogtreecommitdiff
path: root/ext/repo_comps.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/repo_comps.c')
-rw-r--r--ext/repo_comps.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/ext/repo_comps.c b/ext/repo_comps.c
index 6991656..014f89a 100644
--- a/ext/repo_comps.c
+++ b/ext/repo_comps.c
@@ -29,7 +29,6 @@
* TODO:
*
* what's the difference between group/category?
- * handle "default" and "langonly".
*
* maybe handle REL_COND in solver recommends handling?
*/
@@ -97,10 +96,26 @@ struct parsedata {
Solvable *solvable;
const char *kind;
+ int isdefault;
+ int isvisible;
Id handle;
};
+#define COMPS_DEFAULT_ISVISIBLE 1
+#define COMPS_DEFAULT_ISDEFAULT 0
+
+/* Return true if "true", false if "false", default_value otherwise */
+static int
+parse_boolean(char *content, int default_value)
+{
+ if (!strcmp(content, "true"))
+ return 1;
+ if (!strcmp(content, "false"))
+ return 0;
+ return default_value;
+}
+
static void
startElement(struct solv_xmlparser *xmlp, int state, const char *name, const char **atts)
@@ -116,6 +131,8 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
pd->handle = s - pool->solvables;
pd->kind = state == STATE_GROUP ? "group" : "category";
+ pd->isvisible = COMPS_DEFAULT_ISVISIBLE;
+ pd->isdefault = COMPS_DEFAULT_ISDEFAULT;
break;
case STATE_NAME:
@@ -166,6 +183,10 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
s->evr = ID_EMPTY;
if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
+ if (pd->isvisible)
+ repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
+ if (pd->isdefault)
+ repodata_set_void(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
pd->solvable = 0;
break;
@@ -194,7 +215,19 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
break;
case STATE_USERVISIBLE:
- repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
+ pd->isvisible = parse_boolean(content, COMPS_DEFAULT_ISVISIBLE);
+ break;
+
+ case STATE_DEFAULT:
+ pd->isdefault = parse_boolean(content, COMPS_DEFAULT_ISDEFAULT);
+ break;
+
+ case STATE_LANG_ONLY:
+ repodata_set_str(pd->data, pd->handle, SOLVABLE_LANGONLY, content);
+ break;
+
+ case STATE_LANGONLY:
+ repodata_set_str(pd->data, pd->handle, SOLVABLE_LANGONLY, content);
break;
case STATE_DISPLAY_ORDER: