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"
32 struct parsedata_common common;
33 int last_found_source;
34 struct datashare *share_with;
36 Id (*dirs)[3]; // dirid, size, nfiles
38 Id langcache[ID_NUM_INTERNAL];
42 static char *flagtab[] = {
53 langtag(struct parsedata *pd, Id tag, const char *language)
55 if (language && !language[0])
57 if (!language || tag >= ID_NUM_INTERNAL)
58 return pool_id2langid(pd->repo->pool, tag, language, 1);
59 return pool_id2langid(pd->repo->pool, tag, language, 1);
60 if (!pd->langcache[tag])
61 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, language, 1);
62 return pd->langcache[tag];
67 * create and add dependency
71 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
79 /* A file dependency. Do not try to parse it */
80 id = str2id(pool, line + 6, 1);
84 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
85 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
87 pool_debug(pool, SAT_FATAL, "susetags: bad dependency line: %d: %s\n", pd->lineno, line);
91 id = str2id(pool, join2(kind, ":", sp[0]), 1);
93 id = str2id(pool, sp[0], 1);
96 evrid = makeevr(pool, sp[2]);
97 for (flags = 0; flags < 6; flags++)
98 if (!strcmp(sp[1], flagtab[flags]))
102 pool_debug(pool, SAT_FATAL, "susetags: unknown relation in %d: '%s'\n", pd->lineno, sp[1]);
105 id = rel2id(pool, id, evrid, flags + 1, 1);
108 return repo_addid_dep(pd->repo, olddeps, id, marker);
118 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
120 Repo *repo = s->repo;
121 Pool *pool = repo->pool;
124 if (split(line, sp, 5) != 4)
126 pool_debug(pool, SAT_FATAL, "susetags: bad source line: %d: %s\n", pd->lineno, line);
130 Id name = str2id(pool, sp[0], 1);
131 Id evr = makeevr(pool, join2(sp[1], "-", sp[2]));
132 Id arch = str2id(pool, sp[3], 1);
133 /* XXX: could record a dep here, depends on where we want to store the data */
135 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
137 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
139 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
141 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
142 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
147 * add a line with directory information
152 add_dirline(struct parsedata *pd, char *line)
155 if (split(line, sp, 6) != 5)
157 pd->dirs = sat_extend(pd->dirs, pd->ndirs, 1, sizeof(pd->dirs[0]), 31);
158 long filesz = strtol(sp[1], 0, 0);
159 filesz += strtol(sp[2], 0, 0);
160 long filenum = strtol(sp[3], 0, 0);
161 filenum += strtol(sp[4], 0, 0);
162 /* hack: we know that there's room for a / */
165 unsigned dirid = repodata_str2dir(pd->data, sp[0], 1);
167 fprintf(stderr, "%s -> %d\n", sp[0], dirid);
169 pd->dirs[pd->ndirs][0] = dirid;
170 pd->dirs[pd->ndirs][1] = filesz;
171 pd->dirs[pd->ndirs][2] = filenum;
176 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
180 if (split(line, sp, 3) != 2)
182 pool_debug(pd->repo->pool, SAT_FATAL, "susetags: bad checksum line: %d: %s\n", pd->lineno, line);
185 type = sat_chksum_str2type(sp[0]);
188 pool_debug(pd->repo->pool, SAT_FATAL, "susetags: unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
191 if (strlen(sp[1]) != 2 * sat_chksum_len(type))
193 pool_debug(pd->repo->pool, SAT_FATAL, "susetags: bad checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
196 repodata_set_checksum(data, handle, keyname, type, sp[1]);
206 id3_cmp(const void *v1, const void *v2, void *dp)
210 return i1[0] - i2[0];
220 commit_diskusage(struct parsedata *pd, Id handle)
223 Dirpool *dp = &pd->data->dirpool;
224 /* Now sort in dirid order. This ensures that parents come before
227 sat_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
228 /* Substract leaf numbers from all parents to make the numbers
229 non-cumulative. This must be done post-order (i.e. all leafs
230 adjusted before parents). We ensure this by starting at the end of
231 the array moving to the start, hence seeing leafs before parents. */
232 for (i = pd->ndirs; i--;)
234 unsigned p = dirpool_parent(dp, pd->dirs[i][0]);
236 for (; p; p = dirpool_parent(dp, p))
239 if (pd->dirs[j][0] == p)
243 if (pd->dirs[j][1] < pd->dirs[i][1])
246 pd->dirs[j][1] -= pd->dirs[i][1];
247 if (pd->dirs[j][2] < pd->dirs[i][2])
250 pd->dirs[j][2] -= pd->dirs[i][2];
253 /* Haven't found this parent in the list, look further if
254 we maybe find the parents parent. */
261 unsigned slen = sizeof(sbuf);
262 for (i = 0; i < pd->ndirs; i++)
264 dir2str(attr, pd->dirs[i][0], &buf, &slen);
265 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
270 for (i = 0; i < pd->ndirs; i++)
271 if (pd->dirs[i][1] || pd->dirs[i][2])
273 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
279 /* Unfortunately "a"[0] is no constant expression in the C languages,
280 so we need to pass the four characters individually :-/ */
281 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
282 | ((unsigned char)b << 16) \
283 | ((unsigned char)c << 8) \
284 | ((unsigned char)d))
291 static inline unsigned
292 tag_from_string(char *cs)
294 unsigned char *s = (unsigned char *)cs;
295 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
301 * Parse susetags file passed in fp, fill solvables into repo
303 * susetags is key,value based
307 * for long (multi-line) values,
314 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
315 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
316 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
319 * All keys have 3 characters and end in ':'
323 finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens)
325 Pool *pool = pd->repo->pool;
328 /* move file provides to filelist */
329 /* relies on the fact that rpm inserts self-provides at the end */
330 if (s->provides && (pd->flags & REPO_EXTEND_SOLVABLES) == 0)
332 Id *p, *lastreal, did;
333 const char *str, *sp;
334 lastreal = pd->repo->idarraydata + s->provides;
335 for (p = lastreal; *p; p++)
338 for (p = lastreal; *p; p++)
340 str = id2str(pool, *p);
346 for (p = lastreal; *p; p++)
350 str = id2str(pool, *p);
351 sp = strrchr(str, '/');
352 /* Need to copy filename now, before we add string that could
353 realloc the stringspace (and hence invalidate str). */
355 if (strlen(fname) >= 128)
356 fname = strdup(fname);
359 memcpy(fname_buf, fname, strlen(fname) + 1);
364 char *sdup = strdup(str);
366 did = repodata_str2dir(pd->data, sdup, 1);
372 strncpy(sdup, str, sp - str);
374 did = repodata_str2dir(pd->data, sdup, 1);
377 did = repodata_str2dir(pd->data, "/", 1);
378 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, fname);
379 if (fname != fname_buf)
386 /* A self provide, except for source packages. This is harmless
387 to do twice (in case we see the same package twice). */
388 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
389 s->provides = repo_addid_dep(pd->repo, s->provides,
390 rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
391 /* XXX This uses repo_addid_dep internally, so should also be
392 harmless to do twice. */
393 s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, freshens);
394 s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts);
396 commit_diskusage(pd, handle);
400 joinhash_init(Repo *repo, Hashmask *hmp)
402 Hashmask hm = mkmask(repo->nsolvables);
403 Hashtable ht = sat_calloc(hm + 1, sizeof(*ht));
408 FOR_REPO_SOLVABLES(repo, i, s)
410 hh = HASHCHAIN_START;
413 h = HASHCHAIN_NEXT(h, hh, hm);
421 joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch)
425 if (!name || !arch || !evr)
427 hh = HASHCHAIN_START;
431 Solvable *s = repo->pool->solvables + ht[h];
432 if (s->name == name && s->evr == evr && s->arch == arch)
434 h = HASHCHAIN_NEXT(h, hh, hm);
440 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
443 r = repodata_lookup_type(data, p, keyname);
446 if (r == REPOKEY_TYPE_VOID)
448 r = repodata_lookup_id(data, p, keyname);
452 if (uninternalized && data->attrs)
454 Id *ap = data->attrs[p - data->start];
459 if (data->keys[*ap].name != keyname)
461 if (data->keys[*ap].type == REPOKEY_TYPE_VOID)
463 if (data->keys[*ap].type == REPOKEY_TYPE_ID)
474 * fp: file to read from
475 * defvendor: default vendor (0 if none)
476 * language: current language (0 if none)
481 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
483 Pool *pool = repo->pool;
491 int last_found_pack = 0;
496 Hashtable joinhash = 0;
497 Hashmask joinhashm = 0;
500 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
502 joinhash = joinhash_init(repo, &joinhashm);
506 data = repo_add_repodata(repo, flags);
508 memset(&pd, 0, sizeof(pd));
512 pd.repo = pd.common.repo = repo;
514 pd.common.pool = pool;
521 /* if this is a join setup the recorded share data */
526 for (i = 0, sdata = repo->repodata; i < repo->nrepodata; i++, sdata++)
529 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
531 for (p = sdata->start; p < sdata->end; p++)
534 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
537 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
540 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
543 if (p - repo->start >= pd.nshare)
545 pd.share_with = sat_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
546 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
547 pd.nshare = p - repo->start + 256;
549 pd.share_with[p - repo->start].name = name;
550 pd.share_with[p - repo->start].evr = evr;
551 pd.share_with[p - repo->start].arch = arch;
559 * collect values in 'struct parsedata pd'
560 * then build .solv (and .attr) file
566 char *olinep; /* old line pointer */
569 if (linep - line + 16 > aline) /* (re-)alloc buffer */
571 aline = linep - line;
572 line = realloc(line, aline + 512);
573 linep = line + aline;
576 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
579 linep += strlen(linep);
580 if (linep == line || linep[-1] != '\n')
589 /* check for multi-line value tags (+Key:/-Key:) */
591 int is_end = (linep[-intag - keylen + 1] == '-')
592 && (linep[-1] == ':')
593 && (linep == line + 1 + intag + 1 + 1 + 1 + intag + 1 || linep[-intag - keylen] == '\n');
595 && strncmp(linep - 1 - intag, line + 1, intag))
597 pool_debug(pool, SAT_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
599 if (cummulate && !is_end)
604 if (cummulate && is_end)
606 linep[-intag - keylen + 1] = 0;
607 if (linep[-intag - keylen] == '\n')
608 linep[-intag - keylen] = 0;
612 if (!cummulate && is_end)
618 if (!cummulate && !is_end)
619 linep = line + intag + keylen;
624 if (!intag && line[0] == '+' && line[1] && line[1] != ':') /* start of +Key:/-Key: tag */
626 char *tagend = strchr(line, ':');
629 pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
632 intag = tagend - (line + 1);
634 switch (tag_from_string(line)) /* check if accumulation is needed */
636 case CTAG('+', 'D', 'e', 's'):
637 case CTAG('+', 'E', 'u', 'l'):
638 case CTAG('+', 'I', 'n', 's'):
639 case CTAG('+', 'D', 'e', 'l'):
640 case CTAG('+', 'A', 'u', 't'):
647 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
648 line[intag + keylen - 1] = ' ';
649 linep = line + intag + keylen;
652 if (*line == '#' || !*line)
654 if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
659 endlang = strchr(line + 5, ':');
662 keylen = endlang - line - 1;
663 strncpy(line_lang, line + 5, 5);
664 line_lang[endlang - line - 5] = 0;
669 tag = tag_from_string(line);
673 * start of (next) package or pattern
675 * =Pkg: <name> <version> <release> <architecture>
679 if ((tag == CTAG('=', 'P', 'k', 'g')
680 || tag == CTAG('=', 'P', 'a', 't')))
682 /* If we have an old solvable, complete it by filling in some
685 finish_solvable(&pd, s, handle, freshens);
699 if (split(line + 5, sp, 5) != 4)
701 pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
709 /* data join operation. find solvable matching name/arch/evr and
712 /* we don't use the create flag here as a simple pre-check for existance */
714 name = str2id(pool, join2(pd.kind, ":", sp[0]), 0);
716 name = str2id(pool, sp[0], 0);
717 evr = makeevr(pool, join2(sp[1], "-", sp[2]));
718 arch = str2id(pool, sp[3], 0);
721 if (repo->start + last_found_pack + 1 < repo->end)
723 s = pool->solvables + repo->start + last_found_pack + 1;
724 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
728 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch);
730 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
732 /* fallthrough to package creation */
736 /* normal operation. create a new solvable. */
737 s = pool_id2solvable(pool, repo_add_solvable(repo));
739 s->name = str2id(pool, join2(pd.kind, ":", sp[0]), 1);
741 s->name = str2id(pool, sp[0], 1);
742 s->evr = makeevr(pool, join2(sp[1], "-", sp[2]));
743 s->arch = str2id(pool, sp[3], 1);
744 s->vendor = defvendor;
747 last_found_pack = (s - pool->solvables) - repo->start;
749 handle = s - pool->solvables;
752 /* If we have no current solvable to add to, ignore all further lines
753 for it. Probably invalid input data in the second set of
755 if (indesc >= 2 && !s)
758 pool_debug(pool, SAT_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
764 case CTAG('=', 'P', 'r', 'v'): /* provides */
765 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
767 case CTAG('=', 'R', 'e', 'q'): /* requires */
768 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
770 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
773 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
776 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
778 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
779 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
781 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
782 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
784 case CTAG('=', 'R', 'e', 'c'): /* recommends */
785 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
787 case CTAG('=', 'S', 'u', 'p'): /* supplements */
788 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
790 case CTAG('=', 'E', 'n', 'h'): /* enhances */
791 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
793 case CTAG('=', 'S', 'u', 'g'): /* suggests */
794 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
796 case CTAG('=', 'F', 'r', 'e'): /* freshens */
797 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
799 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
800 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
802 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
803 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
805 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
806 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
808 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
809 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
811 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
812 freshens = adddep(pool, &pd, freshens, line, 0, 0);
814 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
815 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
817 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
818 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
820 case CTAG('=', 'V', 'e', 'r'): /* - version - */
827 joinhash = joinhash_init(repo, &joinhashm);
831 case CTAG('=', 'V', 'n', 'd'): /* vendor */
832 s->vendor = str2id(pool, line + 6, 1);
835 /* From here it's the attribute tags. */
836 case CTAG('=', 'G', 'r', 'p'):
837 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
839 case CTAG('=', 'L', 'i', 'c'):
840 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
842 case CTAG('=', 'L', 'o', 'c'):
844 int i = split(line + 6, sp, 3);
845 if (i != 2 && i != 3)
847 pool_debug(pool, SAT_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
850 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : id2str(pool, s->arch), sp[1]);
853 case CTAG('=', 'S', 'r', 'c'):
854 add_source(&pd, line + 6, s, handle);
856 case CTAG('=', 'S', 'i', 'z'):
857 if (split(line + 6, sp, 3) == 2)
859 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
860 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, (unsigned int)(atoi(sp[1]) + 1023) / 1024);
863 case CTAG('=', 'T', 'i', 'm'):
865 unsigned int t = atoi(line + 6);
867 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
870 case CTAG('=', 'K', 'w', 'd'):
871 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
873 case CTAG('=', 'A', 'u', 't'):
874 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
876 case CTAG('=', 'S', 'u', 'm'):
877 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, language ? language : line_lang), line + 3 + keylen );
879 case CTAG('=', 'D', 'e', 's'):
880 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, language ? language : line_lang), line + 3 + keylen );
882 case CTAG('=', 'E', 'u', 'l'):
883 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, language), line + 6);
885 case CTAG('=', 'I', 'n', 's'):
886 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, language), line + 6);
888 case CTAG('=', 'D', 'e', 'l'):
889 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, language), line + 6);
891 case CTAG('=', 'V', 'i', 's'):
893 /* Accept numbers and textual bools. */
896 if (k || !strcasecmp(line + 6, "true"))
897 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE );
900 case CTAG('=', 'S', 'h', 'r'):
903 if (split(line + 6, sp, 5) != 4)
905 pool_debug(pool, SAT_FATAL, "susetags: bad =Shr line: %s\n", line + 6);
908 name = str2id(pool, sp[0], 1);
909 evr = makeevr(pool, join2(sp[1], "-", sp[2]));
910 arch = str2id(pool, sp[3], 1);
911 if (last_found_pack >= pd.nshare)
913 pd.share_with = sat_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
914 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
915 pd.nshare = last_found_pack + 256;
917 pd.share_with[last_found_pack].name = name;
918 pd.share_with[last_found_pack].evr = evr;
919 pd.share_with[last_found_pack].arch = arch;
920 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
923 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
925 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
927 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
929 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
931 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
933 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
937 case CTAG('=', 'D', 'i', 'r'):
938 add_dirline(&pd, line + 6);
940 case CTAG('=', 'C', 'a', 't'):
941 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
943 case CTAG('=', 'O', 'r', 'd'):
944 /* Order is a string not a number, so we can retroactively insert
945 new patterns in the middle, i.e. 1 < 15 < 2. */
946 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
948 case CTAG('=', 'I', 'c', 'o'):
949 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
951 case CTAG('=', 'E', 'x', 't'):
952 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2("pattern", ":", line + 6));
954 case CTAG('=', 'I', 'n', 'c'):
955 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2("pattern", ":", line + 6));
957 case CTAG('=', 'C', 'k', 's'):
958 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
960 case CTAG('=', 'L', 'a', 'n'):
961 language = strdup(line + 6);
964 case CTAG('=', 'F', 'l', 's'):
966 char *p = strrchr(line + 6, '/');
968 if (p && p != line + 6 && !p[1])
971 p = strrchr(line + 6, '/');
976 did = repodata_str2dir(data, line + 6, 1);
984 did = repodata_str2dir(data, "/", 1);
985 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
988 case CTAG('=', 'H', 'd', 'r'):
989 /* rpm header range */
990 if (split(line + 6, sp, 3) == 2)
992 /* we ignore the start value */
993 unsigned int end = (unsigned int)atoi(sp[1]);
995 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
999 case CTAG('=', 'P', 'a', 't'):
1000 case CTAG('=', 'P', 'k', 'g'):
1004 pool_debug(pool, SAT_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1011 finish_solvable(&pd, s, handle, freshens);
1013 /* Shared attributes
1014 * (e.g. multiple binaries built from same source)
1021 map_init(&keyidmap, data->nkeys);
1022 for (i = 1; i < data->nkeys; i++)
1024 Id keyname = data->keys[i].name;
1025 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
1027 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
1029 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
1031 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
1033 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
1035 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
1037 MAPSET(&keyidmap, i);
1040 for (i = 0; i < pd.nshare; i++)
1043 Solvable *found = 0;
1044 if (!pd.share_with[i].name)
1046 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
1048 if (nn >= repo->end)
1050 found = pool->solvables + nn;
1051 if (found->repo == repo
1052 && found->name == pd.share_with[i].name
1053 && found->evr == pd.share_with[i].evr
1054 && found->arch == pd.share_with[i].arch)
1056 last_found = nn - repo->start;
1061 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
1063 free(pd.share_with);
1064 map_free(&keyidmap);
1068 if (!(flags & REPO_NO_INTERNALIZE))
1069 repodata_internalize(data);
1072 free(pd.common.tmp);