2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
19 #include "tools_util.h"
20 #include "repo_susetags.h"
34 int last_found_source;
35 struct datashare *share_with;
37 Id (*dirs)[3]; /* dirid, size, nfiles */
40 char *language; /* the default language */
41 Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
45 static char *flagtab[] = {
56 langtag(struct parsedata *pd, Id tag, const char *language)
58 if (language && *language)
59 return pool_id2langid(pd->repo->pool, tag, language, 1);
62 if (tag >= ID_NUM_INTERNAL)
63 return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
64 if (!pd->langcache[tag])
65 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
66 return pd->langcache[tag];
71 * create and add dependency
75 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
83 /* A file dependency. Do not try to parse it */
84 id = pool_str2id(pool, line + 6, 1);
88 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
89 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
91 pool_debug(pool, SOLV_FATAL, "susetags: bad dependency line: %d: %s\n", pd->lineno, line);
95 id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
97 id = pool_str2id(pool, sp[0], 1);
100 evrid = makeevr(pool, sp[2]);
101 for (flags = 0; flags < 6; flags++)
102 if (!strcmp(sp[1], flagtab[flags]))
106 pool_debug(pool, SOLV_FATAL, "susetags: unknown relation in %d: '%s'\n", pd->lineno, sp[1]);
109 id = pool_rel2id(pool, id, evrid, flags + 1, 1);
112 return repo_addid_dep(pd->repo, olddeps, id, marker);
122 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
124 Repo *repo = s->repo;
125 Pool *pool = repo->pool;
131 if (split(line, sp, 5) != 4)
133 pool_debug(pool, SOLV_FATAL, "susetags: bad source line: %d: %s\n", pd->lineno, line);
137 name = pool_str2id(pool, sp[0], 1);
138 evr = makeevr(pool, join2(&pd->jd, sp[1], "-", sp[2]));
139 arch = pool_str2id(pool, sp[3], 1);
140 /* XXX: could record a dep here, depends on where we want to store the data */
142 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
144 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
146 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
148 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
149 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
154 * add a line with directory information
159 add_dirline(struct parsedata *pd, char *line)
165 if (split(line, sp, 6) != 5)
167 pd->dirs = solv_extend(pd->dirs, pd->ndirs, 1, sizeof(pd->dirs[0]), 31);
168 filesz = strtol(sp[1], 0, 0);
169 filesz += strtol(sp[2], 0, 0);
170 filenum = strtol(sp[3], 0, 0);
171 filenum += strtol(sp[4], 0, 0);
172 /* hack: we know that there's room for a / */
175 dirid = repodata_str2dir(pd->data, sp[0], 1);
177 fprintf(stderr, "%s -> %d\n", sp[0], dirid);
179 pd->dirs[pd->ndirs][0] = dirid;
180 pd->dirs[pd->ndirs][1] = filesz;
181 pd->dirs[pd->ndirs][2] = filenum;
186 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
190 if (split(line, sp, 3) != 2)
192 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum line: %d: %s\n", pd->lineno, line);
195 type = solv_chksum_str2type(sp[0]);
198 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
201 if (strlen(sp[1]) != 2 * solv_chksum_len(type))
203 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
206 repodata_set_checksum(data, handle, keyname, type, sp[1]);
210 set_delta_location(Repodata *data, Id handle, int medianr, char *dir, char *file)
212 Pool *pool = data->repo->pool;
218 if ((dir = strrchr(file, '/')) != 0)
229 if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/'))
234 if (l == 1 && dir[0] == '.')
237 repodata_set_id(data, handle, DELTA_LOCATION_DIR, pool_strn2id(pool, dir, l, 1));
238 if ((p = strrchr(file, '.')) != 0)
241 if ((op = strrchr(file, '.')) != 0)
246 if (!strcmp(p + 1, "delta.rpm") && (op = strrchr(file, '.')) != 0)
253 repodata_set_id(data, handle, DELTA_LOCATION_SUFFIX, pool_str2id(pool, p + 1, 1));
255 if ((p = strrchr(file, '-')) != 0)
258 if ((op = strrchr(file, '-')) != 0)
264 repodata_set_id(data, handle, DELTA_LOCATION_EVR, pool_str2id(pool, p + 1, 1));
266 repodata_set_id(data, handle, DELTA_LOCATION_NAME, pool_str2id(pool, file, 1));
278 id3_cmp(const void *v1, const void *v2, void *dp)
282 return i1[0] - i2[0];
292 commit_diskusage(struct parsedata *pd, Id handle)
295 Dirpool *dp = &pd->data->dirpool;
296 /* Now sort in dirid order. This ensures that parents come before
299 solv_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
300 /* Substract leaf numbers from all parents to make the numbers
301 non-cumulative. This must be done post-order (i.e. all leafs
302 adjusted before parents). We ensure this by starting at the end of
303 the array moving to the start, hence seeing leafs before parents. */
304 for (i = pd->ndirs; i--;)
306 unsigned p = dirpool_parent(dp, pd->dirs[i][0]);
308 for (; p; p = dirpool_parent(dp, p))
311 if (pd->dirs[j][0] == p)
315 if (pd->dirs[j][1] < pd->dirs[i][1])
318 pd->dirs[j][1] -= pd->dirs[i][1];
319 if (pd->dirs[j][2] < pd->dirs[i][2])
322 pd->dirs[j][2] -= pd->dirs[i][2];
325 /* Haven't found this parent in the list, look further if
326 we maybe find the parents parent. */
333 unsigned slen = sizeof(sbuf);
334 for (i = 0; i < pd->ndirs; i++)
336 dir2str(attr, pd->dirs[i][0], &buf, &slen);
337 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
342 for (i = 0; i < pd->ndirs; i++)
343 if (pd->dirs[i][1] || pd->dirs[i][2])
345 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
351 /* Unfortunately "a"[0] is no constant expression in the C languages,
352 so we need to pass the four characters individually :-/ */
353 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
354 | ((unsigned char)b << 16) \
355 | ((unsigned char)c << 8) \
356 | ((unsigned char)d))
363 static inline unsigned
364 tag_from_string(char *cs)
366 unsigned char *s = (unsigned char *)cs;
367 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
373 * Parse susetags file passed in fp, fill solvables into repo
375 * susetags is key,value based
379 * for long (multi-line) values,
386 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
387 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
388 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
391 * All keys have 3 characters and end in ':'
395 finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens)
397 Pool *pool = pd->repo->pool;
400 /* move file provides to filelist */
401 /* relies on the fact that rpm inserts self-provides at the end */
402 if (s->provides && (pd->flags & REPO_EXTEND_SOLVABLES) == 0)
404 Id *p, *lastreal, did;
405 const char *str, *sp;
406 lastreal = pd->repo->idarraydata + s->provides;
407 for (p = lastreal; *p; p++)
410 for (p = lastreal; *p; p++)
412 str = pool_id2str(pool, *p);
418 for (p = lastreal; *p; p++)
422 str = pool_id2str(pool, *p);
423 sp = strrchr(str, '/');
424 /* Need to copy filename now, before we add string that could
425 realloc the stringspace (and hence invalidate str). */
427 if (strlen(fname) >= 128)
428 fname = solv_strdup(fname);
431 memcpy(fname_buf, fname, strlen(fname) + 1);
436 char *sdup = solv_strdup(str);
438 did = repodata_str2dir(pd->data, sdup, 1);
444 strncpy(sdup, str, sp - str);
446 did = repodata_str2dir(pd->data, sdup, 1);
449 did = repodata_str2dir(pd->data, "/", 1);
450 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, fname);
451 if (fname != fname_buf)
458 /* A self provide, except for source packages. This is harmless
459 to do twice (in case we see the same package twice). */
460 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
461 s->provides = repo_addid_dep(pd->repo, s->provides,
462 pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
463 /* XXX This uses repo_addid_dep internally, so should also be
464 harmless to do twice. */
465 s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, freshens);
466 s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts);
468 commit_diskusage(pd, handle);
472 joinhash_init(Repo *repo, Hashmask *hmp)
474 Hashmask hm = mkmask(repo->nsolvables);
475 Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
480 FOR_REPO_SOLVABLES(repo, i, s)
482 hh = HASHCHAIN_START;
485 h = HASHCHAIN_NEXT(h, hh, hm);
493 joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch)
497 if (!name || !arch || !evr)
499 hh = HASHCHAIN_START;
503 Solvable *s = repo->pool->solvables + ht[h];
504 if (s->name == name && s->evr == evr && s->arch == arch)
506 h = HASHCHAIN_NEXT(h, hh, hm);
512 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
515 r = repodata_lookup_type(data, p, keyname);
518 if (r == REPOKEY_TYPE_VOID)
520 r = repodata_lookup_id(data, p, keyname);
524 if (uninternalized && data->attrs)
526 Id *ap = data->attrs[p - data->start];
531 if (data->keys[*ap].name != keyname)
533 if (data->keys[*ap].type == REPOKEY_TYPE_VOID)
535 if (data->keys[*ap].type == REPOKEY_TYPE_ID)
546 * fp: file to read from
547 * defvendor: default vendor (0 if none)
548 * language: current language (0 if none)
553 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
555 Pool *pool = repo->pool;
564 int last_found_pack = 0;
569 Hashtable joinhash = 0;
570 Hashmask joinhashm = 0;
573 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
575 joinhash = joinhash_init(repo, &joinhashm);
579 data = repo_add_repodata(repo, flags);
581 memset(&pd, 0, sizeof(pd));
589 pd.language = language && *language ? solv_strdup(language) : 0;
595 /* if this is a join setup the recorded share data */
601 FOR_REPODATAS(repo, i, sdata)
604 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
606 for (p = sdata->start; p < sdata->end; p++)
609 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
612 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
615 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
618 if (p - repo->start >= pd.nshare)
620 pd.share_with = solv_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
621 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
622 pd.nshare = p - repo->start + 256;
624 pd.share_with[p - repo->start].name = name;
625 pd.share_with[p - repo->start].evr = evr;
626 pd.share_with[p - repo->start].arch = arch;
634 * collect values in 'struct parsedata pd'
635 * then build .solv (and .attr) file
641 char *olinep; /* old line pointer */
644 if (linep - line + 16 > aline) /* (re-)alloc buffer */
646 aline = linep - line;
647 line = realloc(line, aline + 512);
648 linep = line + aline;
651 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
654 linep += strlen(linep);
655 if (linep == line || linep[-1] != '\n')
664 /* check for multi-line value tags (+Key:/-Key:) */
666 int is_end = (linep[-intag - keylen + 1] == '-')
667 && (linep[-1] == ':')
668 && (linep == line + 1 + intag + 1 + 1 + 1 + intag + 1 || linep[-intag - keylen] == '\n');
670 && strncmp(linep - 1 - intag, line + 1, intag))
672 pool_debug(pool, SOLV_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
674 if (cummulate && !is_end)
679 if (cummulate && is_end)
681 linep[-intag - keylen + 1] = 0;
682 if (linep[-intag - keylen] == '\n')
683 linep[-intag - keylen] = 0;
687 if (!cummulate && is_end)
693 if (!cummulate && !is_end)
694 linep = line + intag + keylen;
699 if (!intag && line[0] == '+' && line[1] && line[1] != ':') /* start of +Key:/-Key: tag */
701 char *tagend = strchr(line, ':');
704 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
707 intag = tagend - (line + 1);
709 switch (tag_from_string(line)) /* check if accumulation is needed */
711 case CTAG('+', 'D', 'e', 's'):
712 case CTAG('+', 'E', 'u', 'l'):
713 case CTAG('+', 'I', 'n', 's'):
714 case CTAG('+', 'D', 'e', 'l'):
715 case CTAG('+', 'A', 'u', 't'):
716 if (line[4] == ':' || line[4] == '.')
722 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
723 line[intag + keylen - 1] = ' ';
724 linep = line + intag + keylen;
727 if (*line == '#' || !*line)
729 if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
735 endlang = strchr(line + 5, ':');
738 int langsize = endlang - (line + 5);
739 keylen = endlang - line - 1;
742 strncpy(line_lang, line + 5, langsize);
743 line_lang[langsize] = 0;
746 tag = tag_from_string(line);
751 =Dlt: subversion 1.6.16 1.3.1 i586
752 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
753 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
754 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
759 case CTAG('=', 'D', 's', 'q'):
762 if (split(line + 5, sp, 5) != 5)
764 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
765 evr = makeevr(pool, join2(&pd.jd, sp[1], "-", sp[2]));
766 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
767 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
768 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
769 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
772 case CTAG('=', 'C', 'k', 's'):
773 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
775 case CTAG('=', 'L', 'o', 'c'):
777 int i = split(line + 6, sp, 3);
778 if (i != 2 && i != 3)
780 pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
783 set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
786 case CTAG('=', 'S', 'i', 'z'):
787 if (split(line + 6, sp, 3) == 2)
788 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
790 case CTAG('=', 'P', 'k', 'g'):
791 case CTAG('=', 'P', 'a', 't'):
792 case CTAG('=', 'D', 'l', 't'):
797 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
803 * start of (next) package or pattern or delta
805 * =Pkg: <name> <version> <release> <architecture>
808 if (tag == CTAG('=', 'D', 'l', 't'))
811 finish_solvable(&pd, s, handle, freshens);
814 if (split(line + 5, sp, 5) != 4)
816 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
819 handle = repodata_new_handle(data);
820 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
821 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, makeevr(pool, join2(&pd.jd, sp[1], "-", sp[2])));
822 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
823 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
827 if (tag == CTAG('=', 'P', 'k', 'g')
828 || tag == CTAG('=', 'P', 'a', 't'))
830 /* If we have an old solvable, complete it by filling in some
833 finish_solvable(&pd, s, handle, freshens);
847 if (split(line + 5, sp, 5) != 4)
849 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
857 /* data join operation. find solvable matching name/arch/evr and
860 /* we don't use the create flag here as a simple pre-check for existance */
862 name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 0);
864 name = pool_str2id(pool, sp[0], 0);
865 evr = makeevr(pool, join2(&pd.jd, sp[1], "-", sp[2]));
866 arch = pool_str2id(pool, sp[3], 0);
869 if (repo->start + last_found_pack + 1 < repo->end)
871 s = pool->solvables + repo->start + last_found_pack + 1;
872 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
876 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch);
878 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
880 /* fallthrough to package creation */
884 /* normal operation. create a new solvable. */
885 s = pool_id2solvable(pool, repo_add_solvable(repo));
887 s->name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 1);
889 s->name = pool_str2id(pool, sp[0], 1);
890 s->evr = makeevr(pool, join2(&pd.jd, sp[1], "-", sp[2]));
891 s->arch = pool_str2id(pool, sp[3], 1);
892 s->vendor = defvendor;
895 last_found_pack = (s - pool->solvables) - repo->start;
897 handle = s - pool->solvables;
900 /* If we have no current solvable to add to, ignore all further lines
901 for it. Probably invalid input data in the second set of
903 if (indesc >= 2 && !s)
906 pool_debug(pool, SOLV_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
912 case CTAG('=', 'P', 'r', 'v'): /* provides */
913 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
915 case CTAG('=', 'R', 'e', 'q'): /* requires */
916 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
918 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
921 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
924 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
926 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
927 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
929 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
930 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
932 case CTAG('=', 'R', 'e', 'c'): /* recommends */
933 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
935 case CTAG('=', 'S', 'u', 'p'): /* supplements */
936 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
938 case CTAG('=', 'E', 'n', 'h'): /* enhances */
939 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
941 case CTAG('=', 'S', 'u', 'g'): /* suggests */
942 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
944 case CTAG('=', 'F', 'r', 'e'): /* freshens */
945 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
947 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
948 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
950 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
951 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
953 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
954 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
956 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
957 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
959 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
960 freshens = adddep(pool, &pd, freshens, line, 0, 0);
962 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
963 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
965 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
966 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
968 case CTAG('=', 'V', 'e', 'r'): /* - version - */
975 joinhash = joinhash_init(repo, &joinhashm);
979 case CTAG('=', 'V', 'n', 'd'): /* vendor */
980 s->vendor = pool_str2id(pool, line + 6, 1);
983 /* From here it's the attribute tags. */
984 case CTAG('=', 'G', 'r', 'p'):
985 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
987 case CTAG('=', 'L', 'i', 'c'):
988 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
990 case CTAG('=', 'L', 'o', 'c'):
992 int i = split(line + 6, sp, 3);
993 if (i != 2 && i != 3)
995 pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
998 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
1001 case CTAG('=', 'S', 'r', 'c'):
1002 add_source(&pd, line + 6, s, handle);
1004 case CTAG('=', 'S', 'i', 'z'):
1005 if (split(line + 6, sp, 3) == 2)
1007 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
1008 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, (unsigned int)(atoi(sp[1]) + 1023) / 1024);
1011 case CTAG('=', 'T', 'i', 'm'):
1013 unsigned int t = atoi(line + 6);
1015 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
1018 case CTAG('=', 'K', 'w', 'd'):
1019 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
1021 case CTAG('=', 'A', 'u', 't'):
1022 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
1024 case CTAG('=', 'S', 'u', 'm'):
1025 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
1027 case CTAG('=', 'D', 'e', 's'):
1028 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
1030 case CTAG('=', 'E', 'u', 'l'):
1031 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
1033 case CTAG('=', 'I', 'n', 's'):
1034 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
1036 case CTAG('=', 'D', 'e', 'l'):
1037 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
1039 case CTAG('=', 'V', 'i', 's'):
1041 /* Accept numbers and textual bools. */
1044 if (k || !strcasecmp(line + 6, "true"))
1045 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
1048 case CTAG('=', 'S', 'h', 'r'):
1051 if (split(line + 6, sp, 5) != 4)
1053 pool_debug(pool, SOLV_FATAL, "susetags: bad =Shr line: %s\n", line + 6);
1056 name = pool_str2id(pool, sp[0], 1);
1057 evr = makeevr(pool, join2(&pd.jd, sp[1], "-", sp[2]));
1058 arch = pool_str2id(pool, sp[3], 1);
1059 if (last_found_pack >= pd.nshare)
1061 pd.share_with = solv_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
1062 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
1063 pd.nshare = last_found_pack + 256;
1065 pd.share_with[last_found_pack].name = name;
1066 pd.share_with[last_found_pack].evr = evr;
1067 pd.share_with[last_found_pack].arch = arch;
1068 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
1070 if (s->name == name)
1071 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
1073 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
1075 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
1077 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
1078 if (s->arch == arch)
1079 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
1081 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
1085 case CTAG('=', 'D', 'i', 'r'):
1086 add_dirline(&pd, line + 6);
1088 case CTAG('=', 'C', 'a', 't'):
1089 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
1091 case CTAG('=', 'O', 'r', 'd'):
1092 /* Order is a string not a number, so we can retroactively insert
1093 new patterns in the middle, i.e. 1 < 15 < 2. */
1094 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1096 case CTAG('=', 'I', 'c', 'o'):
1097 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1099 case CTAG('=', 'E', 'x', 't'):
1100 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2(&pd.jd, "pattern", ":", line + 6));
1102 case CTAG('=', 'I', 'n', 'c'):
1103 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2(&pd.jd, "pattern", ":", line + 6));
1105 case CTAG('=', 'C', 'k', 's'):
1106 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1108 case CTAG('=', 'L', 'a', 'n'):
1109 pd.language = solv_free(pd.language);
1111 pd.language = solv_strdup(line + 6);
1114 case CTAG('=', 'F', 'l', 's'):
1116 char *p = strrchr(line + 6, '/');
1118 if (p && p != line + 6 && !p[1])
1121 p = strrchr(line + 6, '/');
1126 did = repodata_str2dir(data, line + 6, 1);
1134 did = repodata_str2dir(data, "/", 1);
1135 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1138 case CTAG('=', 'H', 'd', 'r'):
1139 /* rpm header range */
1140 if (split(line + 6, sp, 3) == 2)
1142 /* we ignore the start value */
1143 unsigned int end = (unsigned int)atoi(sp[1]);
1145 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1149 case CTAG('=', 'P', 'a', 't'):
1150 case CTAG('=', 'P', 'k', 'g'):
1154 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1161 finish_solvable(&pd, s, handle, freshens);
1163 /* Shared attributes
1164 * (e.g. multiple binaries built from same source)
1171 map_init(&keyidmap, data->nkeys);
1172 for (i = 1; i < data->nkeys; i++)
1174 Id keyname = data->keys[i].name;
1175 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
1177 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
1179 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
1181 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
1183 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
1185 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
1187 MAPSET(&keyidmap, i);
1190 for (i = 0; i < pd.nshare; i++)
1193 Solvable *found = 0;
1194 if (!pd.share_with[i].name)
1196 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
1198 if (nn >= repo->end)
1200 found = pool->solvables + nn;
1201 if (found->repo == repo
1202 && found->name == pd.share_with[i].name
1203 && found->evr == pd.share_with[i].evr
1204 && found->arch == pd.share_with[i].arch)
1206 last_found = nn - repo->start;
1211 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
1213 free(pd.share_with);
1214 map_free(&keyidmap);
1217 solv_free(joinhash);
1218 if (!(flags & REPO_NO_INTERNALIZE))
1219 repodata_internalize(data);
1221 solv_free(pd.language);
1223 join_freemem(&pd.jd);