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"
21 #ifdef ENABLE_COMPLEX_DEPS
22 #include "pool_parserpmrichdep.h"
38 int last_found_source;
39 struct datashare *share_with;
41 Id (*dirs)[3]; /* dirid, size, nfiles */
44 char *language; /* the default language */
45 Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
48 int afilelist; /* allocated */
49 int nfilelist; /* used */
52 static char *flagtab[] = {
63 langtag(struct parsedata *pd, Id tag, const char *language)
65 if (language && *language)
66 return pool_id2langid(pd->repo->pool, tag, language, 1);
69 if (tag >= ID_NUM_INTERNAL)
70 return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
71 if (!pd->langcache[tag])
72 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
73 return pd->langcache[tag];
78 * create and add dependency
82 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
90 /* A file dependency. Do not try to parse it */
91 id = pool_str2id(pool, line + 6, 1);
93 #ifdef ENABLE_COMPLEX_DEPS
94 else if (line[6] == '(')
96 id = pool_parserpmrichdep(pool, line + 6);
99 pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
106 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
107 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
109 pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
113 id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
115 id = pool_str2id(pool, sp[0], 1);
118 evrid = makeevr(pool, sp[2]);
119 for (flags = 0; flags < 6; flags++)
120 if (!strcmp(sp[1], flagtab[flags]))
124 if (!strcmp(sp[1], "<>"))
128 pd->ret = pool_error(pool, -1, "susetags: line %d: unknown relation: '%s'\n", pd->lineno, sp[1]);
132 id = pool_rel2id(pool, id, evrid, flags + 1, 1);
135 return repo_addid_dep(pd->repo, olddeps, id, marker);
145 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
147 Pool *pool = s->repo->pool;
151 const char *evr, *sevr;
153 if (split(line, sp, 5) != 4)
155 pd->ret = pool_error(pool, -1, "susetags: line %d: bad source line '%s'\n", pd->lineno, line);
159 name = pool_str2id(pool, sp[0], 1);
160 arch = pool_str2id(pool, sp[3], 1); /* do this before id2str */
161 evr = join2(&pd->jd, sp[1], "-", sp[2]);
162 sevr = pool_id2str(pool, s->evr);
167 for (p = sevr; *p >= '0' && *p <= '9'; p++)
169 if (p != sevr && *p == ':' && p[1])
173 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
175 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
176 if (sevr && !strcmp(sevr, evr))
177 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
179 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, pool_str2id(pool, evr, 1));
180 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
185 * add a line with directory information
190 add_dirline(struct parsedata *pd, char *line)
196 if (split(line, sp, 6) != 5)
198 pd->dirs = solv_extend(pd->dirs, pd->ndirs, 1, sizeof(pd->dirs[0]), 31);
199 filesz = strtol(sp[1], 0, 0);
200 filesz += strtol(sp[2], 0, 0);
201 filenum = strtol(sp[3], 0, 0);
202 filenum += strtol(sp[4], 0, 0);
203 /* hack: we know that there's room for a / */
206 dirid = repodata_str2dir(pd->data, sp[0], 1);
208 fprintf(stderr, "%s -> %d\n", sp[0], dirid);
210 pd->dirs[pd->ndirs][0] = dirid;
211 pd->dirs[pd->ndirs][1] = filesz;
212 pd->dirs[pd->ndirs][2] = filenum;
217 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
221 if (split(line, sp, 3) != 2)
223 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum line '%s'\n", pd->lineno, line);
226 type = solv_chksum_str2type(sp[0]);
229 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: unknown checksum type: '%s'\n", pd->lineno, sp[0]);
232 if (strlen(sp[1]) != 2 * solv_chksum_len(type))
234 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum length for type %s: '%s'\n", pd->lineno, sp[0], sp[1]);
237 repodata_set_checksum(data, handle, keyname, type, sp[1]);
248 id3_cmp(const void *v1, const void *v2, void *dp)
252 return i1[0] - i2[0];
262 commit_diskusage(struct parsedata *pd, Id handle)
265 Dirpool *dp = &pd->data->dirpool;
266 /* Now sort in dirid order. This ensures that parents come before
269 solv_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
270 /* Substract leaf numbers from all parents to make the numbers
271 non-cumulative. This must be done post-order (i.e. all leafs
272 adjusted before parents). We ensure this by starting at the end of
273 the array moving to the start, hence seeing leafs before parents. */
274 for (i = pd->ndirs; i--;)
276 Id p = dirpool_parent(dp, pd->dirs[i][0]);
278 for (; p; p = dirpool_parent(dp, p))
281 if (pd->dirs[j][0] == p)
285 if (pd->dirs[j][1] < pd->dirs[i][1])
288 pd->dirs[j][1] -= pd->dirs[i][1];
289 if (pd->dirs[j][2] < pd->dirs[i][2])
292 pd->dirs[j][2] -= pd->dirs[i][2];
295 /* Haven't found this parent in the list, look further if
296 we maybe find the parents parent. */
303 unsigned slen = sizeof(sbuf);
304 for (i = 0; i < pd->ndirs; i++)
306 dir2str(attr, pd->dirs[i][0], &buf, &slen);
307 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
312 for (i = 0; i < pd->ndirs; i++)
313 if (pd->dirs[i][1] || pd->dirs[i][2])
315 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
321 /* Unfortunately "a"[0] is no constant expression in the C languages,
322 so we need to pass the four characters individually :-/ */
323 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
324 | ((unsigned char)b << 16) \
325 | ((unsigned char)c << 8) \
326 | ((unsigned char)d))
333 static inline unsigned int
334 tag_from_string(char *cs)
336 unsigned char *s = (unsigned char *)cs;
337 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
343 * Parse susetags file passed in fp, fill solvables into repo
345 * susetags is key,value based
349 * for long (multi-line) values,
356 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
357 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
358 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
361 * All keys have 3 characters and end in ':'
365 finish_solvable(struct parsedata *pd, Solvable *s, Offset freshens)
367 Pool *pool = pd->repo->pool;
368 Id handle = s - pool->solvables;
374 for (l = 0; l < pd->nfilelist; l += strlen(pd->filelist + l) + 1)
376 char *p = strrchr(pd->filelist + l, '/');
380 did = repodata_str2dir(pd->data, pd->filelist + l, 1);
383 did = repodata_str2dir(pd->data, "/", 1);
384 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, p);
388 /* A self provide, except for source packages. This is harmless
389 to do twice (in case we see the same package twice). */
390 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
391 s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
392 repo_rewrite_suse_deps(s, freshens);
394 commit_diskusage(pd, handle);
398 joinhash_init(Repo *repo, Hashval *hmp)
400 Hashval hm = mkmask(repo->nsolvables);
401 Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
406 FOR_REPO_SOLVABLES(repo, i, s)
408 hh = HASHCHAIN_START;
411 h = HASHCHAIN_NEXT(h, hh, hm);
419 joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, Id name, Id evr, Id arch, Id start)
423 if (!name || !arch || !evr)
425 hh = HASHCHAIN_START;
429 Solvable *s = repo->pool->solvables + ht[h];
430 if (ht[h] >= start && s->name == name && s->evr == evr && s->arch == arch)
432 h = HASHCHAIN_NEXT(h, hh, hm);
438 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
441 r = repodata_lookup_type(data, p, keyname);
444 if (r == REPOKEY_TYPE_VOID)
446 r = repodata_lookup_id(data, p, keyname);
451 return repodata_lookup_id_uninternalized(data, p, keyname, voidid);
456 toevr(Pool *pool, struct parsedata *pd, const char *version, const char *release)
458 return makeevr(pool, !release || (release[0] == '-' && !release[1]) ?
459 version : join2(&pd->jd, version, "-", release));
466 * fp: file to read from
467 * defvendor: default vendor (0 if none)
468 * language: current language (0 if none)
473 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
475 Pool *pool = repo->pool;
481 int intag_linestart = 0;
485 int last_found_pack = 0;
486 Id first_new_pkg = 0;
491 Hashtable joinhash = 0;
492 Hashval joinhashm = 0;
495 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
497 joinhash = joinhash_init(repo, &joinhashm);
501 data = repo_add_repodata(repo, flags);
503 memset(&pd, 0, sizeof(pd));
504 line = solv_malloc(1024);
511 pd.language = language && *language ? solv_strdup(language) : 0;
517 /* if this is a join setup the recorded share data */
523 FOR_REPODATAS(repo, i, sdata)
526 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
528 for (p = sdata->start; p < sdata->end; p++)
531 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
534 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
537 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
540 if (p - repo->start >= pd.nshare)
542 pd.share_with = solv_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
543 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
544 pd.nshare = p - repo->start + 256;
546 pd.share_with[p - repo->start].name = name;
547 pd.share_with[p - repo->start].evr = evr;
548 pd.share_with[p - repo->start].arch = arch;
556 * collect values in 'struct parsedata pd'
557 * then build .solv (and .attr) file
568 if (linep - line + 16 > aline) /* (re-)alloc buffer */
570 aline = linep - line;
571 line = solv_realloc(line, aline + 512);
572 linep = line + aline;
575 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
577 linep += strlen(linep);
578 if (linep == line || linep[-1] != '\n')
585 /* in multi-line value tags (+Key:/-Key:), check for end, cummulate */
586 int is_end = line[intag_linestart] == '-' && linep[-1] == ':' && linep - line == intag_linestart + intag + 2;
587 if (is_end && strncmp(linep - 1 - intag, line + 1, intag))
589 pool_debug(pool, SOLV_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%.*s'\n", pd.lineno, linep - 1 - intag, intag, line + 1);
596 intag_linestart = linep - line;
599 intag_linestart = intag + 3;
600 linep = line + intag_linestart;
602 continue; /* ignore empty lines, bnc#381828 */
610 line[intag_linestart] = 0;
611 if (line[intag_linestart - 1] == '\n')
612 line[intag_linestart - 1] = 0; /* strip trailing newline */
618 /* ignore comments and empty lines */
619 if (!*line || *line == '#')
622 /* ignore malformed lines */
623 if (!(line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
626 if (!intag && line[0] == '+' && line[1] != ':') /* start of +Key:/-Key: tag */
628 char *tagend = strchr(line, ':');
629 if (!tagend || tagend - line > 100)
631 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
634 intag = tagend - (line + 1); /* set to tagsize */
636 switch (tag_from_string(line)) /* check if accumulation is needed */
638 case CTAG('+', 'D', 'e', 's'):
639 case CTAG('+', 'E', 'u', 'l'):
640 case CTAG('+', 'I', 'n', 's'):
641 case CTAG('+', 'D', 'e', 'l'):
642 case CTAG('+', 'A', 'u', 't'):
648 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
649 line[intag + 2] = ' ';
650 intag_linestart = intag + 3;
651 linep = line + intag_linestart;
655 /* support language suffix */
661 endlang = strchr(line + 5, ':');
664 int langsize = endlang - (line + 5);
665 keylen = endlang - line - 1;
668 strncpy(line_lang, line + 5, langsize);
669 line_lang[langsize] = 0;
673 tag = tag_from_string(line);
678 =Dlt: subversion 1.6.16 1.3.1 i586
679 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
680 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
681 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
686 case CTAG('=', 'D', 's', 'q'):
689 if (split(line + 5, sp, 5) != 5)
691 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
692 evr = toevr(pool, &pd, sp[1], sp[2]);
693 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
694 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
695 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
696 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
699 case CTAG('=', 'C', 'k', 's'):
700 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
702 case CTAG('=', 'L', 'o', 'c'):
704 int i = split(line + 6, sp, 3);
705 if (i != 2 && i != 3)
707 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
710 repodata_set_deltalocation(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
713 case CTAG('=', 'S', 'i', 'z'):
714 if (split(line + 6, sp, 3) == 2)
715 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
717 case CTAG('=', 'P', 'k', 'g'):
718 case CTAG('=', 'P', 'a', 't'):
719 case CTAG('=', 'D', 'l', 't'):
724 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
730 * start of (next) package or pattern or delta
732 * =Pkg: <name> <version> <release> <architecture>
735 if (tag == CTAG('=', 'D', 'l', 't'))
738 finish_solvable(&pd, s, freshens);
741 if (split(line + 5, sp, 5) != 4)
743 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
746 handle = repodata_new_handle(data);
747 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
748 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, toevr(pool, &pd, sp[1], sp[2]));
749 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
750 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
754 if (tag == CTAG('=', 'P', 'k', 'g')
755 || tag == CTAG('=', 'P', 'a', 't'))
757 /* If we have an old solvable, complete it by filling in some
760 finish_solvable(&pd, s, freshens);
774 if (split(line + 5, sp, 5) != 4)
776 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
784 /* data join operation. find solvable matching name/arch/evr and
787 /* we don't use the create flag here as a simple pre-check for existance */
789 name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 0);
791 name = pool_str2id(pool, sp[0], 0);
792 evr = toevr(pool, &pd, sp[1], sp[2]);
793 arch = pool_str2id(pool, sp[3], 0);
796 Id start = (flags & REPO_EXTEND_SOLVABLES) ? 0 : first_new_pkg;
797 if (repo->start + last_found_pack + 1 >= start && repo->start + last_found_pack + 1 < repo->end)
799 s = pool->solvables + repo->start + last_found_pack + 1;
800 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
804 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch, start);
806 /* do not create new packages in EXTEND_SOLVABLES mode */
807 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
809 /* fallthrough to package creation */
813 /* normal operation. create a new solvable. */
814 s = pool_id2solvable(pool, repo_add_solvable(repo));
816 s->name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 1);
818 s->name = pool_str2id(pool, sp[0], 1);
819 s->evr = toevr(pool, &pd, sp[1], sp[2]);
820 s->arch = pool_str2id(pool, sp[3], 1);
821 s->vendor = defvendor;
823 first_new_pkg = s - pool->solvables;
826 last_found_pack = (s - pool->solvables) - repo->start;
828 handle = s - pool->solvables;
831 /* If we have no current solvable to add to, ignore all further lines
832 for it. Probably invalid input data in the second set of
834 if (indesc >= 2 && !s)
837 pool_debug(pool, SOLV_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
843 case CTAG('=', 'P', 'r', 'v'): /* provides */
846 /* probably a filelist entry. stash it away for now */
847 int l = strlen(line + 6) + 1;
848 if (pd.nfilelist + l > pd.afilelist)
850 pd.afilelist = pd.nfilelist + l + 512;
851 pd.filelist = solv_realloc(pd.filelist, pd.afilelist);
853 memcpy(pd.filelist + pd.nfilelist, line + 6, l);
860 for (l = 0; l < pd.nfilelist; l += strlen(pd.filelist + l) + 1)
861 s->provides = repo_addid_dep(pd.repo, s->provides, pool_str2id(pool, pd.filelist + l, 1), 0);
864 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
866 case CTAG('=', 'R', 'e', 'q'): /* requires */
867 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
869 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
872 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
875 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
877 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
878 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
880 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
881 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
883 case CTAG('=', 'R', 'e', 'c'): /* recommends */
884 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
886 case CTAG('=', 'S', 'u', 'p'): /* supplements */
887 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
889 case CTAG('=', 'E', 'n', 'h'): /* enhances */
890 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
892 case CTAG('=', 'S', 'u', 'g'): /* suggests */
893 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
895 case CTAG('=', 'F', 'r', 'e'): /* freshens */
896 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
898 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
899 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
901 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
902 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
904 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
905 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
907 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
908 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
910 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
911 freshens = adddep(pool, &pd, freshens, line, 0, 0);
913 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
914 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
916 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
917 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
919 case CTAG('=', 'V', 'e', 'r'): /* - version - */
926 joinhash = joinhash_init(repo, &joinhashm);
930 case CTAG('=', 'V', 'n', 'd'): /* vendor */
931 s->vendor = pool_str2id(pool, line + 6, 1);
934 /* From here it's the attribute tags. */
935 case CTAG('=', 'G', 'r', 'p'):
936 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
938 case CTAG('=', 'L', 'i', 'c'):
939 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
941 case CTAG('=', 'L', 'o', 'c'):
943 int i = split(line + 6, sp, 3);
944 if (i != 2 && i != 3)
946 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
949 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
952 case CTAG('=', 'S', 'r', 'c'):
953 add_source(&pd, line + 6, s, handle);
955 case CTAG('=', 'S', 'i', 'z'):
956 if (split(line + 6, sp, 3) == 2)
958 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
959 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, strtoull(sp[1], 0, 10));
962 case CTAG('=', 'T', 'i', 'm'):
964 unsigned int t = atoi(line + 6);
966 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
969 case CTAG('=', 'K', 'w', 'd'):
970 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
972 case CTAG('=', 'A', 'u', 't'):
973 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
975 case CTAG('=', 'S', 'u', 'm'):
976 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
978 case CTAG('=', 'D', 'e', 's'):
979 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
981 case CTAG('=', 'E', 'u', 'l'):
982 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
984 case CTAG('=', 'I', 'n', 's'):
985 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
987 case CTAG('=', 'D', 'e', 'l'):
988 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
990 case CTAG('=', 'V', 'i', 's'):
992 /* Accept numbers and textual bools. */
995 if (k || !strcasecmp(line + 6, "true"))
996 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
999 case CTAG('=', 'S', 'h', 'r'):
1002 if (split(line + 6, sp, 5) != 4)
1004 pd.ret = pool_error(pool, -1, "susetags: line %d: bad =Shr line '%s'\n", pd.lineno, line);
1007 name = pool_str2id(pool, sp[0], 1);
1008 evr = toevr(pool, &pd, sp[1], sp[2]);
1009 arch = pool_str2id(pool, sp[3], 1);
1010 if (last_found_pack >= pd.nshare)
1012 pd.share_with = solv_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
1013 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
1014 pd.nshare = last_found_pack + 256;
1016 pd.share_with[last_found_pack].name = name;
1017 pd.share_with[last_found_pack].evr = evr;
1018 pd.share_with[last_found_pack].arch = arch;
1019 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
1021 if (s->name == name)
1022 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
1024 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
1026 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
1028 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
1029 if (s->arch == arch)
1030 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
1032 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
1036 case CTAG('=', 'D', 'i', 'r'):
1037 add_dirline(&pd, line + 6);
1039 case CTAG('=', 'C', 'a', 't'):
1040 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
1042 case CTAG('=', 'O', 'r', 'd'):
1043 /* Order is a string not a number, so we can retroactively insert
1044 new patterns in the middle, i.e. 1 < 15 < 2. */
1045 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1047 case CTAG('=', 'I', 'c', 'o'):
1048 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1050 case CTAG('=', 'E', 'x', 't'):
1051 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2(&pd.jd, "pattern", ":", line + 6));
1053 case CTAG('=', 'I', 'n', 'c'):
1054 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2(&pd.jd, "pattern", ":", line + 6));
1056 case CTAG('=', 'C', 'k', 's'):
1057 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1059 case CTAG('=', 'L', 'a', 'n'):
1060 pd.language = solv_free(pd.language);
1061 memset(pd.langcache, 0, sizeof(pd.langcache));
1063 pd.language = solv_strdup(line + 6);
1066 case CTAG('=', 'F', 'l', 's'):
1068 char *p = strrchr(line + 6, '/');
1070 /* strip trailing slash */
1071 if (p && p != line + 6 && !p[1])
1074 p = strrchr(line + 6, '/');
1079 did = repodata_str2dir(data, line + 6, 1);
1087 did = repodata_str2dir(data, "/", 1);
1088 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1091 case CTAG('=', 'H', 'd', 'r'):
1092 /* rpm header range */
1093 if (split(line + 6, sp, 3) == 2)
1095 /* we ignore the start value */
1096 unsigned int end = (unsigned int)atoi(sp[1]);
1098 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1102 case CTAG('=', 'P', 'a', 't'):
1103 case CTAG('=', 'P', 'k', 'g'):
1108 pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1116 finish_solvable(&pd, s, freshens);
1117 solv_free(pd.filelist);
1119 /* Shared attributes
1120 * (e.g. multiple binaries built from same source)
1127 map_init(&keyidmap, data->nkeys);
1128 for (i = 1; i < data->nkeys; i++)
1130 Id keyname = data->keys[i].name;
1131 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
1133 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
1135 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
1137 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
1139 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
1141 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
1143 MAPSET(&keyidmap, i);
1146 for (i = 0; i < pd.nshare; i++)
1149 Solvable *found = 0;
1150 if (!pd.share_with[i].name)
1152 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
1154 if (nn >= repo->end)
1156 found = pool->solvables + nn;
1157 if (found->repo == repo
1158 && found->name == pd.share_with[i].name
1159 && found->evr == pd.share_with[i].evr
1160 && found->arch == pd.share_with[i].arch)
1162 last_found = nn - repo->start;
1167 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
1169 free(pd.share_with);
1170 map_free(&keyidmap);
1173 solv_free(joinhash);
1174 repodata_free_dircache(data);
1175 if (!(flags & REPO_NO_INTERNALIZE))
1176 repodata_internalize(data);
1178 solv_free(pd.language);
1180 join_freemem(&pd.jd);