2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
14 #include "repo_solv.h"
16 #include "attr_store.h"
17 #include "attr_store_p.h"
20 dump_attrs_1 (Attrstore *s, unsigned int entry)
23 FOR_ATTRS (s, entry, &ai)
25 fprintf (stdout, "%s:", id2str (s->pool, ai.name));
29 fprintf (stdout, "int %u\n", ai.as_int);
33 const char *str = attr_retrieve_blob (s, ai.as_chunk[0], ai.as_chunk[1]);
35 fprintf (stdout, "blob %s\n", str);
37 fprintf (stdout, "blob %u+%u\n", ai.as_chunk[0], ai.as_chunk[1]);
40 case TYPE_ATTR_STRING:
41 fprintf (stdout, "str %s\n", ai.as_string);
43 case TYPE_ATTR_INTLIST:
45 fprintf (stdout, "lint\n ");
49 get_num (ai.as_numlist, val);
50 fprintf (stdout, " %d", (val & 63) | ((val >> 1) & ~63));
54 fprintf (stdout, "\n");
57 case TYPE_ATTR_LOCALIDS:
59 fprintf (stdout, "lids");
63 get_num (ai.as_numlist, val);
66 fprintf (stdout, "\n %s(%d)", localid2str (s, val), val);
68 fprintf (stdout, "\n");
72 fprintf (stdout, "\n");
79 dump_attrs (Repo *repo, unsigned int entry)
82 for (i = 0; i < repo->nrepodata; i++)
84 Attrstore *s = repo->repodata[i].s;
85 if (s && entry < s->entries)
86 dump_attrs_1 (s, entry);
91 dump_repodata (Repo *repo)
95 if (repo->nrepodata == 0)
97 printf("repo refers to %d attribute stores:\n", repo->nrepodata);
98 for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
101 printf("%s has %d keys", data->location ? data->location : "**EMBED**", data->nkeys);
102 for (j = 0; j < data->nkeys; j++)
103 printf("\n %s", id2str(repo->pool, data->keys[j].name));
111 printids(Repo *repo, char *kind, Offset ido)
113 Pool *pool = repo->pool;
117 printf("%s:\n", kind);
118 ids = repo->idarraydata + ido;
119 while((id = *ids++) != 0)
120 printf(" %s\n", dep2str(pool, id));
124 printdir(Repodata *data, Id dir)
127 Id parent = dirpool_parent(&data->dirpool, dir);
130 printdir(data, parent);
133 comp = dirpool_compid(&data->dirpool, dir);
135 printf("%s", stringpool_id2str(&data->spool, comp));
137 printf("%s", id2str(data->repo->pool, comp));
141 dump_repoattrs_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *kv)
145 keyname = id2str(data->repo->pool, key->name);
150 kv->str = stringpool_id2str(&data->spool, kv->id);
152 kv->str = id2str(data->repo->pool, kv->id);
153 printf("%s: %s\n", keyname, kv->str);
156 printf("%s: %s\n", keyname, kv->str);
159 printf("%s\n", keyname);
163 printf("%s: %d\n", keyname, kv->num);
165 case TYPE_DIRNUMNUMARRAY:
166 printf("%s: ", keyname);
167 printdir(data, kv->id);
168 printf(" %d %d\n", kv->num, kv->num2);
171 printf("%s: ?\n", keyname);
178 dump_repoattrs(Repo *repo, Id p)
182 for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
184 if (data->state == REPODATA_STUB || data->state == REPODATA_ERROR)
186 if (p < data->start || p >= data->end)
188 repodata_search(data, p - data->start, 0, dump_repoattrs_cb, 0);
192 int main(int argc, char **argv)
201 if (freopen(argv[1], "r", stdin) == 0)
207 pool = pool_create();
208 pool_setdebuglevel(pool, 1);
210 repo = repo_create(pool, argc != 1 ? argv[1] : "<stdin>");
211 if (repo_add_solv(repo, stdin))
212 printf("could not read repository\n");
214 dump_repodata (repo);
216 printf("repo contains %d solvables\n", repo->nsolvables);
217 for (i = repo->start, n = 1; i < repo->end; i++)
219 s = pool->solvables + i;
223 printf("solvable %d:\n", n);
224 if (s->name || s->evr || s->arch)
225 printf("name: %s %s %s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch));
227 printf("vendor: %s\n", id2str(pool, s->vendor));
228 printids(repo, "provides", s->provides);
229 printids(repo, "obsoletes", s->obsoletes);
230 printids(repo, "conflicts", s->conflicts);
231 printids(repo, "requires", s->requires);
232 printids(repo, "recommends", s->recommends);
233 printids(repo, "suggests", s->suggests);
234 printids(repo, "supplements", s->supplements);
235 printids(repo, "enhances", s->enhances);
236 printids(repo, "freshens", s->freshens);
238 dump_attrs (repo, n - 1);
240 dump_repoattrs(repo, i);