38676efdde9feda08bbf446067d24ad18dd428ca
[platform/upstream/libsolv.git] / ext / repo_testcase.c
1 /*
2  * Copyright (c) 2019, SUSE LLC
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <errno.h>
14
15 #include "pool.h"
16 #include "repo.h"
17 #include "testcase.h"
18
19 #define DISABLE_JOIN2
20 #include "tools_util.h"
21
22 static const char *
23 testcase_id2str(Pool *pool, Id id, int isname)
24 {
25   const char *s = pool_id2str(pool, id);
26   const char *ss;
27   char *s2, *s2p;
28   int bad = 0, paren = 0, parenbad = 0;
29
30   if (id == 0)
31     return "<NULL>";
32   if (id == 1)
33     return "\\00";
34   if (strchr("[(<=>!", *s))
35     bad++;
36   if (!strncmp(s, "namespace:", 10))
37     bad++;
38   for (ss = s + bad; *ss; ss++)
39     {
40       if (*ss == ' ' || *ss == '\\' || *(unsigned char *)ss < 32 || *ss == '(' || *ss == ')')
41         bad++;
42       if (*ss == '(')
43         paren = paren == 0 ? 1 : -1;
44       else if (*ss == ')')
45         {
46           paren = paren == 1 ? 0 : -1;
47           if (!paren)
48             parenbad += 2;
49         }
50     }
51   if (isname && ss - s > 4 && !strcmp(ss - 4, ":any"))
52     bad++;
53   if (!paren && !(bad - parenbad))
54     return s;
55
56   /* we need escaping! */
57   s2 = s2p = pool_alloctmpspace(pool, strlen(s) + bad * 2 + 1);
58   if (!strncmp(s, "namespace:", 10))
59     {
60       strcpy(s2p, "namespace\\3a");
61       s2p += 12;
62       s += 10;
63     }
64   ss = s;
65   for (; *ss; ss++)
66     {
67       *s2p++ = *ss;
68       if ((ss == s && strchr("[(<=>!", *s)) || *ss == ' ' || *ss == '\\' || *(unsigned char *)ss < 32 || *ss == '(' || *ss == ')')
69         {
70           s2p[-1] = '\\';
71           solv_bin2hex((unsigned char *)ss, 1, s2p);
72           s2p += 2;
73         }
74     }
75   *s2p = 0;
76   if (isname && s2p - s2 > 4 && !strcmp(s2p - 4, ":any"))
77     strcpy(s2p - 4, "\\3aany");
78   return s2;
79 }
80
81 struct oplist {
82   Id flags;
83   const char *opname;
84 } oplist[] = {
85   { REL_EQ, "=" },
86   { REL_GT | REL_LT | REL_EQ, "<=>" },
87   { REL_LT | REL_EQ, "<=" },
88   { REL_GT | REL_EQ, ">=" },
89   { REL_GT, ">" },
90   { REL_GT | REL_LT, "<>" },
91   { REL_AND,   "&" },
92   { REL_OR ,   "|" },
93   { REL_WITH , "+" },
94   { REL_WITHOUT , "-" },
95   { REL_NAMESPACE , "<NAMESPACE>" },
96   { REL_ARCH,       "." },
97   { REL_MULTIARCH,  "<MULTIARCH>" },
98   { REL_FILECONFLICT,  "<FILECONFLICT>" },
99   { REL_COND,  "<IF>" },
100   { REL_COMPAT,  "compat >=" },
101   { REL_KIND,  "<KIND>" },
102   { REL_ELSE, "<ELSE>" },
103   { REL_ERROR, "<ERROR>" },
104   { REL_UNLESS, "<UNLESS>" },
105   { REL_CONDA, "<CONDA>" },
106   { REL_LT, "<" },
107   { 0, 0 }
108 };
109
110 static char *
111 testcase_dep2str_complex(Pool *pool, char *s, Id id, int addparens)
112 {
113   Reldep *rd;
114   const char *s2;
115   int needparens;
116   struct oplist *op;
117
118   if (!ISRELDEP(id))
119     {
120       s2 = testcase_id2str(pool, id, 1);
121       s = pool_tmpappend(pool, s, s2, 0);
122       pool_freetmpspace(pool, s2);
123       return s;
124     }
125   rd = GETRELDEP(pool, id);
126
127   /* check for special shortcuts */
128   if (rd->flags == REL_NAMESPACE && !ISRELDEP(rd->name) && !strncmp(pool_id2str(pool, rd->name), "namespace:", 10))
129     {
130       s = pool_tmpappend(pool, s, pool_id2str(pool, rd->name), "(");
131       s = testcase_dep2str_complex(pool, s, rd->evr, 0);
132       return pool_tmpappend(pool, s, ")", 0);
133     }
134   if (rd->flags == REL_MULTIARCH && !ISRELDEP(rd->name) && rd->evr == ARCH_ANY)
135     {
136       /* append special :any suffix */
137       s2 = testcase_id2str(pool, rd->name, 1);
138       s = pool_tmpappend(pool, s, s2, ":any");
139       pool_freetmpspace(pool, s2);
140       return s;
141     }
142
143   needparens = 0;
144   if (ISRELDEP(rd->name))
145     {
146       Reldep *rd2 = GETRELDEP(pool, rd->name);
147       needparens = 1;
148       if (rd->flags > 7 && rd->flags != REL_COMPAT && rd2->flags && rd2->flags <= 7)
149         needparens = 0;
150     }
151
152   if (addparens)
153     s = pool_tmpappend(pool, s, "(", 0);
154   s = testcase_dep2str_complex(pool, s, rd->name, needparens);
155
156   for (op = oplist; op->flags; op++)
157     if (rd->flags == op->flags)
158       break;
159   if (op->flags)
160     {
161       s = pool_tmpappend(pool, s, " ", op->opname);
162       s = pool_tmpappend(pool, s, " ", 0);
163     }
164   else
165     {
166       char buf[64];
167       sprintf(buf, " <%u> ", rd->flags);
168       s = pool_tmpappend(pool, s, buf, 0);
169     }
170
171   needparens = 0;
172   if (ISRELDEP(rd->evr))
173     {
174       Reldep *rd2 = GETRELDEP(pool, rd->evr);
175       needparens = 1;
176       if (rd->flags > 7 && rd2->flags && rd2->flags <= 7)
177         needparens = 0;
178       if (rd->flags == REL_AND && rd2->flags == REL_AND)
179         needparens = 0; /* chain */
180       if (rd->flags == REL_OR && rd2->flags == REL_OR)
181         needparens = 0; /* chain */
182       if (rd->flags > 0 && rd->flags < 8 && rd2->flags == REL_COMPAT)
183         needparens = 0; /* chain */
184     }
185   if (!ISRELDEP(rd->evr))
186     {
187       s2 = testcase_id2str(pool, rd->evr, 0);
188       s = pool_tmpappend(pool, s, s2, 0);
189       pool_freetmpspace(pool, s2);
190     }
191   else
192     s = (char *)testcase_dep2str_complex(pool, s, rd->evr, needparens);
193   if (addparens)
194     s = pool_tmpappend(pool, s, ")", 0);
195   return s;
196 }
197
198 const char *
199 testcase_dep2str(Pool *pool, Id id)
200 {
201   char *s;
202   if (!ISRELDEP(id))
203     return testcase_id2str(pool, id, 1);
204   s = pool_alloctmpspace(pool, 1);
205   *s = 0;
206   return testcase_dep2str_complex(pool, s, id, 0);
207 }
208
209
210 /* Convert a simple string. Also handle the :any suffix */
211 static Id
212 testcase_str2dep_simple(Pool *pool, const char **sp, int isname)
213 {
214   int haveesc = 0;
215   int paren = 0;
216   int isany = 0;
217   Id id;
218   const char *s;
219   for (s = *sp; *s; s++)
220     {
221       if (*s == '\\')
222         haveesc++;
223       if (*s == ' ' || *(unsigned char *)s < 32)
224         break;
225       if (*s == '(')
226         paren++;
227       if (*s == ')' && paren-- <= 0)
228         break;
229     }
230   if (isname && s - *sp > 4 && !strncmp(s - 4, ":any", 4))
231     {
232       isany = 1;
233       s -= 4;
234     }
235   if (!haveesc)
236     {
237       if (s - *sp == 6 && !strncmp(*sp, "<NULL>", 6))
238         id = 0;
239       else
240         id = pool_strn2id(pool, *sp, s - *sp, 1);
241     }
242   else if (s - *sp == 3 && !strncmp(*sp, "\\00", 3))
243     id = 1;
244   else
245     {
246       char buf[128], *bp, *bp2;
247       const char *sp2;
248       bp = s - *sp >= 128 ? solv_malloc(s - *sp + 1) : buf;
249       for (bp2 = bp, sp2 = *sp; sp2 < s;)
250         {
251           *bp2++ = *sp2++;
252           if (bp2[-1] == '\\')
253             solv_hex2bin(&sp2, (unsigned char *)bp2 - 1, 1);
254         }
255       *bp2 = 0;
256       id = pool_str2id(pool, bp, 1);
257       if (bp != buf)
258         solv_free(bp);
259     }
260   if (isany)
261     {
262       id = pool_rel2id(pool, id, ARCH_ANY, REL_MULTIARCH, 1);
263       s += 4;
264     }
265   *sp = s;
266   return id;
267 }
268
269
270 static Id
271 testcase_str2dep_complex(Pool *pool, const char **sp, int relop)
272 {
273   const char *s = *sp;
274   Id flags, id, id2, namespaceid = 0;
275   struct oplist *op;
276
277   if (!s)
278     return 0;
279   while (*s == ' ' || *s == '\t')
280     s++;
281   if (!strncmp(s, "namespace:", 10))
282     {
283       /* special namespace hack */
284       const char *s2;
285       for (s2 = s + 10; *s2 && *s2 != '('; s2++)
286         ;
287       if (*s2 == '(')
288         {
289           namespaceid = pool_strn2id(pool, s, s2 - s, 1);
290           s = s2;
291         }
292     }
293   if (*s == '(')
294     {
295       s++;
296       id = testcase_str2dep_complex(pool, &s, 0);
297       if (!s || *s != ')')
298         {
299           *sp = 0;
300           return 0;
301         }
302       s++;
303     }
304   else
305     id = testcase_str2dep_simple(pool, &s, relop ? 0 : 1);
306   if (namespaceid)
307     id = pool_rel2id(pool, namespaceid, id, REL_NAMESPACE, 1);
308     
309   for (;;)
310     {
311       while (*s == ' ' || *s == '\t')
312         s++;
313       if (!*s || *s == ')' || (relop && strncmp(s, "compat >= ", 10) != 0))
314         {
315           *sp = s;
316           return id;
317         }
318
319       /* we have an op! Find the end */
320       flags = -1;
321       if (s[0] == '<' && (s[1] >= '0' && s[1] <= '9'))
322         {
323           const char *s2;
324           for (s2 = s + 1; *s2 >= '0' && *s2 <= '9'; s2++)
325             ;
326           if (*s2 == '>')
327             {
328               flags = strtoul(s + 1, 0, 10);
329               s = s2 + 1;
330             }
331         }
332       if (flags == -1)
333         {
334           for (op = oplist; op->flags; op++)
335             if (!strncmp(s, op->opname, strlen(op->opname)))
336               break;
337           if (!op->flags)
338             {
339               *sp = 0;
340               return 0;
341             }
342           flags = op->flags;
343           s += strlen(op->opname);
344         }
345       id2 = testcase_str2dep_complex(pool, &s, flags > 0 && flags < 8);
346       if (!s)
347         {
348           *sp = 0;
349           return 0;
350         }
351       id = pool_rel2id(pool, id, id2, flags, 1);
352     }
353 }
354
355 Id
356 testcase_str2dep(Pool *pool, const char *s)
357 {
358   Id id = testcase_str2dep_complex(pool, &s, 0);
359   return s && !*s ? id : 0;
360 }
361
362 static void
363 writedeps(Repo *repo, FILE *fp, const char *tag, Id key, Solvable *s, Offset off)
364 {
365   Pool *pool = repo->pool;
366   Id id, *dp;
367   int tagwritten = 0;
368   const char *idstr;
369
370   if (!off)
371     return;
372   dp = repo->idarraydata + off;
373   while ((id = *dp++) != 0)
374     {
375       if (key == SOLVABLE_REQUIRES && id == SOLVABLE_PREREQMARKER)
376         {
377           if (tagwritten)
378             fprintf(fp, "-%s\n", tag);
379           tagwritten = 0;
380           tag = "Prq:";
381           continue;
382         }
383       if (key == SOLVABLE_PROVIDES && id == SOLVABLE_FILEMARKER)
384         continue;
385       idstr = testcase_dep2str(pool, id);
386       if (!tagwritten)
387         {
388           fprintf(fp, "+%s\n", tag);
389           tagwritten = 1;
390         }
391       fprintf(fp, "%s\n", idstr);
392     }
393   if (tagwritten)
394     fprintf(fp, "-%s\n", tag);
395 }
396
397 static void
398 writefilelist(Repo *repo, FILE *fp, const char *tag, Solvable *s)
399 {
400   Pool *pool = repo->pool;
401   int tagwritten = 0;
402   Dataiterator di;
403
404   dataiterator_init(&di, pool, repo, s - pool->solvables, SOLVABLE_FILELIST, 0, 0);
405   while (dataiterator_step(&di))
406     {
407       const char *s = repodata_dir2str(di.data, di.kv.id, di.kv.str);
408       if (!tagwritten)
409         {
410           fprintf(fp, "+%s\n", tag);
411           tagwritten = 1;
412         }
413       fprintf(fp, "%s\n", s);
414     }
415   if (tagwritten)
416     fprintf(fp, "-%s\n", tag);
417   dataiterator_free(&di);
418 }
419
420 int
421 testcase_write_testtags(Repo *repo, FILE *fp)
422 {
423   Pool *pool = repo->pool;
424   Solvable *s;
425   Id p;
426   const char *name;
427   const char *evr;
428   const char *arch;
429   const char *release;
430   const char *tmp;
431   unsigned int ti;
432   Queue q;
433
434   fprintf(fp, "=Ver: 3.0\n");
435   queue_init(&q);
436   FOR_REPO_SOLVABLES(repo, p, s)
437     {
438       name = pool_id2str(pool, s->name);
439       evr = pool_id2str(pool, s->evr);
440       arch = s->arch ? pool_id2str(pool, s->arch) : "-";
441       release = strrchr(evr, '-');
442       if (!release)
443         release = evr + strlen(evr);
444       fprintf(fp, "=Pkg: %s %.*s %s %s\n", name, (int)(release - evr), evr, *release && release[1] ? release + 1 : "-", arch);
445       tmp = solvable_lookup_str(s, SOLVABLE_SUMMARY);
446       if (tmp)
447         fprintf(fp, "=Sum: %s\n", tmp);
448       writedeps(repo, fp, "Req:", SOLVABLE_REQUIRES, s, s->requires);
449       writedeps(repo, fp, "Prv:", SOLVABLE_PROVIDES, s, s->provides);
450       writedeps(repo, fp, "Obs:", SOLVABLE_OBSOLETES, s, s->obsoletes);
451       writedeps(repo, fp, "Con:", SOLVABLE_CONFLICTS, s, s->conflicts);
452       writedeps(repo, fp, "Rec:", SOLVABLE_RECOMMENDS, s, s->recommends);
453       writedeps(repo, fp, "Sup:", SOLVABLE_SUPPLEMENTS, s, s->supplements);
454       writedeps(repo, fp, "Sug:", SOLVABLE_SUGGESTS, s, s->suggests);
455       writedeps(repo, fp, "Enh:", SOLVABLE_ENHANCES, s, s->enhances);
456       if (solvable_lookup_idarray(s, SOLVABLE_PREREQ_IGNOREINST, &q))
457         {
458           int i;
459           fprintf(fp, "+Ipr:\n");
460           for (i = 0; i < q.count; i++)
461             fprintf(fp, "%s\n", testcase_dep2str(pool, q.elements[i]));
462           fprintf(fp, "-Ipr:\n");
463         }
464       if (solvable_lookup_idarray(s, SOLVABLE_CONSTRAINS, &q))
465         {
466           int i;
467           fprintf(fp, "+Cns:\n");
468           for (i = 0; i < q.count; i++)
469             fprintf(fp, "%s\n", testcase_dep2str(pool, q.elements[i]));
470           fprintf(fp, "-Cns:\n");
471         }
472       if (s->vendor)
473         fprintf(fp, "=Vnd: %s\n", pool_id2str(pool, s->vendor));
474       if (solvable_lookup_idarray(s, SOLVABLE_BUILDFLAVOR, &q))
475         {
476           int i;
477           for (i = 0; i < q.count; i++)
478             fprintf(fp, "=Flv: %s\n", pool_id2str(pool, q.elements[i]));
479         }
480       tmp = solvable_lookup_str(s, SOLVABLE_BUILDVERSION);
481       if (tmp)
482         fprintf(fp, "=Bvr: %s\n", tmp);
483       if (solvable_lookup_idarray(s, SOLVABLE_TRACK_FEATURES, &q))
484         {
485           int i;
486           for (i = 0; i < q.count; i++)
487             fprintf(fp, "=Trf: %s\n", pool_id2str(pool, q.elements[i]));
488         }
489       ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
490       if (ti)
491         fprintf(fp, "=Tim: %u\n", ti);
492       ti = solvable_lookup_num(s, SOLVABLE_INSTALLTIME, 0);
493       if (ti)
494         fprintf(fp, "=Itm: %u\n", ti);
495       writefilelist(repo, fp, "Fls:", s);
496     }
497   queue_free(&q);
498   return 0;
499 }
500
501 static inline Offset
502 adddep(Repo *repo, Offset olddeps, char *str, Id marker)
503 {
504   Id id = *str == '/' ? pool_str2id(repo->pool, str, 1) : testcase_str2dep(repo->pool, str);
505   return repo_addid_dep(repo, olddeps, id, marker);
506 }
507
508 static void
509 finish_v2_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
510 {
511   if (nfilelist)
512     {
513       int l;
514       Id did;
515       for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
516         {
517           char *p = strrchr(filelist + l, '/');
518           if (!p)
519             continue;
520           *p++ = 0;
521           did = repodata_str2dir(data, filelist + l, 1);
522           p[-1] = '/';
523           if (!did)
524             did = repodata_str2dir(data, "/", 1);
525           repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
526         }
527     }
528   repo_rewrite_suse_deps(s, 0);
529 }
530
531 /* stripped down version of susetags parser used for testcases */
532 int
533 testcase_add_testtags(Repo *repo, FILE *fp, int flags)
534 {
535   Pool *pool = repo->pool;
536   char *line, *linep;
537   int aline;
538   int tag;
539   Repodata *data;
540   Solvable *s;
541   char *sp[5];
542   unsigned int t;
543   int intag;
544   char *filelist = 0;
545   int afilelist = 0;
546   int nfilelist = 0;
547   int tagsversion = 0;
548   int addselfprovides = 1;      /* for compat reasons */
549
550   data = repo_add_repodata(repo, flags);
551   s = 0;
552   intag = 0;
553
554   aline = 1024;
555   line = solv_malloc(aline);
556   linep = line;
557   for (;;)
558     {
559       if (linep - line + 16 > aline)
560         {
561           aline = linep - line;
562           line = solv_realloc(line, aline + 512);
563           linep = line + aline;
564           aline += 512;
565         }
566       if (!fgets(linep, aline - (linep - line), fp))
567         break;
568       linep += strlen(linep);
569       if (linep == line || linep[-1] != '\n')
570         continue;
571       linep[-1] = 0;
572       linep = line + intag;
573       if (intag)
574         {
575           if (line[intag] == '-' && !strncmp(line + 1, line + intag + 1, intag - 2))
576             {
577               intag = 0;
578               linep = line;
579               continue;
580             }
581         }
582       else if (line[0] == '+' && line[1] && line[1] != ':')
583         {
584           char *tagend = strchr(line, ':');
585           if (!tagend)
586             continue;
587           line[0] = '=';
588           tagend[1] = ' ';
589           intag = tagend + 2 - line;
590           linep = line + intag;
591           continue;
592         }
593       if (*line != '=' || !line[1] || !line[2] || !line[3] || line[4] != ':')
594         continue;
595       tag = line[1] << 16 | line[2] << 8 | line[3];
596       /* tags that do not need a solvable */
597       switch(tag)
598         {
599         case 'V' << 16 | 'e' << 8 | 'r':
600           tagsversion = atoi(line + 6);
601           addselfprovides = tagsversion < 3 || strstr(line + 6, "addselfprovides") != 0;
602           continue;
603         case 'P' << 16 | 'k' << 8 | 'g':
604           if (s)
605             {
606               if (tagsversion == 2)
607                 finish_v2_solvable(pool, data, s, filelist, nfilelist);
608               if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
609                 s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
610             }
611           nfilelist = 0;
612           if (split(line + 5, sp, 5) != 4)
613             break;
614           s = pool_id2solvable(pool, repo_add_solvable(repo));
615           s->name = pool_str2id(pool, sp[0], 1);
616           /* join back version and release */
617           if (sp[2] && !(sp[2][0] == '-' && !sp[2][1]))
618             sp[2][-1] = '-';
619           s->evr = makeevr(pool, sp[1]);
620           s->arch = strcmp(sp[3], "-") ? pool_str2id(pool, sp[3], 1) : 0;
621           continue;
622         default:
623           break;
624         }
625       if (!s)
626         continue;
627       /* tags that need a solvable */
628       switch(tag)
629         {
630         case 'S' << 16 | 'u' << 8 | 'm':
631           repodata_set_str(data, s - pool->solvables, SOLVABLE_SUMMARY, line + 6);
632           break;
633         case 'V' << 16 | 'n' << 8 | 'd':
634           s->vendor = pool_str2id(pool, line + 6, 1);
635           break;
636         case 'T' << 16 | 'i' << 8 | 'm':
637           t = atoi(line + 6);
638           if (t)
639             repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, t);
640           break;
641         case 'I' << 16 | 't' << 8 | 'm':
642           t = atoi(line + 6);
643           if (t)
644             repodata_set_num(data, s - pool->solvables, SOLVABLE_INSTALLTIME, t);
645           break;
646         case 'R' << 16 | 'e' << 8 | 'q':
647           s->requires = adddep(repo, s->requires, line + 6, -SOLVABLE_PREREQMARKER);
648           break;
649         case 'P' << 16 | 'r' << 8 | 'q':
650           s->requires = adddep(repo, s->requires, line + 6, SOLVABLE_PREREQMARKER);
651           break;
652         case 'P' << 16 | 'r' << 8 | 'v':
653           /* version 2 had the file list at the end of the provides */
654           if (tagsversion == 2)
655             {
656               if (line[6] == '/')
657                 {
658                   int l = strlen(line + 6) + 1;
659                   if (nfilelist + l > afilelist)
660                     {
661                       afilelist = nfilelist + l + 512;
662                       filelist = solv_realloc(filelist, afilelist);
663                     }
664                   memcpy(filelist + nfilelist, line + 6, l);
665                   nfilelist += l;
666                   break;
667                 }
668               if (nfilelist)
669                 {
670                   int l;
671                   for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
672                     s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
673                   nfilelist = 0;
674                 }
675             }
676           s->provides = adddep(repo, s->provides, line + 6, 0);
677           break;
678         case 'F' << 16 | 'l' << 8 | 's':
679           {
680             char *p = strrchr(line + 6, '/');
681             Id did;
682             if (!p)
683               break;
684             *p++ = 0;
685             did = repodata_str2dir(data, line + 6, 1);
686             if (!did)
687               did = repodata_str2dir(data, "/", 1);
688             repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
689             break;
690           }
691         case 'O' << 16 | 'b' << 8 | 's':
692           s->obsoletes = adddep(repo, s->obsoletes, line + 6, 0);
693           break;
694         case 'C' << 16 | 'o' << 8 | 'n':
695           s->conflicts = adddep(repo, s->conflicts, line + 6, 0);
696           break;
697         case 'R' << 16 | 'e' << 8 | 'c':
698           s->recommends = adddep(repo, s->recommends, line + 6, 0);
699           break;
700         case 'S' << 16 | 'u' << 8 | 'p':
701           s->supplements = adddep(repo, s->supplements, line + 6, 0);
702           break;
703         case 'S' << 16 | 'u' << 8 | 'g':
704           s->suggests = adddep(repo, s->suggests, line + 6, 0);
705           break;
706         case 'E' << 16 | 'n' << 8 | 'h':
707           s->enhances = adddep(repo, s->enhances, line + 6, 0);
708           break;
709         case 'I' << 16 | 'p' << 8 | 'r':
710           {
711             Id id = line[6] == '/' ? pool_str2id(pool, line + 6, 1) : testcase_str2dep(pool, line + 6);
712             repodata_add_idarray(data, s - pool->solvables, SOLVABLE_PREREQ_IGNOREINST, id);
713             break;
714           }
715         case 'C' << 16 | 'n' << 8 | 's':
716           repodata_add_idarray(data, s - pool->solvables, SOLVABLE_CONSTRAINS, testcase_str2dep(pool, line + 6));
717           break;
718         case 'F' << 16 | 'l' << 8 | 'v':
719           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_BUILDFLAVOR, line + 6);
720           break;
721         case 'B' << 16 | 'v' << 8 | 'r':
722           repodata_set_str(data, s - pool->solvables, SOLVABLE_BUILDVERSION, line + 6);
723           break;
724         case 'T' << 16 | 'r' << 8 | 'f':
725           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_TRACK_FEATURES, line + 6);
726           break;
727         default:
728           break;
729         }
730     }
731   if (s)
732     {
733       if (tagsversion == 2)
734         finish_v2_solvable(pool, data, s, filelist, nfilelist);
735       if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
736         s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
737     }
738   solv_free(line);
739   solv_free(filelist);
740   repodata_free_dircache(data);
741   if (!(flags & REPO_NO_INTERNALIZE))
742     repodata_internalize(data);
743   return 0;
744 }