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 */
44 int afilelist; /* allocated */
45 int nfilelist; /* used */
48 static char *flagtab[] = {
59 langtag(struct parsedata *pd, Id tag, const char *language)
61 if (language && *language)
62 return pool_id2langid(pd->repo->pool, tag, language, 1);
65 if (tag >= ID_NUM_INTERNAL)
66 return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
67 if (!pd->langcache[tag])
68 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
69 return pd->langcache[tag];
74 * create and add dependency
78 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
86 /* A file dependency. Do not try to parse it */
87 id = pool_str2id(pool, line + 6, 1);
91 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
92 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
94 pool_debug(pool, SOLV_FATAL, "susetags: bad dependency line: %d: %s\n", pd->lineno, line);
98 id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
100 id = pool_str2id(pool, sp[0], 1);
103 evrid = makeevr(pool, sp[2]);
104 for (flags = 0; flags < 6; flags++)
105 if (!strcmp(sp[1], flagtab[flags]))
109 if (!strcmp(sp[1], "<>"))
113 pool_debug(pool, SOLV_FATAL, "susetags: unknown relation in %d: '%s'\n", pd->lineno, sp[1]);
117 id = pool_rel2id(pool, id, evrid, flags + 1, 1);
120 return repo_addid_dep(pd->repo, olddeps, id, marker);
130 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
132 Repo *repo = s->repo;
133 Pool *pool = repo->pool;
139 if (split(line, sp, 5) != 4)
141 pool_debug(pool, SOLV_FATAL, "susetags: bad source line: %d: %s\n", pd->lineno, line);
145 name = pool_str2id(pool, sp[0], 1);
146 evr = makeevr(pool, join2(&pd->jd, sp[1], "-", sp[2]));
147 arch = pool_str2id(pool, sp[3], 1);
148 /* XXX: could record a dep here, depends on where we want to store the data */
150 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
152 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
154 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
156 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, evr);
157 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
162 * add a line with directory information
167 add_dirline(struct parsedata *pd, char *line)
173 if (split(line, sp, 6) != 5)
175 pd->dirs = solv_extend(pd->dirs, pd->ndirs, 1, sizeof(pd->dirs[0]), 31);
176 filesz = strtol(sp[1], 0, 0);
177 filesz += strtol(sp[2], 0, 0);
178 filenum = strtol(sp[3], 0, 0);
179 filenum += strtol(sp[4], 0, 0);
180 /* hack: we know that there's room for a / */
183 dirid = repodata_str2dir(pd->data, sp[0], 1);
185 fprintf(stderr, "%s -> %d\n", sp[0], dirid);
187 pd->dirs[pd->ndirs][0] = dirid;
188 pd->dirs[pd->ndirs][1] = filesz;
189 pd->dirs[pd->ndirs][2] = filenum;
194 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
198 if (split(line, sp, 3) != 2)
200 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum line: %d: %s\n", pd->lineno, line);
203 type = solv_chksum_str2type(sp[0]);
206 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: unknown checksum type: %d: %s\n", pd->lineno, sp[0]);
209 if (strlen(sp[1]) != 2 * solv_chksum_len(type))
211 pool_debug(pd->repo->pool, SOLV_FATAL, "susetags: bad checksum length: %d: for %s: %s\n", pd->lineno, sp[0], sp[1]);
214 repodata_set_checksum(data, handle, keyname, type, sp[1]);
218 set_delta_location(Repodata *data, Id handle, int medianr, char *dir, char *file)
220 Pool *pool = data->repo->pool;
226 if ((dir = strrchr(file, '/')) != 0)
237 if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/'))
242 if (l == 1 && dir[0] == '.')
245 repodata_set_id(data, handle, DELTA_LOCATION_DIR, pool_strn2id(pool, dir, l, 1));
246 if ((p = strrchr(file, '.')) != 0)
249 if ((op = strrchr(file, '.')) != 0)
254 if (!strcmp(p + 1, "delta.rpm") && (op = strrchr(file, '.')) != 0)
261 repodata_set_id(data, handle, DELTA_LOCATION_SUFFIX, pool_str2id(pool, p + 1, 1));
263 if ((p = strrchr(file, '-')) != 0)
266 if ((op = strrchr(file, '-')) != 0)
272 repodata_set_id(data, handle, DELTA_LOCATION_EVR, pool_str2id(pool, p + 1, 1));
274 repodata_set_id(data, handle, DELTA_LOCATION_NAME, pool_str2id(pool, file, 1));
286 id3_cmp(const void *v1, const void *v2, void *dp)
290 return i1[0] - i2[0];
300 commit_diskusage(struct parsedata *pd, Id handle)
303 Dirpool *dp = &pd->data->dirpool;
304 /* Now sort in dirid order. This ensures that parents come before
307 solv_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
308 /* Substract leaf numbers from all parents to make the numbers
309 non-cumulative. This must be done post-order (i.e. all leafs
310 adjusted before parents). We ensure this by starting at the end of
311 the array moving to the start, hence seeing leafs before parents. */
312 for (i = pd->ndirs; i--;)
314 Id p = dirpool_parent(dp, pd->dirs[i][0]);
316 for (; p; p = dirpool_parent(dp, p))
319 if (pd->dirs[j][0] == p)
323 if (pd->dirs[j][1] < pd->dirs[i][1])
326 pd->dirs[j][1] -= pd->dirs[i][1];
327 if (pd->dirs[j][2] < pd->dirs[i][2])
330 pd->dirs[j][2] -= pd->dirs[i][2];
333 /* Haven't found this parent in the list, look further if
334 we maybe find the parents parent. */
341 unsigned slen = sizeof(sbuf);
342 for (i = 0; i < pd->ndirs; i++)
344 dir2str(attr, pd->dirs[i][0], &buf, &slen);
345 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
350 for (i = 0; i < pd->ndirs; i++)
351 if (pd->dirs[i][1] || pd->dirs[i][2])
353 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
359 /* Unfortunately "a"[0] is no constant expression in the C languages,
360 so we need to pass the four characters individually :-/ */
361 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
362 | ((unsigned char)b << 16) \
363 | ((unsigned char)c << 8) \
364 | ((unsigned char)d))
371 static inline unsigned
372 tag_from_string(char *cs)
374 unsigned char *s = (unsigned char *)cs;
375 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
381 * Parse susetags file passed in fp, fill solvables into repo
383 * susetags is key,value based
387 * for long (multi-line) values,
394 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
395 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
396 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
399 * All keys have 3 characters and end in ':'
403 finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens)
405 Pool *pool = pd->repo->pool;
411 for (l = 0; l < pd->nfilelist; l += strlen(pd->filelist + l) + 1)
413 char *p = strrchr(pd->filelist + l, '/');
417 did = repodata_str2dir(pd->data, pd->filelist + l, 1);
420 did = repodata_str2dir(pd->data, "/", 1);
421 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, p);
425 /* A self provide, except for source packages. This is harmless
426 to do twice (in case we see the same package twice). */
427 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
428 s->provides = repo_addid_dep(pd->repo, s->provides,
429 pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
430 /* XXX This uses repo_addid_dep internally, so should also be
431 harmless to do twice. */
432 s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, freshens);
433 s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts);
435 commit_diskusage(pd, handle);
439 joinhash_init(Repo *repo, Hashmask *hmp)
441 Hashmask hm = mkmask(repo->nsolvables);
442 Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
447 FOR_REPO_SOLVABLES(repo, i, s)
449 hh = HASHCHAIN_START;
452 h = HASHCHAIN_NEXT(h, hh, hm);
460 joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch)
464 if (!name || !arch || !evr)
466 hh = HASHCHAIN_START;
470 Solvable *s = repo->pool->solvables + ht[h];
471 if (s->name == name && s->evr == evr && s->arch == arch)
473 h = HASHCHAIN_NEXT(h, hh, hm);
479 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
482 r = repodata_lookup_type(data, p, keyname);
485 if (r == REPOKEY_TYPE_VOID)
487 r = repodata_lookup_id(data, p, keyname);
492 return repodata_lookup_id_uninternalized(data, p, keyname, voidid);
497 toevr(Pool *pool, struct parsedata *pd, const char *version, const char *release)
499 return makeevr(pool, !release || (release[0] == '-' && !release[1]) ?
500 version : join2(&pd->jd, version, "-", release));
507 * fp: file to read from
508 * defvendor: default vendor (0 if none)
509 * language: current language (0 if none)
514 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
516 Pool *pool = repo->pool;
525 int last_found_pack = 0;
530 Hashtable joinhash = 0;
531 Hashmask joinhashm = 0;
534 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
536 joinhash = joinhash_init(repo, &joinhashm);
540 data = repo_add_repodata(repo, flags);
542 memset(&pd, 0, sizeof(pd));
543 line = solv_malloc(1024);
550 pd.language = language && *language ? solv_strdup(language) : 0;
556 /* if this is a join setup the recorded share data */
562 FOR_REPODATAS(repo, i, sdata)
565 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
567 for (p = sdata->start; p < sdata->end; p++)
570 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
573 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
576 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
579 if (p - repo->start >= pd.nshare)
581 pd.share_with = solv_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
582 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
583 pd.nshare = p - repo->start + 256;
585 pd.share_with[p - repo->start].name = name;
586 pd.share_with[p - repo->start].evr = evr;
587 pd.share_with[p - repo->start].arch = arch;
595 * collect values in 'struct parsedata pd'
596 * then build .solv (and .attr) file
602 char *olinep; /* old line pointer */
605 if (linep - line + 16 > aline) /* (re-)alloc buffer */
607 aline = linep - line;
608 line = solv_realloc(line, aline + 512);
609 linep = line + aline;
612 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
615 linep += strlen(linep);
616 if (linep == line || linep[-1] != '\n')
625 /* check for multi-line value tags (+Key:/-Key:) */
627 int is_end = (linep[-intag - keylen + 1] == '-')
628 && (linep[-1] == ':')
629 && (linep == line + 1 + intag + 1 + 1 + 1 + intag + 1 || linep[-intag - keylen] == '\n');
631 && strncmp(linep - 1 - intag, line + 1, intag))
633 pool_debug(pool, SOLV_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
635 if (cummulate && !is_end)
640 if (cummulate && is_end)
642 linep[-intag - keylen + 1] = 0;
643 if (linep[-intag - keylen] == '\n')
644 linep[-intag - keylen] = 0;
648 if (!cummulate && is_end)
654 if (!cummulate && !is_end)
655 linep = line + intag + keylen;
660 if (!intag && line[0] == '+' && line[1] && line[1] != ':') /* start of +Key:/-Key: tag */
662 char *tagend = strchr(line, ':');
665 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
668 intag = tagend - (line + 1);
670 switch (tag_from_string(line)) /* check if accumulation is needed */
672 case CTAG('+', 'D', 'e', 's'):
673 case CTAG('+', 'E', 'u', 'l'):
674 case CTAG('+', 'I', 'n', 's'):
675 case CTAG('+', 'D', 'e', 'l'):
676 case CTAG('+', 'A', 'u', 't'):
677 if (line[4] == ':' || line[4] == '.')
683 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
684 line[intag + keylen - 1] = ' ';
685 linep = line + intag + keylen;
688 if (*line == '#' || !*line)
690 if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
696 endlang = strchr(line + 5, ':');
699 int langsize = endlang - (line + 5);
700 keylen = endlang - line - 1;
703 strncpy(line_lang, line + 5, langsize);
704 line_lang[langsize] = 0;
707 tag = tag_from_string(line);
712 =Dlt: subversion 1.6.16 1.3.1 i586
713 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
714 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
715 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
720 case CTAG('=', 'D', 's', 'q'):
723 if (split(line + 5, sp, 5) != 5)
725 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
726 evr = toevr(pool, &pd, sp[1], sp[2]);
727 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
728 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
729 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
730 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
733 case CTAG('=', 'C', 'k', 's'):
734 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
736 case CTAG('=', 'L', 'o', 'c'):
738 int i = split(line + 6, sp, 3);
739 if (i != 2 && i != 3)
741 pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
744 set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
747 case CTAG('=', 'S', 'i', 'z'):
748 if (split(line + 6, sp, 3) == 2)
749 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
751 case CTAG('=', 'P', 'k', 'g'):
752 case CTAG('=', 'P', 'a', 't'):
753 case CTAG('=', 'D', 'l', 't'):
758 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
764 * start of (next) package or pattern or delta
766 * =Pkg: <name> <version> <release> <architecture>
769 if (tag == CTAG('=', 'D', 'l', 't'))
772 finish_solvable(&pd, s, handle, freshens);
775 if (split(line + 5, sp, 5) != 4)
777 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
780 handle = repodata_new_handle(data);
781 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
782 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, toevr(pool, &pd, sp[1], sp[2]));
783 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
784 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
788 if (tag == CTAG('=', 'P', 'k', 'g')
789 || tag == CTAG('=', 'P', 'a', 't'))
791 /* If we have an old solvable, complete it by filling in some
794 finish_solvable(&pd, s, handle, freshens);
808 if (split(line + 5, sp, 5) != 4)
810 pool_debug(pool, SOLV_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
818 /* data join operation. find solvable matching name/arch/evr and
821 /* we don't use the create flag here as a simple pre-check for existance */
823 name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 0);
825 name = pool_str2id(pool, sp[0], 0);
826 evr = toevr(pool, &pd, sp[1], sp[2]);
827 arch = pool_str2id(pool, sp[3], 0);
830 if (repo->start + last_found_pack + 1 < repo->end)
832 s = pool->solvables + repo->start + last_found_pack + 1;
833 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
837 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch);
839 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
841 /* fallthrough to package creation */
845 /* normal operation. create a new solvable. */
846 s = pool_id2solvable(pool, repo_add_solvable(repo));
848 s->name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 1);
850 s->name = pool_str2id(pool, sp[0], 1);
851 s->evr = toevr(pool, &pd, sp[1], sp[2]);
852 s->arch = pool_str2id(pool, sp[3], 1);
853 s->vendor = defvendor;
856 last_found_pack = (s - pool->solvables) - repo->start;
858 handle = s - pool->solvables;
861 /* If we have no current solvable to add to, ignore all further lines
862 for it. Probably invalid input data in the second set of
864 if (indesc >= 2 && !s)
867 pool_debug(pool, SOLV_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
873 case CTAG('=', 'P', 'r', 'v'): /* provides */
876 /* probably a filelist entry. stash it away for now */
877 int l = strlen(line + 6) + 1;
878 if (pd.nfilelist + l > pd.afilelist)
880 pd.afilelist = pd.nfilelist + l + 512;
881 pd.filelist = solv_realloc(pd.filelist, pd.afilelist);
883 memcpy(pd.filelist + pd.nfilelist, line + 6, l);
890 for (l = 0; l < pd.nfilelist; l += strlen(pd.filelist + l) + 1)
891 s->provides = repo_addid_dep(pd.repo, s->provides, pool_str2id(pool, pd.filelist + l, 1), 0);
894 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
896 case CTAG('=', 'R', 'e', 'q'): /* requires */
897 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
899 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
902 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
905 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
907 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
908 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
910 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
911 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
913 case CTAG('=', 'R', 'e', 'c'): /* recommends */
914 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
916 case CTAG('=', 'S', 'u', 'p'): /* supplements */
917 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
919 case CTAG('=', 'E', 'n', 'h'): /* enhances */
920 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
922 case CTAG('=', 'S', 'u', 'g'): /* suggests */
923 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
925 case CTAG('=', 'F', 'r', 'e'): /* freshens */
926 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
928 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
929 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
931 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
932 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
934 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
935 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
937 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
938 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
940 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
941 freshens = adddep(pool, &pd, freshens, line, 0, 0);
943 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
944 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
946 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
947 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
949 case CTAG('=', 'V', 'e', 'r'): /* - version - */
956 joinhash = joinhash_init(repo, &joinhashm);
960 case CTAG('=', 'V', 'n', 'd'): /* vendor */
961 s->vendor = pool_str2id(pool, line + 6, 1);
964 /* From here it's the attribute tags. */
965 case CTAG('=', 'G', 'r', 'p'):
966 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
968 case CTAG('=', 'L', 'i', 'c'):
969 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
971 case CTAG('=', 'L', 'o', 'c'):
973 int i = split(line + 6, sp, 3);
974 if (i != 2 && i != 3)
976 pool_debug(pool, SOLV_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
979 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
982 case CTAG('=', 'S', 'r', 'c'):
983 add_source(&pd, line + 6, s, handle);
985 case CTAG('=', 'S', 'i', 'z'):
986 if (split(line + 6, sp, 3) == 2)
988 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
989 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, (unsigned int)(atoi(sp[1]) + 1023) / 1024);
992 case CTAG('=', 'T', 'i', 'm'):
994 unsigned int t = atoi(line + 6);
996 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
999 case CTAG('=', 'K', 'w', 'd'):
1000 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
1002 case CTAG('=', 'A', 'u', 't'):
1003 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
1005 case CTAG('=', 'S', 'u', 'm'):
1006 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
1008 case CTAG('=', 'D', 'e', 's'):
1009 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
1011 case CTAG('=', 'E', 'u', 'l'):
1012 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
1014 case CTAG('=', 'I', 'n', 's'):
1015 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
1017 case CTAG('=', 'D', 'e', 'l'):
1018 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
1020 case CTAG('=', 'V', 'i', 's'):
1022 /* Accept numbers and textual bools. */
1025 if (k || !strcasecmp(line + 6, "true"))
1026 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
1029 case CTAG('=', 'S', 'h', 'r'):
1032 if (split(line + 6, sp, 5) != 4)
1034 pool_debug(pool, SOLV_FATAL, "susetags: bad =Shr line: %s\n", line + 6);
1037 name = pool_str2id(pool, sp[0], 1);
1038 evr = toevr(pool, &pd, sp[1], sp[2]);
1039 arch = pool_str2id(pool, sp[3], 1);
1040 if (last_found_pack >= pd.nshare)
1042 pd.share_with = solv_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
1043 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
1044 pd.nshare = last_found_pack + 256;
1046 pd.share_with[last_found_pack].name = name;
1047 pd.share_with[last_found_pack].evr = evr;
1048 pd.share_with[last_found_pack].arch = arch;
1049 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
1051 if (s->name == name)
1052 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
1054 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
1056 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
1058 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
1059 if (s->arch == arch)
1060 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
1062 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
1066 case CTAG('=', 'D', 'i', 'r'):
1067 add_dirline(&pd, line + 6);
1069 case CTAG('=', 'C', 'a', 't'):
1070 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
1072 case CTAG('=', 'O', 'r', 'd'):
1073 /* Order is a string not a number, so we can retroactively insert
1074 new patterns in the middle, i.e. 1 < 15 < 2. */
1075 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1077 case CTAG('=', 'I', 'c', 'o'):
1078 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1080 case CTAG('=', 'E', 'x', 't'):
1081 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2(&pd.jd, "pattern", ":", line + 6));
1083 case CTAG('=', 'I', 'n', 'c'):
1084 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2(&pd.jd, "pattern", ":", line + 6));
1086 case CTAG('=', 'C', 'k', 's'):
1087 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1089 case CTAG('=', 'L', 'a', 'n'):
1090 pd.language = solv_free(pd.language);
1091 memset(pd.langcache, 0, sizeof(pd.langcache));
1093 pd.language = solv_strdup(line + 6);
1096 case CTAG('=', 'F', 'l', 's'):
1098 char *p = strrchr(line + 6, '/');
1100 /* strip trailing slash */
1101 if (p && p != line + 6 && !p[1])
1104 p = strrchr(line + 6, '/');
1109 did = repodata_str2dir(data, line + 6, 1);
1117 did = repodata_str2dir(data, "/", 1);
1118 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1121 case CTAG('=', 'H', 'd', 'r'):
1122 /* rpm header range */
1123 if (split(line + 6, sp, 3) == 2)
1125 /* we ignore the start value */
1126 unsigned int end = (unsigned int)atoi(sp[1]);
1128 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1132 case CTAG('=', 'P', 'a', 't'):
1133 case CTAG('=', 'P', 'k', 'g'):
1137 pool_debug(pool, SOLV_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1144 finish_solvable(&pd, s, handle, freshens);
1145 solv_free(pd.filelist);
1147 /* Shared attributes
1148 * (e.g. multiple binaries built from same source)
1155 map_init(&keyidmap, data->nkeys);
1156 for (i = 1; i < data->nkeys; i++)
1158 Id keyname = data->keys[i].name;
1159 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
1161 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
1163 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
1165 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
1167 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
1169 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
1171 MAPSET(&keyidmap, i);
1174 for (i = 0; i < pd.nshare; i++)
1177 Solvable *found = 0;
1178 if (!pd.share_with[i].name)
1180 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
1182 if (nn >= repo->end)
1184 found = pool->solvables + nn;
1185 if (found->repo == repo
1186 && found->name == pd.share_with[i].name
1187 && found->evr == pd.share_with[i].evr
1188 && found->arch == pd.share_with[i].arch)
1190 last_found = nn - repo->start;
1195 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
1197 free(pd.share_with);
1198 map_free(&keyidmap);
1201 solv_free(joinhash);
1202 repodata_free_dircache(data);
1203 if (!(flags & REPO_NO_INTERNALIZE))
1204 repodata_internalize(data);
1206 solv_free(pd.language);
1208 join_freemem(&pd.jd);