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;
62 #elif defined(ARCHLINUX)
63 pool->disttype = DISTTYPE_ARCH;
64 pool->noarchid = ARCH_ANY;
66 pool->disttype = DISTTYPE_RPM;
67 pool->noarchid = ARCH_NOARCH;
70 /* initialize the system solvable */
71 s = pool->solvables + SYSTEMSOLVABLE;
72 s->name = SYSTEM_SYSTEM;
73 s->arch = pool->noarchid;
76 pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
78 pool->obsoleteusescolors = 1;
81 pool->forbidselfconflicts = 1;
82 pool->obsoleteusesprovides = 1;
83 pool->implicitobsoleteusesprovides = 1;
84 pool->havedistepoch = 1;
90 /* free all the resources of our pool */
96 pool_freewhatprovides(pool);
97 pool_freeidhashes(pool);
98 pool_freeallrepos(pool, 1);
99 solv_free(pool->id2arch);
100 solv_free(pool->id2color);
101 solv_free(pool->solvables);
102 stringpool_free(&pool->ss);
103 solv_free(pool->rels);
104 pool_setvendorclasses(pool, 0);
105 queue_free(&pool->vendormap);
106 for (i = 0; i < POOL_TMPSPACEBUF; i++)
107 solv_free(pool->tmpspace.buf[i]);
108 for (i = 0; i < pool->nlanguages; i++)
109 free((char *)pool->languages[i]);
110 solv_free(pool->languages);
111 solv_free(pool->languagecache);
112 solv_free(pool->errstr);
113 solv_free(pool->rootdir);
118 pool_freeallrepos(Pool *pool, int reuseids)
122 pool_freewhatprovides(pool);
123 for (i = 1; i < pool->nrepos; i++)
125 repo_freedata(pool->repos[i]);
126 pool->repos = solv_free(pool->repos);
129 /* the first two solvables don't belong to a repo */
130 pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
133 #ifdef MULTI_SEMANTICS
135 pool_setdisttype(Pool *pool, int disttype)
137 pool->disttype = disttype;
138 if (disttype == DISTTYPE_RPM)
139 pool->noarchid = ARCH_NOARCH;
140 if (disttype == DISTTYPE_DEB)
141 pool->noarchid = ARCH_ALL;
142 if (disttype == DISTTYPE_ARCH)
143 pool->noarchid = ARCH_ANY;
144 pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
149 pool_get_flag(Pool *pool, int flag)
153 case POOL_FLAG_PROMOTEEPOCH:
154 return pool->promoteepoch;
155 case POOL_FLAG_FORBIDSELFCONFLICTS:
156 return pool->forbidselfconflicts;
157 case POOL_FLAG_OBSOLETEUSESPROVIDES:
158 return pool->obsoleteusesprovides;
159 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
160 return pool->implicitobsoleteusesprovides;
161 case POOL_FLAG_OBSOLETEUSESCOLORS:
162 return pool->obsoleteusescolors;
163 case POOL_FLAG_NOINSTALLEDOBSOLETES:
164 return pool->noinstalledobsoletes;
165 case POOL_FLAG_HAVEDISTEPOCH:
166 return pool->havedistepoch;
174 pool_set_flag(Pool *pool, int flag, int value)
176 int old = pool_get_flag(pool, flag);
179 case POOL_FLAG_PROMOTEEPOCH:
180 pool->promoteepoch = value;
182 case POOL_FLAG_FORBIDSELFCONFLICTS:
183 pool->forbidselfconflicts = value;
185 case POOL_FLAG_OBSOLETEUSESPROVIDES:
186 pool->obsoleteusesprovides = value;
188 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
189 pool->implicitobsoleteusesprovides = value;
191 case POOL_FLAG_OBSOLETEUSESCOLORS:
192 pool->obsoleteusescolors = value;
194 case POOL_FLAG_NOINSTALLEDOBSOLETES:
195 pool->noinstalledobsoletes = value;
197 case POOL_FLAG_HAVEDISTEPOCH:
198 pool->havedistepoch = value;
208 pool_add_solvable(Pool *pool)
210 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
211 memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable));
212 return pool->nsolvables++;
216 pool_add_solvable_block(Pool *pool, int count)
218 Id nsolvables = pool->nsolvables;
221 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
222 memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count);
223 pool->nsolvables += count;
228 pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids)
232 if (reuseids && start + count == pool->nsolvables)
234 /* might want to shrink solvable array */
235 pool->nsolvables = start;
238 memset(pool->solvables + start, 0, sizeof(Solvable) * count);
243 pool_set_installed(Pool *pool, Repo *installed)
245 if (pool->installed == installed)
247 pool->installed = installed;
248 pool_freewhatprovides(pool);
252 pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
257 oa = pool->whatprovides[*(Id *)ap];
258 ob = pool->whatprovides[*(Id *)bp];
260 return *(Id *)ap - *(Id *)bp;
261 da = pool->whatprovidesdata + oa;
262 db = pool->whatprovidesdata + ob;
264 if ((r = (*da++ - *db++)) != 0)
268 return *(Id *)ap - *(Id *)bp;
272 * pool_shrink_whatprovides - unify whatprovides data
274 * whatprovides_rel must be empty for this to work!
278 pool_shrink_whatprovides(Pool *pool)
282 Id lastid, *last, *dp, *lp;
286 if (pool->ss.nstrings < 3)
288 sorted = solv_malloc2(pool->ss.nstrings, sizeof(Id));
289 for (i = id = 0; id < pool->ss.nstrings; id++)
290 if (pool->whatprovides[id] && pool->whatprovides[id] != 1)
293 solv_sort(sorted, n, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
296 for (i = 0; i < n; i++)
299 o = pool->whatprovides[id];
300 dp = pool->whatprovidesdata + o;
314 pool->whatprovides[id] = -lastid;
318 last = pool->whatprovidesdata + o;
322 dp = pool->whatprovidesdata + 2;
323 for (id = 1; id < pool->ss.nstrings; id++)
325 o = pool->whatprovides[id];
326 if (o == 0 || o == 1)
333 pool->whatprovides[id] = pool->whatprovides[i];
336 lp = pool->whatprovidesdata + o;
339 pool->whatprovides[id] = dp - pool->whatprovidesdata;
340 while ((*dp++ = *lp++) != 0)
343 o = dp - pool->whatprovidesdata;
344 POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
345 if (pool->whatprovidesdataoff == o)
347 r = pool->whatprovidesdataoff - o;
348 pool->whatprovidesdataoff = o;
349 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
350 if (r > pool->whatprovidesdataleft)
351 r = pool->whatprovidesdataleft;
352 memset(pool->whatprovidesdata + o, 0, r * sizeof(Id));
357 * pool_createwhatprovides()
359 * create hashes over pool of solvables to ease provide lookups
363 pool_createwhatprovides(Pool *pool)
365 int i, num, np, extra;
370 Offset *whatprovides;
371 Id *whatprovidesdata, *d;
372 Repo *installed = pool->installed;
375 now = solv_timems(0);
376 POOL_DEBUG(SOLV_DEBUG_STATS, "number of solvables: %d, memory used: %d K\n", pool->nsolvables, pool->nsolvables * (int)sizeof(Solvable) / 1024);
377 POOL_DEBUG(SOLV_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
378 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);
379 if (pool->ss.stringhashmask || pool->relhashmask)
380 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)));
382 pool_freeidhashes(pool); /* XXX: should not be here! */
383 pool_freewhatprovides(pool);
384 num = pool->ss.nstrings;
385 pool->whatprovides = whatprovides = solv_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
386 pool->whatprovides_rel = solv_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
388 /* count providers for each name */
389 for (i = pool->nsolvables - 1; i > 0; i--)
392 s = pool->solvables + i;
393 if (!s->provides || !s->repo || s->repo->disabled)
395 /* we always need the installed solvable in the whatprovides data,
396 otherwise obsoletes/conflicts on them won't work */
397 if (s->repo != installed && !pool_installable(pool, s))
399 pp = s->repo->idarraydata + s->provides;
400 while ((id = *pp++) != 0)
404 Reldep *rd = GETRELDEP(pool, id);
407 whatprovides[id]++; /* inc count of providers */
411 off = 2; /* first entry is undef, second is empty list */
412 np = 0; /* number of names provided */
413 for (i = 0, idp = whatprovides; i < num; i++, idp++)
416 if (!n) /* no providers */
418 off += n; /* make space for all providers */
419 *idp = off++; /* now idp points to terminating zero */
420 np++; /* inc # of provider 'slots' for stats */
423 POOL_DEBUG(SOLV_DEBUG_STATS, "provide ids: %d\n", np);
425 /* reserve some space for relation data */
426 extra = 2 * pool->nrels;
430 POOL_DEBUG(SOLV_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
432 /* alloc space for all providers + extra */
433 whatprovidesdata = solv_calloc(off + extra, sizeof(Id));
435 /* now fill data for all provides */
436 for (i = pool->nsolvables - 1; i > 0; i--)
439 s = pool->solvables + i;
440 if (!s->provides || !s->repo || s->repo->disabled)
442 if (s->repo != installed && !pool_installable(pool, s))
445 /* for all provides of this solvable */
446 pp = s->repo->idarraydata + s->provides;
447 while ((id = *pp++) != 0)
451 Reldep *rd = GETRELDEP(pool, id);
454 d = whatprovidesdata + whatprovides[id]; /* offset into whatprovidesdata */
455 if (*d != i) /* don't add same solvable twice */
462 pool->whatprovidesdata = whatprovidesdata;
463 pool->whatprovidesdataoff = off;
464 pool->whatprovidesdataleft = extra;
465 pool_shrink_whatprovides(pool);
466 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)));
467 POOL_DEBUG(SOLV_DEBUG_STATS, "createwhatprovides took %d ms\n", solv_timems(now));
471 * free all of our whatprovides data
472 * be careful, everything internalized with pool_queuetowhatprovides is
476 pool_freewhatprovides(Pool *pool)
478 pool->whatprovides = solv_free(pool->whatprovides);
479 pool->whatprovides_rel = solv_free(pool->whatprovides_rel);
480 pool->whatprovidesdata = solv_free(pool->whatprovidesdata);
481 pool->whatprovidesdataoff = 0;
482 pool->whatprovidesdataleft = 0;
486 /******************************************************************************/
489 * pool_queuetowhatprovides - add queue contents to whatprovidesdata
491 * on-demand filling of provider information
492 * move queue data into whatprovidesdata
494 * returns: Offset into whatprovides
498 pool_queuetowhatprovides(Pool *pool, Queue *q)
501 int count = q->count;
503 if (count == 0) /* queue empty -> 1 */
506 /* extend whatprovidesdata if needed, +1 for ID_NULL-termination */
507 if (pool->whatprovidesdataleft < count + 1)
509 POOL_DEBUG(SOLV_DEBUG_STATS, "growing provides hash data...\n");
510 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
511 pool->whatprovidesdataleft = count + 4096;
514 /* copy queue to next free slot */
515 off = pool->whatprovidesdataoff;
516 memcpy(pool->whatprovidesdata + pool->whatprovidesdataoff, q->elements, count * sizeof(Id));
518 /* adapt count and ID_NULL-terminate */
519 pool->whatprovidesdataoff += count;
520 pool->whatprovidesdata[pool->whatprovidesdataoff++] = ID_NULL;
521 pool->whatprovidesdataleft -= count + 1;
527 /*************************************************************************/
529 #if defined(MULTI_SEMANTICS)
530 # define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
531 #elif defined(DEBIAN)
532 # define EVRCMP_DEPCMP EVRCMP_COMPARE
534 # define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
537 /* check if a package's nevr matches a dependency */
540 pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
542 Reldep *rd = GETRELDEP(pool, d);
545 int flags = rd->flags;
554 if (evr != ARCH_SRC || s->arch != ARCH_NOSRC)
557 return pool_match_nevr(pool, s, name);
559 if (pool_match_nevr(pool, s, name))
561 return pool_match_nevr(pool, s, evr);
564 if (!pool_match_nevr(pool, s, name))
566 return pool_match_nevr(pool, s, evr);
571 if (!pool_match_nevr(pool, s, name))
574 return (flags & REL_EQ) ? 1 : 0;
579 switch (pool_evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP))
584 return (flags & REL_LT) ? 1 : 0;
586 return (flags & REL_EQ) ? 1 : 0;
588 return (flags & REL_GT) ? 1 : 0;
590 return (flags & REL_EQ) ? 1 : 0;
597 /* match (flags, evr) against provider (pflags, pevr) */
599 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
601 if (!pflags || !flags || pflags >= 8 || flags >= 8)
603 if (flags == 7 || pflags == 7)
604 return 1; /* rel provides every version */
605 if ((pflags & flags & (REL_LT | REL_GT)) != 0)
606 return 1; /* both rels show in the same direction */
608 return (flags & pflags & REL_EQ) ? 1 : 0;
609 switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
612 return (pflags & REL_EQ) ? 1 : 0;
614 return (flags & REL_LT) || (pflags & REL_GT) ? 1 : 0;
616 return (flags & pflags & REL_EQ) ? 1 : 0;
618 return (flags & REL_GT) || (pflags & REL_LT) ? 1 : 0;
620 return (flags & REL_EQ) ? 1 : 0;
627 /* match two dependencies (d1 = provider) */
630 pool_match_dep(Pool *pool, Id d1, Id d2)
640 rd2 = GETRELDEP(pool, d2);
641 return pool_match_dep(pool, d1, rd2->name);
643 rd1 = GETRELDEP(pool, d1);
646 return pool_match_dep(pool, rd1->name, d2);
648 rd2 = GETRELDEP(pool, d2);
649 /* first match name */
650 if (!pool_match_dep(pool, rd1->name, rd2->name))
652 /* name matches, check flags and evr */
653 return pool_match_flags_evr(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
659 * add packages fulfilling the relation to whatprovides array
660 * no exact providers, do range match
665 pool_addrelproviders(Pool *pool, Id d)
667 Reldep *rd = GETRELDEP(pool, d);
673 int flags = rd->flags;
678 queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
682 /* special relation */
690 wp = pool_whatprovides(pool, name);
691 pp2 = pool_whatprovides_ptr(pool, evr);
692 pp = pool->whatprovidesdata + wp;
693 while ((p = *pp++) != 0)
695 for (pp3 = pp2; *pp3; pp3++)
699 queue_push(&plist, p); /* found it */
705 wp = pool_whatprovides(pool, name);
706 pp = pool->whatprovidesdata + wp;
708 wp = pool_whatprovides(pool, evr);
712 while ((p = *pp++) != 0)
713 queue_push(&plist, p);
715 pp = pool_whatprovides_ptr(pool, evr);
716 while ((p = *pp++) != 0)
717 queue_pushunique(&plist, p);
718 if (plist.count != cnt)
723 if (name == NAMESPACE_OTHERPROVIDERS)
725 wp = pool_whatprovides(pool, evr);
728 if (pool->nscallback)
730 /* ask callback which packages provide the dependency
732 * 1: the system (aka SYSTEMSOLVABLE)
733 * >1: set of packages, stored as offset on whatprovidesdata
735 p = pool->nscallback(pool, pool->nscallbackdata, name, evr);
739 queue_push(&plist, SYSTEMSOLVABLE);
743 /* small hack: make it possible to match <pkg>.src
744 * we have to iterate over the solvables as src packages do not
745 * provide anything, thus they are not indexed in our
746 * whatprovides hash */
747 if (evr == ARCH_SRC || evr == ARCH_NOSRC)
750 for (p = 1, s = pool->solvables + p; p < pool->nsolvables; p++, s++)
754 if (s->arch != evr && s->arch != ARCH_NOSRC)
756 if (pool_match_nevr(pool, s, name))
757 queue_push(&plist, p);
761 wp = pool_whatprovides(pool, name);
762 pp = pool->whatprovidesdata + wp;
763 while ((p = *pp++) != 0)
765 Solvable *s = pool->solvables + p;
767 queue_push(&plist, p);
772 case REL_FILECONFLICT:
773 pp = pool_whatprovides_ptr(pool, name);
774 while ((p = *pp++) != 0)
776 Id origd = MAKERELDEP(d);
777 Solvable *s = pool->solvables + p;
780 pidp = s->repo->idarraydata + s->provides;
781 while ((pid = *pidp++) != 0)
785 queue_push(&plist, p);
793 /* we can reuse an existing entry */
795 pool->whatprovides_rel[d] = wp;
801 /* simple version comparison relation */
803 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: what provides %s?\n", pool_dep2str(pool, name));
805 pp = pool_whatprovides_ptr(pool, name);
806 while (ISRELDEP(name))
808 rd = GETRELDEP(pool, name);
811 while ((p = *pp++) != 0)
813 Solvable *s = pool->solvables + p;
816 /* no provides - check nevr */
817 if (pool_match_nevr_rel(pool, s, MAKERELDEP(d)))
818 queue_push(&plist, p);
821 /* solvable p provides name in some rels */
822 pidp = s->repo->idarraydata + s->provides;
823 while ((pid = *pidp++) != 0)
828 continue; /* wrong provides name */
829 if (pool->disttype == DISTTYPE_DEB)
830 continue; /* unversioned provides can never match versioned deps */
833 prd = GETRELDEP(pool, pid);
834 if (prd->name != name)
835 continue; /* wrong provides name */
836 /* right package, both deps are rels. check flags/evr */
837 if (pool_match_flags_evr(pool, prd->flags, prd->evr, flags, evr))
841 continue; /* none of the providers matched */
842 queue_push(&plist, p);
844 /* make our system solvable provide all unknown rpmlib() stuff */
845 if (plist.count == 0 && !strncmp(pool_id2str(pool, name), "rpmlib(", 7))
846 queue_push(&plist, SYSTEMSOLVABLE);
848 /* add providers to whatprovides */
850 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
852 pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
855 return pool->whatprovides_rel[d];
858 /*************************************************************************/
861 pool_debug(Pool *pool, int type, const char *format, ...)
866 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0)
868 if ((pool->debugmask & type) == 0)
871 va_start(args, format);
872 if (!pool->debugcallback)
874 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0 && !(pool->debugmask & SOLV_DEBUG_TO_STDERR))
875 vprintf(format, args);
877 vfprintf(stderr, format, args);
880 vsnprintf(buf, sizeof(buf), format, args);
882 pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
886 pool_error(Pool *pool, int ret, const char *format, ...)
890 va_start(args, format);
893 pool->errstra = 1024;
894 pool->errstr = solv_malloc(pool->errstra);
902 l = vsnprintf(pool->errstr, pool->errstra, format, args);
904 if (l >= 0 && l + 1 > pool->errstra)
906 pool->errstra = l + 256;
907 pool->errstr = solv_realloc(pool->errstr, pool->errstra);
908 va_start(args, format);
909 l = vsnprintf(pool->errstr, pool->errstra, format, args);
913 strcpy(pool->errstr, "unknown error");
914 if (pool->debugmask & SOLV_ERROR)
915 pool_debug(pool, SOLV_ERROR, "%s\n", pool->errstr);
920 pool_errstr(Pool *pool)
922 return pool->errstr ? pool->errstr : "no error";
926 pool_setdebuglevel(Pool *pool, int level)
928 int mask = SOLV_DEBUG_RESULT;
930 mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION|SOLV_ERROR;
932 mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
934 mask |= SOLV_DEBUG_PROPAGATE;
936 mask |= SOLV_DEBUG_RULE_CREATION;
937 mask |= pool->debugmask & SOLV_DEBUG_TO_STDERR; /* keep bit */
938 pool->debugmask = mask;
941 void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
943 pool->debugcallback = debugcallback;
944 pool->debugcallbackdata = debugcallbackdata;
947 void pool_setdebugmask(Pool *pool, int mask)
949 pool->debugmask = mask;
952 void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
954 pool->loadcallback = cb;
955 pool->loadcallbackdata = loadcbdata;
958 /*************************************************************************/
968 #define SEARCHFILES_BLOCK 127
971 pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct searchfiles *isf)
975 struct searchfiles *csf;
977 while ((dep = *ida++) != 0)
980 while (ISRELDEP(dep))
983 sid = pool->ss.nstrings + GETRELID(dep);
984 if (MAPTST(&csf->seen, sid))
989 MAPSET(&csf->seen, sid);
990 rd = GETRELDEP(pool, dep);
993 else if (rd->flags == REL_NAMESPACE)
995 if (rd->name == NAMESPACE_INSTALLED || rd->name == NAMESPACE_SPLITPROVIDES)
998 if (!csf || MAPTST(&csf->seen, sid))
1003 MAPSET(&csf->seen, sid);
1007 else if (rd->flags == REL_FILECONFLICT)
1017 pool_addfileprovides_dep(pool, ids, csf, isf);
1023 if (MAPTST(&csf->seen, dep))
1025 MAPSET(&csf->seen, dep);
1026 s = pool_id2str(pool, dep);
1029 csf->ids = solv_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
1030 csf->dirs = solv_extend(csf->dirs, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
1031 csf->names = solv_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
1032 csf->ids[csf->nfiles] = dep;
1033 sr = strrchr(s, '/');
1034 csf->names[csf->nfiles] = solv_strdup(sr + 1);
1035 csf->dirs[csf->nfiles] = solv_malloc(sr - s + 1);
1037 strncpy(csf->dirs[csf->nfiles], s, sr - s);
1038 csf->dirs[csf->nfiles][sr - s] = 0;
1043 struct addfileprovides_cbdata {
1057 addfileprovides_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
1059 struct addfileprovides_cbdata *cbd = cbdata;
1062 if (!cbd->useddirs.size)
1064 map_init(&cbd->useddirs, data->dirpool.ndirs + 1);
1065 for (i = 0; i < cbd->nfiles; i++)
1068 if (MAPTST(&cbd->providedids, cbd->ids[i]))
1073 did = repodata_str2dir(data, cbd->dirs[i], 0);
1076 MAPSET(&cbd->useddirs, did);
1078 repodata_free_dircache(data);
1080 if (value->id >= data->dirpool.ndirs || !MAPTST(&cbd->useddirs, value->id))
1082 for (i = 0; i < cbd->nfiles; i++)
1084 if (cbd->dids[i] != value->id)
1086 if (!strcmp(cbd->names[i], value->str))
1089 if (i == cbd->nfiles)
1091 s->provides = repo_addid_dep(s->repo, s->provides, cbd->ids[i], SOLVABLE_FILEMARKER);
1096 pool_addfileprovides_search(Pool *pool, struct addfileprovides_cbdata *cbd, struct searchfiles *sf, Repo *repoonly)
1101 Queue fileprovidesq;
1102 int i, j, repoid, repodataid;
1103 int provstart, provend;
1105 int ndone, incomplete;
1110 cbd->nfiles = sf->nfiles;
1112 cbd->dirs = sf->dirs;
1113 cbd->names = sf->names;
1114 cbd->dids = solv_realloc2(cbd->dids, sf->nfiles, sizeof(Id));
1115 map_init(&cbd->providedids, pool->ss.nstrings);
1118 repo = repoonly ? repoonly : pool->repos[repoid];
1119 map_init(&donemap, pool->nsolvables);
1120 queue_init(&fileprovidesq);
1121 provstart = provend = 0;
1124 if (!repo || repo->disabled)
1126 if (repoonly || ++repoid == pool->nrepos)
1128 repo = pool->repos[repoid];
1132 FOR_REPODATAS(repo, repodataid, data)
1134 if (ndone >= repo->nsolvables)
1137 if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
1139 map_empty(&cbd->providedids);
1140 for (i = 0; i < fileprovidesq.count; i++)
1141 MAPSET(&cbd->providedids, fileprovidesq.elements[i]);
1142 provstart = data->start;
1143 provend = data->end;
1144 for (i = 0; i < cbd->nfiles; i++)
1145 if (!MAPTST(&cbd->providedids, cbd->ids[i]))
1147 if (i == cbd->nfiles)
1149 /* great! no need to search files */
1150 for (p = data->start; p < data->end; p++)
1151 if (pool->solvables[p].repo == repo)
1153 if (MAPTST(&donemap, p))
1155 MAPSET(&donemap, p);
1162 if (!repodata_has_keyname(data, SOLVABLE_FILELIST))
1165 if (data->start < provstart || data->end > provend)
1167 map_empty(&cbd->providedids);
1168 provstart = provend = 0;
1171 /* check if the data is incomplete */
1173 if (data->state == REPODATA_AVAILABLE)
1175 for (j = 1; j < data->nkeys; j++)
1176 if (data->keys[j].name != REPOSITORY_SOLVABLES && data->keys[j].name != SOLVABLE_FILELIST)
1178 if (j < data->nkeys)
1181 for (i = 0; i < cbd->nfiles; i++)
1182 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1183 printf("need complete filelist because of %s\n", pool_id2str(pool, cbd->ids[i]));
1185 for (i = 0; i < cbd->nfiles; i++)
1186 if (!MAPTST(&cbd->providedids, cbd->ids[i]) && !repodata_filelistfilter_matches(data, pool_id2str(pool, cbd->ids[i])))
1188 if (i < cbd->nfiles)
1194 map_init(&cbd->useddirs, 0);
1195 for (p = data->start; p < data->end; p++)
1196 if (pool->solvables[p].repo == repo)
1198 if (MAPTST(&donemap, p))
1200 repodata_search(data, p, SOLVABLE_FILELIST, 0, addfileprovides_cb, cbd);
1203 MAPSET(&donemap, p);
1207 map_free(&cbd->useddirs);
1210 if (repoonly || ++repoid == pool->nrepos)
1212 repo = pool->repos[repoid];
1215 queue_free(&fileprovidesq);
1216 map_free(&cbd->providedids);
1220 pool_addfileprovides_queue(Pool *pool, Queue *idq, Queue *idqinst)
1223 Repo *installed, *repo;
1224 struct searchfiles sf, isf, *isfp;
1225 struct addfileprovides_cbdata cbd;
1229 installed = pool->installed;
1230 now = solv_timems(0);
1231 memset(&sf, 0, sizeof(sf));
1232 map_init(&sf.seen, pool->ss.nstrings + pool->nrels);
1233 memset(&isf, 0, sizeof(isf));
1234 map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
1239 queue_empty(idqinst);
1240 isfp = installed ? &isf : 0;
1241 for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
1247 pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &sf, isfp);
1249 pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &sf, isfp);
1251 pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &sf, isfp);
1253 pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &sf, isfp);
1255 pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &sf, isfp);
1257 pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &sf, isfp);
1259 pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &sf, isfp);
1262 map_free(&isf.seen);
1263 POOL_DEBUG(SOLV_DEBUG_STATS, "found %d file dependencies, %d installed file dependencies\n", sf.nfiles, isf.nfiles);
1268 for (i = 0; i < sf.nfiles; i++)
1269 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in filelist\n", pool_id2str(pool, sf.ids[i]));
1271 pool_addfileprovides_search(pool, &cbd, &sf, 0);
1273 for (i = 0; i < sf.nfiles; i++)
1274 queue_push(idq, sf.ids[i]);
1276 for (i = 0; i < sf.nfiles; i++)
1277 queue_push(idqinst, sf.ids[i]);
1279 for (i = 0; i < sf.nfiles; i++)
1281 solv_free(sf.dirs[i]);
1282 solv_free(sf.names[i]);
1285 solv_free(sf.names);
1290 for (i = 0; i < isf.nfiles; i++)
1291 POOL_DEBUG(SOLV_DEBUG_STATS, "looking up %s in installed filelist\n", pool_id2str(pool, isf.ids[i]));
1294 pool_addfileprovides_search(pool, &cbd, &isf, installed);
1295 if (installed && idqinst)
1296 for (i = 0; i < isf.nfiles; i++)
1297 queue_pushunique(idqinst, isf.ids[i]);
1299 for (i = 0; i < isf.nfiles; i++)
1301 solv_free(isf.dirs[i]);
1302 solv_free(isf.names[i]);
1304 solv_free(isf.dirs);
1305 solv_free(isf.names);
1307 solv_free(cbd.dids);
1308 pool_freewhatprovides(pool); /* as we have added provides */
1309 POOL_DEBUG(SOLV_DEBUG_STATS, "addfileprovides took %d ms\n", solv_timems(now));
1313 pool_addfileprovides(Pool *pool)
1315 pool_addfileprovides_queue(pool, 0, 0);
1319 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)
1323 if (pool->solvables[p].repo)
1324 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1327 /* FIXME: obey callback return value! */
1328 for (p = 1; p < pool->nsolvables; p++)
1329 if (pool->solvables[p].repo)
1330 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1334 pool_clear_pos(Pool *pool)
1336 memset(&pool->pos, 0, sizeof(pool->pos));
1341 pool_set_languages(Pool *pool, const char **languages, int nlanguages)
1345 pool->languagecache = solv_free(pool->languagecache);
1346 pool->languagecacheother = 0;
1347 if (pool->nlanguages)
1349 for (i = 0; i < pool->nlanguages; i++)
1350 free((char *)pool->languages[i]);
1351 free(pool->languages);
1353 pool->nlanguages = nlanguages;
1356 pool->languages = solv_calloc(nlanguages, sizeof(const char **));
1357 for (i = 0; i < pool->nlanguages; i++)
1358 pool->languages[i] = solv_strdup(languages[i]);
1362 pool_id2langid(Pool *pool, Id id, const char *lang, int create)
1368 if (!lang || !*lang)
1370 n = pool_id2str(pool, id);
1371 l = strlen(n) + strlen(lang) + 2;
1372 if (l > sizeof(buf))
1373 p = solv_malloc(strlen(n) + strlen(lang) + 2);
1376 sprintf(p, "%s:%s", n, lang);
1377 id = pool_str2id(pool, p, create);
1384 pool_alloctmpspace(Pool *pool, int len)
1386 int n = pool->tmpspace.n;
1389 if (len > pool->tmpspace.len[n])
1391 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1392 pool->tmpspace.len[n] = len + 32;
1394 pool->tmpspace.n = (n + 1) % POOL_TMPSPACEBUF;
1395 return pool->tmpspace.buf[n];
1399 pool_alloctmpspace_free(Pool *pool, const char *space, int len)
1404 n = oldn = pool->tmpspace.n;
1408 n = POOL_TMPSPACEBUF - 1;
1411 if (pool->tmpspace.buf[n] != space)
1413 if (len > pool->tmpspace.len[n])
1415 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1416 pool->tmpspace.len[n] = len + 32;
1418 return pool->tmpspace.buf[n];
1425 pool_freetmpspace(Pool *pool, const char *space)
1427 int n = pool->tmpspace.n;
1430 n = (n + (POOL_TMPSPACEBUF - 1)) % POOL_TMPSPACEBUF;
1431 if (pool->tmpspace.buf[n] == space)
1432 pool->tmpspace.n = n;
1436 pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3)
1440 l1 = str1 ? strlen(str1) : 0;
1441 l2 = str2 ? strlen(str2) : 0;
1442 l3 = str3 ? strlen(str3) : 0;
1443 s = str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1464 pool_tmpappend(Pool *pool, const char *str1, const char *str2, const char *str3)
1469 l1 = str1 ? strlen(str1) : 0;
1470 l2 = str2 ? strlen(str2) : 0;
1471 l3 = str3 ? strlen(str3) : 0;
1472 str = pool_alloctmpspace_free(pool, str1, l1 + l2 + l3 + 1);
1476 str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1499 pool_bin2hex(Pool *pool, const unsigned char *buf, int len)
1504 s = pool_alloctmpspace(pool, 2 * len + 1);
1505 solv_bin2hex(buf, len, s);
1509 /*******************************************************************/
1521 struct mptree *mptree;
1532 solver_fill_DU_cb(void *cbdata, Solvable *s, Repodata *data, Repokey *key, KeyValue *value)
1534 struct ducbdata *cbd = cbdata;
1537 if (data != cbd->olddata)
1539 Id dn, mp, comp, *dirmap, *dirs;
1541 const char *compstr;
1542 struct mptree *mptree;
1544 /* create map from dir to mptree */
1545 cbd->dirmap = solv_free(cbd->dirmap);
1547 dirmap = solv_calloc(data->dirpool.ndirs, sizeof(Id));
1548 mptree = cbd->mptree;
1550 for (dn = 2, dirs = data->dirpool.dirs + dn; dn < data->dirpool.ndirs; dn++)
1564 if (!mptree[mp].child)
1569 if (data->localpool)
1570 compstr = stringpool_id2str(&data->spool, comp);
1572 compstr = pool_id2str(data->repo->pool, comp);
1573 compl = strlen(compstr);
1574 for (i = mptree[mp].child; i; i = mptree[i].sibling)
1575 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1577 dirmap[dn] = i ? i : -mp;
1579 /* change dirmap to point to mountpoint instead of mptree */
1580 for (dn = 0; dn < data->dirpool.ndirs; dn++)
1583 dirmap[dn] = mptree[mp > 0 ? mp : -mp].mountpoint;
1585 cbd->dirmap = dirmap;
1586 cbd->nmap = data->dirpool.ndirs;
1587 cbd->olddata = data;
1590 if (value->id < 0 || value->id >= cbd->nmap)
1592 mp = cbd->dirmap[value->id];
1595 if (cbd->addsub > 0)
1597 cbd->mps[mp].kbytes += value->num;
1598 cbd->mps[mp].files += value->num2;
1602 cbd->mps[mp].kbytes -= value->num;
1603 cbd->mps[mp].files -= value->num2;
1609 propagate_mountpoints(struct mptree *mptree, int pos, Id mountpoint)
1612 if (mptree[pos].mountpoint == -1)
1613 mptree[pos].mountpoint = mountpoint;
1615 mountpoint = mptree[pos].mountpoint;
1616 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1617 propagate_mountpoints(mptree, i, mountpoint);
1620 #define MPTREE_BLOCK 15
1623 pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
1626 const char *path, *compstr;
1627 struct mptree *mptree;
1631 struct ducbdata cbd;
1635 Repo *oldinstalled = pool->installed;
1637 memset(&ignoredu, 0, sizeof(ignoredu));
1644 mptree = solv_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
1647 mptree[0].sibling = 0;
1648 mptree[0].child = 0;
1650 mptree[0].compl = 0;
1651 mptree[0].mountpoint = -1;
1654 /* create component tree */
1655 for (mp = 0; mp < nmps; mp++)
1660 path = mps[mp].path;
1665 if ((p = strchr(path, '/')) == 0)
1668 compl = strlen(compstr);
1679 for (i = mptree[pos].child; i; i = mptree[i].sibling)
1680 if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
1684 /* create new node */
1685 mptree = solv_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
1687 mptree[i].sibling = mptree[pos].child;
1688 mptree[i].child = 0;
1689 mptree[i].comp = compstr;
1690 mptree[i].compl = compl;
1691 mptree[i].mountpoint = -1;
1692 mptree[pos].child = i;
1696 mptree[pos].mountpoint = mp;
1699 propagate_mountpoints(mptree, 0, mptree[0].mountpoint);
1702 for (i = 0; i < nmptree; i++)
1704 printf("#%d sibling: %d\n", i, mptree[i].sibling);
1705 printf("#%d child: %d\n", i, mptree[i].child);
1706 printf("#%d comp: %s\n", i, mptree[i].comp);
1707 printf("#%d compl: %d\n", i, mptree[i].compl);
1708 printf("#%d mountpont: %d\n", i, mptree[i].mountpoint);
1712 cbd.mptree = mptree;
1714 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1716 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1718 if (!MAPTST(installedmap, sp))
1721 repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1722 if (!cbd.hasdu && oldinstalled)
1725 /* no du data available, ignore data of all installed solvables we obsolete */
1727 map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
1730 Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
1731 while ((obs = *obsp++) != 0)
1732 FOR_PROVIDES(op, opp, obs)
1733 if (op >= oldinstalled->start && op < oldinstalled->end)
1734 MAPSET(&ignoredu, op - oldinstalled->start);
1736 FOR_PROVIDES(op, opp, s->name)
1737 if (pool->solvables[op].name == s->name)
1738 if (op >= oldinstalled->start && op < oldinstalled->end)
1739 MAPSET(&ignoredu, op - oldinstalled->start);
1745 /* assumes we allways have du data for installed solvables */
1746 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1748 if (MAPTST(installedmap, sp))
1750 if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start))
1752 repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
1756 map_free(&ignoredu);
1757 solv_free(cbd.dirmap);
1762 pool_calc_installsizechange(Pool *pool, Map *installedmap)
1767 Repo *oldinstalled = pool->installed;
1769 for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
1771 if (!s->repo || (oldinstalled && s->repo == oldinstalled))
1773 if (!MAPTST(installedmap, sp))
1775 change += solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
1779 FOR_REPO_SOLVABLES(oldinstalled, sp, s)
1781 if (MAPTST(installedmap, sp))
1783 change -= solvable_lookup_sizek(s, SOLVABLE_INSTALLSIZE, 0);
1791 * 2: conflicts with installed
1792 * 8: interesting (only true if installed)
1796 static inline Id dep2name(Pool *pool, Id dep)
1798 while (ISRELDEP(dep))
1800 Reldep *rd = rd = GETRELDEP(pool, dep);
1806 static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
1809 Solvable *sn = pool->solvables + n;
1811 FOR_PROVIDES(p, pp, sn->name)
1813 Solvable *s = pool->solvables + p;
1814 if (s->name != sn->name || s->arch != sn->arch)
1816 if ((map[p] & 9) != 9)
1818 if (pool_match_nevr(pool, pool->solvables + p, con))
1820 return 1; /* found installed package that doesn't conflict */
1825 static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
1829 FOR_PROVIDES(p, pp, dep)
1831 if (p == SYSTEMSOLVABLE)
1832 return 1; /* always boring, as never constraining */
1833 if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
1835 if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
1836 if (providedbyinstalled_multiversion(pool, map, p, dep))
1838 if ((map[p] & 9) == 9)
1846 * pool_trivial_installable - calculate if a set of solvables is
1847 * trivial installable without any other installs/deinstalls of
1848 * packages not belonging to the set.
1850 * the state is returned in the result queue:
1851 * 1: solvable is installable without any other package changes
1852 * 0: solvable is not installable
1853 * -1: solvable is installable, but doesn't constrain any installed packages
1857 pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
1860 Id p, *dp, con, *conp, req, *reqp;
1864 map = solv_calloc(pool->nsolvables, 1);
1865 for (p = 1; p < pool->nsolvables; p++)
1867 if (!MAPTST(installedmap, p))
1870 s = pool->solvables + p;
1873 conp = s->repo->idarraydata + s->conflicts;
1874 while ((con = *conp++) != 0)
1876 dp = pool_whatprovides_ptr(pool, con);
1878 map[p] |= 2; /* XXX: self conflict ? */
1881 for (i = 0; i < pkgs->count; i++)
1882 map[pkgs->elements[i]] = 16;
1884 for (i = 0, did = 0; did < pkgs->count; i++, did++)
1886 if (i == pkgs->count)
1888 p = pkgs->elements[i];
1889 if ((map[p] & 16) == 0)
1891 if ((map[p] & 2) != 0)
1896 s = pool->solvables + p;
1900 reqp = s->repo->idarraydata + s->requires;
1901 while ((req = *reqp++) != 0)
1903 if (req == SOLVABLE_PREREQMARKER)
1905 r = providedbyinstalled(pool, map, req, 0, 0);
1908 /* decided and miss */
1912 m |= r; /* 1 | 9 | 16 | 17 */
1921 int ispatch = 0; /* see solver.c patch handling */
1923 if (!strncmp("patch:", pool_id2str(pool, s->name), 6))
1925 conp = s->repo->idarraydata + s->conflicts;
1926 while ((con = *conp++) != 0)
1928 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1933 if ((m == 1 || m == 17) && ISRELDEP(con))
1935 con = dep2name(pool, con);
1936 if ((providedbyinstalled(pool, map, con, ispatch, noobsoletesmap) & 1) != 0)
1941 continue; /* found a conflict */
1944 if (s->repo && s->repo != oldinstalled)
1946 Id p2, obs, *obsp, *pp;
1950 obsp = s->repo->idarraydata + s->obsoletes;
1951 while ((obs = *obsp++) != 0)
1953 if ((providedbyinstalled(pool, map, obs, 0, 0) & 1) != 0)
1962 FOR_PROVIDES(p2, pp, s->name)
1964 s2 = pool->solvables + p2;
1965 if (s2->name == s->name && (map[p2] & 1) != 0)
1982 queue_init_clone(res, pkgs);
1983 for (i = 0; i < pkgs->count; i++)
1985 m = map[pkgs->elements[i]];
1992 res->elements[i] = r;
1998 pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res)
2000 pool_trivial_installable_noobsoletesmap(pool, installedmap, pkgs, res, 0);
2004 pool_lookup_str(Pool *pool, Id entry, Id keyname)
2006 if (entry == SOLVID_POS && pool->pos.repo)
2007 return repodata_lookup_str(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
2010 return solvable_lookup_str(pool->solvables + entry, keyname);
2014 pool_lookup_id(Pool *pool, Id entry, Id keyname)
2016 if (entry == SOLVID_POS && pool->pos.repo)
2018 Repodata *data = pool->pos.repo->repodata + pool->pos.repodataid;
2019 Id id = repodata_lookup_id(data, SOLVID_POS, keyname);
2020 return data->localpool ? repodata_globalize_id(data, id, 1) : id;
2024 return solvable_lookup_id(pool->solvables + entry, keyname);
2028 pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned long long notfound)
2030 if (entry == SOLVID_POS && pool->pos.repo)
2032 unsigned long long value;
2033 if (repodata_lookup_num(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, &value))
2039 return solvable_lookup_num(pool->solvables + entry, keyname, notfound);
2043 pool_lookup_void(Pool *pool, Id entry, Id keyname)
2045 if (entry == SOLVID_POS && pool->pos.repo)
2046 return repodata_lookup_void(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname);
2049 return solvable_lookup_void(pool->solvables + entry, keyname);
2052 const unsigned char *
2053 pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
2055 if (entry == SOLVID_POS && pool->pos.repo)
2056 return repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
2059 return solvable_lookup_bin_checksum(pool->solvables + entry, keyname, typep);
2063 pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
2065 if (entry == SOLVID_POS && pool->pos.repo)
2067 const unsigned char *chk = repodata_lookup_bin_checksum(pool->pos.repo->repodata + pool->pos.repodataid, SOLVID_POS, keyname, typep);
2068 return chk ? repodata_chk2str(pool->pos.repo->repodata + pool->pos.repodataid, *typep, chk) : 0;
2072 return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
2076 pool_lookup_deltalocation(Pool *pool, Id entry)
2079 if (entry != SOLVID_POS)
2081 loc = pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_DIR);
2082 loc = pool_tmpjoin(pool, loc, loc ? "/" : 0, pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_NAME));
2083 loc = pool_tmpappend(pool, loc, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_EVR));
2084 loc = pool_tmpappend(pool, loc, ".", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_SUFFIX));
2089 pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
2091 int hadhashes = pool->relhashtbl ? 1 : 0;
2097 if (!conflicts->count)
2099 pool_freewhatprovides(pool);
2100 for (i = 0; i < conflicts->count; i += 5)
2102 fn = conflicts->elements[i];
2103 p = conflicts->elements[i + 1];
2104 md5 = conflicts->elements[i + 2];
2105 q = conflicts->elements[i + 3];
2106 id = pool_rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
2107 s = pool->solvables + p;
2110 s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
2111 s = pool->solvables + q;
2114 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
2117 pool_freeidhashes(pool);
2121 pool_prepend_rootdir(Pool *pool, const char *path)
2126 return solv_strdup(path);
2127 return solv_dupjoin(pool->rootdir, "/", *path == '/' ? path + 1 : path);
2131 pool_prepend_rootdir_tmp(Pool *pool, const char *path)
2137 return pool_tmpjoin(pool, pool->rootdir, "/", *path == '/' ? path + 1 : path);
2141 pool_set_rootdir(Pool *pool, const char *rootdir)
2143 solv_free(pool->rootdir);
2144 pool->rootdir = solv_strdup(rootdir);
2148 pool_get_rootdir(Pool *pool)
2150 return pool->rootdir;