2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
17 #include "tools_util.h"
18 #include "repo_susetags.h"
19 #ifdef ENABLE_COMPLEX_DEPS
20 #include "pool_parserpmrichdep.h"
22 #include "repodata_diskusage.h"
37 int last_found_source;
38 struct datashare *share_with;
42 char *language; /* the default language */
43 Id langcache[ID_NUM_INTERNAL]; /* cache for the default language */
46 int afilelist; /* allocated */
47 int nfilelist; /* used */
50 static char *flagtab[] = {
61 langtag(struct parsedata *pd, Id tag, const char *language)
63 if (language && *language)
64 return pool_id2langid(pd->repo->pool, tag, language, 1);
67 if (tag >= ID_NUM_INTERNAL)
68 return pool_id2langid(pd->repo->pool, tag, pd->language, 1);
69 if (!pd->langcache[tag])
70 pd->langcache[tag] = pool_id2langid(pd->repo->pool, tag, pd->language, 1);
71 return pd->langcache[tag];
76 * create and add dependency
80 adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind)
88 /* A file dependency. Do not try to parse it */
89 id = pool_str2id(pool, line + 6, 1);
91 #ifdef ENABLE_COMPLEX_DEPS
92 else if (line[6] == '(')
94 id = pool_parserpmrichdep(pool, line + 6);
97 pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
104 i = split(line + 6, sp, 4); /* name, <op>, evr, ? */
105 if (i != 1 && i != 3) /* expect either 'name' or 'name' <op> 'evr' */
107 pd->ret = pool_error(pool, -1, "susetags: line %d: bad dependency: '%s'\n", pd->lineno, line);
111 id = pool_str2id(pool, join2(&pd->jd, kind, ":", sp[0]), 1);
113 id = pool_str2id(pool, sp[0], 1);
116 evrid = makeevr(pool, sp[2]);
117 for (flags = 0; flags < 6; flags++)
118 if (!strcmp(sp[1], flagtab[flags]))
122 if (!strcmp(sp[1], "<>"))
126 pd->ret = pool_error(pool, -1, "susetags: line %d: unknown relation: '%s'\n", pd->lineno, sp[1]);
130 id = pool_rel2id(pool, id, evrid, flags + 1, 1);
133 return repo_addid_dep(pd->repo, olddeps, id, marker);
143 add_source(struct parsedata *pd, char *line, Solvable *s, Id handle)
145 Pool *pool = s->repo->pool;
149 const char *evr, *sevr;
151 if (split(line, sp, 5) != 4)
153 pd->ret = pool_error(pool, -1, "susetags: line %d: bad source line '%s'\n", pd->lineno, line);
157 name = pool_str2id(pool, sp[0], 1);
158 arch = pool_str2id(pool, sp[3], 1); /* do this before id2str */
159 evr = join2(&pd->jd, sp[1], "-", sp[2]);
160 sevr = pool_id2str(pool, s->evr);
165 for (p = sevr; *p >= '0' && *p <= '9'; p++)
167 if (p != sevr && *p == ':' && p[1])
171 repodata_set_void(pd->data, handle, SOLVABLE_SOURCENAME);
173 repodata_set_id(pd->data, handle, SOLVABLE_SOURCENAME, name);
174 if (sevr && !strcmp(sevr, evr))
175 repodata_set_void(pd->data, handle, SOLVABLE_SOURCEEVR);
177 repodata_set_id(pd->data, handle, SOLVABLE_SOURCEEVR, pool_str2id(pool, evr, 1));
178 repodata_set_constantid(pd->data, handle, SOLVABLE_SOURCEARCH, arch);
182 set_checksum(struct parsedata *pd, Repodata *data, Id handle, Id keyname, char *line)
186 if (split(line, sp, 3) != 2)
188 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum line '%s'\n", pd->lineno, line);
191 type = solv_chksum_str2type(sp[0]);
194 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: unknown checksum type: '%s'\n", pd->lineno, sp[0]);
197 if (strlen(sp[1]) != 2 * solv_chksum_len(type))
199 pd->ret = pool_error(pd->pool, -1, "susetags: line %d: bad checksum length for type %s: '%s'\n", pd->lineno, sp[0], sp[1]);
202 repodata_set_checksum(data, handle, keyname, type, sp[1]);
206 /* Unfortunately "a"[0] is no constant expression in the C languages,
207 so we need to pass the four characters individually :-/ */
208 #define CTAG(a,b,c,d) ((unsigned)(((unsigned char)a) << 24) \
209 | ((unsigned char)b << 16) \
210 | ((unsigned char)c << 8) \
211 | ((unsigned char)d))
218 static inline unsigned int
219 tag_from_string(char *cs)
221 unsigned char *s = (unsigned char *)cs;
222 return ((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]);
228 * Parse susetags file passed in fp, fill solvables into repo
230 * susetags is key,value based
234 * for long (multi-line) values,
241 * See http://en.opensuse.org/Standards/YaST2_Repository_Metadata
242 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/packages
243 * and http://en.opensuse.org/Standards/YaST2_Repository_Metadata/pattern
246 * All keys have 3 characters and end in ':'
250 finish_solvable(struct parsedata *pd, Solvable *s, Offset freshens)
252 Pool *pool = pd->repo->pool;
253 Id handle = s - pool->solvables;
259 for (l = 0; l < pd->nfilelist; l += strlen(pd->filelist + l) + 1)
261 char *p = strrchr(pd->filelist + l, '/');
265 did = repodata_str2dir(pd->data, pd->filelist + l, 1);
268 did = repodata_str2dir(pd->data, "/", 1);
269 repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, p);
273 /* Add self provide, except for source packages. This is harmless
274 to do twice (in case we see the same package twice). */
275 if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
276 s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
277 repo_rewrite_suse_deps(s, freshens);
278 if (pd->diskusageq.count)
279 repodata_add_diskusage(pd->data, handle, &pd->diskusageq);
283 joinhash_init(Repo *repo, Hashval *hmp)
285 Hashval hm = mkmask(repo->nsolvables);
286 Hashtable ht = solv_calloc(hm + 1, sizeof(*ht));
291 FOR_REPO_SOLVABLES(repo, i, s)
293 hh = HASHCHAIN_START;
296 h = HASHCHAIN_NEXT(h, hh, hm);
304 joinhash_lookup(Repo *repo, Hashtable ht, Hashval hm, Id name, Id evr, Id arch, Id start)
308 if (!name || !arch || !evr)
310 hh = HASHCHAIN_START;
314 Solvable *s = repo->pool->solvables + ht[h];
315 if (ht[h] >= start && s->name == name && s->evr == evr && s->arch == arch)
317 h = HASHCHAIN_NEXT(h, hh, hm);
323 lookup_shared_id(Repodata *data, Id p, Id keyname, Id voidid, int uninternalized)
326 r = repodata_lookup_type(data, p, keyname);
329 if (r == REPOKEY_TYPE_VOID)
331 r = repodata_lookup_id(data, p, keyname);
336 return repodata_lookup_id_uninternalized(data, p, keyname, voidid);
341 toevr(Pool *pool, struct parsedata *pd, const char *version, const char *release)
343 return makeevr(pool, !release || (release[0] == '-' && !release[1]) ?
344 version : join2(&pd->jd, version, "-", release));
348 static inline void record_share(struct parsedata *pd, Id handle, Id name, Id evr, Id arch)
350 Repo *repo = pd->repo;
351 int i = handle - repo->start;
354 pd->share_with = solv_realloc2(pd->share_with, i + 256, sizeof(*pd->share_with));
355 memset(pd->share_with + pd->nshare, 0, (i + 256 - pd->nshare) * sizeof(*pd->share_with));
356 pd->nshare = i + 256;
358 pd->share_with[i].name = name;
359 pd->share_with[i].evr = evr;
360 pd->share_with[i].arch = arch;
363 static void process_shares(struct parsedata *pd)
365 Pool *pool = pd->pool;
366 Repo *repo = pd->repo;
367 Repodata *data = pd->data;
371 map_init(&keyidmap, data->nkeys);
372 for (i = 1; i < data->nkeys; i++)
374 Id keyname = data->keys[i].name;
375 if (keyname == SOLVABLE_INSTALLSIZE || keyname == SOLVABLE_DISKUSAGE || keyname == SOLVABLE_FILELIST)
377 if (keyname == SOLVABLE_MEDIADIR || keyname == SOLVABLE_MEDIAFILE || keyname == SOLVABLE_MEDIANR)
379 if (keyname == SOLVABLE_DOWNLOADSIZE || keyname == SOLVABLE_CHECKSUM)
381 if (keyname == SOLVABLE_SOURCENAME || keyname == SOLVABLE_SOURCEARCH || keyname == SOLVABLE_SOURCEEVR)
383 if (keyname == SOLVABLE_PKGID || keyname == SOLVABLE_HDRID || keyname == SOLVABLE_LEADSIGID)
385 if (keyname == SUSETAGS_SHARE_NAME || keyname == SUSETAGS_SHARE_EVR || keyname == SUSETAGS_SHARE_ARCH)
387 MAPSET(&keyidmap, i);
390 for (i = 0; i < pd->nshare; i++)
394 if (!pd->share_with[i].name)
396 for (n = repo->start, nn = repo->start + last_found; n < repo->end; n++, nn++)
400 found = pool->solvables + nn;
401 if (found->repo == repo
402 && found->name == pd->share_with[i].name
403 && found->evr == pd->share_with[i].evr
404 && found->arch == pd->share_with[i].arch)
406 last_found = nn - repo->start;
411 repodata_merge_some_attrs(data, repo->start + i, repo->start + last_found, &keyidmap, 0);
413 pd->share_with = solv_free(pd->share_with);
422 * fp: file to read from
423 * defvendor: default vendor (0 if none)
424 * language: current language (0 if none)
429 repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int flags)
431 Pool *pool = repo->pool;
437 int intag_linestart = 0;
441 int last_found_pack = 0;
442 Id first_new_pkg = 0;
447 Hashtable joinhash = 0;
448 Hashval joinhashm = 0;
451 if ((flags & (SUSETAGS_EXTEND|REPO_EXTEND_SOLVABLES)) != 0 && repo->nrepodata)
453 joinhash = joinhash_init(repo, &joinhashm);
456 data = repo_add_repodata(repo, flags);
458 memset(&pd, 0, sizeof(pd));
459 line = solv_malloc(1024);
466 pd.language = language && *language ? solv_strdup(language) : 0;
467 queue_init(&pd.diskusageq);
473 /* if this is a join setup the recorded share data */
479 FOR_REPODATAS(repo, i, sdata)
482 if (!repodata_has_keyname(sdata, SUSETAGS_SHARE_NAME))
484 for (p = sdata->start; p < sdata->end; p++)
487 name = lookup_shared_id(sdata, p, SUSETAGS_SHARE_NAME, pool->solvables[p].name, sdata == data);
490 evr = lookup_shared_id(sdata, p, SUSETAGS_SHARE_EVR, pool->solvables[p].evr, sdata == data);
493 arch = lookup_shared_id(sdata, p, SUSETAGS_SHARE_ARCH, pool->solvables[p].arch, sdata == data);
496 record_share(&pd, p, name, evr, arch);
504 * collect values in 'struct parsedata pd'
505 * then build .solv (and .attr) file
516 if (linep - line + 16 > aline) /* (re-)alloc buffer */
518 aline = linep - line;
519 line = solv_realloc(line, aline + 512);
520 linep = line + aline;
523 if (!fgets(linep, aline - (linep - line), fp)) /* read line */
525 linep += strlen(linep);
526 if (linep == line || linep[-1] != '\n')
533 /* in multi-line value tags (+Key:/-Key:), check for end, cummulate */
534 int is_end = line[intag_linestart] == '-' && linep[-1] == ':' && linep - line == intag_linestart + intag + 2;
535 if (is_end && strncmp(linep - 1 - intag, line + 1, intag))
537 pool_debug(pool, SOLV_ERROR, "susetags: Nonmatching multi-line tags: %d: '%s' '%.*s'\n", pd.lineno, linep - 1 - intag, intag, line + 1);
544 intag_linestart = linep - line;
547 intag_linestart = intag + 3;
548 linep = line + intag_linestart;
550 continue; /* ignore empty lines, bnc#381828 */
558 line[intag_linestart] = 0;
559 if (line[intag_linestart - 1] == '\n')
560 line[intag_linestart - 1] = 0; /* strip trailing newline */
566 /* ignore comments and empty lines */
567 if (!*line || *line == '#')
570 /* ignore malformed lines */
571 if (!(line[0] && line[1] && line[2] && line[3] && (line[4] == ':' || line[4] == '.')))
574 if (!intag && line[0] == '+' && line[1] != ':') /* start of +Key:/-Key: tag */
576 char *tagend = strchr(line, ':');
577 if (!tagend || tagend - line > 100)
579 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
582 intag = tagend - (line + 1); /* set to tagsize */
584 switch (tag_from_string(line)) /* check if accumulation is needed */
586 case CTAG('+', 'D', 'e', 's'):
587 case CTAG('+', 'E', 'u', 'l'):
588 case CTAG('+', 'I', 'n', 's'):
589 case CTAG('+', 'D', 'e', 'l'):
590 case CTAG('+', 'A', 'u', 't'):
596 line[0] = '='; /* handle lines between +Key:/-Key: as =Key: */
597 line[intag + 2] = ' ';
598 intag_linestart = intag + 3;
599 linep = line + intag_linestart;
603 /* support language suffix */
609 endlang = strchr(line + 5, ':');
612 int langsize = endlang - (line + 5);
613 keylen = endlang - line - 1;
616 strncpy(line_lang, line + 5, langsize);
617 line_lang[langsize] = 0;
621 tag = tag_from_string(line);
623 /* handle global tags and tags that start a new section */
626 case CTAG('=', 'V', 'e', 'r'):
627 /* start of a new file */
629 finish_solvable(&pd, s, freshens);
639 joinhash = joinhash_init(repo, &joinhashm);
644 case CTAG('=', 'L', 'a', 'n'):
645 /* define language of the following material */
646 pd.language = solv_free(pd.language);
647 memset(pd.langcache, 0, sizeof(pd.langcache));
649 pd.language = solv_strdup(line + 6);
652 case CTAG('=', 'P', 'k', 'g'): /* start of a package */
653 case CTAG('=', 'P', 'a', 't'): /* start of a pattern */
654 case CTAG('=', 'D', 'l', 't'): /* start of a delta */
655 /* =Pkg: <name> <version> <release> <architecture> */
656 /* If we have an old solvable, complete it by filling in some default stuff. */
658 finish_solvable(&pd, s, freshens);
667 if (tag == CTAG('=', 'P', 'a', 't'))
671 if (split(line + 5, sp, 5) != 4)
673 pd.ret = pool_error(pool, -1, "susetags: line %d: bad line '%s'\n", pd.lineno, line);
677 if (tag == CTAG('=', 'D', 'l', 't'))
679 /* start new delta */
680 handle = repodata_new_handle(data);
681 repodata_set_id(data, handle, DELTA_PACKAGE_NAME, pool_str2id(pool, sp[0], 1));
682 repodata_set_id(data, handle, DELTA_PACKAGE_EVR, toevr(pool, &pd, sp[1], sp[2]));
683 repodata_set_id(data, handle, DELTA_PACKAGE_ARCH, pool_str2id(pool, sp[3], 1));
684 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_DELTAINFO, handle);
691 /* data join operation. find solvable matching name/arch/evr and
694 /* we don't use the create flag here as a simple pre-check for existance */
696 name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 0);
698 name = pool_str2id(pool, sp[0], 0);
699 arch = pool_str2id(pool, sp[3], 0);
702 Id start = (flags & REPO_EXTEND_SOLVABLES) ? 0 : first_new_pkg;
703 Id evr = toevr(pool, &pd, sp[1], sp[2]);
704 if (repo->start + last_found_pack + 1 >= start && repo->start + last_found_pack + 1 < repo->end)
706 s = pool->solvables + repo->start + last_found_pack + 1;
707 if (s->repo != repo || s->name != name || s->evr != evr || s->arch != arch)
711 s = joinhash_lookup(repo, joinhash, joinhashm, name, evr, arch, start);
713 /* do not create new packages in EXTEND_SOLVABLES mode */
714 if (!s && (flags & REPO_EXTEND_SOLVABLES) != 0)
719 /* fallthrough to package creation */
723 /* normal operation. create a new solvable. */
724 s = pool_id2solvable(pool, repo_add_solvable(repo));
726 s->name = pool_str2id(pool, join2(&pd.jd, pd.kind, ":", sp[0]), 1);
728 s->name = pool_str2id(pool, sp[0], 1);
729 s->evr = toevr(pool, &pd, sp[1], sp[2]);
730 s->arch = pool_str2id(pool, sp[3], 1);
731 s->vendor = defvendor;
733 first_new_pkg = s - pool->solvables;
736 handle = s - pool->solvables;
737 last_found_pack = (s - pool->solvables) - repo->start;
744 /* handle delta tags */
748 =Dlt: subversion 1.6.16 1.3.1 i586
749 =Dsq: subversion 1.6.15 4.2 i586 d57b3fc86e7a2f73796e8e35b96fa86212c910
750 =Cks: SHA1 14a8410cf741856a5d70d89dab62984dba6a1ca7
751 =Loc: 1 subversion-1.6.15_1.6.16-4.2_1.3.1.i586.delta.rpm
756 case CTAG('=', 'D', 's', 'q'):
759 if (split(line + 5, sp, 5) != 5)
761 repodata_set_id(data, handle, DELTA_SEQ_NAME, pool_str2id(pool, sp[0], 1));
762 evr = toevr(pool, &pd, sp[1], sp[2]);
763 repodata_set_id(data, handle, DELTA_SEQ_EVR, evr);
764 /* repodata_set_id(data, handle, DELTA_SEQ_ARCH, pool_str2id(pool, sp[3], 1)); */
765 repodata_set_str(data, handle, DELTA_SEQ_NUM, sp[4]);
766 repodata_set_id(data, handle, DELTA_BASE_EVR, evr);
769 case CTAG('=', 'C', 'k', 's'):
770 set_checksum(&pd, data, handle, DELTA_CHECKSUM, line + 6);
772 case CTAG('=', 'L', 'o', 'c'):
774 int i = split(line + 6, sp, 3);
775 if (i != 2 && i != 3)
777 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
780 repodata_set_deltalocation(data, handle, atoi(sp[0]), i == 3 ? sp[2] : 0, sp[1]);
783 case CTAG('=', 'S', 'i', 'z'):
784 if (split(line + 6, sp, 3) == 2)
785 repodata_set_num(data, handle, DELTA_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
788 pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
793 /* we need a solvable for all other tags */
797 continue; /* did not find the solvable to extend */
799 pool_debug(pool, SOLV_WARN, "susetags: stray line: %d: %s\n", pd.lineno, line);
806 case CTAG('=', 'P', 'r', 'v'): /* provides */
809 /* probably a filelist entry. stash it away for now */
810 int l = strlen(line + 6) + 1;
811 if (pd.nfilelist + l > pd.afilelist)
813 pd.afilelist = pd.nfilelist + l + 512;
814 pd.filelist = solv_realloc(pd.filelist, pd.afilelist);
816 memcpy(pd.filelist + pd.nfilelist, line + 6, l);
823 for (l = 0; l < pd.nfilelist; l += strlen(pd.filelist + l) + 1)
824 s->provides = repo_addid_dep(pd.repo, s->provides, pool_str2id(pool, pd.filelist + l, 1), 0);
827 s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind);
829 case CTAG('=', 'R', 'e', 'q'): /* requires */
830 s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind);
832 case CTAG('=', 'P', 'r', 'q'): /* pre-requires / packages required */
834 s->requires = adddep(pool, &pd, s->requires, line, 0, 0); /* pattern: package requires */
836 s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); /* pre-requires */
838 case CTAG('=', 'O', 'b', 's'): /* obsoletes */
839 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind);
841 case CTAG('=', 'C', 'o', 'n'): /* conflicts */
842 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, pd.kind);
844 case CTAG('=', 'R', 'e', 'c'): /* recommends */
845 s->recommends = adddep(pool, &pd, s->recommends, line, 0, pd.kind);
847 case CTAG('=', 'S', 'u', 'p'): /* supplements */
848 s->supplements = adddep(pool, &pd, s->supplements, line, 0, pd.kind);
850 case CTAG('=', 'E', 'n', 'h'): /* enhances */
851 s->enhances = adddep(pool, &pd, s->enhances, line, 0, pd.kind);
853 case CTAG('=', 'S', 'u', 'g'): /* suggests */
854 s->suggests = adddep(pool, &pd, s->suggests, line, 0, pd.kind);
856 case CTAG('=', 'F', 'r', 'e'): /* freshens */
857 freshens = adddep(pool, &pd, freshens, line, 0, pd.kind);
859 case CTAG('=', 'P', 'r', 'c'): /* packages recommended */
860 s->recommends = adddep(pool, &pd, s->recommends, line, 0, 0);
862 case CTAG('=', 'P', 's', 'g'): /* packages suggested */
863 s->suggests = adddep(pool, &pd, s->suggests, line, 0, 0);
865 case CTAG('=', 'P', 'c', 'n'): /* pattern: package conflicts */
866 s->conflicts = adddep(pool, &pd, s->conflicts, line, 0, 0);
868 case CTAG('=', 'P', 'o', 'b'): /* pattern: package obsoletes */
869 s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, 0);
871 case CTAG('=', 'P', 'f', 'r'): /* pattern: package freshens */
872 freshens = adddep(pool, &pd, freshens, line, 0, 0);
874 case CTAG('=', 'P', 's', 'p'): /* pattern: package supplements */
875 s->supplements = adddep(pool, &pd, s->supplements, line, 0, 0);
877 case CTAG('=', 'P', 'e', 'n'): /* pattern: package enhances */
878 s->enhances = adddep(pool, &pd, s->enhances, line, 0, 0);
880 case CTAG('=', 'V', 'n', 'd'): /* vendor */
881 s->vendor = pool_str2id(pool, line + 6, 1);
884 /* From here it's the attribute tags. */
885 case CTAG('=', 'G', 'r', 'p'):
886 repodata_set_poolstr(data, handle, SOLVABLE_GROUP, line + 6);
888 case CTAG('=', 'L', 'i', 'c'):
889 repodata_set_poolstr(data, handle, SOLVABLE_LICENSE, line + 6);
891 case CTAG('=', 'L', 'o', 'c'):
893 int i = split(line + 6, sp, 3);
894 if (i != 2 && i != 3)
896 pd.ret = pool_error(pool, -1, "susetags: line %d: bad location line '%s'\n", pd.lineno, line);
899 repodata_set_location(data, handle, atoi(sp[0]), i == 3 ? sp[2] : pool_id2str(pool, s->arch), sp[1]);
902 case CTAG('=', 'S', 'r', 'c'):
903 add_source(&pd, line + 6, s, handle);
905 case CTAG('=', 'S', 'i', 'z'):
906 if (split(line + 6, sp, 3) == 2)
908 repodata_set_num(data, handle, SOLVABLE_DOWNLOADSIZE, strtoull(sp[0], 0, 10));
909 repodata_set_num(data, handle, SOLVABLE_INSTALLSIZE, strtoull(sp[1], 0, 10));
912 case CTAG('=', 'T', 'i', 'm'):
914 unsigned int t = atoi(line + 6);
916 repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t);
919 case CTAG('=', 'K', 'w', 'd'):
920 repodata_add_poolstr_array(data, handle, SOLVABLE_KEYWORDS, line + 6);
922 case CTAG('=', 'A', 'u', 't'):
923 repodata_set_str(data, handle, SOLVABLE_AUTHORS, line + 6);
925 case CTAG('=', 'S', 'u', 'm'):
926 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_SUMMARY, line_lang), line + 3 + keylen);
928 case CTAG('=', 'D', 'e', 's'):
929 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_DESCRIPTION, line_lang), line + 3 + keylen);
931 case CTAG('=', 'E', 'u', 'l'):
932 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_EULA, line_lang), line + 6);
934 case CTAG('=', 'I', 'n', 's'):
935 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEINS, line_lang), line + 6);
937 case CTAG('=', 'D', 'e', 'l'):
938 repodata_set_str(data, handle, langtag(&pd, SOLVABLE_MESSAGEDEL, line_lang), line + 6);
940 case CTAG('=', 'V', 'i', 's'):
942 /* Accept numbers and textual bools. */
945 if (k || !strcasecmp(line + 6, "true"))
946 repodata_set_void(data, handle, SOLVABLE_ISVISIBLE);
949 case CTAG('=', 'S', 'h', 'r'):
952 if (split(line + 6, sp, 5) != 4)
954 pd.ret = pool_error(pool, -1, "susetags: line %d: bad =Shr line '%s'\n", pd.lineno, line);
957 name = pool_str2id(pool, sp[0], 1);
958 evr = toevr(pool, &pd, sp[1], sp[2]);
959 arch = pool_str2id(pool, sp[3], 1);
960 record_share(&pd, handle, name, evr, arch);
961 if ((flags & SUSETAGS_RECORD_SHARES) != 0)
964 repodata_set_void(data, handle, SUSETAGS_SHARE_NAME);
966 repodata_set_id(data, handle, SUSETAGS_SHARE_NAME, name);
968 repodata_set_void(data, handle, SUSETAGS_SHARE_EVR);
970 repodata_set_id(data, handle, SUSETAGS_SHARE_EVR, evr);
972 repodata_set_void(data, handle, SUSETAGS_SHARE_ARCH);
974 repodata_set_id(data, handle, SUSETAGS_SHARE_ARCH, arch);
978 case CTAG('=', 'D', 'i', 'r'):
979 if (split(line + 6, sp, 6) == 5)
981 long filesz, filenum;
984 filesz = strtol(sp[1], 0, 0);
985 filesz += strtol(sp[2], 0, 0);
986 filenum = strtol(sp[3], 0, 0);
987 filenum += strtol(sp[4], 0, 0);
989 *--sp[0] = '/'; /* hack: we know that there's room for a / */
990 did = repodata_str2dir(data, sp[0], 1);
991 queue_push(&pd.diskusageq, did);
992 queue_push2(&pd.diskusageq, (Id)filesz, (Id)filenum);
995 case CTAG('=', 'C', 'a', 't'):
996 repodata_set_poolstr(data, handle, langtag(&pd, SOLVABLE_CATEGORY, line_lang), line + 3 + keylen);
998 case CTAG('=', 'O', 'r', 'd'):
999 /* Order is a string not a number, so we can retroactively insert
1000 new patterns in the middle, i.e. 1 < 15 < 2. */
1001 repodata_set_str(data, handle, SOLVABLE_ORDER, line + 6);
1003 case CTAG('=', 'I', 'c', 'o'):
1004 repodata_set_str(data, handle, SOLVABLE_ICON, line + 6);
1006 case CTAG('=', 'E', 'x', 't'):
1007 repodata_add_poolstr_array(data, handle, SOLVABLE_EXTENDS, join2(&pd.jd, "pattern", ":", line + 6));
1009 case CTAG('=', 'I', 'n', 'c'):
1010 repodata_add_poolstr_array(data, handle, SOLVABLE_INCLUDES, join2(&pd.jd, "pattern", ":", line + 6));
1012 case CTAG('=', 'C', 'k', 's'):
1013 set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6);
1016 case CTAG('=', 'F', 'l', 's'):
1018 char *p, *file = line + 6;
1022 *--file = '/'; /* hack: we know there is room */
1023 p = strrchr(file, '/');
1024 /* strip trailing slashes */
1025 while (p != file && !p[1])
1028 p = strrchr(file, '/');
1031 did = repodata_str2dir(data, *file ? file : "/", 1);
1032 repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, p);
1036 case CTAG('=', 'H', 'd', 'r'):
1037 /* rpm header range */
1038 if (split(line + 6, sp, 3) == 2)
1040 /* we ignore the start value */
1041 unsigned int end = (unsigned int)atoi(sp[1]);
1043 repodata_set_num(data, handle, SOLVABLE_HEADEREND, end);
1049 pool_debug(pool, SOLV_WARN, "susetags: unknown line: %d: %s\n", pd.lineno, line);
1056 finish_solvable(&pd, s, freshens);
1057 solv_free(pd.filelist);
1059 /* process shared attributes (e.g. multiple binaries built from same source) */
1061 process_shares(&pd);
1063 solv_free(joinhash);
1064 repodata_free_dircache(data);
1065 if (!(flags & REPO_NO_INTERNALIZE))
1066 repodata_internalize(data);
1068 solv_free(pd.language);
1070 join_freemem(&pd.jd);
1071 queue_free(&pd.diskusageq);