Imported Upstream version 0.7.12
[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       ti = solvable_lookup_num(s, SOLVABLE_BUILDTIME, 0);
484       if (ti)
485         fprintf(fp, "=Tim: %u\n", ti);
486       writefilelist(repo, fp, "Fls:", s);
487     }
488   queue_free(&q);
489   return 0;
490 }
491
492 static inline Offset
493 adddep(Repo *repo, Offset olddeps, char *str, Id marker)
494 {
495   Id id = *str == '/' ? pool_str2id(repo->pool, str, 1) : testcase_str2dep(repo->pool, str);
496   return repo_addid_dep(repo, olddeps, id, marker);
497 }
498
499 static void
500 finish_v2_solvable(Pool *pool, Repodata *data, Solvable *s, char *filelist, int nfilelist)
501 {
502   if (nfilelist)
503     {
504       int l;
505       Id did;
506       for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
507         {
508           char *p = strrchr(filelist + l, '/');
509           if (!p)
510             continue;
511           *p++ = 0;
512           did = repodata_str2dir(data, filelist + l, 1);
513           p[-1] = '/';
514           if (!did)
515             did = repodata_str2dir(data, "/", 1);
516           repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
517         }
518     }
519   repo_rewrite_suse_deps(s, 0);
520 }
521
522 /* stripped down version of susetags parser used for testcases */
523 int
524 testcase_add_testtags(Repo *repo, FILE *fp, int flags)
525 {
526   Pool *pool = repo->pool;
527   char *line, *linep;
528   int aline;
529   int tag;
530   Repodata *data;
531   Solvable *s;
532   char *sp[5];
533   unsigned int t;
534   int intag;
535   char *filelist = 0;
536   int afilelist = 0;
537   int nfilelist = 0;
538   int tagsversion = 0;
539   int addselfprovides = 1;      /* for compat reasons */
540
541   data = repo_add_repodata(repo, flags);
542   s = 0;
543   intag = 0;
544
545   aline = 1024;
546   line = solv_malloc(aline);
547   linep = line;
548   for (;;)
549     {
550       if (linep - line + 16 > aline)
551         {
552           aline = linep - line;
553           line = solv_realloc(line, aline + 512);
554           linep = line + aline;
555           aline += 512;
556         }
557       if (!fgets(linep, aline - (linep - line), fp))
558         break;
559       linep += strlen(linep);
560       if (linep == line || linep[-1] != '\n')
561         continue;
562       linep[-1] = 0;
563       linep = line + intag;
564       if (intag)
565         {
566           if (line[intag] == '-' && !strncmp(line + 1, line + intag + 1, intag - 2))
567             {
568               intag = 0;
569               linep = line;
570               continue;
571             }
572         }
573       else if (line[0] == '+' && line[1] && line[1] != ':')
574         {
575           char *tagend = strchr(line, ':');
576           if (!tagend)
577             continue;
578           line[0] = '=';
579           tagend[1] = ' ';
580           intag = tagend + 2 - line;
581           linep = line + intag;
582           continue;
583         }
584       if (*line != '=' || !line[1] || !line[2] || !line[3] || line[4] != ':')
585         continue;
586       tag = line[1] << 16 | line[2] << 8 | line[3];
587       /* tags that do not need a solvable */
588       switch(tag)
589         {
590         case 'V' << 16 | 'e' << 8 | 'r':
591           tagsversion = atoi(line + 6);
592           addselfprovides = tagsversion < 3 || strstr(line + 6, "addselfprovides") != 0;
593           continue;
594         case 'P' << 16 | 'k' << 8 | 'g':
595           if (s)
596             {
597               if (tagsversion == 2)
598                 finish_v2_solvable(pool, data, s, filelist, nfilelist);
599               if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
600                 s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
601             }
602           nfilelist = 0;
603           if (split(line + 5, sp, 5) != 4)
604             break;
605           s = pool_id2solvable(pool, repo_add_solvable(repo));
606           s->name = pool_str2id(pool, sp[0], 1);
607           /* join back version and release */
608           if (sp[2] && !(sp[2][0] == '-' && !sp[2][1]))
609             sp[2][-1] = '-';
610           s->evr = makeevr(pool, sp[1]);
611           s->arch = strcmp(sp[3], "-") ? pool_str2id(pool, sp[3], 1) : 0;
612           continue;
613         default:
614           break;
615         }
616       if (!s)
617         continue;
618       /* tags that need a solvable */
619       switch(tag)
620         {
621         case 'S' << 16 | 'u' << 8 | 'm':
622           repodata_set_str(data, s - pool->solvables, SOLVABLE_SUMMARY, line + 6);
623           break;
624         case 'V' << 16 | 'n' << 8 | 'd':
625           s->vendor = pool_str2id(pool, line + 6, 1);
626           break;
627         case 'T' << 16 | 'i' << 8 | 'm':
628           t = atoi(line + 6);
629           if (t)
630             repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, t);
631           break;
632         case 'R' << 16 | 'e' << 8 | 'q':
633           s->requires = adddep(repo, s->requires, line + 6, -SOLVABLE_PREREQMARKER);
634           break;
635         case 'P' << 16 | 'r' << 8 | 'q':
636           s->requires = adddep(repo, s->requires, line + 6, SOLVABLE_PREREQMARKER);
637           break;
638         case 'P' << 16 | 'r' << 8 | 'v':
639           /* version 2 had the file list at the end of the provides */
640           if (tagsversion == 2)
641             {
642               if (line[6] == '/')
643                 {
644                   int l = strlen(line + 6) + 1;
645                   if (nfilelist + l > afilelist)
646                     {
647                       afilelist = nfilelist + l + 512;
648                       filelist = solv_realloc(filelist, afilelist);
649                     }
650                   memcpy(filelist + nfilelist, line + 6, l);
651                   nfilelist += l;
652                   break;
653                 }
654               if (nfilelist)
655                 {
656                   int l;
657                   for (l = 0; l < nfilelist; l += strlen(filelist + l) + 1)
658                     s->provides = repo_addid_dep(repo, s->provides, pool_str2id(pool, filelist + l, 1), 0);
659                   nfilelist = 0;
660                 }
661             }
662           s->provides = adddep(repo, s->provides, line + 6, 0);
663           break;
664         case 'F' << 16 | 'l' << 8 | 's':
665           {
666             char *p = strrchr(line + 6, '/');
667             Id did;
668             if (!p)
669               break;
670             *p++ = 0;
671             did = repodata_str2dir(data, line + 6, 1);
672             if (!did)
673               did = repodata_str2dir(data, "/", 1);
674             repodata_add_dirstr(data, s - pool->solvables, SOLVABLE_FILELIST, did, p);
675             break;
676           }
677         case 'O' << 16 | 'b' << 8 | 's':
678           s->obsoletes = adddep(repo, s->obsoletes, line + 6, 0);
679           break;
680         case 'C' << 16 | 'o' << 8 | 'n':
681           s->conflicts = adddep(repo, s->conflicts, line + 6, 0);
682           break;
683         case 'R' << 16 | 'e' << 8 | 'c':
684           s->recommends = adddep(repo, s->recommends, line + 6, 0);
685           break;
686         case 'S' << 16 | 'u' << 8 | 'p':
687           s->supplements = adddep(repo, s->supplements, line + 6, 0);
688           break;
689         case 'S' << 16 | 'u' << 8 | 'g':
690           s->suggests = adddep(repo, s->suggests, line + 6, 0);
691           break;
692         case 'E' << 16 | 'n' << 8 | 'h':
693           s->enhances = adddep(repo, s->enhances, line + 6, 0);
694           break;
695         case 'I' << 16 | 'p' << 8 | 'r':
696           {
697             Id id = line[6] == '/' ? pool_str2id(pool, line + 6, 1) : testcase_str2dep(pool, line + 6);
698             repodata_add_idarray(data, s - pool->solvables, SOLVABLE_PREREQ_IGNOREINST, id);
699             break;
700           }
701         case 'C' << 16 | 'n' << 8 | 's':
702           repodata_add_idarray(data, s - pool->solvables, SOLVABLE_CONSTRAINS, testcase_str2dep(pool, line + 6));
703           break;
704         case 'F' << 16 | 'l' << 8 | 'v':
705           repodata_add_poolstr_array(data, s - pool->solvables, SOLVABLE_BUILDFLAVOR, line + 6);
706           break;
707         case 'B' << 16 | 'v' << 8 | 'r':
708           repodata_set_str(data, s - pool->solvables, SOLVABLE_BUILDVERSION, line + 6);
709           break;
710         default:
711           break;
712         }
713     }
714   if (s)
715     {
716       if (tagsversion == 2)
717         finish_v2_solvable(pool, data, s, filelist, nfilelist);
718       if (addselfprovides && s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
719         s->provides = repo_addid_dep(s->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
720     }
721   solv_free(line);
722   solv_free(filelist);
723   repodata_free_dircache(data);
724   if (!(flags & REPO_NO_INTERNALIZE))
725     repodata_internalize(data);
726   return 0;
727 }