make license/group a poolstr array for archlinux
authorMichael Schroeder <mls@suse.de>
Tue, 11 Jun 2013 16:50:51 +0000 (18:50 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 11 Jun 2013 16:50:51 +0000 (18:50 +0200)
The archlinux spec says that there can be multiple entries.
Also add a little hack to solvable_lookup_str so that it joins
the array elements for license/group lookups.

ext/repo_arch.c
src/solvable.c

index d8dd8af..e09d838 100644 (file)
@@ -411,11 +411,11 @@ repo_add_arch_pkg(Repo *repo, const char *fn, int flags)
          else if (!strncmp(line, "arch = ", 7))
            s->arch = pool_str2id(pool, line + 7, 1);
          else if (!strncmp(line, "license = ", 10))
-           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_LICENSE, line + 10);
+           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_LICENSE, line + 10);
          else if (!strncmp(line, "replaces = ", 11))
            s->obsoletes = adddep(repo, s->obsoletes, line + 11);
          else if (!strncmp(line, "group = ", 8))
-           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_GROUP, line + 8);
+           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_GROUP, line + 8);
          else if (!strncmp(line, "depend = ", 9))
            s->requires = adddep(repo, s->requires, line + 9);
          else if (!strncmp(line, "optdepend = ", 12))
@@ -601,7 +601,7 @@ adddata(Repodata *data, Solvable *s, struct tarhead *th)
       else if (!strcmp(line, "%GROUPS%"))
        {
          if (getsentrynl(th, line, sizeof(line)))
-           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_GROUP, line);
+           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_GROUP, line);
        }
       else if (!strcmp(line, "%CSIZE%"))
        {
@@ -634,7 +634,7 @@ adddata(Repodata *data, Solvable *s, struct tarhead *th)
       else if (!strcmp(line, "%LICENSE%"))
        {
          if (getsentrynl(th, line, sizeof(line)))
-           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_LICENSE, line);
+           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_LICENSE, line);
        }
       else if (!strcmp(line, "%ARCH%"))
        {
index a5baea5..3b8130e 100644 (file)
@@ -97,12 +97,36 @@ solvable_lookup_deparray(Solvable *s, Id keyname, Queue *q, Id marker)
   return repo_lookup_deparray(s->repo, s - s->repo->pool->solvables, keyname, q, marker);
 }
 
+static const char *
+solvable_lookup_str_joinarray(Solvable *s, Id keyname)
+{
+  Queue q;
+  Id qbuf[10];
+  char *str = 0;
+
+  queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
+  if (solvable_lookup_idarray(s, keyname, &q) && q.count)
+    {
+      Pool *pool = s->repo->pool;
+      int i;
+      str = pool_tmpjoin(pool, pool_id2str(pool, q.elements[0]), 0, 0);
+      for (i = 1; i < q.count; i++)
+       str = pool_tmpappend(pool, str, ", ", pool_id2str(pool, q.elements[i]));
+    }
+  queue_free(&q);
+  return str;
+}
+
 const char *
 solvable_lookup_str(Solvable *s, Id keyname)
 {
+  const char *str;
   if (!s->repo)
     return 0;
-  return repo_lookup_str(s->repo, s - s->repo->pool->solvables, keyname);
+  str = repo_lookup_str(s->repo, s - s->repo->pool->solvables, keyname);
+  if (!str && (keyname == SOLVABLE_LICENSE || keyname == SOLVABLE_GROUP))
+    str = solvable_lookup_str_joinarray(s, keyname);
+  return str;
 }
 
 static const char *