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 /* initialize the system solvable */
58 s = pool->solvables + SYSTEMSOLVABLE;
59 s->name = SYSTEM_SYSTEM;
60 s->arch = ARCH_NOARCH;
63 queue_init(&pool->vendormap);
65 pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
67 pool->obsoleteusescolors = 1;
70 pool->disttype = DISTTYPE_DEB;
73 pool->forbidselfconflicts = 1;
74 pool->obsoleteusesprovides = 1;
75 pool->implicitobsoleteusesprovides = 1;
76 pool->havedistepoch = 1;
82 /* free all the resources of our pool */
88 pool_freewhatprovides(pool);
89 pool_freeidhashes(pool);
90 pool_freeallrepos(pool, 1);
91 solv_free(pool->id2arch);
92 solv_free(pool->id2color);
93 solv_free(pool->solvables);
94 stringpool_free(&pool->ss);
95 solv_free(pool->rels);
96 pool_setvendorclasses(pool, 0);
97 queue_free(&pool->vendormap);
98 for (i = 0; i < POOL_TMPSPACEBUF; i++)
99 solv_free(pool->tmpspace.buf[i]);
100 for (i = 0; i < pool->nlanguages; i++)
101 free((char *)pool->languages[i]);
102 solv_free(pool->languages);
103 solv_free(pool->languagecache);
108 pool_freeallrepos(Pool *pool, int reuseids)
112 pool_freewhatprovides(pool);
113 for (i = 1; i < pool->nrepos; i++)
115 repo_freedata(pool->repos[i]);
116 pool->repos = solv_free(pool->repos);
119 /* the first two solvables don't belong to a repo */
120 pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
123 #ifdef MULTI_SEMANTICS
125 pool_setdisttype(Pool *pool, int disttype)
127 pool->disttype = disttype;
132 pool_get_flag(Pool *pool, int flag)
136 case POOL_FLAG_PROMOTEEPOCH:
137 return pool->promoteepoch;
138 case POOL_FLAG_FORBIDSELFCONFLICTS:
139 return pool->forbidselfconflicts;
140 case POOL_FLAG_OBSOLETEUSESPROVIDES:
141 return pool->obsoleteusesprovides;
142 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
143 return pool->implicitobsoleteusesprovides;
144 case POOL_FLAG_OBSOLETEUSESCOLORS:
145 return pool->obsoleteusescolors;
146 case POOL_FLAG_NOINSTALLEDOBSOLETES:
147 return pool->noinstalledobsoletes;
155 pool_set_flag(Pool *pool, int flag, int value)
157 int old = pool_get_flag(pool, flag);
160 case POOL_FLAG_PROMOTEEPOCH:
161 pool->promoteepoch = value;
163 case POOL_FLAG_FORBIDSELFCONFLICTS:
164 pool->forbidselfconflicts = value;
166 case POOL_FLAG_OBSOLETEUSESPROVIDES:
167 pool->obsoleteusesprovides = value;
169 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
170 pool->implicitobsoleteusesprovides = value;
172 case POOL_FLAG_OBSOLETEUSESCOLORS:
173 pool->obsoleteusescolors = value;
175 case POOL_FLAG_NOINSTALLEDOBSOLETES:
176 pool->noinstalledobsoletes = value;
186 pool_add_solvable(Pool *pool)
188 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
189 memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable));
190 return pool->nsolvables++;
194 pool_add_solvable_block(Pool *pool, int count)
196 Id nsolvables = pool->nsolvables;
199 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
200 memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count);
201 pool->nsolvables += count;
206 pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids)
210 if (reuseids && start + count == pool->nsolvables)
212 /* might want to shrink solvable array */
213 pool->nsolvables = start;
216 memset(pool->solvables + start, 0, sizeof(Solvable) * count);
221 pool_set_installed(Pool *pool, Repo *installed)
223 if (pool->installed == installed)
225 pool->installed = installed;
226 pool_freewhatprovides(pool);
230 pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
235 oa = pool->whatprovides[*(Id *)ap];
236 ob = pool->whatprovides[*(Id *)bp];
238 return *(Id *)ap - *(Id *)bp;
239 da = pool->whatprovidesdata + oa;
240 db = pool->whatprovidesdata + ob;
242 if ((r = (*da++ - *db++)) != 0)
246 return *(Id *)ap - *(Id *)bp;
250 * pool_shrink_whatprovides - unify whatprovides data
252 * whatprovides_rel must be empty for this to work!
256 pool_shrink_whatprovides(Pool *pool)
260 Id lastid, *last, *dp, *lp;
264 if (pool->ss.nstrings < 3)
266 sorted = solv_malloc2(pool->ss.nstrings, sizeof(Id));
267 for (i = id = 0; id < pool->ss.nstrings; id++)
268 if (pool->whatprovides[id] && pool->whatprovides[id] != 1)
271 solv_sort(sorted, n, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
274 for (i = 0; i < n; i++)
277 o = pool->whatprovides[id];
278 dp = pool->whatprovidesdata + o;
292 pool->whatprovides[id] = -lastid;
296 last = pool->whatprovidesdata + o;
300 dp = pool->whatprovidesdata + 2;
301 for (id = 1; id < pool->ss.nstrings; id++)
303 o = pool->whatprovides[id];
304 if (o == 0 || o == 1)
311 pool->whatprovides[id] = pool->whatprovides[i];
314 lp = pool->whatprovidesdata + o;
317 pool->whatprovides[id] = dp - pool->whatprovidesdata;
318 while ((*dp++ = *lp++) != 0)
321 o = dp - pool->whatprovidesdata;
322 POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
323 if (pool->whatprovidesdataoff == o)
325 r = pool->whatprovidesdataoff - o;
326 pool->whatprovidesdataoff = o;
327 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
328 if (r > pool->whatprovidesdataleft)
329 r = pool->whatprovidesdataleft;
330 memset(pool->whatprovidesdata + o, 0, r * sizeof(Id));
335 * pool_createwhatprovides()
337 * create hashes over pool of solvables to ease provide lookups
341 pool_createwhatprovides(Pool *pool)
343 int i, num, np, extra;
348 Offset *whatprovides;
349 Id *whatprovidesdata, *d;
350 Repo *installed = pool->installed;
353 now = solv_timems(0);
354 POOL_DEBUG(SOLV_DEBUG_STATS, "number of solvables: %d, memory used: %d K\n", pool->nsolvables, pool->nsolvables * (int)sizeof(Solvable) / 1024);
355 POOL_DEBUG(SOLV_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
356 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);
357 if (pool->ss.stringhashmask || pool->relhashmask)
358 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)));
360 pool_freeidhashes(pool); /* XXX: should not be here! */
361 pool_freewhatprovides(pool);
362 num = pool->ss.nstrings;
363 pool->whatprovides = whatprovides = solv_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
364 pool->whatprovides_rel = solv_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
366 /* count providers for each name */
367 for (i = pool->nsolvables - 1; i > 0; i--)
370 s = pool->solvables + i;
371 if (!s->provides || !s->repo || s->repo->disabled)
373 /* we always need the installed solvable in the whatprovides data,
374 otherwise obsoletes/conflicts on them won't work */
375 if (s->repo != installed && !pool_installable(pool, s))
377 pp = s->repo->idarraydata + s->provides;
378 while ((id = *pp++) != 0)
382 Reldep *rd = GETRELDEP(pool, id);
385 whatprovides[id]++; /* inc count of providers */
389 off = 2; /* first entry is undef, second is empty list */
390 np = 0; /* number of names provided */
391 for (i = 0, idp = whatprovides; i < num; i++, idp++)
394 if (!n) /* no providers */
396 off += n; /* make space for all providers */
397 *idp = off++; /* now idp points to terminating zero */
398 np++; /* inc # of provider 'slots' for stats */
401 POOL_DEBUG(SOLV_DEBUG_STATS, "provide ids: %d\n", np);
403 /* reserve some space for relation data */
404 extra = 2 * pool->nrels;
408 POOL_DEBUG(SOLV_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
410 /* alloc space for all providers + extra */
411 whatprovidesdata = solv_calloc(off + extra, sizeof(Id));
413 /* now fill data for all provides */
414 for (i = pool->nsolvables - 1; i > 0; i--)
417 s = pool->solvables + i;
418 if (!s->provides || !s->repo || s->repo->disabled)
420 if (s->repo != installed && !pool_installable(pool, s))
423 /* for all provides of this solvable */
424 pp = s->repo->idarraydata + s->provides;
425 while ((id = *pp++) != 0)
429 Reldep *rd = GETRELDEP(pool, id);
432 d = whatprovidesdata + whatprovides[id]; /* offset into whatprovidesdata */
433 if (*d != i) /* don't add same solvable twice */
440 pool->whatprovidesdata = whatprovidesdata;
441 pool->whatprovidesdataoff = off;
442 pool->whatprovidesdataleft = extra;
443 pool_shrink_whatprovides(pool);
444 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)));
445 POOL_DEBUG(SOLV_DEBUG_STATS, "createwhatprovides took %d ms\n", solv_timems(now));
449 * free all of our whatprovides data
450 * be careful, everything internalized with pool_queuetowhatprovides is
454 pool_freewhatprovides(Pool *pool)
456 pool->whatprovides = solv_free(pool->whatprovides);
457 pool->whatprovides_rel = solv_free(pool->whatprovides_rel);
458 pool->whatprovidesdata = solv_free(pool->whatprovidesdata);
459 pool->whatprovidesdataoff = 0;
460 pool->whatprovidesdataleft = 0;
464 /******************************************************************************/
467 * pool_queuetowhatprovides - add queue contents to whatprovidesdata
469 * on-demand filling of provider information
470 * move queue data into whatprovidesdata
472 * returns: Offset into whatprovides
476 pool_queuetowhatprovides(Pool *pool, Queue *q)
479 int count = q->count;
481 if (count == 0) /* queue empty -> 1 */
484 /* extend whatprovidesdata if needed, +1 for ID_NULL-termination */
485 if (pool->whatprovidesdataleft < count + 1)
487 POOL_DEBUG(SOLV_DEBUG_STATS, "growing provides hash data...\n");
488 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
489 pool->whatprovidesdataleft = count + 4096;
492 /* copy queue to next free slot */
493 off = pool->whatprovidesdataoff;
494 memcpy(pool->whatprovidesdata + pool->whatprovidesdataoff, q->elements, count * sizeof(Id));
496 /* adapt count and ID_NULL-terminate */
497 pool->whatprovidesdataoff += count;
498 pool->whatprovidesdata[pool->whatprovidesdataoff++] = ID_NULL;
499 pool->whatprovidesdataleft -= count + 1;
505 /*************************************************************************/
507 #if defined(MULTI_SEMANTICS)
508 # define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
509 #elif defined(DEBIAN_SEMANTICS)
510 # define EVRCMP_DEPCMP EVRCMP_COMPARE
512 # define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
515 /* check if a package's nevr matches a dependency */
518 pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
520 Reldep *rd = GETRELDEP(pool, d);
523 int flags = rd->flags;
532 return pool_match_nevr(pool, s, name);
534 if (pool_match_nevr(pool, s, name))
536 return pool_match_nevr(pool, s, evr);
539 if (!pool_match_nevr(pool, s, name))
541 return pool_match_nevr(pool, s, evr);
546 if (!pool_match_nevr(pool, s, name))
549 return (flags & REL_EQ) ? 1 : 0;
554 switch (pool_evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP))
559 return (flags & REL_LT) ? 1 : 0;
561 return (flags & REL_EQ) ? 1 : 0;
563 return (flags & REL_GT) ? 1 : 0;
565 return (flags & REL_EQ) ? 1 : 0;
572 /* match (flags, evr) against provider (pflags, pevr) */
574 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
576 if (!pflags || !flags || pflags >= 8 || flags >= 8)
578 if (flags == 7 || pflags == 7)
579 return 1; /* rel provides every version */
580 if ((pflags & flags & (REL_LT | REL_GT)) != 0)
581 return 1; /* both rels show in the same direction */
583 return (flags & pflags & REL_EQ) ? 1 : 0;
584 switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
587 return (pflags & REL_EQ) ? 1 : 0;
589 return (flags & REL_LT) || (pflags & REL_GT) ? 1 : 0;
591 return (flags & pflags & REL_EQ) ? 1 : 0;
593 return (flags & REL_GT) || (pflags & REL_LT) ? 1 : 0;
595 return (flags & REL_EQ) ? 1 : 0;
602 /* match two dependencies (d1 = provider) */
605 pool_match_dep(Pool *pool, Id d1, Id d2)
615 rd2 = GETRELDEP(pool, d2);
616 return pool_match_dep(pool, d1, rd2->name);
618 rd1 = GETRELDEP(pool, d1);
621 return pool_match_dep(pool, rd1->name, d2);
623 rd2 = GETRELDEP(pool, d2);
624 /* first match name */
625 if (!pool_match_dep(pool, rd1->name, rd2->name))
627 /* name matches, check flags and evr */
628 return pool_match_flags_evr(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
634 * add packages fulfilling the relation to whatprovides array
635 * no exact providers, do range match
640 pool_addrelproviders(Pool *pool, Id d)
642 Reldep *rd = GETRELDEP(pool, d);
648 int flags = rd->flags;
653 queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
657 /* special relation */
665 wp = pool_whatprovides(pool, name);
666 pp2 = pool_whatprovides_ptr(pool, evr);
667 pp = pool->whatprovidesdata + wp;
668 while ((p = *pp++) != 0)
670 for (pp3 = pp2; *pp3; pp3++)
674 queue_push(&plist, p); /* found it */
680 wp = pool_whatprovides(pool, name);
681 pp = pool->whatprovidesdata + wp;
683 wp = pool_whatprovides(pool, evr);
687 while ((p = *pp++) != 0)
688 queue_push(&plist, p);
690 pp = pool_whatprovides_ptr(pool, evr);
691 while ((p = *pp++) != 0)
692 queue_pushunique(&plist, p);
693 if (plist.count != cnt)
698 if (name == NAMESPACE_OTHERPROVIDERS)
700 wp = pool_whatprovides(pool, evr);
703 if (pool->nscallback)
705 /* ask callback which packages provide the dependency
707 * 1: the system (aka SYSTEMSOLVABLE)
708 * >1: set of packages, stored as offset on whatprovidesdata
710 p = pool->nscallback(pool, pool->nscallbackdata, name, evr);
714 queue_push(&plist, SYSTEMSOLVABLE);
718 /* small hack: make it possible to match <pkg>.src
719 * we have to iterate over the solvables as src packages do not
720 * provide anything, thus they are not indexed in our
721 * whatprovides hash */
725 for (p = 1, s = pool->solvables + p; p < pool->nsolvables; p++, s++)
727 if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
729 if (pool_match_nevr(pool, s, name))
730 queue_push(&plist, p);
734 wp = pool_whatprovides(pool, name);
735 pp = pool->whatprovidesdata + wp;
736 while ((p = *pp++) != 0)
738 Solvable *s = pool->solvables + p;
740 queue_push(&plist, p);
745 case REL_FILECONFLICT:
746 pp = pool_whatprovides_ptr(pool, name);
747 while ((p = *pp++) != 0)
749 Id origd = MAKERELDEP(d);
750 Solvable *s = pool->solvables + p;
753 pidp = s->repo->idarraydata + s->provides;
754 while ((pid = *pidp++) != 0)
758 queue_push(&plist, p);
766 /* we can reuse an existing entry */
768 pool->whatprovides_rel[d] = wp;
774 /* simple version comparison relation */
776 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: what provides %s?\n", pool_dep2str(pool, name));
778 pp = pool_whatprovides_ptr(pool, name);
779 while (ISRELDEP(name))
781 rd = GETRELDEP(pool, name);
784 while ((p = *pp++) != 0)
786 Solvable *s = pool->solvables + p;
789 /* no provides - check nevr */
790 if (pool_match_nevr_rel(pool, s, MAKERELDEP(d)))
791 queue_push(&plist, p);
794 /* solvable p provides name in some rels */
795 pidp = s->repo->idarraydata + s->provides;
796 while ((pid = *pidp++) != 0)
801 continue; /* wrong provides name */
802 if (pool->disttype == DISTTYPE_DEB)
803 continue; /* unversioned provides can never match versioned deps */
806 prd = GETRELDEP(pool, pid);
807 if (prd->name != name)
808 continue; /* wrong provides name */
809 /* right package, both deps are rels. check flags/evr */
810 if (pool_match_flags_evr(pool, prd->flags, prd->evr, flags, evr))
814 continue; /* none of the providers matched */
815 queue_push(&plist, p);
817 /* make our system solvable provide all unknown rpmlib() stuff */
818 if (plist.count == 0 && !strncmp(pool_id2str(pool, name), "rpmlib(", 7))
819 queue_push(&plist, SYSTEMSOLVABLE);
821 /* add providers to whatprovides */
823 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
825 pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
828 return pool->whatprovides_rel[d];
831 /*************************************************************************/
834 pool_debug(Pool *pool, int type, const char *format, ...)
839 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0)
841 if ((pool->debugmask & type) == 0)
844 va_start(args, format);
845 if (!pool->debugcallback)
847 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0 && !(pool->debugmask & SOLV_DEBUG_TO_STDERR))
848 vprintf(format, args);
850 vfprintf(stderr, format, args);
853 vsnprintf(buf, sizeof(buf), format, args);
854 pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
858 pool_setdebuglevel(Pool *pool, int level)
860 int mask = SOLV_DEBUG_RESULT;
862 mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION;
864 mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
866 mask |= SOLV_DEBUG_PROPAGATE;
868 mask |= SOLV_DEBUG_RULE_CREATION;
869 mask |= pool->debugmask & SOLV_DEBUG_TO_STDERR; /* keep bit */
870 pool->debugmask = mask;
873 void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
875 pool->debugcallback = debugcallback;
876 pool->debugcallbackdata = debugcallbackdata;
879 void pool_setdebugmask(Pool *pool, int mask)
881 pool->debugmask = mask;
884 void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
886 pool->loadcallback = cb;
887 pool->loadcallbackdata = loadcbdata;
890 /*************************************************************************/
900 #define SEARCHFILES_BLOCK 127
903 pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct searchfiles *isf)
907 struct searchfiles *csf;
909 while ((dep = *ida++) != 0)
912 while (ISRELDEP(dep))
915 sid = pool->ss.nstrings + GETRELID(dep);
916 if (MAPTST(&csf->seen, sid))
921 MAPSET(&csf->seen, sid);
922 rd = GETRELDEP(pool, dep);
925 else if (rd->flags == REL_NAMESPACE)
927 if (rd->name == NAMESPACE_INSTALLED || rd->name == NAMESPACE_SPLITPROVIDES)
930 if (!csf || MAPTST(&csf->seen, sid))
935 MAPSET(&csf->seen, sid);
939 else if (rd->flags == REL_FILECONFLICT)
949 pool_addfileprovides_dep(pool, ids, csf, isf);
955 if (MAPTST(&csf->seen, dep))
957 MAPSET(&csf->seen, dep);
958 s = pool_id2str(pool, dep);
961 csf->ids = solv_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
962 csf->dirs = solv_extend(csf->dirs, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
963 csf->names = solv_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
964 csf->ids[csf->nfiles] = dep;
965 sr = strrchr(s, '/');
966 csf->names[csf->nfiles] = solv_strdup(sr + 1);
967 csf->dirs[csf->nfiles] = solv_malloc(sr - s + 1);
969 strncpy(csf->dirs[csf->nfiles], s, sr - s);
970 csf->dirs[csf->nfiles][sr - s] = 0;
975 struct addfileprovides_cbdata {
989 addfileprovides_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
991 struct addfileprovides_cbdata *cbd = cbdata;
994 if (!cbd->useddirs.size)
996 map_init(&cbd->useddirs, data->dirpool.ndirs + 1);
997 for (i = 0; i < cbd->nfiles; i++)
1000 if (MAPTST(&cbd->providedids, cbd->ids[i]))
1005 did = repodata_str2dir(data, cbd->dirs[i], 0);
1008 MAPSET(&cbd->useddirs, did);
1010 repodata_free_dircache(data);
1012 if (value->id >= data->dirpool.ndirs || !MAPTST(&cbd->useddirs, value->id))
1014 for (i = 0; i < cbd->nfiles; i++)
1016 if (cbd->dids[i] != value->id)
1018 if (!strcmp(cbd->names[i], value->str))
1021 if (i == cbd->nfiles)
1023 s->provides = repo_addid_dep(s->repo, s->provides, cbd->ids[i], SOLVABLE_FILEMARKER);
1028 pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, struct searchfiles *sf, Repo *repoonly)
1033 Queue fileprovidesq;
1034 int i, j, repoid, repodataid;
1035 int provstart, provend;
1037 int ndone, incomplete;
1042 cbd->nfiles = sf->nfiles;
1044 cbd->dirs = sf->dirs;
1045 cbd->names = sf->names;
1046 cbd->dids = solv_realloc2(cbd->dids, sf->nfiles, sizeof(Id));
1047 map_init(&cbd->providedids, pool->ss.nstrings);
1050 repo = repoonly ? repoonly : pool->repos[repoid];
1051 map_init(&donemap, pool->nsolvables);
1052 queue_init(&fileprovidesq);
1053 provstart = provend = 0;
1056 if (!repo || repo->disabled)
1058 if (repoonly || ++repoid == pool->nrepos)
1060 repo = pool->repos[repoid];
1064 FOR_REPODATAS(repo, repodataid, data)
1066 if (ndone >= repo->nsolvables)
1069 if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
1071 map_empty(&cbd->providedids);
1072 for (i = 0; i < fileprovidesq.count; i++)
1073 MAPSET(&cbd->providedids, fileprovidesq.elements[i]);
1074 provstart = data->start;
1075 provend = data->end;
1076 for (i = 0; i < cbd->nfiles; i++)
1077 if (!MAPTST(&cbd->providedids, cbd->ids[i]))
1079 if (i == cbd->nfiles)
1081 /* great! no need to search files */
1082 for (p = data->start; p < data->end; p++)
1083 if (pool->solvables[p].repo == repo)
1085 if (MAPTST(&donemap, p))
1087 MAPSET(&donemap, p);
1094 if (!repodata_has_keyname(data, SOLVABLE_FILELIST))
1097 if (data->start < provstart || data->end > provend)
1099 map_empty(&cbd->providedids);
1100 provstart = provend = 0;
1103 /* check if the data is incomplete */
1105 if (data->state == REPODATA_AVAILABLE)
1107 for (j = 1; j < data->nkeys; j++)
1108 if (data->keys[j].name != REPOSITORY_SOLVABLES && data->keys[j].name != SOLVABLE_FILELIST)
1110 if (j < data->nkeys)
1113 for (i = 0; i < cbd->nfiles; i++)
1114 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1115 printf("need complete filelist because of %s\n", pool_id2str(pool, cbd->ids[i]));
1117 for (i = 0; i < cbd->nfiles; i++)
1118 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1120 if (i < cbd->nfiles)
1126 map_init(&cbd->useddirs, 0);
1127 for (p = data->start; p < data->end; p++)
1128 if (pool->solvables[p].repo == repo)
1130 if (MAPTST(&donemap, p))
1132 repodata_search(data, p, SOLVABLE_FILELIST, 0, addfileprovides_cb, cbd);
1135 MAPSET(&donemap, p);
1139 map_free(&cbd->useddirs);
1142 if (repoonly || ++repoid == pool->nrepos)
1144 repo = pool->repos[repoid];
1147 queue_free(&fileprovidesq);
1148 map_free(&cbd->providedids);
1152 pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst)
1155 Repo *installed, *repo;
1156 struct searchfiles sf, isf, *isfp;
1157 struct addfileprovides_cbdata cbd;
1161 installed = pool->installed;
1162 now = solv_timems(0);
1163 memset(&sf, 0, sizeof(sf));
1164 map_init(&sf.seen, pool->ss.nstrings + pool->nrels);
1165 memset(&isf, 0, sizeof(isf));
1166 map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
1171 queue_empty(idqinst);
1172 isfp = installed ? &isf : 0;
1173 for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
1179 pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &sf, isfp);
1181 pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &sf, isfp);
1183 pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &sf, isfp);
1185 pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &sf, isfp);
1187 pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &sf, isfp);
1189 pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &sf, isfp);
1191 pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &sf, isfp);
1194 map_free(&isf.seen);
1195 POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
1200 for (i = 0; i < sf.nfiles; i++)
1201 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i]));
1203 pool_addfileprovides_search(pool, &cbd, &sf, 0);
1205 for (i = 0; i < sf.nfiles; i++)
1206 queue_push(idq, sf.ids[i]);
1208 for (i = 0; i < sf.nfiles; i++)
1209 queue_push(idqinst, sf.ids[i]);
1211 for (i = 0; i < sf.nfiles; i++)
1213 solv_free(sf.dirs[i]);
1214 solv_free(sf.names[i]);
1217 solv_free(sf.names);
1222 for (i = 0; i < isf.nfiles; i++)
1223 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in installed filelist\n", pool_id2str(pool, isf.ids[i]));
1226 pool_addfileprovides_search(pool, &cbd, &isf, installed);
1227 if (installed && idqinst)
1228 for (i = 0; i < isf.nfiles; i++)
1229 queue_pushunique(idqinst, isf.ids[i]);
1231 for (i = 0; i < isf.nfiles; i++)
1233 solv_free(isf.dirs[i]);
1234 solv_free(isf.names[i]);
1236 solv_free(isf.dirs);
1237 solv_free(isf.names);
1239 solv_free(cbd.dids);
1240 pool_freewhatprovides(pool); /* as we have added provides */
1241 POOL_DEBUG(SOLV_DEBUG_STATS, "addfileprovides took %d ms\n", solv_timems(now));
1245 pool_addfileprovides(Pool *pool)
1247 pool_addfileprovides_queue(pool, 0, 0);
1251 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)
1255 if (pool->solvables[p].repo)
1256 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1259 /* FIXME: obey callback return value! */
1260 for (p = 1; p < pool->nsolvables; p++)
1261 if (pool->solvables[p].repo)
1262 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1266 pool_clear_pos(Pool *pool)
1268 memset(&pool->pos, 0, sizeof(pool->pos));
1273 pool_set_languages(Pool *pool, const char **languages, int nlanguages)
1277 pool->languagecache = solv_free(pool->languagecache);
1278 pool->languagecacheother = 0;
1279 if (pool->nlanguages)
1281 for (i = 0; i < pool->nlanguages; i++)
1282 free((char *)pool->languages[i]);
1283 free(pool->languages);
1285 pool->nlanguages = nlanguages;
1288 pool->languages = solv_calloc(nlanguages, sizeof(const char **));
1289 for (i = 0; i < pool->nlanguages; i++)
1290 pool->languages[i] = solv_strdup(languages[i]);
1294 pool_id2langid(Pool *pool, Id id, const char *lang, int create)
1300 if (!lang || !*lang)
1302 n = pool_id2str(pool, id);
1303 l = strlen(n) + strlen(lang) + 2;
1304 if (l > sizeof(buf))
1305 p = solv_malloc(strlen(n) + strlen(lang) + 2);
1308 sprintf(p, "%s:%s", n, lang);
1309 id = pool_str2id(pool, p, create);
1316 pool_alloctmpspace(Pool *pool, int len)
1318 int n = pool->tmpspace.n;
1321 if (len > pool->tmpspace.len[n])
1323 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1324 pool->tmpspace.len[n] = len + 32;
1326 pool->tmpspace.n = (n + 1) % POOL_TMPSPACEBUF;
1327 return pool->tmpspace.buf[n];
1331 pool_alloctmpspace_free(Pool *pool, const char *space, int len)
1336 n = oldn = pool->tmpspace.n;
1340 n = POOL_TMPSPACEBUF - 1;
1343 if (pool->tmpspace.buf[n] != space)
1345 if (len > pool->tmpspace.len[n])
1347 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1348 pool->tmpspace.len[n] = len + 32;
1350 return pool->tmpspace.buf[n];
1357 pool_freetmpspace(Pool *pool, const char *space)
1359 int n = pool->tmpspace.n;
1362 n = (n + (POOL_TMPSPACEBUF - 1)) % POOL_TMPSPACEBUF;
1363 if (pool->tmpspace.buf[n] == space)
1364 pool->tmpspace.n = n;
1368 pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3)
1372 l1 = str1 ? strlen(str1) : 0;
1373 l2 = str2 ? strlen(str2) : 0;
1374 l3 = str3 ? strlen(str3) : 0;
1375 s = str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1396 pool_tmpappend(Pool *pool, const char *str1, const char *str2, const char *str3)
1401 l1 = str1 ? strlen(str1) : 0;
1402 l2 = str2 ? strlen(str2) : 0;
1403 l3 = str3 ? strlen(str3) : 0;
1404 str = pool_alloctmpspace_free(pool, str1, l1 + l2 + l3 + 1);
1408 str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1431 pool_bin2hex(Pool *pool, const unsigned char *buf, int len)
1436 s = pool_alloctmpspace(pool, 2 * len + 1);
1437 solv_bin2hex(buf, len, s);
1441 /*******************************************************************/
1453 struct mptree *mptree;
1464 solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
1466 struct ducbdata *cbd = cbdata;
1469 if (data != cbd->olddata)
1471 Id dn, mp, comp, *dirmap, *dirs;
1473 const char *compstr;
1474 struct mptree *mptree;
1476 /* create map from dir to mptree */
1477 cbd->dirmap = solv_free(cbd->dirmap);
1479 dirmap = solv_calloc(data->dirpool.ndirs, sizeof(Id));
1480 mptree = cbd->mptree;
1482 for (dn = 2, dirs = data->dirpool.dirs + dn; dn < data->dirpool.ndirs; dn++)
1496 if (!mptree[mp].child)
1501 if (data->localpool)
1502 compstr = stringpool_id2str(&data->spool, comp);
1504 compstr = pool_id2str(data->repo->pool, comp);
1505 compl = strlen(compstr);
1506 for (i = mptree[mp].child; i; i = mptree[i].sibling)
1507 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1509 dirmap[dn] = i ? i : -mp;
1511 /* change dirmap to point to mountpoint instead of mptree */
1512 for (dn = 0; dn < data->dirpool.ndirs; dn++)
1515 dirmap[dn] = mptree[mp > 0 ? mp : -mp].mountpoint;
1517 cbd->dirmap = dirmap;
1518 cbd->nmap = data->dirpool.ndirs;
1519 cbd->olddata = data;
1522 if (value->id < 0 || value->id >= cbd->nmap)
1524 mp = cbd->dirmap[value->id];
1527 if (cbd->addsub > 0)
1529 cbd->mps[mp].kbytes += value->num;
1530 cbd->mps[mp].files += value->num2;
1534 cbd->mps[mp].kbytes -= value->num;
1535 cbd->mps[mp].files -= value->num2;
1541 propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint)
1544 if (mptree[pos].mountpoint == -1)
1545 mptree[pos].mountpoint = mountpoint;
1547 mountpoint = mptree[pos].mountpoint;
1548 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1549 propagate_mountpoints(mptree, i, mountpoint);
1552 #define MPTREE_BLOCK 15
1555 pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
1558 const char *path, *compstr;
1559 struct mptree *mptree;
1563 struct ducbdata cbd;
1567 Repo *oldinstalled = pool->installed;
1569 memset(&ignoredu, 0, sizeof(ignoredu));
1576 mptree = solv_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
1579 mptree[0].sibling = 0;
1580 mptree[0].child = 0;
1582 mptree[0].compl = 0;
1583 mptree[0].mountpoint = -1;
1586 /* create component tree */
1587 for (mp = 0; mp < nmps; mp++)
1592 path = mps[mp].path;
1597 if ((p = strchr(path, '/')) == 0)
1600 compl = strlen(compstr);
1611 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1612 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1616 /* create new node */
1617 mptree = solv_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
1619 mptree[i].sibling = mptree[pos].child;
1620 mptree[i].child = 0;
1621 mptree[i].comp = compstr;
1622 mptree[i].compl = compl;
1623 mptree[i].mountpoint = -1;
1624 mptree[pos].child = i;
1628 mptree[pos].mountpoint = mp;
1631 propagate_mountpoints(mptree, 0, mptree[0].mountpoint);
1634 for (i = 0; i < nmptree; i++)
1636 printf("#%d sibling: %d\n", i, mptree[i].sibling);
1637 printf("#%d child: %d\n", i, mptree[i].child);
1638 printf("#%d comp: %s\n", i, mptree[i].comp);
1639 printf("#%d compl: %d\n", i, mptree[i].compl);
1640 printf("#%d mountpont: %d\n", i, mptree[i].mountpoint);
1644 cbd.mptree = mptree;
1646 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1648 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1650 if (!MAPTST(installedmap, sp))
1653 repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1654 if (!cbd.hasdu && oldinstalled)
1657 /* no du data available, ignore data of all installed solvables we obsolete */
1659 map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
1662 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
1663 while ((obs = *obsp++) != 0)
1664 FOR_PROVIDES(op, opp, obs)
1665 if (op >= oldinstalled->start && op < oldinstalled->end)
1666 MAPSET(&ignoredu, op - oldinstalled->start);
1668 FOR_PROVIDES(op, opp, s->name)
1669 if (pool->solvables[op].name == s->name)
1670 if (op >= oldinstalled->start && op < oldinstalled->end)
1671 MAPSET(&ignoredu, op - oldinstalled->start);
1677 /* assumes we allways have du data for installed solvables */
1678 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1680 if (MAPTST(installedmap, sp))
1682 if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start))
1684 repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1688 map_free(&ignoredu);
1689 solv_free(cbd.dirmap);
1694 pool_calc_installsizechange(Pool *pool, Map *installedmap)
1699 Repo *oldinstalled = pool->installed;
1701 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1703 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1705 if (!MAPTST(installedmap, sp))
1707 change += solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
1711 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1713 if (MAPTST(installedmap, sp))
1715 change -= solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
1723 * 2: conflicts with installed
1724 * 8: interesting (only true if installed)
1728 static inline Id dep2name(Pool *pool, Id dep)
1730 while (ISRELDEP(dep))
1732 Reldep *rd = rd = GETRELDEP(pool, dep);
1738 static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
1741 Solvable *sn = pool->solvables + n;
1743 FOR_PROVIDES(p, pp, sn->name)
1745 Solvable *s = pool->solvables + p;
1746 if (s->name != sn->name || s->arch != sn->arch)
1748 if ((map[p] & 9) != 9)
1750 if (pool_match_nevr(pool, pool->solvables + p, con))
1752 return 1; /* found installed package that doesn't conflict */
1757 static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
1761 FOR_PROVIDES(p, pp, dep)
1763 if (p == SYSTEMSOLVABLE)
1764 return 1; /* always boring, as never constraining */
1765 if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
1767 if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
1768 if (providedbyinstalled_multiversion(pool, map, p, dep))
1770 if ((map[p] & 9) == 9)
1778 * pool_trivial_installable - calculate if a set of solvables is
1779 * trivial installable without any other installs/deinstalls of
1780 * packages not belonging to the set.
1782 * the state is returned in the result queue:
1783 * 1: solvable is installable without any other package changes
1784 * 0: solvable is not installable
1785 * -1: solvable is installable, but doesn't constrain any installed packages
1789 pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
1792 Id p, *dp, con, *conp, req, *reqp;
1796 map = solv_calloc(pool->nsolvables, 1);
1797 for (p = 1; p < pool->nsolvables; p++)
1799 if (!MAPTST(installedmap, p))
1802 s = pool->solvables + p;
1805 conp = s->repo->idarraydata + s->conflicts;
1806 while ((con = *conp++) != 0)
1808 dp = pool_whatprovides_ptr(pool, con);
1810 map[p] |= 2; /* XXX: self conflict ? */
1813 for (i = 0; i < pkgs->count; i++)
1814 map[pkgs->elements[i]] = 16;
1816 for (i = 0, did = 0; did < pkgs->count; i++, did++)
1818 if (i == pkgs->count)
1820 p = pkgs->elements[i];
1821 if ((map[p] & 16) == 0)
1823 if ((map[p] & 2) != 0)
1828 s = pool->solvables + p;
1832 reqp = s->repo->idarraydata + s->requires;
1833 while ((req = *reqp++) != 0)
1835 if (req == SOLVABLE_PREREQMARKER)
1837 r = providedbyinstalled(pool, map, req, 0, 0);
1840 /* decided and miss */
1844 m |= r; /* 1 | 9 | 16 | 17 */
1853 int ispatch = 0; /* see solver.c patch handling */
1855 if (!strncmp("patch:", pool_id2str(pool, s->name), 6))
1857 conp = s->repo->idarraydata + s->conflicts;
1858 while ((con = *conp++) != 0)
1860 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1865 if ((m == 1 || m == 17) && ISRELDEP(con))
1867 con = dep2name(pool, con);
1868 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1873 continue; /* found a conflict */
1876 if (s->repo && s->repo != oldinstalled)
1878 Id p2, obs, *obsp, *pp;
1882 obsp = s->repo->idarraydata + s->obsoletes;
1883 while ((obs = *obsp++) != 0)
1885 if ((providedbyinstalled(pool, map, obs, 0, 0) & 1) != 0)
1894 FOR_PROVIDES(p2, pp, s->name)
1896 s2 = pool->solvables + p2;
1897 if (s2->name == s->name && (map[p2] & 1) != 0)
1914 queue_init_clone(res, pkgs);
1915 for (i = 0; i < pkgs->count; i++)
1917 m = map[pkgs->elements[i]];
1924 res->elements[i] = r;
1930 pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
1932 pool_trivial_installable_noobsoletesmap(pool, installedmap, pkgs, res, 0);
1936 pool_lookup_str(Pool *pool, Id entry, Id keyname)
1938 if (entry == SOLVID_POS && pool->pos.repo)
1939 return repodata_lookup_str(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
1942 return solvable_lookup_str(pool->solvables + entry, keyname);
1946 pool_lookup_id(Pool *pool, Id entry, Id keyname)
1948 if (entry == SOLVID_POS && pool->pos.repo)
1950 Repodata *data = pool->pos.repo->repodata + pool->pos.repodataid;
1951 Id id = repodata_lookup_id(data, SOLVID_POS, keyname);
1952 return data->localpool ? repodata_globalize_id(data, id, 1) : id;
1956 return solvable_lookup_id(pool->solvables + entry, keyname);
1960 pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned int notfound)
1962 if (entry == SOLVID_POS && pool->pos.repo)
1965 if (repodata_lookup_num(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, &value))
1971 return solvable_lookup_num(pool->solvables + entry, keyname, notfound);
1975 pool_lookup_void(Pool *pool, Id entry, Id keyname)
1977 if (entry == SOLVID_POS && pool->pos.repo)
1978 return repodata_lookup_void(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
1981 return solvable_lookup_void(pool->solvables + entry, keyname);
1984 const unsigned char *
1985 pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
1987 if (entry == SOLVID_POS && pool->pos.repo)
1988 return repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
1991 return solvable_lookup_bin_checksum(pool->solvables + entry, keyname, typep);
1995 pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
1997 if (entry == SOLVID_POS && pool->pos.repo)
1999 const unsigned char *chk = repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
2000 return chk ? repodata_chk2str(pool->pos.repo->repodata + pool->pos.repodataid, *typep, chk) : 0;
2004 return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
2008 pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
2010 int hadhashes = pool->relhashtbl ? 1 : 0;
2016 if (!conflicts->count)
2018 pool_freewhatprovides(pool);
2019 for (i = 0; i < conflicts->count; i += 5)
2021 fn = conflicts->elements[i];
2022 p = conflicts->elements[i + 1];
2023 md5 = conflicts->elements[i + 2];
2024 q = conflicts->elements[i + 3];
2025 id = pool_rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
2026 s = pool->solvables + p;
2029 s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
2030 s = pool->solvables + q;
2033 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2036 pool_freeidhashes(pool);