2 * Copyright (c) 2007-2009, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * The pool contains information about solvables
12 * stored optimized for memory consumption and fast retrieval.
24 #include "poolid_private.h"
30 #define SOLVABLE_BLOCK 255
32 #define KNOWNID_INITIALIZE
34 #undef KNOWNID_INITIALIZE
43 pool = (Pool *)solv_calloc(1, sizeof(*pool));
45 stringpool_init (&pool->ss, initpool_data);
47 /* alloc space for RelDep 0 */
48 pool->rels = solv_extend_resize(0, 1, sizeof(Reldep), REL_BLOCK);
50 memset(pool->rels, 0, sizeof(Reldep));
52 /* alloc space for Solvable 0 and system solvable */
53 pool->solvables = solv_extend_resize(0, 2, sizeof(Solvable), SOLVABLE_BLOCK);
55 memset(pool->solvables, 0, 2 * sizeof(Solvable));
57 queue_init(&pool->vendormap);
60 pool->disttype = DISTTYPE_DEB;
61 pool->noarchid = ARCH_ALL;
63 pool->disttype = DISTTYPE_RPM;
64 pool->noarchid = ARCH_NOARCH;
67 /* initialize the system solvable */
68 s = pool->solvables + SYSTEMSOLVABLE;
69 s->name = SYSTEM_SYSTEM;
70 s->arch = pool->noarchid;
73 pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
75 pool->obsoleteusescolors = 1;
78 pool->forbidselfconflicts = 1;
79 pool->obsoleteusesprovides = 1;
80 pool->implicitobsoleteusesprovides = 1;
81 pool->havedistepoch = 1;
87 /* free all the resources of our pool */
93 pool_freewhatprovides(pool);
94 pool_freeidhashes(pool);
95 pool_freeallrepos(pool, 1);
96 solv_free(pool->id2arch);
97 solv_free(pool->id2color);
98 solv_free(pool->solvables);
99 stringpool_free(&pool->ss);
100 solv_free(pool->rels);
101 pool_setvendorclasses(pool, 0);
102 queue_free(&pool->vendormap);
103 for (i = 0; i < POOL_TMPSPACEBUF; i++)
104 solv_free(pool->tmpspace.buf[i]);
105 for (i = 0; i < pool->nlanguages; i++)
106 free((char *)pool->languages[i]);
107 solv_free(pool->languages);
108 solv_free(pool->languagecache);
113 pool_freeallrepos(Pool *pool, int reuseids)
117 pool_freewhatprovides(pool);
118 for (i = 1; i < pool->nrepos; i++)
120 repo_freedata(pool->repos[i]);
121 pool->repos = solv_free(pool->repos);
124 /* the first two solvables don't belong to a repo */
125 pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
128 #ifdef MULTI_SEMANTICS
130 pool_setdisttype(Pool *pool, int disttype)
132 pool->disttype = disttype;
133 if (disttype == DISTTYPE_RPM)
134 pool->noarchid = ARCH_NOARCH;
135 if (disttype == DISTTYPE_DEB)
136 pool->noarchid = ARCH_ALL;
137 if (disttype == DISTTYPE_ARCH)
138 pool->noarchid = ARCH_ANY;
139 pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
144 pool_get_flag(Pool *pool, int flag)
148 case POOL_FLAG_PROMOTEEPOCH:
149 return pool->promoteepoch;
150 case POOL_FLAG_FORBIDSELFCONFLICTS:
151 return pool->forbidselfconflicts;
152 case POOL_FLAG_OBSOLETEUSESPROVIDES:
153 return pool->obsoleteusesprovides;
154 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
155 return pool->implicitobsoleteusesprovides;
156 case POOL_FLAG_OBSOLETEUSESCOLORS:
157 return pool->obsoleteusescolors;
158 case POOL_FLAG_NOINSTALLEDOBSOLETES:
159 return pool->noinstalledobsoletes;
160 case POOL_FLAG_HAVEDISTEPOCH:
161 return pool->havedistepoch;
169 pool_set_flag(Pool *pool, int flag, int value)
171 int old = pool_get_flag(pool, flag);
174 case POOL_FLAG_PROMOTEEPOCH:
175 pool->promoteepoch = value;
177 case POOL_FLAG_FORBIDSELFCONFLICTS:
178 pool->forbidselfconflicts = value;
180 case POOL_FLAG_OBSOLETEUSESPROVIDES:
181 pool->obsoleteusesprovides = value;
183 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
184 pool->implicitobsoleteusesprovides = value;
186 case POOL_FLAG_OBSOLETEUSESCOLORS:
187 pool->obsoleteusescolors = value;
189 case POOL_FLAG_NOINSTALLEDOBSOLETES:
190 pool->noinstalledobsoletes = value;
192 case POOL_FLAG_HAVEDISTEPOCH:
193 pool->havedistepoch = value;
203 pool_add_solvable(Pool *pool)
205 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
206 memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable));
207 return pool->nsolvables++;
211 pool_add_solvable_block(Pool *pool, int count)
213 Id nsolvables = pool->nsolvables;
216 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
217 memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count);
218 pool->nsolvables += count;
223 pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids)
227 if (reuseids && start + count == pool->nsolvables)
229 /* might want to shrink solvable array */
230 pool->nsolvables = start;
233 memset(pool->solvables + start, 0, sizeof(Solvable) * count);
238 pool_set_installed(Pool *pool, Repo *installed)
240 if (pool->installed == installed)
242 pool->installed = installed;
243 pool_freewhatprovides(pool);
247 pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
252 oa = pool->whatprovides[*(Id *)ap];
253 ob = pool->whatprovides[*(Id *)bp];
255 return *(Id *)ap - *(Id *)bp;
256 da = pool->whatprovidesdata + oa;
257 db = pool->whatprovidesdata + ob;
259 if ((r = (*da++ - *db++)) != 0)
263 return *(Id *)ap - *(Id *)bp;
267 * pool_shrink_whatprovides - unify whatprovides data
269 * whatprovides_rel must be empty for this to work!
273 pool_shrink_whatprovides(Pool *pool)
277 Id lastid, *last, *dp, *lp;
281 if (pool->ss.nstrings < 3)
283 sorted = solv_malloc2(pool->ss.nstrings, sizeof(Id));
284 for (i = id = 0; id < pool->ss.nstrings; id++)
285 if (pool->whatprovides[id] && pool->whatprovides[id] != 1)
288 solv_sort(sorted, n, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
291 for (i = 0; i < n; i++)
294 o = pool->whatprovides[id];
295 dp = pool->whatprovidesdata + o;
309 pool->whatprovides[id] = -lastid;
313 last = pool->whatprovidesdata + o;
317 dp = pool->whatprovidesdata + 2;
318 for (id = 1; id < pool->ss.nstrings; id++)
320 o = pool->whatprovides[id];
321 if (o == 0 || o == 1)
328 pool->whatprovides[id] = pool->whatprovides[i];
331 lp = pool->whatprovidesdata + o;
334 pool->whatprovides[id] = dp - pool->whatprovidesdata;
335 while ((*dp++ = *lp++) != 0)
338 o = dp - pool->whatprovidesdata;
339 POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
340 if (pool->whatprovidesdataoff == o)
342 r = pool->whatprovidesdataoff - o;
343 pool->whatprovidesdataoff = o;
344 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
345 if (r > pool->whatprovidesdataleft)
346 r = pool->whatprovidesdataleft;
347 memset(pool->whatprovidesdata + o, 0, r * sizeof(Id));
352 * pool_createwhatprovides()
354 * create hashes over pool of solvables to ease provide lookups
358 pool_createwhatprovides(Pool *pool)
360 int i, num, np, extra;
365 Offset *whatprovides;
366 Id *whatprovidesdata, *d;
367 Repo *installed = pool->installed;
370 now = solv_timems(0);
371 POOL_DEBUG(SOLV_DEBUG_STATS, "number of solvables: %d, memory used: %d K\n", pool->nsolvables, pool->nsolvables * (int)sizeof(Solvable) / 1024);
372 POOL_DEBUG(SOLV_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
373 POOL_DEBUG(SOLV_DEBUG_STATS, "string memory used: %d K array + %d K data, rel memory used: %d K array\n", pool->ss.nstrings / (1024 / (int)sizeof(Id)), pool->ss.sstrings / 1024, pool->nrels * (int)sizeof(Reldep) / 1024);
374 if (pool->ss.stringhashmask || pool->relhashmask)
375 POOL_DEBUG(SOLV_DEBUG_STATS, "string hash memory: %d K, rel hash memory : %d K\n", (pool->ss.stringhashmask + 1) / (int)(1024/sizeof(Id)), (pool->relhashmask + 1) / (int)(1024/sizeof(Id)));
377 pool_freeidhashes(pool); /* XXX: should not be here! */
378 pool_freewhatprovides(pool);
379 num = pool->ss.nstrings;
380 pool->whatprovides = whatprovides = solv_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
381 pool->whatprovides_rel = solv_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
383 /* count providers for each name */
384 for (i = pool->nsolvables - 1; i > 0; i--)
387 s = pool->solvables + i;
388 if (!s->provides || !s->repo || s->repo->disabled)
390 /* we always need the installed solvable in the whatprovides data,
391 otherwise obsoletes/conflicts on them won't work */
392 if (s->repo != installed && !pool_installable(pool, s))
394 pp = s->repo->idarraydata + s->provides;
395 while ((id = *pp++) != 0)
399 Reldep *rd = GETRELDEP(pool, id);
402 whatprovides[id]++; /* inc count of providers */
406 off = 2; /* first entry is undef, second is empty list */
407 np = 0; /* number of names provided */
408 for (i = 0, idp = whatprovides; i < num; i++, idp++)
411 if (!n) /* no providers */
413 off += n; /* make space for all providers */
414 *idp = off++; /* now idp points to terminating zero */
415 np++; /* inc # of provider 'slots' for stats */
418 POOL_DEBUG(SOLV_DEBUG_STATS, "provide ids: %d\n", np);
420 /* reserve some space for relation data */
421 extra = 2 * pool->nrels;
425 POOL_DEBUG(SOLV_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
427 /* alloc space for all providers + extra */
428 whatprovidesdata = solv_calloc(off + extra, sizeof(Id));
430 /* now fill data for all provides */
431 for (i = pool->nsolvables - 1; i > 0; i--)
434 s = pool->solvables + i;
435 if (!s->provides || !s->repo || s->repo->disabled)
437 if (s->repo != installed && !pool_installable(pool, s))
440 /* for all provides of this solvable */
441 pp = s->repo->idarraydata + s->provides;
442 while ((id = *pp++) != 0)
446 Reldep *rd = GETRELDEP(pool, id);
449 d = whatprovidesdata + whatprovides[id]; /* offset into whatprovidesdata */
450 if (*d != i) /* don't add same solvable twice */
457 pool->whatprovidesdata = whatprovidesdata;
458 pool->whatprovidesdataoff = off;
459 pool->whatprovidesdataleft = extra;
460 pool_shrink_whatprovides(pool);
461 POOL_DEBUG(SOLV_DEBUG_STATS, "whatprovides memory used: %d K id array, %d K data\n", (pool->ss.nstrings + pool->nrels + WHATPROVIDES_BLOCK) / (int)(1024/sizeof(Id)), (pool->whatprovidesdataoff + pool->whatprovidesdataleft) / (int)(1024/sizeof(Id)));
462 POOL_DEBUG(SOLV_DEBUG_STATS, "createwhatprovides took %d ms\n", solv_timems(now));
466 * free all of our whatprovides data
467 * be careful, everything internalized with pool_queuetowhatprovides is
471 pool_freewhatprovides(Pool *pool)
473 pool->whatprovides = solv_free(pool->whatprovides);
474 pool->whatprovides_rel = solv_free(pool->whatprovides_rel);
475 pool->whatprovidesdata = solv_free(pool->whatprovidesdata);
476 pool->whatprovidesdataoff = 0;
477 pool->whatprovidesdataleft = 0;
481 /******************************************************************************/
484 * pool_queuetowhatprovides - add queue contents to whatprovidesdata
486 * on-demand filling of provider information
487 * move queue data into whatprovidesdata
489 * returns: Offset into whatprovides
493 pool_queuetowhatprovides(Pool *pool, Queue *q)
496 int count = q->count;
498 if (count == 0) /* queue empty -> 1 */
501 /* extend whatprovidesdata if needed, +1 for ID_NULL-termination */
502 if (pool->whatprovidesdataleft < count + 1)
504 POOL_DEBUG(SOLV_DEBUG_STATS, "growing provides hash data...\n");
505 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
506 pool->whatprovidesdataleft = count + 4096;
509 /* copy queue to next free slot */
510 off = pool->whatprovidesdataoff;
511 memcpy(pool->whatprovidesdata + pool->whatprovidesdataoff, q->elements, count * sizeof(Id));
513 /* adapt count and ID_NULL-terminate */
514 pool->whatprovidesdataoff += count;
515 pool->whatprovidesdata[pool->whatprovidesdataoff++] = ID_NULL;
516 pool->whatprovidesdataleft -= count + 1;
522 /*************************************************************************/
524 #if defined(MULTI_SEMANTICS)
525 # define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
526 #elif defined(DEBIAN)
527 # define EVRCMP_DEPCMP EVRCMP_COMPARE
529 # define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
532 /* check if a package's nevr matches a dependency */
535 pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
537 Reldep *rd = GETRELDEP(pool, d);
540 int flags = rd->flags;
549 return pool_match_nevr(pool, s, name);
551 if (pool_match_nevr(pool, s, name))
553 return pool_match_nevr(pool, s, evr);
556 if (!pool_match_nevr(pool, s, name))
558 return pool_match_nevr(pool, s, evr);
563 if (!pool_match_nevr(pool, s, name))
566 return (flags & REL_EQ) ? 1 : 0;
571 switch (pool_evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP))
576 return (flags & REL_LT) ? 1 : 0;
578 return (flags & REL_EQ) ? 1 : 0;
580 return (flags & REL_GT) ? 1 : 0;
582 return (flags & REL_EQ) ? 1 : 0;
589 /* match (flags, evr) against provider (pflags, pevr) */
591 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
593 if (!pflags || !flags || pflags >= 8 || flags >= 8)
595 if (flags == 7 || pflags == 7)
596 return 1; /* rel provides every version */
597 if ((pflags & flags & (REL_LT | REL_GT)) != 0)
598 return 1; /* both rels show in the same direction */
600 return (flags & pflags & REL_EQ) ? 1 : 0;
601 switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
604 return (pflags & REL_EQ) ? 1 : 0;
606 return (flags & REL_LT) || (pflags & REL_GT) ? 1 : 0;
608 return (flags & pflags & REL_EQ) ? 1 : 0;
610 return (flags & REL_GT) || (pflags & REL_LT) ? 1 : 0;
612 return (flags & REL_EQ) ? 1 : 0;
619 /* match two dependencies (d1 = provider) */
622 pool_match_dep(Pool *pool, Id d1, Id d2)
632 rd2 = GETRELDEP(pool, d2);
633 return pool_match_dep(pool, d1, rd2->name);
635 rd1 = GETRELDEP(pool, d1);
638 return pool_match_dep(pool, rd1->name, d2);
640 rd2 = GETRELDEP(pool, d2);
641 /* first match name */
642 if (!pool_match_dep(pool, rd1->name, rd2->name))
644 /* name matches, check flags and evr */
645 return pool_match_flags_evr(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
651 * add packages fulfilling the relation to whatprovides array
652 * no exact providers, do range match
657 pool_addrelproviders(Pool *pool, Id d)
659 Reldep *rd = GETRELDEP(pool, d);
665 int flags = rd->flags;
670 queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
674 /* special relation */
682 wp = pool_whatprovides(pool, name);
683 pp2 = pool_whatprovides_ptr(pool, evr);
684 pp = pool->whatprovidesdata + wp;
685 while ((p = *pp++) != 0)
687 for (pp3 = pp2; *pp3; pp3++)
691 queue_push(&plist, p); /* found it */
697 wp = pool_whatprovides(pool, name);
698 pp = pool->whatprovidesdata + wp;
700 wp = pool_whatprovides(pool, evr);
704 while ((p = *pp++) != 0)
705 queue_push(&plist, p);
707 pp = pool_whatprovides_ptr(pool, evr);
708 while ((p = *pp++) != 0)
709 queue_pushunique(&plist, p);
710 if (plist.count != cnt)
715 if (name == NAMESPACE_OTHERPROVIDERS)
717 wp = pool_whatprovides(pool, evr);
720 if (pool->nscallback)
722 /* ask callback which packages provide the dependency
724 * 1: the system (aka SYSTEMSOLVABLE)
725 * >1: set of packages, stored as offset on whatprovidesdata
727 p = pool->nscallback(pool, pool->nscallbackdata, name, evr);
731 queue_push(&plist, SYSTEMSOLVABLE);
735 /* small hack: make it possible to match <pkg>.src
736 * we have to iterate over the solvables as src packages do not
737 * provide anything, thus they are not indexed in our
738 * whatprovides hash */
742 for (p = 1, s = pool->solvables + p; p < pool->nsolvables; p++, s++)
744 if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
746 if (pool_match_nevr(pool, s, name))
747 queue_push(&plist, p);
751 wp = pool_whatprovides(pool, name);
752 pp = pool->whatprovidesdata + wp;
753 while ((p = *pp++) != 0)
755 Solvable *s = pool->solvables + p;
757 queue_push(&plist, p);
762 case REL_FILECONFLICT:
763 pp = pool_whatprovides_ptr(pool, name);
764 while ((p = *pp++) != 0)
766 Id origd = MAKERELDEP(d);
767 Solvable *s = pool->solvables + p;
770 pidp = s->repo->idarraydata + s->provides;
771 while ((pid = *pidp++) != 0)
775 queue_push(&plist, p);
783 /* we can reuse an existing entry */
785 pool->whatprovides_rel[d] = wp;
791 /* simple version comparison relation */
793 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: what provides %s?\n", pool_dep2str(pool, name));
795 pp = pool_whatprovides_ptr(pool, name);
796 while (ISRELDEP(name))
798 rd = GETRELDEP(pool, name);
801 while ((p = *pp++) != 0)
803 Solvable *s = pool->solvables + p;
806 /* no provides - check nevr */
807 if (pool_match_nevr_rel(pool, s, MAKERELDEP(d)))
808 queue_push(&plist, p);
811 /* solvable p provides name in some rels */
812 pidp = s->repo->idarraydata + s->provides;
813 while ((pid = *pidp++) != 0)
818 continue; /* wrong provides name */
819 if (pool->disttype == DISTTYPE_DEB)
820 continue; /* unversioned provides can never match versioned deps */
823 prd = GETRELDEP(pool, pid);
824 if (prd->name != name)
825 continue; /* wrong provides name */
826 /* right package, both deps are rels. check flags/evr */
827 if (pool_match_flags_evr(pool, prd->flags, prd->evr, flags, evr))
831 continue; /* none of the providers matched */
832 queue_push(&plist, p);
834 /* make our system solvable provide all unknown rpmlib() stuff */
835 if (plist.count == 0 && !strncmp(pool_id2str(pool, name), "rpmlib(", 7))
836 queue_push(&plist, SYSTEMSOLVABLE);
838 /* add providers to whatprovides */
840 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
842 pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
845 return pool->whatprovides_rel[d];
848 /*************************************************************************/
851 pool_debug(Pool *pool, int type, const char *format, ...)
856 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0)
858 if ((pool->debugmask & type) == 0)
861 va_start(args, format);
862 if (!pool->debugcallback)
864 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0 && !(pool->debugmask & SOLV_DEBUG_TO_STDERR))
865 vprintf(format, args);
867 vfprintf(stderr, format, args);
870 vsnprintf(buf, sizeof(buf), format, args);
871 pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
875 pool_setdebuglevel(Pool *pool, int level)
877 int mask = SOLV_DEBUG_RESULT;
879 mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION;
881 mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
883 mask |= SOLV_DEBUG_PROPAGATE;
885 mask |= SOLV_DEBUG_RULE_CREATION;
886 mask |= pool->debugmask & SOLV_DEBUG_TO_STDERR; /* keep bit */
887 pool->debugmask = mask;
890 void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
892 pool->debugcallback = debugcallback;
893 pool->debugcallbackdata = debugcallbackdata;
896 void pool_setdebugmask(Pool *pool, int mask)
898 pool->debugmask = mask;
901 void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
903 pool->loadcallback = cb;
904 pool->loadcallbackdata = loadcbdata;
907 /*************************************************************************/
917 #define SEARCHFILES_BLOCK 127
920 pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct searchfiles *isf)
924 struct searchfiles *csf;
926 while ((dep = *ida++) != 0)
929 while (ISRELDEP(dep))
932 sid = pool->ss.nstrings + GETRELID(dep);
933 if (MAPTST(&csf->seen, sid))
938 MAPSET(&csf->seen, sid);
939 rd = GETRELDEP(pool, dep);
942 else if (rd->flags == REL_NAMESPACE)
944 if (rd->name == NAMESPACE_INSTALLED || rd->name == NAMESPACE_SPLITPROVIDES)
947 if (!csf || MAPTST(&csf->seen, sid))
952 MAPSET(&csf->seen, sid);
956 else if (rd->flags == REL_FILECONFLICT)
966 pool_addfileprovides_dep(pool, ids, csf, isf);
972 if (MAPTST(&csf->seen, dep))
974 MAPSET(&csf->seen, dep);
975 s = pool_id2str(pool, dep);
978 csf->ids = solv_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
979 csf->dirs = solv_extend(csf->dirs, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
980 csf->names = solv_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
981 csf->ids[csf->nfiles] = dep;
982 sr = strrchr(s, '/');
983 csf->names[csf->nfiles] = solv_strdup(sr + 1);
984 csf->dirs[csf->nfiles] = solv_malloc(sr - s + 1);
986 strncpy(csf->dirs[csf->nfiles], s, sr - s);
987 csf->dirs[csf->nfiles][sr - s] = 0;
992 struct addfileprovides_cbdata {
1006 addfileprovides_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
1008 struct addfileprovides_cbdata *cbd = cbdata;
1011 if (!cbd->useddirs.size)
1013 map_init(&cbd->useddirs, data->dirpool.ndirs + 1);
1014 for (i = 0; i < cbd->nfiles; i++)
1017 if (MAPTST(&cbd->providedids, cbd->ids[i]))
1022 did = repodata_str2dir(data, cbd->dirs[i], 0);
1025 MAPSET(&cbd->useddirs, did);
1027 repodata_free_dircache(data);
1029 if (value->id >= data->dirpool.ndirs || !MAPTST(&cbd->useddirs, value->id))
1031 for (i = 0; i < cbd->nfiles; i++)
1033 if (cbd->dids[i] != value->id)
1035 if (!strcmp(cbd->names[i], value->str))
1038 if (i == cbd->nfiles)
1040 s->provides = repo_addid_dep(s->repo, s->provides, cbd->ids[i], SOLVABLE_FILEMARKER);
1045 pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, struct searchfiles *sf, Repo *repoonly)
1050 Queue fileprovidesq;
1051 int i, j, repoid, repodataid;
1052 int provstart, provend;
1054 int ndone, incomplete;
1059 cbd->nfiles = sf->nfiles;
1061 cbd->dirs = sf->dirs;
1062 cbd->names = sf->names;
1063 cbd->dids = solv_realloc2(cbd->dids, sf->nfiles, sizeof(Id));
1064 map_init(&cbd->providedids, pool->ss.nstrings);
1067 repo = repoonly ? repoonly : pool->repos[repoid];
1068 map_init(&donemap, pool->nsolvables);
1069 queue_init(&fileprovidesq);
1070 provstart = provend = 0;
1073 if (!repo || repo->disabled)
1075 if (repoonly || ++repoid == pool->nrepos)
1077 repo = pool->repos[repoid];
1081 FOR_REPODATAS(repo, repodataid, data)
1083 if (ndone >= repo->nsolvables)
1086 if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
1088 map_empty(&cbd->providedids);
1089 for (i = 0; i < fileprovidesq.count; i++)
1090 MAPSET(&cbd->providedids, fileprovidesq.elements[i]);
1091 provstart = data->start;
1092 provend = data->end;
1093 for (i = 0; i < cbd->nfiles; i++)
1094 if (!MAPTST(&cbd->providedids, cbd->ids[i]))
1096 if (i == cbd->nfiles)
1098 /* great! no need to search files */
1099 for (p = data->start; p < data->end; p++)
1100 if (pool->solvables[p].repo == repo)
1102 if (MAPTST(&donemap, p))
1104 MAPSET(&donemap, p);
1111 if (!repodata_has_keyname(data, SOLVABLE_FILELIST))
1114 if (data->start < provstart || data->end > provend)
1116 map_empty(&cbd->providedids);
1117 provstart = provend = 0;
1120 /* check if the data is incomplete */
1122 if (data->state == REPODATA_AVAILABLE)
1124 for (j = 1; j < data->nkeys; j++)
1125 if (data->keys[j].name != REPOSITORY_SOLVABLES && data->keys[j].name != SOLVABLE_FILELIST)
1127 if (j < data->nkeys)
1130 for (i = 0; i < cbd->nfiles; i++)
1131 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1132 printf("need complete filelist because of %s\n", pool_id2str(pool, cbd->ids[i]));
1134 for (i = 0; i < cbd->nfiles; i++)
1135 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1137 if (i < cbd->nfiles)
1143 map_init(&cbd->useddirs, 0);
1144 for (p = data->start; p < data->end; p++)
1145 if (pool->solvables[p].repo == repo)
1147 if (MAPTST(&donemap, p))
1149 repodata_search(data, p, SOLVABLE_FILELIST, 0, addfileprovides_cb, cbd);
1152 MAPSET(&donemap, p);
1156 map_free(&cbd->useddirs);
1159 if (repoonly || ++repoid == pool->nrepos)
1161 repo = pool->repos[repoid];
1164 queue_free(&fileprovidesq);
1165 map_free(&cbd->providedids);
1169 pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst)
1172 Repo *installed, *repo;
1173 struct searchfiles sf, isf, *isfp;
1174 struct addfileprovides_cbdata cbd;
1178 installed = pool->installed;
1179 now = solv_timems(0);
1180 memset(&sf, 0, sizeof(sf));
1181 map_init(&sf.seen, pool->ss.nstrings + pool->nrels);
1182 memset(&isf, 0, sizeof(isf));
1183 map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
1188 queue_empty(idqinst);
1189 isfp = installed ? &isf : 0;
1190 for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
1196 pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &sf, isfp);
1198 pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &sf, isfp);
1200 pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &sf, isfp);
1202 pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &sf, isfp);
1204 pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &sf, isfp);
1206 pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &sf, isfp);
1208 pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &sf, isfp);
1211 map_free(&isf.seen);
1212 POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
1217 for (i = 0; i < sf.nfiles; i++)
1218 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i]));
1220 pool_addfileprovides_search(pool, &cbd, &sf, 0);
1222 for (i = 0; i < sf.nfiles; i++)
1223 queue_push(idq, sf.ids[i]);
1225 for (i = 0; i < sf.nfiles; i++)
1226 queue_push(idqinst, sf.ids[i]);
1228 for (i = 0; i < sf.nfiles; i++)
1230 solv_free(sf.dirs[i]);
1231 solv_free(sf.names[i]);
1234 solv_free(sf.names);
1239 for (i = 0; i < isf.nfiles; i++)
1240 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in installed filelist\n", pool_id2str(pool, isf.ids[i]));
1243 pool_addfileprovides_search(pool, &cbd, &isf, installed);
1244 if (installed && idqinst)
1245 for (i = 0; i < isf.nfiles; i++)
1246 queue_pushunique(idqinst, isf.ids[i]);
1248 for (i = 0; i < isf.nfiles; i++)
1250 solv_free(isf.dirs[i]);
1251 solv_free(isf.names[i]);
1253 solv_free(isf.dirs);
1254 solv_free(isf.names);
1256 solv_free(cbd.dids);
1257 pool_freewhatprovides(pool); /* as we have added provides */
1258 POOL_DEBUG(SOLV_DEBUG_STATS, "addfileprovides took %d ms\n", solv_timems(now));
1262 pool_addfileprovides(Pool *pool)
1264 pool_addfileprovides_queue(pool, 0, 0);
1268 pool_search(Pool *pool, Id p, Id key, const char *match, int flags, int (*callback)(void *cbdata, Solvable *s, struct _Repodata *data, struct _Repokey *key, struct _KeyValue *kv), void *cbdata)
1272 if (pool->solvables[p].repo)
1273 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1276 /* FIXME: obey callback return value! */
1277 for (p = 1; p < pool->nsolvables; p++)
1278 if (pool->solvables[p].repo)
1279 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1283 pool_clear_pos(Pool *pool)
1285 memset(&pool->pos, 0, sizeof(pool->pos));
1290 pool_set_languages(Pool *pool, const char **languages, int nlanguages)
1294 pool->languagecache = solv_free(pool->languagecache);
1295 pool->languagecacheother = 0;
1296 if (pool->nlanguages)
1298 for (i = 0; i < pool->nlanguages; i++)
1299 free((char *)pool->languages[i]);
1300 free(pool->languages);
1302 pool->nlanguages = nlanguages;
1305 pool->languages = solv_calloc(nlanguages, sizeof(const char **));
1306 for (i = 0; i < pool->nlanguages; i++)
1307 pool->languages[i] = solv_strdup(languages[i]);
1311 pool_id2langid(Pool *pool, Id id, const char *lang, int create)
1317 if (!lang || !*lang)
1319 n = pool_id2str(pool, id);
1320 l = strlen(n) + strlen(lang) + 2;
1321 if (l > sizeof(buf))
1322 p = solv_malloc(strlen(n) + strlen(lang) + 2);
1325 sprintf(p, "%s:%s", n, lang);
1326 id = pool_str2id(pool, p, create);
1333 pool_alloctmpspace(Pool *pool, int len)
1335 int n = pool->tmpspace.n;
1338 if (len > pool->tmpspace.len[n])
1340 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1341 pool->tmpspace.len[n] = len + 32;
1343 pool->tmpspace.n = (n + 1) % POOL_TMPSPACEBUF;
1344 return pool->tmpspace.buf[n];
1348 pool_alloctmpspace_free(Pool *pool, const char *space, int len)
1353 n = oldn = pool->tmpspace.n;
1357 n = POOL_TMPSPACEBUF - 1;
1360 if (pool->tmpspace.buf[n] != space)
1362 if (len > pool->tmpspace.len[n])
1364 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1365 pool->tmpspace.len[n] = len + 32;
1367 return pool->tmpspace.buf[n];
1374 pool_freetmpspace(Pool *pool, const char *space)
1376 int n = pool->tmpspace.n;
1379 n = (n + (POOL_TMPSPACEBUF - 1)) % POOL_TMPSPACEBUF;
1380 if (pool->tmpspace.buf[n] == space)
1381 pool->tmpspace.n = n;
1385 pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3)
1389 l1 = str1 ? strlen(str1) : 0;
1390 l2 = str2 ? strlen(str2) : 0;
1391 l3 = str3 ? strlen(str3) : 0;
1392 s = str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1413 pool_tmpappend(Pool *pool, const char *str1, const char *str2, const char *str3)
1418 l1 = str1 ? strlen(str1) : 0;
1419 l2 = str2 ? strlen(str2) : 0;
1420 l3 = str3 ? strlen(str3) : 0;
1421 str = pool_alloctmpspace_free(pool, str1, l1 + l2 + l3 + 1);
1425 str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1448 pool_bin2hex(Pool *pool, const unsigned char *buf, int len)
1453 s = pool_alloctmpspace(pool, 2 * len + 1);
1454 solv_bin2hex(buf, len, s);
1458 /*******************************************************************/
1470 struct mptree *mptree;
1481 solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
1483 struct ducbdata *cbd = cbdata;
1486 if (data != cbd->olddata)
1488 Id dn, mp, comp, *dirmap, *dirs;
1490 const char *compstr;
1491 struct mptree *mptree;
1493 /* create map from dir to mptree */
1494 cbd->dirmap = solv_free(cbd->dirmap);
1496 dirmap = solv_calloc(data->dirpool.ndirs, sizeof(Id));
1497 mptree = cbd->mptree;
1499 for (dn = 2, dirs = data->dirpool.dirs + dn; dn < data->dirpool.ndirs; dn++)
1513 if (!mptree[mp].child)
1518 if (data->localpool)
1519 compstr = stringpool_id2str(&data->spool, comp);
1521 compstr = pool_id2str(data->repo->pool, comp);
1522 compl = strlen(compstr);
1523 for (i = mptree[mp].child; i; i = mptree[i].sibling)
1524 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1526 dirmap[dn] = i ? i : -mp;
1528 /* change dirmap to point to mountpoint instead of mptree */
1529 for (dn = 0; dn < data->dirpool.ndirs; dn++)
1532 dirmap[dn] = mptree[mp > 0 ? mp : -mp].mountpoint;
1534 cbd->dirmap = dirmap;
1535 cbd->nmap = data->dirpool.ndirs;
1536 cbd->olddata = data;
1539 if (value->id < 0 || value->id >= cbd->nmap)
1541 mp = cbd->dirmap[value->id];
1544 if (cbd->addsub > 0)
1546 cbd->mps[mp].kbytes += value->num;
1547 cbd->mps[mp].files += value->num2;
1551 cbd->mps[mp].kbytes -= value->num;
1552 cbd->mps[mp].files -= value->num2;
1558 propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint)
1561 if (mptree[pos].mountpoint == -1)
1562 mptree[pos].mountpoint = mountpoint;
1564 mountpoint = mptree[pos].mountpoint;
1565 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1566 propagate_mountpoints(mptree, i, mountpoint);
1569 #define MPTREE_BLOCK 15
1572 pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
1575 const char *path, *compstr;
1576 struct mptree *mptree;
1580 struct ducbdata cbd;
1584 Repo *oldinstalled = pool->installed;
1586 memset(&ignoredu, 0, sizeof(ignoredu));
1593 mptree = solv_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
1596 mptree[0].sibling = 0;
1597 mptree[0].child = 0;
1599 mptree[0].compl = 0;
1600 mptree[0].mountpoint = -1;
1603 /* create component tree */
1604 for (mp = 0; mp < nmps; mp++)
1609 path = mps[mp].path;
1614 if ((p = strchr(path, '/')) == 0)
1617 compl = strlen(compstr);
1628 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1629 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1633 /* create new node */
1634 mptree = solv_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
1636 mptree[i].sibling = mptree[pos].child;
1637 mptree[i].child = 0;
1638 mptree[i].comp = compstr;
1639 mptree[i].compl = compl;
1640 mptree[i].mountpoint = -1;
1641 mptree[pos].child = i;
1645 mptree[pos].mountpoint = mp;
1648 propagate_mountpoints(mptree, 0, mptree[0].mountpoint);
1651 for (i = 0; i < nmptree; i++)
1653 printf("#%d sibling: %d\n", i, mptree[i].sibling);
1654 printf("#%d child: %d\n", i, mptree[i].child);
1655 printf("#%d comp: %s\n", i, mptree[i].comp);
1656 printf("#%d compl: %d\n", i, mptree[i].compl);
1657 printf("#%d mountpont: %d\n", i, mptree[i].mountpoint);
1661 cbd.mptree = mptree;
1663 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1665 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1667 if (!MAPTST(installedmap, sp))
1670 repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1671 if (!cbd.hasdu && oldinstalled)
1674 /* no du data available, ignore data of all installed solvables we obsolete */
1676 map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
1679 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
1680 while ((obs = *obsp++) != 0)
1681 FOR_PROVIDES(op, opp, obs)
1682 if (op >= oldinstalled->start && op < oldinstalled->end)
1683 MAPSET(&ignoredu, op - oldinstalled->start);
1685 FOR_PROVIDES(op, opp, s->name)
1686 if (pool->solvables[op].name == s->name)
1687 if (op >= oldinstalled->start && op < oldinstalled->end)
1688 MAPSET(&ignoredu, op - oldinstalled->start);
1694 /* assumes we allways have du data for installed solvables */
1695 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1697 if (MAPTST(installedmap, sp))
1699 if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start))
1701 repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1705 map_free(&ignoredu);
1706 solv_free(cbd.dirmap);
1711 pool_calc_installsizechange(Pool *pool, Map *installedmap)
1716 Repo *oldinstalled = pool->installed;
1718 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1720 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1722 if (!MAPTST(installedmap, sp))
1724 change += solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
1728 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1730 if (MAPTST(installedmap, sp))
1732 change -= solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
1740 * 2: conflicts with installed
1741 * 8: interesting (only true if installed)
1745 static inline Id dep2name(Pool *pool, Id dep)
1747 while (ISRELDEP(dep))
1749 Reldep *rd = rd = GETRELDEP(pool, dep);
1755 static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
1758 Solvable *sn = pool->solvables + n;
1760 FOR_PROVIDES(p, pp, sn->name)
1762 Solvable *s = pool->solvables + p;
1763 if (s->name != sn->name || s->arch != sn->arch)
1765 if ((map[p] & 9) != 9)
1767 if (pool_match_nevr(pool, pool->solvables + p, con))
1769 return 1; /* found installed package that doesn't conflict */
1774 static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
1778 FOR_PROVIDES(p, pp, dep)
1780 if (p == SYSTEMSOLVABLE)
1781 return 1; /* always boring, as never constraining */
1782 if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
1784 if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
1785 if (providedbyinstalled_multiversion(pool, map, p, dep))
1787 if ((map[p] & 9) == 9)
1795 * pool_trivial_installable - calculate if a set of solvables is
1796 * trivial installable without any other installs/deinstalls of
1797 * packages not belonging to the set.
1799 * the state is returned in the result queue:
1800 * 1: solvable is installable without any other package changes
1801 * 0: solvable is not installable
1802 * -1: solvable is installable, but doesn't constrain any installed packages
1806 pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
1809 Id p, *dp, con, *conp, req, *reqp;
1813 map = solv_calloc(pool->nsolvables, 1);
1814 for (p = 1; p < pool->nsolvables; p++)
1816 if (!MAPTST(installedmap, p))
1819 s = pool->solvables + p;
1822 conp = s->repo->idarraydata + s->conflicts;
1823 while ((con = *conp++) != 0)
1825 dp = pool_whatprovides_ptr(pool, con);
1827 map[p] |= 2; /* XXX: self conflict ? */
1830 for (i = 0; i < pkgs->count; i++)
1831 map[pkgs->elements[i]] = 16;
1833 for (i = 0, did = 0; did < pkgs->count; i++, did++)
1835 if (i == pkgs->count)
1837 p = pkgs->elements[i];
1838 if ((map[p] & 16) == 0)
1840 if ((map[p] & 2) != 0)
1845 s = pool->solvables + p;
1849 reqp = s->repo->idarraydata + s->requires;
1850 while ((req = *reqp++) != 0)
1852 if (req == SOLVABLE_PREREQMARKER)
1854 r = providedbyinstalled(pool, map, req, 0, 0);
1857 /* decided and miss */
1861 m |= r; /* 1 | 9 | 16 | 17 */
1870 int ispatch = 0; /* see solver.c patch handling */
1872 if (!strncmp("patch:", pool_id2str(pool, s->name), 6))
1874 conp = s->repo->idarraydata + s->conflicts;
1875 while ((con = *conp++) != 0)
1877 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1882 if ((m == 1 || m == 17) && ISRELDEP(con))
1884 con = dep2name(pool, con);
1885 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1890 continue; /* found a conflict */
1893 if (s->repo && s->repo != oldinstalled)
1895 Id p2, obs, *obsp, *pp;
1899 obsp = s->repo->idarraydata + s->obsoletes;
1900 while ((obs = *obsp++) != 0)
1902 if ((providedbyinstalled(pool, map, obs, 0, 0) & 1) != 0)
1911 FOR_PROVIDES(p2, pp, s->name)
1913 s2 = pool->solvables + p2;
1914 if (s2->name == s->name && (map[p2] & 1) != 0)
1931 queue_init_clone(res, pkgs);
1932 for (i = 0; i < pkgs->count; i++)
1934 m = map[pkgs->elements[i]];
1941 res->elements[i] = r;
1947 pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
1949 pool_trivial_installable_noobsoletesmap(pool, installedmap, pkgs, res, 0);
1953 pool_lookup_str(Pool *pool, Id entry, Id keyname)
1955 if (entry == SOLVID_POS && pool->pos.repo)
1956 return repodata_lookup_str(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
1959 return solvable_lookup_str(pool->solvables + entry, keyname);
1963 pool_lookup_id(Pool *pool, Id entry, Id keyname)
1965 if (entry == SOLVID_POS && pool->pos.repo)
1967 Repodata *data = pool->pos.repo->repodata + pool->pos.repodataid;
1968 Id id = repodata_lookup_id(data, SOLVID_POS, keyname);
1969 return data->localpool ? repodata_globalize_id(data, id, 1) : id;
1973 return solvable_lookup_id(pool->solvables + entry, keyname);
1977 pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned long long notfound)
1979 if (entry == SOLVID_POS && pool->pos.repo)
1981 unsigned long long value;
1982 if (repodata_lookup_num(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, &value))
1988 return solvable_lookup_num(pool->solvables + entry, keyname, notfound);
1992 pool_lookup_void(Pool *pool, Id entry, Id keyname)
1994 if (entry == SOLVID_POS && pool->pos.repo)
1995 return repodata_lookup_void(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
1998 return solvable_lookup_void(pool->solvables + entry, keyname);
2001 const unsigned char *
2002 pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
2004 if (entry == SOLVID_POS && pool->pos.repo)
2005 return repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
2008 return solvable_lookup_bin_checksum(pool->solvables + entry, keyname, typep);
2012 pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
2014 if (entry == SOLVID_POS && pool->pos.repo)
2016 const unsigned char *chk = repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
2017 return chk ? repodata_chk2str(pool->pos.repo->repodata + pool->pos.repodataid, *typep, chk) : 0;
2021 return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
2025 pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
2027 int hadhashes = pool->relhashtbl ? 1 : 0;
2033 if (!conflicts->count)
2035 pool_freewhatprovides(pool);
2036 for (i = 0; i < conflicts->count; i += 5)
2038 fn = conflicts->elements[i];
2039 p = conflicts->elements[i + 1];
2040 md5 = conflicts->elements[i + 2];
2041 q = conflicts->elements[i + 3];
2042 id = pool_rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
2043 s = pool->solvables + p;
2046 s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
2047 s = pool->solvables + q;
2050 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2053 pool_freeidhashes(pool);