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"
35 int last_found_source;
36 struct datashare *share_with;
38 Id (*dirs)[3]; /* dirid, size, nfiles */
41 char *language; /* the default language */
42 Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
45 int afilelist; /* allocated */
46 int nfilelist; /* used */
49 static char *flagtab[] = {
60 langtag(struct parsedata *pd, Id tag, const char *language)
62 if (language && *language)
63 return pool_id2langid(pd->repo->pool, tag, language, 1);
66 if (tag >= ID_NUM_INTERNAL)
67 return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
68 if (!pd->langcache[tag])
69 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
70 return pd->langcache[tag];
75 * create and add dependency
79 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
87 /* A file dependency. Do not try to parse it */
88 id = pool_str2id(pool, line + 6, 1);
92 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
93 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
95 pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
99 id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
101 id = pool_str2id(pool, sp[0], 1);
104 evrid = makeevr(pool, sp[2]);
105 for (flags = 0; flags < 6; flags++)
106 if (!strcmp(sp[1], flagtab[flags]))
110 if (!strcmp(sp[1], "<>"))
114 pd->ret = pool_error(pool, -1, "susetags: line %d: unknown relation: '%s'\n", pd->lineno, sp[1]);
118 id = pool_rel2id(pool, id, evrid, flags + 1, 1);
121 return repo_addid_dep(pd->repo, olddeps, id, marker);
131 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
133 Repo *repo = s->repo;
134 Pool *pool = repo->pool;
140 if (split(line, sp, 5) != 4)
142 pd->ret = pool_error(pool, -1, "susetags: line %d: bad source line '%s'\n", pd->lineno, line);
146 name = pool_str2id(pool, sp[0], 1);
147 evr = makeevr(pool, join2(&pd->jd, sp[1], "-", sp[2]));
148 arch = pool_str2id(pool, sp[3], 1);
149 /* XXX: could record a dep here, depends on where we want to store the data */
151 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
153 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
155 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
157 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
158 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
163 * add a line with directory information
168 add_dirline(struct parsedata *pd, char *line)
174 if (split(line, sp, 6) != 5)
176 pd->dirs = solv_extend(pd->dirs, pd->ndirs, 1, sizeof(pd->dirs[0]), 31);
177 filesz = strtol(sp[1], 0, 0);
178 filesz += strtol(sp[2], 0, 0);
179 filenum = strtol(sp[3], 0, 0);
180 filenum += strtol(sp[4], 0, 0);
181 /* hack: we know that there's room for a / */
184 dirid = repodata_str2dir(pd->data, sp[0], 1);
186 fprintf(stderr, "%s -> %d\n", sp[0], dirid);
188 pd->dirs[pd->ndirs][0] = dirid;
189 pd->dirs[pd->ndirs][1] = filesz;
190 pd->dirs[pd->ndirs][2] = filenum;
195 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
199 if (split(line, sp, 3) != 2)
201 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum line '%s'\n", pd->lineno, line);
204 type = solv_chksum_str2type(sp[0]);
207 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: unknown checksum type: '%s'\n", pd->lineno, sp[0]);
210 if (strlen(sp[1]) != 2 * solv_chksum_len(type))
212 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum length for type %s: '%s'\n", pd->lineno, sp[0], sp[1]);
215 repodata_set_checksum(data, handle, keyname, type, sp[1]);
219 set_delta_location(Repodata *data, Id handle, int medianr, char *dir, char *file)
221 Pool *pool = data->repo->pool;
227 if ((dir = strrchr(file, '/')) != 0)
238 if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/'))
243 if (l == 1 && dir[0] == '.')
246 repodata_set_id(data, handle, DELTA_LOCATION_DIR, pool_strn2id(pool, dir, l, 1));
247 if ((p = strrchr(file, '.')) != 0)
250 if ((op = strrchr(file, '.')) != 0)
255 if (!strcmp(p + 1, "delta.rpm") && (op = strrchr(file, '.')) != 0)
262 repodata_set_id(data, handle, DELTA_LOCATION_SUFFIX, pool_str2id(pool, p + 1, 1));
264 if ((p = strrchr(file, '-')) != 0)
267 if ((op = strrchr(file, '-')) != 0)
273 repodata_set_id(data, handle, DELTA_LOCATION_EVR, pool_str2id(pool, p + 1, 1));
275 repodata_set_id(data, handle, DELTA_LOCATION_NAME, pool_str2id(pool, file, 1));
287 id3_cmp(const void *v1, const void *v2, void *dp)
291 return i1[0] - i2[0];
301 commit_diskusage(struct parsedata *pd, Id handle)
304 Dirpool *dp = &pd->data->dirpool;
305 /* Now sort in dirid order. This ensures that parents come before
308 solv_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
309 /* Substract leaf numbers from all parents to make the numbers
310 non-cumulative. This must be done post-order (i.e. all leafs
311 adjusted before parents). We ensure this by starting at the end of
312 the array moving to the start, hence seeing leafs before parents. */
313 for (i = pd->ndirs; i--;)
315 Id p = dirpool_parent(dp, pd->dirs[i][0]);
317 for (; p; p = dirpool_parent(dp, p))
320 if (pd->dirs[j][0] == p)
324 if (pd->dirs[j][1] < pd->dirs[i][1])
327 pd->dirs[j][1] -= pd->dirs[i][1];
328 if (pd->dirs[j][2] < pd->dirs[i][2])
331 pd->dirs[j][2] -= pd->dirs[i][2];
334 /* Haven't found this parent in the list, look further if
335 we maybe find the parents parent. */
342 unsigned slen = sizeof(sbuf);
343 for (i = 0; i < pd->ndirs; i++)
345 dir2str(attr, pd->dirs[i][0], &buf, &slen);
346 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
351 for (i = 0; i < pd->ndirs; i++)
352 if (pd->dirs[i][1] || pd->dirs[i][2])
354 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
360 /* Unfortunately "a"[0] is no constant expression in the C languages,
361 so we need to pass the four characters individually :-/ */
362 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
363 | ((unsigned char)b << 16) \
364 | ((unsigned char)c << 8) \
365 | ((unsigned char)d))
372 static inline unsigned
373 tag_from_string(char *cs)
375 unsigned char *s = (unsigned char *)cs;
376 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
382 * Parse susetags file passed in fp, fill solvables into repo
384 * susetags is key,value based
388 * for long (multi-line) values,
395 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
396 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
397 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
400 * All keys have 3 characters and end in ':'
404 finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens)
406 Pool *pool = pd->repo->pool;
412 for (l = 0; l < pd->nfilelist; l += strlen(pd->filelist + l) + 1)
414 char *p = strrchr(pd->filelist + l, '/');
418 did = repodata_str2dir(pd->data, pd->filelist + l, 1);
421 did = repodata_str2dir(pd->data, "/", 1);
422 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, p);
426 /* A self provide, except for source packages. This is harmless
427 to do twice (in case we see the same package twice). */
428 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
429 s->provides = repo_addid_dep(pd->repo, s->provides,
430 pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
431 /* XXX This uses repo_addid_dep internally, so should also be
432 harmless to do twice. */
433 s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, freshens);
434 s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts);
436 commit_diskusage(pd, handle);
440 joinhash_init(Repo *repo, Hashmask *hmp)
442 Hashmask hm = mkmask(repo->nsolvables);
443 Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
448 FOR_REPO_SOLVABLES(repo, i, s)
450 hh = HASHCHAIN_START;
453 h = HASHCHAIN_NEXT(h, hh, hm);
461 joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch, Id start)
465 if (!name || !arch || !evr)
467 hh = HASHCHAIN_START;
471 Solvable *s = repo->pool->solvables + ht[h];
472 if (ht[h] >= start && s->name == name && s->evr == evr && s->arch == arch)
474 h = HASHCHAIN_NEXT(h, hh, hm);
480 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
483 r = repodata_lookup_type(data, p, keyname);
486 if (r == REPOKEY_TYPE_VOID)
488 r = repodata_lookup_id(data, p, keyname);
493 return repodata_lookup_id_uninternalized(data, p, keyname, voidid);
498 toevr(Pool *pool, struct parsedata *pd, const char *version, const char *release)
500 return makeevr(pool, !release || (release[0] == '-' && !release[1]) ?
501 version : join2(&pd->jd, version, "-", release));
508 * fp: file to read from
509 * defvendor: default vendor (0 if none)
510 * language: current language (0 if none)
515 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
517 Pool *pool = repo->pool;
526 int last_found_pack = 0;
527 Id first_new_pkg = 0;
532 Hashtable joinhash = 0;
533 Hashmask joinhashm = 0;
536 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
538 joinhash = joinhash_init(repo, &joinhashm);
542 data = repo_add_repodata(repo, flags);
544 memset(&pd, 0, sizeof(pd));
545 line = solv_malloc(1024);
552 pd.language = language && *language ? solv_strdup(language) : 0;
558 /* if this is a join setup the recorded share data */
564 FOR_REPODATAS(repo, i, sdata)
567 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
569 for (p = sdata->start; p < sdata->end; p++)
572 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
575 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
578 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
581 if (p - repo->start >= pd.nshare)
583 pd.share_with = solv_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
584 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
585 pd.nshare = p - repo->start + 256;
587 pd.share_with[p - repo->start].name = name;
588 pd.share_with[p - repo->start].evr = evr;
589 pd.share_with[p - repo->start].arch = arch;
597 * collect values in 'struct parsedata pd'
598 * then build .solv (and .attr) file
604 char *olinep; /* old line pointer */
610 if (linep - line + 16 > aline) /* (re-)alloc buffer */
612 aline = linep - line;
613 line = solv_realloc(line, aline + 512);
614 linep = line + aline;
617 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
620 linep += strlen(linep);
621 if (linep == line || linep[-1] != '\n')
630 /* check for multi-line value tags (+Key:/-Key:) */
632 int is_end = (linep[-intag - keylen + 1] == '-')
633 && (linep[-1] == ':')
634 && (linep == line + 1 + intag + 1 + 1 + 1 + intag + 1 || linep[-intag - keylen] == '\n');
636 && strncmp(linep - 1 - intag, line + 1, intag))
638 pool_debug(pool, SOLV_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
640 if (cummulate && !is_end)
645 if (cummulate && is_end)
647 linep[-intag - keylen + 1] = 0;
648 if (linep[-intag - keylen] == '\n')
649 linep[-intag - keylen] = 0;
653 if (!cummulate && is_end)
659 if (!cummulate && !is_end)
660 linep = line + intag + keylen;
665 if (!intag && line[0] == '+' && line[1] && line[1] != ':') /* start of +Key:/-Key: tag */
667 char *tagend = strchr(line, ':');
670 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
673 intag = tagend - (line + 1);
675 switch (tag_from_string(line)) /* check if accumulation is needed */
677 case CTAG('+', 'D', 'e', 's'):
678 case CTAG('+', 'E', 'u', 'l'):
679 case CTAG('+', 'I', 'n', 's'):
680 case CTAG('+', 'D', 'e', 'l'):
681 case CTAG('+', 'A', 'u', 't'):
682 if (line[4] == ':' || line[4] == '.')
688 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
689 line[intag + keylen - 1] = ' ';
690 linep = line + intag + keylen;
693 if (*line == '#' || !*line)
695 if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
701 endlang = strchr(line + 5, ':');
704 int langsize = endlang - (line + 5);
705 keylen = endlang - line - 1;
708 strncpy(line_lang, line + 5, langsize);
709 line_lang[langsize] = 0;
712 tag = tag_from_string(line);
717 =Dlt: subversion 1.6.16 1.3.1 i586
718 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
719 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
720 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
725 case CTAG('=', 'D', 's', 'q'):
728 if (split(line + 5, sp, 5) != 5)
730 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
731 evr = toevr(pool, &pd, sp[1], sp[2]);
732 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
733 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
734 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
735 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
738 case CTAG('=', 'C', 'k', 's'):
739 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
741 case CTAG('=', 'L', 'o', 'c'):
743 int i = split(line + 6, sp, 3);
744 if (i != 2 && i != 3)
746 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
749 set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
752 case CTAG('=', 'S', 'i', 'z'):
753 if (split(line + 6, sp, 3) == 2)
754 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
756 case CTAG('=', 'P', 'k', 'g'):
757 case CTAG('=', 'P', 'a', 't'):
758 case CTAG('=', 'D', 'l', 't'):
763 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
769 * start of (next) package or pattern or delta
771 * =Pkg: <name> <version> <release> <architecture>
774 if (tag == CTAG('=', 'D', 'l', 't'))
777 finish_solvable(&pd, s, handle, freshens);
780 if (split(line + 5, sp, 5) != 4)
782 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
785 handle = repodata_new_handle(data);
786 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
787 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, toevr(pool, &pd, sp[1], sp[2]));
788 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
789 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
793 if (tag == CTAG('=', 'P', 'k', 'g')
794 || tag == CTAG('=', 'P', 'a', 't'))
796 /* If we have an old solvable, complete it by filling in some
799 finish_solvable(&pd, s, handle, freshens);
813 if (split(line + 5, sp, 5) != 4)
815 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
823 /* data join operation. find solvable matching name/arch/evr and
826 /* we don't use the create flag here as a simple pre-check for existance */
828 name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 0);
830 name = pool_str2id(pool, sp[0], 0);
831 evr = toevr(pool, &pd, sp[1], sp[2]);
832 arch = pool_str2id(pool, sp[3], 0);
835 Id start = (flags & REPO_EXTEND_SOLVABLES) ? 0 : first_new_pkg;
836 if (repo->start + last_found_pack + 1 >= start && repo->start + last_found_pack + 1 < repo->end)
838 s = pool->solvables + repo->start + last_found_pack + 1;
839 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
843 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch, start);
845 /* do not create new packages in EXTEND_SOLVABLES mode */
846 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
848 /* fallthrough to package creation */
852 /* normal operation. create a new solvable. */
853 s = pool_id2solvable(pool, repo_add_solvable(repo));
855 s->name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 1);
857 s->name = pool_str2id(pool, sp[0], 1);
858 s->evr = toevr(pool, &pd, sp[1], sp[2]);
859 s->arch = pool_str2id(pool, sp[3], 1);
860 s->vendor = defvendor;
862 first_new_pkg = s - pool->solvables;
865 last_found_pack = (s - pool->solvables) - repo->start;
867 handle = s - pool->solvables;
870 /* If we have no current solvable to add to, ignore all further lines
871 for it. Probably invalid input data in the second set of
873 if (indesc >= 2 && !s)
876 pool_debug(pool, SOLV_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
882 case CTAG('=', 'P', 'r', 'v'): /* provides */
885 /* probably a filelist entry. stash it away for now */
886 int l = strlen(line + 6) + 1;
887 if (pd.nfilelist + l > pd.afilelist)
889 pd.afilelist = pd.nfilelist + l + 512;
890 pd.filelist = solv_realloc(pd.filelist, pd.afilelist);
892 memcpy(pd.filelist + pd.nfilelist, line + 6, l);
899 for (l = 0; l < pd.nfilelist; l += strlen(pd.filelist + l) + 1)
900 s->provides = repo_addid_dep(pd.repo, s->provides, pool_str2id(pool, pd.filelist + l, 1), 0);
903 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
905 case CTAG('=', 'R', 'e', 'q'): /* requires */
906 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
908 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
911 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
914 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
916 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
917 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
919 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
920 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
922 case CTAG('=', 'R', 'e', 'c'): /* recommends */
923 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
925 case CTAG('=', 'S', 'u', 'p'): /* supplements */
926 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
928 case CTAG('=', 'E', 'n', 'h'): /* enhances */
929 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
931 case CTAG('=', 'S', 'u', 'g'): /* suggests */
932 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
934 case CTAG('=', 'F', 'r', 'e'): /* freshens */
935 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
937 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
938 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
940 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
941 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
943 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
944 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
946 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
947 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
949 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
950 freshens = adddep(pool, &pd, freshens, line, 0, 0);
952 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
953 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
955 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
956 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
958 case CTAG('=', 'V', 'e', 'r'): /* - version - */
965 joinhash = joinhash_init(repo, &joinhashm);
969 case CTAG('=', 'V', 'n', 'd'): /* vendor */
970 s->vendor = pool_str2id(pool, line + 6, 1);
973 /* From here it's the attribute tags. */
974 case CTAG('=', 'G', 'r', 'p'):
975 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
977 case CTAG('=', 'L', 'i', 'c'):
978 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
980 case CTAG('=', 'L', 'o', 'c'):
982 int i = split(line + 6, sp, 3);
983 if (i != 2 && i != 3)
985 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
988 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
991 case CTAG('=', 'S', 'r', 'c'):
992 add_source(&pd, line + 6, s, handle);
994 case CTAG('=', 'S', 'i', 'z'):
995 if (split(line + 6, sp, 3) == 2)
997 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
998 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, strtoull(sp[1], 0, 10));
1001 case CTAG('=', 'T', 'i', 'm'):
1003 unsigned int t = atoi(line + 6);
1005 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
1008 case CTAG('=', 'K', 'w', 'd'):
1009 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
1011 case CTAG('=', 'A', 'u', 't'):
1012 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
1014 case CTAG('=', 'S', 'u', 'm'):
1015 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
1017 case CTAG('=', 'D', 'e', 's'):
1018 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
1020 case CTAG('=', 'E', 'u', 'l'):
1021 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
1023 case CTAG('=', 'I', 'n', 's'):
1024 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
1026 case CTAG('=', 'D', 'e', 'l'):
1027 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
1029 case CTAG('=', 'V', 'i', 's'):
1031 /* Accept numbers and textual bools. */
1034 if (k || !strcasecmp(line + 6, "true"))
1035 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
1038 case CTAG('=', 'S', 'h', 'r'):
1041 if (split(line + 6, sp, 5) != 4)
1043 pd.ret = pool_error(pool, -1, "susetags: line %d: bad =Shr line '%s'\n", pd.lineno, line);
1046 name = pool_str2id(pool, sp[0], 1);
1047 evr = toevr(pool, &pd, sp[1], sp[2]);
1048 arch = pool_str2id(pool, sp[3], 1);
1049 if (last_found_pack >= pd.nshare)
1051 pd.share_with = solv_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
1052 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
1053 pd.nshare = last_found_pack + 256;
1055 pd.share_with[last_found_pack].name = name;
1056 pd.share_with[last_found_pack].evr = evr;
1057 pd.share_with[last_found_pack].arch = arch;
1058 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
1060 if (s->name == name)
1061 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
1063 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
1065 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
1067 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
1068 if (s->arch == arch)
1069 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
1071 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
1075 case CTAG('=', 'D', 'i', 'r'):
1076 add_dirline(&pd, line + 6);
1078 case CTAG('=', 'C', 'a', 't'):
1079 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
1081 case CTAG('=', 'O', 'r', 'd'):
1082 /* Order is a string not a number, so we can retroactively insert
1083 new patterns in the middle, i.e. 1 < 15 < 2. */
1084 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1086 case CTAG('=', 'I', 'c', 'o'):
1087 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1089 case CTAG('=', 'E', 'x', 't'):
1090 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2(&pd.jd, "pattern", ":", line + 6));
1092 case CTAG('=', 'I', 'n', 'c'):
1093 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2(&pd.jd, "pattern", ":", line + 6));
1095 case CTAG('=', 'C', 'k', 's'):
1096 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1098 case CTAG('=', 'L', 'a', 'n'):
1099 pd.language = solv_free(pd.language);
1100 memset(pd.langcache, 0, sizeof(pd.langcache));
1102 pd.language = solv_strdup(line + 6);
1105 case CTAG('=', 'F', 'l', 's'):
1107 char *p = strrchr(line + 6, '/');
1109 /* strip trailing slash */
1110 if (p && p != line + 6 && !p[1])
1113 p = strrchr(line + 6, '/');
1118 did = repodata_str2dir(data, line + 6, 1);
1126 did = repodata_str2dir(data, "/", 1);
1127 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1130 case CTAG('=', 'H', 'd', 'r'):
1131 /* rpm header range */
1132 if (split(line + 6, sp, 3) == 2)
1134 /* we ignore the start value */
1135 unsigned int end = (unsigned int)atoi(sp[1]);
1137 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1141 case CTAG('=', 'P', 'a', 't'):
1142 case CTAG('=', 'P', 'k', 'g'):
1146 pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1153 finish_solvable(&pd, s, handle, freshens);
1154 solv_free(pd.filelist);
1156 /* Shared attributes
1157 * (e.g. multiple binaries built from same source)
1164 map_init(&keyidmap, data->nkeys);
1165 for (i = 1; i < data->nkeys; i++)
1167 Id keyname = data->keys[i].name;
1168 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
1170 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
1172 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
1174 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
1176 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
1178 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
1180 MAPSET(&keyidmap, i);
1183 for (i = 0; i < pd.nshare; i++)
1186 Solvable *found = 0;
1187 if (!pd.share_with[i].name)
1189 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
1191 if (nn >= repo->end)
1193 found = pool->solvables + nn;
1194 if (found->repo == repo
1195 && found->name == pd.share_with[i].name
1196 && found->evr == pd.share_with[i].evr
1197 && found->arch == pd.share_with[i].arch)
1199 last_found = nn - repo->start;
1204 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
1206 free(pd.share_with);
1207 map_free(&keyidmap);
1210 solv_free(joinhash);
1211 repodata_free_dircache(data);
1212 if (!(flags & REPO_NO_INTERNALIZE))
1213 repodata_internalize(data);
1215 solv_free(pd.language);
1217 join_freemem(&pd.jd);