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 = pool_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 = pool_str2id(pool, join2(kind, ":", sp[0]), 1);
93 id = pool_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 = pool_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 = pool_str2id(pool, sp[0], 1);
131 Id evr = makeevr(pool, join2(sp[1], "-", sp[2]));
132 Id arch = pool_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]);
200 set_delta_location(Repodata *data, Id handle, int medianr, char *dir, char *file)
202 Pool *pool = data->repo->pool;
208 if ((dir = strrchr(file, '/')) != 0)
219 if (l >= 2 && dir[0] == '.' && dir[1] == '/' && (l == 2 || dir[2] != '/'))
224 if (l == 1 && dir[0] == '.')
227 repodata_set_id(data, handle, DELTA_LOCATION_DIR, pool_strn2id(pool, dir, l, 1));
228 if ((p = strrchr(file, '.')) != 0)
231 if ((op = strrchr(file, '.')) != 0)
236 if (!strcmp(p + 1, "delta.rpm") && (op = strrchr(file, '.')) != 0)
243 repodata_set_id(data, handle, DELTA_LOCATION_SUFFIX, pool_str2id(pool, p + 1, 1));
245 if ((p = strrchr(file, '-')) != 0)
248 if ((op = strrchr(file, '-')) != 0)
254 repodata_set_id(data, handle, DELTA_LOCATION_EVR, pool_str2id(pool, p + 1, 1));
256 repodata_set_id(data, handle, DELTA_LOCATION_NAME, pool_str2id(pool, file, 1));
268 id3_cmp(const void *v1, const void *v2, void *dp)
272 return i1[0] - i2[0];
282 commit_diskusage(struct parsedata *pd, Id handle)
285 Dirpool *dp = &pd->data->dirpool;
286 /* Now sort in dirid order. This ensures that parents come before
289 sat_sort(pd->dirs, pd->ndirs, sizeof(pd->dirs[0]), id3_cmp, 0);
290 /* Substract leaf numbers from all parents to make the numbers
291 non-cumulative. This must be done post-order (i.e. all leafs
292 adjusted before parents). We ensure this by starting at the end of
293 the array moving to the start, hence seeing leafs before parents. */
294 for (i = pd->ndirs; i--;)
296 unsigned p = dirpool_parent(dp, pd->dirs[i][0]);
298 for (; p; p = dirpool_parent(dp, p))
301 if (pd->dirs[j][0] == p)
305 if (pd->dirs[j][1] < pd->dirs[i][1])
308 pd->dirs[j][1] -= pd->dirs[i][1];
309 if (pd->dirs[j][2] < pd->dirs[i][2])
312 pd->dirs[j][2] -= pd->dirs[i][2];
315 /* Haven't found this parent in the list, look further if
316 we maybe find the parents parent. */
323 unsigned slen = sizeof(sbuf);
324 for (i = 0; i < pd->ndirs; i++)
326 dir2str(attr, pd->dirs[i][0], &buf, &slen);
327 fprintf(stderr, "have dir %d %d %d %s\n", pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2], buf);
332 for (i = 0; i < pd->ndirs; i++)
333 if (pd->dirs[i][1] || pd->dirs[i][2])
335 repodata_add_dirnumnum(pd->data, handle, SOLVABLE_DISKUSAGE, pd->dirs[i][0], pd->dirs[i][1], pd->dirs[i][2]);
341 /* Unfortunately "a"[0] is no constant expression in the C languages,
342 so we need to pass the four characters individually :-/ */
343 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
344 | ((unsigned char)b << 16) \
345 | ((unsigned char)c << 8) \
346 | ((unsigned char)d))
353 static inline unsigned
354 tag_from_string(char *cs)
356 unsigned char *s = (unsigned char *)cs;
357 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
363 * Parse susetags file passed in fp, fill solvables into repo
365 * susetags is key,value based
369 * for long (multi-line) values,
376 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
377 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
378 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
381 * All keys have 3 characters and end in ':'
385 finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens)
387 Pool *pool = pd->repo->pool;
390 /* move file provides to filelist */
391 /* relies on the fact that rpm inserts self-provides at the end */
392 if (s->provides && (pd->flags & REPO_EXTEND_SOLVABLES) == 0)
394 Id *p, *lastreal, did;
395 const char *str, *sp;
396 lastreal = pd->repo->idarraydata + s->provides;
397 for (p = lastreal; *p; p++)
400 for (p = lastreal; *p; p++)
402 str = pool_id2str(pool, *p);
408 for (p = lastreal; *p; p++)
412 str = pool_id2str(pool, *p);
413 sp = strrchr(str, '/');
414 /* Need to copy filename now, before we add string that could
415 realloc the stringspace (and hence invalidate str). */
417 if (strlen(fname) >= 128)
418 fname = strdup(fname);
421 memcpy(fname_buf, fname, strlen(fname) + 1);
426 char *sdup = strdup(str);
428 did = repodata_str2dir(pd->data, sdup, 1);
434 strncpy(sdup, str, sp - str);
436 did = repodata_str2dir(pd->data, sdup, 1);
439 did = repodata_str2dir(pd->data, "/", 1);
440 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, fname);
441 if (fname != fname_buf)
448 /* A self provide, except for source packages. This is harmless
449 to do twice (in case we see the same package twice). */
450 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
451 s->provides = repo_addid_dep(pd->repo, s->provides,
452 pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
453 /* XXX This uses repo_addid_dep internally, so should also be
454 harmless to do twice. */
455 s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, freshens);
456 s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts);
458 commit_diskusage(pd, handle);
462 joinhash_init(Repo *repo, Hashmask *hmp)
464 Hashmask hm = mkmask(repo->nsolvables);
465 Hashtable ht = sat_calloc(hm + 1, sizeof(*ht));
470 FOR_REPO_SOLVABLES(repo, i, s)
472 hh = HASHCHAIN_START;
475 h = HASHCHAIN_NEXT(h, hh, hm);
483 joinhash_lookup(Repo *repo, Hashtable ht, Hashmask hm, Id name, Id evr, Id arch)
487 if (!name || !arch || !evr)
489 hh = HASHCHAIN_START;
493 Solvable *s = repo->pool->solvables + ht[h];
494 if (s->name == name && s->evr == evr && s->arch == arch)
496 h = HASHCHAIN_NEXT(h, hh, hm);
502 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
505 r = repodata_lookup_type(data, p, keyname);
508 if (r == REPOKEY_TYPE_VOID)
510 r = repodata_lookup_id(data, p, keyname);
514 if (uninternalized && data->attrs)
516 Id *ap = data->attrs[p - data->start];
521 if (data->keys[*ap].name != keyname)
523 if (data->keys[*ap].type == REPOKEY_TYPE_VOID)
525 if (data->keys[*ap].type == REPOKEY_TYPE_ID)
536 * fp: file to read from
537 * defvendor: default vendor (0 if none)
538 * language: current language (0 if none)
543 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
545 Pool *pool = repo->pool;
554 int last_found_pack = 0;
559 Hashtable joinhash = 0;
560 Hashmask joinhashm = 0;
563 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
565 joinhash = joinhash_init(repo, &joinhashm);
569 data = repo_add_repodata(repo, flags);
571 memset(&pd, 0, sizeof(pd));
575 pd.repo = pd.common.repo = repo;
577 pd.common.pool = pool;
584 /* if this is a join setup the recorded share data */
589 for (i = 0, sdata = repo->repodata; i < repo->nrepodata; i++, sdata++)
592 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
594 for (p = sdata->start; p < sdata->end; p++)
597 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
600 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
603 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
606 if (p - repo->start >= pd.nshare)
608 pd.share_with = sat_realloc2(pd.share_with, p - repo->start + 256, sizeof(*pd.share_with));
609 memset(pd.share_with + pd.nshare, 0, (p - repo->start + 256 - pd.nshare) * sizeof(*pd.share_with));
610 pd.nshare = p - repo->start + 256;
612 pd.share_with[p - repo->start].name = name;
613 pd.share_with[p - repo->start].evr = evr;
614 pd.share_with[p - repo->start].arch = arch;
622 * collect values in 'struct parsedata pd'
623 * then build .solv (and .attr) file
629 char *olinep; /* old line pointer */
632 if (linep - line + 16 > aline) /* (re-)alloc buffer */
634 aline = linep - line;
635 line = realloc(line, aline + 512);
636 linep = line + aline;
639 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
642 linep += strlen(linep);
643 if (linep == line || linep[-1] != '\n')
652 /* check for multi-line value tags (+Key:/-Key:) */
654 int is_end = (linep[-intag - keylen + 1] == '-')
655 && (linep[-1] == ':')
656 && (linep == line + 1 + intag + 1 + 1 + 1 + intag + 1 || linep[-intag - keylen] == '\n');
658 && strncmp(linep - 1 - intag, line + 1, intag))
660 pool_debug(pool, SAT_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%s' %d\n", pd.lineno, linep - 1 - intag, line + 1, intag);
662 if (cummulate && !is_end)
667 if (cummulate && is_end)
669 linep[-intag - keylen + 1] = 0;
670 if (linep[-intag - keylen] == '\n')
671 linep[-intag - keylen] = 0;
675 if (!cummulate && is_end)
681 if (!cummulate && !is_end)
682 linep = line + intag + keylen;
687 if (!intag && line[0] == '+' && line[1] && line[1] != ':') /* start of +Key:/-Key: tag */
689 char *tagend = strchr(line, ':');
692 pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
695 intag = tagend - (line + 1);
697 switch (tag_from_string(line)) /* check if accumulation is needed */
699 case CTAG('+', 'D', 'e', 's'):
700 case CTAG('+', 'E', 'u', 'l'):
701 case CTAG('+', 'I', 'n', 's'):
702 case CTAG('+', 'D', 'e', 'l'):
703 case CTAG('+', 'A', 'u', 't'):
704 if (line[4] == ':' || line[4] == '.')
710 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
711 line[intag + keylen - 1] = ' ';
712 linep = line + intag + keylen;
715 if (*line == '#' || !*line)
717 if (! (line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
722 endlang = strchr(line + 5, ':');
725 keylen = endlang - line - 1;
726 strncpy(line_lang, line + 5, 5);
727 line_lang[endlang - line - 5] = 0;
732 tag = tag_from_string(line);
737 =Dlt: subversion 1.6.16 1.3.1 i586
738 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
739 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
740 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
745 case CTAG('=', 'D', 's', 'q'):
748 if (split(line + 5, sp, 5) != 5)
750 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
751 evr = makeevr(pool, join2(sp[1], "-", sp[2]));
752 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
753 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
754 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
755 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
758 case CTAG('=', 'C', 'k', 's'):
759 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
761 case CTAG('=', 'L', 'o', 'c'):
763 int i = split(line + 6, sp, 3);
764 if (i != 2 && i != 3)
766 pool_debug(pool, SAT_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
769 set_delta_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
772 case CTAG('=', 'S', 'i', 'z'):
773 if (split(line + 6, sp, 3) == 2)
774 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
776 case CTAG('=', 'P', 'k', 'g'):
777 case CTAG('=', 'P', 'a', 't'):
778 case CTAG('=', 'D', 'l', 't'):
783 pool_debug(pool, SAT_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
789 * start of (next) package or pattern or delta
791 * =Pkg: <name> <version> <release> <architecture>
794 if (tag == CTAG('=', 'D', 'l', 't'))
797 finish_solvable(&pd, s, handle, freshens);
800 if (split(line + 5, sp, 5) != 4)
802 pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
805 handle = repodata_new_handle(data);
806 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
807 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, makeevr(pool, join2(sp[1], "-", sp[2])));
808 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
809 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
813 if (tag == CTAG('=', 'P', 'k', 'g')
814 || tag == CTAG('=', 'P', 'a', 't'))
816 /* If we have an old solvable, complete it by filling in some
819 finish_solvable(&pd, s, handle, freshens);
833 if (split(line + 5, sp, 5) != 4)
835 pool_debug(pool, SAT_FATAL, "susetags: bad line: %d: %s\n", pd.lineno, line);
843 /* data join operation. find solvable matching name/arch/evr and
846 /* we don't use the create flag here as a simple pre-check for existance */
848 name = pool_str2id(pool, join2(pd.kind, ":", sp[0]), 0);
850 name = pool_str2id(pool, sp[0], 0);
851 evr = makeevr(pool, join2(sp[1], "-", sp[2]));
852 arch = pool_str2id(pool, sp[3], 0);
855 if (repo->start + last_found_pack + 1 < repo->end)
857 s = pool->solvables + repo->start + last_found_pack + 1;
858 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
862 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch);
864 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
866 /* fallthrough to package creation */
870 /* normal operation. create a new solvable. */
871 s = pool_id2solvable(pool, repo_add_solvable(repo));
873 s->name = pool_str2id(pool, join2(pd.kind, ":", sp[0]), 1);
875 s->name = pool_str2id(pool, sp[0], 1);
876 s->evr = makeevr(pool, join2(sp[1], "-", sp[2]));
877 s->arch = pool_str2id(pool, sp[3], 1);
878 s->vendor = defvendor;
881 last_found_pack = (s - pool->solvables) - repo->start;
883 handle = s - pool->solvables;
886 /* If we have no current solvable to add to, ignore all further lines
887 for it. Probably invalid input data in the second set of
889 if (indesc >= 2 && !s)
892 pool_debug(pool, SAT_ERROR, "susetags: huh %d: %s?\n", pd.lineno, line);
898 case CTAG('=', 'P', 'r', 'v'): /* provides */
899 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
901 case CTAG('=', 'R', 'e', 'q'): /* requires */
902 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
904 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
907 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* patterns: a required package */
910 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* package: pre-requires */
912 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
913 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
915 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
916 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
918 case CTAG('=', 'R', 'e', 'c'): /* recommends */
919 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
921 case CTAG('=', 'S', 'u', 'p'): /* supplements */
922 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
924 case CTAG('=', 'E', 'n', 'h'): /* enhances */
925 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
927 case CTAG('=', 'S', 'u', 'g'): /* suggests */
928 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
930 case CTAG('=', 'F', 'r', 'e'): /* freshens */
931 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
933 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
934 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
936 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
937 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
939 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
940 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
942 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
943 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
945 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
946 freshens = adddep(pool, &pd, freshens, line, 0, 0);
948 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
949 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
951 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
952 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
954 case CTAG('=', 'V', 'e', 'r'): /* - version - */
961 joinhash = joinhash_init(repo, &joinhashm);
965 case CTAG('=', 'V', 'n', 'd'): /* vendor */
966 s->vendor = pool_str2id(pool, line + 6, 1);
969 /* From here it's the attribute tags. */
970 case CTAG('=', 'G', 'r', 'p'):
971 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
973 case CTAG('=', 'L', 'i', 'c'):
974 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
976 case CTAG('=', 'L', 'o', 'c'):
978 int i = split(line + 6, sp, 3);
979 if (i != 2 && i != 3)
981 pool_debug(pool, SAT_FATAL, "susetags: bad location line: %d: %s\n", pd.lineno, line);
984 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
987 case CTAG('=', 'S', 'r', 'c'):
988 add_source(&pd, line + 6, s, handle);
990 case CTAG('=', 'S', 'i', 'z'):
991 if (split(line + 6, sp, 3) == 2)
993 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, (unsigned int)(atoi(sp[0]) + 1023) / 1024);
994 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, (unsigned int)(atoi(sp[1]) + 1023) / 1024);
997 case CTAG('=', 'T', 'i', 'm'):
999 unsigned int t = atoi(line + 6);
1001 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
1004 case CTAG('=', 'K', 'w', 'd'):
1005 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
1007 case CTAG('=', 'A', 'u', 't'):
1008 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
1010 case CTAG('=', 'S', 'u', 'm'):
1011 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, language ? language : line_lang), line + 3 + keylen );
1013 case CTAG('=', 'D', 'e', 's'):
1014 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, language ? language : line_lang), line + 3 + keylen );
1016 case CTAG('=', 'E', 'u', 'l'):
1017 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, language), line + 6);
1019 case CTAG('=', 'I', 'n', 's'):
1020 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, language), line + 6);
1022 case CTAG('=', 'D', 'e', 'l'):
1023 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, language), line + 6);
1025 case CTAG('=', 'V', 'i', 's'):
1027 /* Accept numbers and textual bools. */
1030 if (k || !strcasecmp(line + 6, "true"))
1031 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE );
1034 case CTAG('=', 'S', 'h', 'r'):
1037 if (split(line + 6, sp, 5) != 4)
1039 pool_debug(pool, SAT_FATAL, "susetags: bad =Shr line: %s\n", line + 6);
1042 name = pool_str2id(pool, sp[0], 1);
1043 evr = makeevr(pool, join2(sp[1], "-", sp[2]));
1044 arch = pool_str2id(pool, sp[3], 1);
1045 if (last_found_pack >= pd.nshare)
1047 pd.share_with = sat_realloc2(pd.share_with, last_found_pack + 256, sizeof(*pd.share_with));
1048 memset(pd.share_with + pd.nshare, 0, (last_found_pack + 256 - pd.nshare) * sizeof(*pd.share_with));
1049 pd.nshare = last_found_pack + 256;
1051 pd.share_with[last_found_pack].name = name;
1052 pd.share_with[last_found_pack].evr = evr;
1053 pd.share_with[last_found_pack].arch = arch;
1054 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
1056 if (s->name == name)
1057 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
1059 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
1061 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
1063 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
1064 if (s->arch == arch)
1065 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
1067 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
1071 case CTAG('=', 'D', 'i', 'r'):
1072 add_dirline(&pd, line + 6);
1074 case CTAG('=', 'C', 'a', 't'):
1075 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
1077 case CTAG('=', 'O', 'r', 'd'):
1078 /* Order is a string not a number, so we can retroactively insert
1079 new patterns in the middle, i.e. 1 < 15 < 2. */
1080 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1082 case CTAG('=', 'I', 'c', 'o'):
1083 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1085 case CTAG('=', 'E', 'x', 't'):
1086 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2("pattern", ":", line + 6));
1088 case CTAG('=', 'I', 'n', 'c'):
1089 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2("pattern", ":", line + 6));
1091 case CTAG('=', 'C', 'k', 's'):
1092 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1094 case CTAG('=', 'L', 'a', 'n'):
1095 language = strdup(line + 6);
1098 case CTAG('=', 'F', 'l', 's'):
1100 char *p = strrchr(line + 6, '/');
1102 if (p && p != line + 6 && !p[1])
1105 p = strrchr(line + 6, '/');
1110 did = repodata_str2dir(data, line + 6, 1);
1118 did = repodata_str2dir(data, "/", 1);
1119 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1122 case CTAG('=', 'H', 'd', 'r'):
1123 /* rpm header range */
1124 if (split(line + 6, sp, 3) == 2)
1126 /* we ignore the start value */
1127 unsigned int end = (unsigned int)atoi(sp[1]);
1129 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1133 case CTAG('=', 'P', 'a', 't'):
1134 case CTAG('=', 'P', 'k', 'g'):
1138 pool_debug(pool, SAT_ERROR, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1145 finish_solvable(&pd, s, handle, freshens);
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);
1202 if (!(flags & REPO_NO_INTERNALIZE))
1203 repodata_internalize(data);
1206 free(pd.common.tmp);