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.
22 #include "poolvendor.h"
25 #include "poolid_private.h"
31 #define SOLVABLE_BLOCK 255
33 #undef LIBSOLV_KNOWNID_H
34 #define KNOWNID_INITIALIZE
36 #undef KNOWNID_INITIALIZE
45 pool = (Pool *)solv_calloc(1, sizeof(*pool));
47 stringpool_init (&pool->ss, initpool_data);
49 /* alloc space for RelDep 0 */
50 pool->rels = solv_extend_resize(0, 1, sizeof(Reldep), REL_BLOCK);
52 memset(pool->rels, 0, sizeof(Reldep));
54 /* alloc space for Solvable 0 and system solvable */
55 pool->solvables = solv_extend_resize(0, 2, sizeof(Solvable), SOLVABLE_BLOCK);
57 memset(pool->solvables, 0, 2 * sizeof(Solvable));
59 queue_init(&pool->vendormap);
60 queue_init(&pool->pooljobs);
61 queue_init(&pool->lazywhatprovidesq);
64 pool->disttype = DISTTYPE_DEB;
65 pool->noarchid = ARCH_ALL;
66 #elif defined(ARCHLINUX)
67 pool->disttype = DISTTYPE_ARCH;
68 pool->noarchid = ARCH_ANY;
70 pool->disttype = DISTTYPE_HAIKU;
71 pool->noarchid = ARCH_ANY;
72 pool->obsoleteusesprovides = 1;
74 pool->disttype = DISTTYPE_RPM;
75 pool->noarchid = ARCH_NOARCH;
78 /* initialize the system solvable */
79 s = pool->solvables + SYSTEMSOLVABLE;
80 s->name = SYSTEM_SYSTEM;
81 s->arch = pool->noarchid;
84 pool->debugmask = SOLV_DEBUG_RESULT; /* FIXME */
85 #if defined(FEDORA) || defined(MAGEIA)
86 pool->implicitobsoleteusescolors = 1;
89 pool->noobsoletesmultiversion = 1;
90 pool->forbidselfconflicts = 1;
91 pool->obsoleteusesprovides = 1;
92 pool->implicitobsoleteusesprovides = 1;
93 pool->havedistepoch = 1;
99 /* free all the resources of our pool */
101 pool_free(Pool *pool)
105 pool_freewhatprovides(pool);
106 pool_freeidhashes(pool);
107 pool_freeallrepos(pool, 1);
108 solv_free(pool->id2arch);
109 solv_free(pool->id2color);
110 solv_free(pool->solvables);
111 stringpool_free(&pool->ss);
112 solv_free(pool->rels);
113 pool_setvendorclasses(pool, 0);
114 queue_free(&pool->vendormap);
115 queue_free(&pool->pooljobs);
116 queue_free(&pool->lazywhatprovidesq);
117 for (i = 0; i < POOL_TMPSPACEBUF; i++)
118 solv_free(pool->tmpspace.buf[i]);
119 for (i = 0; i < pool->nlanguages; i++)
120 free((char *)pool->languages[i]);
121 solv_free((void *)pool->languages);
122 solv_free(pool->languagecache);
123 solv_free(pool->errstr);
124 solv_free(pool->rootdir);
129 pool_freeallrepos(Pool *pool, int reuseids)
133 pool_freewhatprovides(pool);
134 for (i = 1; i < pool->nrepos; i++)
136 repo_freedata(pool->repos[i]);
137 pool->repos = solv_free(pool->repos);
140 /* the first two solvables don't belong to a repo */
141 pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
145 pool_setdisttype(Pool *pool, int disttype)
147 #ifdef MULTI_SEMANTICS
148 int olddisttype = pool->disttype;
152 pool->noarchid = ARCH_NOARCH;
155 pool->noarchid = ARCH_ALL;
159 pool->noarchid = ARCH_ANY;
164 pool->disttype = disttype;
165 pool->solvables[SYSTEMSOLVABLE].arch = pool->noarchid;
168 return pool->disttype == disttype ? disttype : -1;
173 pool_get_flag(Pool *pool, int flag)
177 case POOL_FLAG_PROMOTEEPOCH:
178 return pool->promoteepoch;
179 case POOL_FLAG_FORBIDSELFCONFLICTS:
180 return pool->forbidselfconflicts;
181 case POOL_FLAG_OBSOLETEUSESPROVIDES:
182 return pool->obsoleteusesprovides;
183 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
184 return pool->implicitobsoleteusesprovides;
185 case POOL_FLAG_OBSOLETEUSESCOLORS:
186 return pool->obsoleteusescolors;
187 case POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS:
188 return pool->implicitobsoleteusescolors;
189 case POOL_FLAG_NOINSTALLEDOBSOLETES:
190 return pool->noinstalledobsoletes;
191 case POOL_FLAG_HAVEDISTEPOCH:
192 return pool->havedistepoch;
193 case POOL_FLAG_NOOBSOLETESMULTIVERSION:
194 return pool->noobsoletesmultiversion;
195 case POOL_FLAG_ADDFILEPROVIDESFILTERED:
196 return pool->addfileprovidesfiltered;
197 case POOL_FLAG_NOWHATPROVIDESAUX:
198 return pool->nowhatprovidesaux;
206 pool_set_flag(Pool *pool, int flag, int value)
208 int old = pool_get_flag(pool, flag);
211 case POOL_FLAG_PROMOTEEPOCH:
212 pool->promoteepoch = value;
214 case POOL_FLAG_FORBIDSELFCONFLICTS:
215 pool->forbidselfconflicts = value;
217 case POOL_FLAG_OBSOLETEUSESPROVIDES:
218 pool->obsoleteusesprovides = value;
220 case POOL_FLAG_IMPLICITOBSOLETEUSESPROVIDES:
221 pool->implicitobsoleteusesprovides = value;
223 case POOL_FLAG_OBSOLETEUSESCOLORS:
224 pool->obsoleteusescolors = value;
226 case POOL_FLAG_IMPLICITOBSOLETEUSESCOLORS:
227 pool->implicitobsoleteusescolors = value;
229 case POOL_FLAG_NOINSTALLEDOBSOLETES:
230 pool->noinstalledobsoletes = value;
232 case POOL_FLAG_HAVEDISTEPOCH:
233 pool->havedistepoch = value;
235 case POOL_FLAG_NOOBSOLETESMULTIVERSION:
236 pool->noobsoletesmultiversion = value;
238 case POOL_FLAG_ADDFILEPROVIDESFILTERED:
239 pool->addfileprovidesfiltered = value;
241 case POOL_FLAG_NOWHATPROVIDESAUX:
242 pool->nowhatprovidesaux = value;
252 pool_add_solvable(Pool *pool)
254 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, 1, sizeof(Solvable), SOLVABLE_BLOCK);
255 memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable));
256 return pool->nsolvables++;
260 pool_add_solvable_block(Pool *pool, int count)
262 Id nsolvables = pool->nsolvables;
265 pool->solvables = solv_extend(pool->solvables, pool->nsolvables, count, sizeof(Solvable), SOLVABLE_BLOCK);
266 memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count);
267 pool->nsolvables += count;
272 pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids)
276 if (reuseids && start + count == pool->nsolvables)
278 /* might want to shrink solvable array */
279 pool->nsolvables = start;
282 memset(pool->solvables + start, 0, sizeof(Solvable) * count);
287 pool_set_installed(Pool *pool, Repo *installed)
289 if (pool->installed == installed)
291 pool->installed = installed;
292 pool_freewhatprovides(pool);
296 pool_shrink_whatprovides_sortcmp(const void *ap, const void *bp, void *dp)
301 oa = pool->whatprovides[*(Id *)ap];
302 ob = pool->whatprovides[*(Id *)bp];
304 return *(Id *)ap - *(Id *)bp;
305 da = pool->whatprovidesdata + oa;
306 db = pool->whatprovidesdata + ob;
308 if ((r = (*da++ - *db++)) != 0)
312 return *(Id *)ap - *(Id *)bp;
316 * pool_shrink_whatprovides - unify whatprovides data
318 * whatprovides_rel must be empty for this to work!
322 pool_shrink_whatprovides(Pool *pool)
326 Id lastid, *last, *dp, *lp;
330 if (pool->ss.nstrings < 3)
332 sorted = solv_malloc2(pool->ss.nstrings, sizeof(Id));
333 for (i = id = 0; id < pool->ss.nstrings; id++)
334 if (pool->whatprovides[id] >= 4)
337 solv_sort(sorted, n, sizeof(Id), pool_shrink_whatprovides_sortcmp, pool);
340 for (i = 0; i < n; i++)
343 o = pool->whatprovides[id];
344 dp = pool->whatprovidesdata + o;
358 pool->whatprovides[id] = -lastid;
362 last = pool->whatprovidesdata + o;
366 dp = pool->whatprovidesdata + 4;
367 for (id = 1; id < pool->ss.nstrings; id++)
369 o = pool->whatprovides[id];
377 pool->whatprovides[id] = pool->whatprovides[i];
382 lp = pool->whatprovidesdata + o;
385 pool->whatprovides[id] = dp - pool->whatprovidesdata;
386 while ((*dp++ = *lp++) != 0)
389 o = dp - pool->whatprovidesdata;
390 POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesdata from %d to %d\n", pool->whatprovidesdataoff, o);
391 if (pool->whatprovidesdataoff == o)
393 r = pool->whatprovidesdataoff - o;
394 pool->whatprovidesdataoff = o;
395 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id));
396 if (r > pool->whatprovidesdataleft)
397 r = pool->whatprovidesdataleft;
398 memset(pool->whatprovidesdata + o, 0, r * sizeof(Id));
401 /* this gets rid of all the zeros in the aux */
403 pool_shrink_whatprovidesaux(Pool *pool)
405 int num = pool->whatprovidesauxoff;
408 Id *op, *wp = pool->whatprovidesauxdata + 1;
411 for (i = 0; i < num; i++)
413 Offset o = pool->whatprovidesaux[i];
416 op = pool->whatprovidesauxdata + o;
417 pool->whatprovidesaux[i] = wp - pool->whatprovidesauxdata;
420 while ((id = *op++) != 0)
423 newoff = wp - pool->whatprovidesauxdata;
424 pool->whatprovidesauxdata = solv_realloc(pool->whatprovidesauxdata, newoff * sizeof(Id));
425 POOL_DEBUG(SOLV_DEBUG_STATS, "shrunk whatprovidesauxdata from %d to %d\n", pool->whatprovidesauxdataoff, newoff);
426 pool->whatprovidesauxdataoff = newoff;
431 * pool_createwhatprovides()
433 * create hashes over pool of solvables to ease provide lookups
437 pool_createwhatprovides(Pool *pool)
439 int i, num, np, extra;
444 Offset *whatprovides;
445 Id *whatprovidesdata, *dp, *whatprovidesauxdata;
446 Offset *whatprovidesaux;
447 Repo *installed = pool->installed;
450 now = solv_timems(0);
451 POOL_DEBUG(SOLV_DEBUG_STATS, "number of solvables: %d, memory used: %d K\n", pool->nsolvables, pool->nsolvables * (int)sizeof(Solvable) / 1024);
452 POOL_DEBUG(SOLV_DEBUG_STATS, "number of ids: %d + %d\n", pool->ss.nstrings, pool->nrels);
453 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);
454 if (pool->ss.stringhashmask || pool->relhashmask)
455 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)));
457 pool_freeidhashes(pool); /* XXX: should not be here! */
458 pool_freewhatprovides(pool);
459 num = pool->ss.nstrings;
460 pool->whatprovides = whatprovides = solv_calloc_block(num, sizeof(Offset), WHATPROVIDES_BLOCK);
461 pool->whatprovides_rel = solv_calloc_block(pool->nrels, sizeof(Offset), WHATPROVIDES_BLOCK);
463 /* count providers for each name */
464 for (i = pool->nsolvables - 1; i > 0; i--)
467 s = pool->solvables + i;
468 if (!s->provides || !s->repo || s->repo->disabled)
470 /* we always need the installed solvable in the whatprovides data,
471 otherwise obsoletes/conflicts on them won't work */
472 if (s->repo != installed && !pool_installable(pool, s))
474 pp = s->repo->idarraydata + s->provides;
475 while ((id = *pp++) != 0)
479 Reldep *rd = GETRELDEP(pool, id);
482 whatprovides[id]++; /* inc count of providers */
486 off = 4; /* first entry is undef, second is empty list, third is system solvable */
487 np = 0; /* number of names provided */
488 for (i = 0, idp = whatprovides; i < num; i++, idp++)
491 if (!n) /* no providers */
493 *idp = 1; /* offset for empty list */
496 off += n; /* make space for all providers */
497 *idp = off++; /* now idp points to terminating zero */
498 np++; /* inc # of provider 'slots' for stats */
501 POOL_DEBUG(SOLV_DEBUG_STATS, "provide ids: %d\n", np);
503 /* reserve some space for relation data */
504 extra = 2 * pool->nrels;
508 POOL_DEBUG(SOLV_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra);
510 /* alloc space for all providers + extra */
511 whatprovidesdata = solv_calloc(off + extra, sizeof(Id));
512 whatprovidesdata[2] = SYSTEMSOLVABLE;
514 /* alloc aux vector */
515 whatprovidesauxdata = 0;
516 if (!pool->nowhatprovidesaux)
518 pool->whatprovidesaux = whatprovidesaux = solv_calloc(num, sizeof(Offset));
519 pool->whatprovidesauxoff = num;
520 pool->whatprovidesauxdataoff = off;
521 pool->whatprovidesauxdata = whatprovidesauxdata = solv_calloc(pool->whatprovidesauxdataoff, sizeof(Id));
524 /* now fill data for all provides */
525 for (i = pool->nsolvables - 1; i > 0; i--)
528 s = pool->solvables + i;
529 if (!s->provides || !s->repo || s->repo->disabled)
531 if (s->repo != installed && !pool_installable(pool, s))
534 /* for all provides of this solvable */
535 pp = s->repo->idarraydata + s->provides;
536 while ((id = *pp++) != 0)
541 Reldep *rd = GETRELDEP(pool, id);
544 dp = whatprovidesdata + whatprovides[id]; /* offset into whatprovidesdata */
545 if (*dp != i) /* don't add same solvable twice */
552 if (whatprovidesauxdata)
553 whatprovidesauxdata[whatprovides[id]] = auxid;
556 if (pool->whatprovidesaux)
557 memcpy(pool->whatprovidesaux, pool->whatprovides, num * sizeof(Id));
558 pool->whatprovidesdata = whatprovidesdata;
559 pool->whatprovidesdataoff = off;
560 pool->whatprovidesdataleft = extra;
561 pool_shrink_whatprovides(pool);
562 if (pool->whatprovidesaux)
563 pool_shrink_whatprovidesaux(pool);
564 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)));
565 if (pool->whatprovidesaux)
566 POOL_DEBUG(SOLV_DEBUG_STATS, "whatprovidesaux memory used: %d K id array, %d K data\n", pool->whatprovidesauxoff / (int)(1024/sizeof(Id)), pool->whatprovidesauxdataoff / (int)(1024/sizeof(Id)));
568 queue_empty(&pool->lazywhatprovidesq);
569 if ((!pool->addedfileprovides && pool->disttype == DISTTYPE_RPM) || pool->addedfileprovides == 1)
571 if (!pool->addedfileprovides)
572 POOL_DEBUG(SOLV_DEBUG_STATS, "WARNING: pool_addfileprovides was not called, this may result in slow operation\n");
573 /* lazyly add file provides */
574 for (i = 1; i < num; i++)
576 const char *str = pool->ss.stringspace + pool->ss.strings[i];
579 if (pool->addedfileprovides == 1 && repodata_filelistfilter_matches(0, str))
581 /* setup lazy adding, but remember old value */
582 if (pool->whatprovides[i] > 1)
583 queue_push2(&pool->lazywhatprovidesq, i, pool->whatprovides[i]);
584 pool->whatprovides[i] = 0;
585 if (pool->whatprovidesaux)
586 pool->whatprovidesaux[i] = 0; /* sorry */
588 POOL_DEBUG(SOLV_DEBUG_STATS, "lazywhatprovidesq size: %d entries\n", pool->lazywhatprovidesq.count / 2);
591 POOL_DEBUG(SOLV_DEBUG_STATS, "createwhatprovides took %d ms\n", solv_timems(now));
595 * free all of our whatprovides data
596 * be careful, everything internalized with pool_queuetowhatprovides is
600 pool_freewhatprovides(Pool *pool)
602 pool->whatprovides = solv_free(pool->whatprovides);
603 pool->whatprovides_rel = solv_free(pool->whatprovides_rel);
604 pool->whatprovidesdata = solv_free(pool->whatprovidesdata);
605 pool->whatprovidesdataoff = 0;
606 pool->whatprovidesdataleft = 0;
607 pool->whatprovidesaux = solv_free(pool->whatprovidesaux);
608 pool->whatprovidesauxdata = solv_free(pool->whatprovidesauxdata);
609 pool->whatprovidesauxoff = 0;
610 pool->whatprovidesauxdataoff = 0;
614 /******************************************************************************/
617 * pool_queuetowhatprovides - add queue contents to whatprovidesdata
619 * used for whatprovides, jobs, learnt rules, selections
620 * input: q: queue of Ids
621 * returns: Offset into whatprovidesdata
626 pool_ids2whatprovides(Pool *pool, Id *ids, int count)
630 if (count == 0) /* queue empty -> 1 */
632 if (count == 1 && *ids == SYSTEMSOLVABLE)
635 /* extend whatprovidesdata if needed, +1 for 0-termination */
636 if (pool->whatprovidesdataleft < count + 1)
638 POOL_DEBUG(SOLV_DEBUG_STATS, "growing provides hash data...\n");
639 pool->whatprovidesdata = solv_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id));
640 pool->whatprovidesdataleft = count + 4096;
643 /* copy queue to next free slot */
644 off = pool->whatprovidesdataoff;
645 memcpy(pool->whatprovidesdata + pool->whatprovidesdataoff, ids, count * sizeof(Id));
647 /* adapt count and 0-terminate */
648 pool->whatprovidesdataoff += count;
649 pool->whatprovidesdata[pool->whatprovidesdataoff++] = 0;
650 pool->whatprovidesdataleft -= count + 1;
656 pool_queuetowhatprovides(Pool *pool, Queue *q)
658 int count = q->count;
659 if (count == 0) /* queue empty -> 1 */
661 if (count == 1 && q->elements[0] == SYSTEMSOLVABLE)
663 return pool_ids2whatprovides(pool, q->elements, count);
667 /*************************************************************************/
669 #if defined(MULTI_SEMANTICS)
670 # define EVRCMP_DEPCMP (pool->disttype == DISTTYPE_DEB ? EVRCMP_COMPARE : EVRCMP_MATCH_RELEASE)
671 #elif defined(DEBIAN)
672 # define EVRCMP_DEPCMP EVRCMP_COMPARE
674 # define EVRCMP_DEPCMP EVRCMP_MATCH_RELEASE
677 /* check if a package's nevr matches a dependency */
678 /* semi-private, called from public pool_match_nevr */
681 pool_match_nevr_rel(Pool *pool, Solvable *s, Id d)
683 Reldep *rd = GETRELDEP(pool, d);
686 int flags = rd->flags;
695 if (evr != ARCH_SRC || s->arch != ARCH_NOSRC)
698 return pool_match_nevr(pool, s, name);
700 if (pool_match_nevr(pool, s, name))
702 return pool_match_nevr(pool, s, evr);
705 if (!pool_match_nevr(pool, s, name))
707 return pool_match_nevr(pool, s, evr);
711 /* XXX : need to check for Multi-Arch: allowed! */
712 return pool_match_nevr(pool, s, name);
717 if (!pool_match_nevr(pool, s, name))
720 return (flags & REL_EQ) ? 1 : 0;
725 switch (pool_evrcmp(pool, s->evr, evr, EVRCMP_DEPCMP))
730 return (flags & REL_LT) ? 1 : 0;
732 return (flags & REL_EQ) ? 1 : 0;
734 return (flags & REL_GT) ? 1 : 0;
736 return (flags & REL_EQ) ? 1 : 0;
743 #if defined(HAIKU) || defined(MULTI_SEMANTICS)
744 /* forward declaration */
745 static int pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr);
748 /* match (flags, evr) against provider (pflags, pevr) */
750 pool_match_flags_evr(Pool *pool, int pflags, Id pevr, int flags, int evr)
752 if (!pflags || !flags || pflags >= 8 || flags >= 8)
754 if (flags == 7 || pflags == 7)
755 return 1; /* rel provides every version */
756 if ((pflags & flags & (REL_LT | REL_GT)) != 0)
757 return 1; /* both rels show in the same direction */
759 return (flags & pflags & REL_EQ) ? 1 : 0;
760 #if defined(HAIKU) || defined(MULTI_SEMANTICS)
763 Reldep *rd = GETRELDEP(pool, pevr);
764 if (rd->flags == REL_COMPAT)
765 return pool_match_flags_evr_rel_compat(pool, rd, flags, evr);
768 switch (pool_evrcmp(pool, pevr, evr, EVRCMP_DEPCMP))
771 return (pflags & REL_EQ) ? 1 : 0;
773 return (flags & REL_LT) || (pflags & REL_GT) ? 1 : 0;
775 return (flags & pflags & REL_EQ) ? 1 : 0;
777 return (flags & REL_GT) || (pflags & REL_LT) ? 1 : 0;
779 return (flags & REL_EQ) ? 1 : 0;
786 #if defined(HAIKU) || defined(MULTI_SEMANTICS)
788 pool_match_flags_evr_rel_compat(Pool *pool, Reldep *range, int flags, int evr)
790 /* range->name is the actual version, range->evr the backwards compatibility
791 version. If flags are '>=' or '>', we match the compatibility version
792 as well, otherwise only the actual version. */
793 if (!(flags & REL_GT) || (flags & REL_LT))
794 return pool_match_flags_evr(pool, REL_EQ, range->name, flags, evr);
795 return pool_match_flags_evr(pool, REL_LT | REL_EQ, range->name, flags, evr) &&
796 pool_match_flags_evr(pool, REL_GT | REL_EQ, range->evr, REL_EQ, evr);
800 /* public (i.e. not inlined) version of pool_match_flags_evr */
802 pool_intersect_evrs(Pool *pool, int pflags, Id pevr, int flags, int evr)
804 return pool_match_flags_evr(pool, pflags, pevr, flags, evr);
807 /* match two dependencies (d1 = provider) */
810 pool_match_dep(Pool *pool, Id d1, Id d2)
819 /* we use potentially matches for complex deps */
820 rd1 = GETRELDEP(pool, d1);
821 if (rd1->flags == REL_AND || rd1->flags == REL_OR || rd1->flags == REL_WITH || rd1->flags == REL_COND)
823 if (pool_match_dep(pool, rd1->name, d2))
825 if (rd1->flags == REL_COND && ISRELDEP(rd1->evr))
827 rd1 = GETRELDEP(pool, rd1->evr);
828 if (rd1->flags != REL_ELSE)
831 if (rd1->flags != REL_COND && pool_match_dep(pool, rd1->evr, d2))
838 /* we use potentially matches for complex deps */
839 rd2 = GETRELDEP(pool, d2);
840 if (rd2->flags == REL_AND || rd2->flags == REL_OR || rd2->flags == REL_WITH || rd2->flags == REL_COND)
842 if (pool_match_dep(pool, d1, rd2->name))
844 if (rd2->flags == REL_COND && ISRELDEP(rd2->evr))
846 rd2 = GETRELDEP(pool, rd2->evr);
847 if (rd2->flags != REL_ELSE)
850 if (rd2->flags != REL_COND && pool_match_dep(pool, d1, rd2->evr))
859 rd2 = GETRELDEP(pool, d2);
860 return pool_match_dep(pool, d1, rd2->name);
862 rd1 = GETRELDEP(pool, d1);
865 return pool_match_dep(pool, rd1->name, d2);
867 rd2 = GETRELDEP(pool, d2);
868 /* first match name */
869 if (!pool_match_dep(pool, rd1->name, rd2->name))
871 /* name matches, check flags and evr */
872 return pool_intersect_evrs(pool, rd1->flags, rd1->evr, rd2->flags, rd2->evr);
876 pool_searchlazywhatprovidesq(Pool *pool, Id d)
879 int end = pool->lazywhatprovidesq.count;
883 elements = pool->lazywhatprovidesq.elements;
884 while (end - start > 16)
886 int mid = (start + end) / 2 & ~1;
887 if (elements[mid] == d)
888 return elements[mid + 1];
889 if (elements[mid] < d)
894 for (; start < end; start += 2)
895 if (elements[start] == d)
896 return elements[start + 1];
903 * lazy populating of the whatprovides array, non relation case
906 pool_addstdproviders(Pool *pool, Id d)
914 if (pool->addedfileprovides == 2)
916 pool->whatprovides[d] = 1;
919 str = pool->ss.stringspace + pool->ss.strings[d];
922 pool->whatprovides[d] = 1;
925 queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf));
926 dataiterator_init(&di, pool, 0, 0, SOLVABLE_FILELIST, str, SEARCH_STRING|SEARCH_FILES|SEARCH_COMPLETE_FILELIST);
927 for (; dataiterator_step(&di); dataiterator_skip_solvable(&di))
929 Solvable *s = pool->solvables + di.solvid;
930 /* XXX: maybe should add a provides dependency to the solvables
931 * OTOH this is only needed for rel deps that filter the provides,
932 * and those should not use filelist entries */
933 if (s->repo->disabled)
935 if (s->repo != pool->installed && !pool_installable(pool, s))
937 queue_push(&q, di.solvid);
939 dataiterator_free(&di);
940 oldoffset = pool_searchlazywhatprovidesq(pool, d);
942 pool->whatprovides[d] = oldoffset ? oldoffset : 1;
947 Id *oo = pool->whatprovidesdata + oldoffset;
949 /* unify both queues. easy, as we know both are sorted */
950 for (i = 0; i < q.count; i++)
952 if (*oo > q.elements[i])
954 if (*oo < q.elements[i])
955 queue_insert(&q, i, *oo);
961 queue_push(&q, *oo++);
962 if (q.count == oo - (pool->whatprovidesdata + oldoffset))
964 /* end result has same size as oldoffset -> no new entries */
966 pool->whatprovides[d] = oldoffset;
970 pool->whatprovides[d] = pool_queuetowhatprovides(pool, &q);
973 return pool->whatprovides[d];
978 pool_is_kind(Pool *pool, Id name, Id kind)
983 n = pool_id2str(pool, name);
986 const char *kn = pool_id2str(pool, kind);
987 int knl = strlen(kn);
988 return !strncmp(n, kn, knl) && n[knl] == ':' ? 1 : 0;
994 while(*n >= 'a' && *n <= 'z')
996 return *n == ':' ? 0 : 1;
1003 * add packages fulfilling the relation to whatprovides array
1005 * some words about REL_AND and REL_IF: we assume the best case
1006 * here, so that you get a "potential" result if you ask for a match.
1007 * E.g. if you ask for "whatrequires A" and package X contains
1008 * "Requires: A & B", you'll get "X" as an answer.
1011 pool_addrelproviders(Pool *pool, Id d)
1017 Id name, evr, flags;
1022 return pool_addstdproviders(pool, d);
1023 rd = GETRELDEP(pool, d);
1028 queue_init_buffer(&plist, buf, sizeof(buf)/sizeof(*buf));
1032 /* special relation */
1039 wp = pool_whatprovides(pool, name);
1040 pp2 = pool_whatprovides_ptr(pool, evr);
1041 pp = pool->whatprovidesdata + wp;
1042 while ((p = *pp++) != 0)
1044 for (pp3 = pp2; *pp3; pp3++)
1048 queue_push(&plist, p); /* found it */
1057 if (flags == REL_COND)
1061 Reldep *rd2 = GETRELDEP(pool, evr);
1062 evr = rd2->flags == REL_ELSE ? rd2->evr : 0;
1065 evr = 0; /* assume cond is true */
1067 wp = pool_whatprovides(pool, name);
1068 if (!pool->whatprovidesdata[wp])
1069 wp = evr ? pool_whatprovides(pool, evr) : 1;
1073 pp2 = pool_whatprovides_ptr(pool, evr);
1074 pp = pool->whatprovidesdata + wp;
1078 queue_push(&plist, *pp++);
1083 queue_push(&plist, *pp2++);
1087 queue_push(&plist, *pp++);
1089 queue_push(&plist, *pp2++);
1090 /* if the number of elements did not change, we can reuse wp */
1091 if (pp - (pool->whatprovidesdata + wp) != plist.count)
1097 if (name == NAMESPACE_OTHERPROVIDERS)
1099 wp = pool_whatprovides(pool, evr);
1102 if (pool->nscallback)
1104 /* ask callback which packages provide the dependency
1106 * 1: the system (aka SYSTEMSOLVABLE)
1107 * >1: set of packages, stored as offset on whatprovidesdata
1109 p = pool->nscallback(pool, pool->nscallbackdata, name, evr);
1113 queue_push(&plist, SYSTEMSOLVABLE);
1117 /* small hack: make it possible to match <pkg>.src
1118 * we have to iterate over the solvables as src packages do not
1119 * provide anything, thus they are not indexed in our
1120 * whatprovides hash */
1121 if (evr == ARCH_SRC || evr == ARCH_NOSRC)
1124 for (p = 1, s = pool->solvables + p; p < pool->nsolvables; p++, s++)
1128 if (s->arch != evr && s->arch != ARCH_NOSRC)
1130 if (pool_disabled_solvable(pool, s))
1132 if (!name || pool_match_nevr(pool, s, name))
1133 queue_push(&plist, p);
1139 FOR_POOL_SOLVABLES(p)
1141 Solvable *s = pool->solvables + p;
1142 if (s->repo != pool->installed && !pool_installable(pool, s))
1145 queue_push(&plist, p);
1149 wp = pool_whatprovides(pool, name);
1150 pp = pool->whatprovidesdata + wp;
1151 while ((p = *pp++) != 0)
1153 Solvable *s = pool->solvables + p;
1155 queue_push(&plist, p);
1161 if (evr != ARCH_ANY)
1163 /* XXX : need to check for Multi-Arch: allowed! */
1164 wp = pool_whatprovides(pool, name);
1167 /* package kind filtering */
1170 FOR_POOL_SOLVABLES(p)
1172 Solvable *s = pool->solvables + p;
1173 if (s->repo != pool->installed && !pool_installable(pool, s))
1175 if (pool_is_kind(pool, s->name, evr))
1176 queue_push(&plist, p);
1180 wp = pool_whatprovides(pool, name);
1181 pp = pool->whatprovidesdata + wp;
1182 while ((p = *pp++) != 0)
1184 Solvable *s = pool->solvables + p;
1185 if (pool_is_kind(pool, s->name, evr))
1186 queue_push(&plist, p);
1191 case REL_FILECONFLICT:
1192 pp = pool_whatprovides_ptr(pool, name);
1193 while ((p = *pp++) != 0)
1195 Id origd = MAKERELDEP(d);
1196 Solvable *s = pool->solvables + p;
1199 pidp = s->repo->idarraydata + s->provides;
1200 while ((pid = *pidp++) != 0)
1204 queue_push(&plist, p);
1212 /* we can reuse an existing entry */
1214 pool->whatprovides_rel[d] = wp;
1221 /* simple version comparison relation */
1223 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: what provides %s?\n", pool_dep2str(pool, name));
1225 pp = pool_whatprovides_ptr(pool, name);
1226 if (!ISRELDEP(name) && name < pool->whatprovidesauxoff)
1227 ppaux = pool->whatprovidesaux[name] ? pool->whatprovidesauxdata + pool->whatprovidesaux[name] : 0;
1228 while (ISRELDEP(name))
1230 rd = GETRELDEP(pool, name);
1233 while ((p = *pp++) != 0)
1235 Solvable *s = pool->solvables + p;
1239 if (pid && pid != 1)
1242 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: aux hit %d %s\n", p, pool_dep2str(pool, pid));
1247 continue; /* wrong provides name */
1248 if (pool->disttype == DISTTYPE_DEB)
1249 continue; /* unversioned provides can never match versioned deps */
1253 prd = GETRELDEP(pool, pid);
1254 if (prd->name != name)
1255 continue; /* wrong provides name */
1256 /* right package, both deps are rels. check flags/evr */
1257 if (!pool_match_flags_evr(pool, prd->flags, prd->evr, flags, evr))
1260 queue_push(&plist, p);
1266 /* no provides - check nevr */
1267 if (pool_match_nevr_rel(pool, s, MAKERELDEP(d)))
1268 queue_push(&plist, p);
1271 /* solvable p provides name in some rels */
1272 pidp = s->repo->idarraydata + s->provides;
1273 while ((pid = *pidp++) != 0)
1278 continue; /* wrong provides name */
1279 if (pool->disttype == DISTTYPE_DEB)
1280 continue; /* unversioned provides can never match versioned deps */
1283 prd = GETRELDEP(pool, pid);
1284 if (prd->name != name)
1285 continue; /* wrong provides name */
1286 /* right package, both deps are rels. check flags/evr */
1287 if (pool_match_flags_evr(pool, prd->flags, prd->evr, flags, evr))
1288 break; /* matches */
1291 continue; /* none of the providers matched */
1292 queue_push(&plist, p);
1294 /* make our system solvable provide all unknown rpmlib() stuff */
1295 if (plist.count == 0 && !strncmp(pool_id2str(pool, name), "rpmlib(", 7))
1296 queue_push(&plist, SYSTEMSOLVABLE);
1298 /* add providers to whatprovides */
1300 POOL_DEBUG(SOLV_DEBUG_STATS, "addrelproviders: adding %d packages to %d\n", plist.count, d);
1302 pool->whatprovides_rel[d] = pool_queuetowhatprovides(pool, &plist);
1305 return pool->whatprovides_rel[d];
1309 pool_flush_namespaceproviders(Pool *pool, Id ns, Id evr)
1311 int nrels = pool->nrels;
1315 if (!pool->whatprovides_rel)
1317 for (d = 1, rd = pool->rels + d; d < nrels; d++, rd++)
1319 if (rd->flags != REL_NAMESPACE || rd->name == NAMESPACE_OTHERPROVIDERS)
1321 if (ns && rd->name != ns)
1323 if (evr && rd->evr != evr)
1325 pool->whatprovides_rel[d] = 0;
1329 /* intersect dependencies in keyname with dep, return list of matching packages */
1331 pool_whatmatchesdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker)
1339 FOR_POOL_SOLVABLES(p)
1341 Solvable *s = pool->solvables + p;
1342 if (s->repo->disabled)
1344 if (s->repo != pool->installed && !pool_installable(pool, s))
1348 solvable_lookup_deparray(s, keyname, &qq, marker);
1349 for (i = 0; i < qq.count; i++)
1350 if (pool_match_dep(pool, qq.elements[i], dep))
1359 /* check if keyname contains dep, return list of matching packages */
1361 pool_whatcontainsdep(Pool *pool, Id keyname, Id dep, Queue *q, int marker)
1371 FOR_POOL_SOLVABLES(p)
1373 Solvable *s = pool->solvables + p;
1374 if (s->repo->disabled)
1376 if (s->repo != pool->installed && !pool_installable(pool, s))
1380 solvable_lookup_deparray(s, keyname, &qq, marker);
1381 for (i = 0; i < qq.count; i++)
1382 if (qq.elements[i] == dep)
1391 /*************************************************************************/
1394 pool_debug(Pool *pool, int type, const char *format, ...)
1399 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0)
1401 if ((pool->debugmask & type) == 0)
1404 va_start(args, format);
1405 if (!pool->debugcallback)
1407 if ((type & (SOLV_FATAL|SOLV_ERROR)) == 0 && !(pool->debugmask & SOLV_DEBUG_TO_STDERR))
1408 vprintf(format, args);
1410 vfprintf(stderr, format, args);
1413 vsnprintf(buf, sizeof(buf), format, args);
1415 pool->debugcallback(pool, pool->debugcallbackdata, type, buf);
1419 pool_error(Pool *pool, int ret, const char *format, ...)
1423 va_start(args, format);
1426 pool->errstra = 1024;
1427 pool->errstr = solv_malloc(pool->errstra);
1435 l = vsnprintf(pool->errstr, pool->errstra, format, args);
1437 if (l >= 0 && l + 1 > pool->errstra)
1439 pool->errstra = l + 256;
1440 pool->errstr = solv_realloc(pool->errstr, pool->errstra);
1441 va_start(args, format);
1442 l = vsnprintf(pool->errstr, pool->errstra, format, args);
1446 strcpy(pool->errstr, "unknown error");
1447 if (pool->debugmask & SOLV_ERROR)
1448 pool_debug(pool, SOLV_ERROR, "%s\n", pool->errstr);
1453 pool_errstr(Pool *pool)
1455 return pool->errstr ? pool->errstr : "no error";
1459 pool_setdebuglevel(Pool *pool, int level)
1461 int mask = SOLV_DEBUG_RESULT;
1463 mask |= SOLV_DEBUG_STATS|SOLV_DEBUG_ANALYZE|SOLV_DEBUG_UNSOLVABLE|SOLV_DEBUG_SOLVER|SOLV_DEBUG_TRANSACTION|SOLV_ERROR;
1465 mask |= SOLV_DEBUG_JOB|SOLV_DEBUG_SOLUTIONS|SOLV_DEBUG_POLICY;
1467 mask |= SOLV_DEBUG_PROPAGATE;
1469 mask |= SOLV_DEBUG_RULE_CREATION;
1470 mask |= pool->debugmask & SOLV_DEBUG_TO_STDERR; /* keep bit */
1471 pool->debugmask = mask;
1474 void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
1476 pool->debugcallback = debugcallback;
1477 pool->debugcallbackdata = debugcallbackdata;
1480 void pool_setdebugmask(Pool *pool, int mask)
1482 pool->debugmask = mask;
1485 void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
1487 pool->loadcallback = cb;
1488 pool->loadcallbackdata = loadcbdata;
1491 void pool_setnamespacecallback(Pool *pool, Id (*cb)(struct _Pool *, void *, Id, Id), void *nscbdata)
1493 pool->nscallback = cb;
1494 pool->nscallbackdata = nscbdata;
1498 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)
1502 if (pool->solvables[p].repo)
1503 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1506 /* FIXME: obey callback return value! */
1507 for (p = 1; p < pool->nsolvables; p++)
1508 if (pool->solvables[p].repo)
1509 repo_search(pool->solvables[p].repo, p, key, match, flags, callback, cbdata);
1513 pool_clear_pos(Pool *pool)
1515 memset(&pool->pos, 0, sizeof(pool->pos));
1519 pool_set_languages(Pool *pool, const char **languages, int nlanguages)
1523 pool->languagecache = solv_free(pool->languagecache);
1524 pool->languagecacheother = 0;
1525 for (i = 0; i < pool->nlanguages; i++)
1526 free((char *)pool->languages[i]);
1527 pool->languages = solv_free((void *)pool->languages);
1528 pool->nlanguages = nlanguages;
1531 pool->languages = solv_calloc(nlanguages, sizeof(const char **));
1532 for (i = 0; i < pool->nlanguages; i++)
1533 pool->languages[i] = solv_strdup(languages[i]);
1537 pool_id2langid(Pool *pool, Id id, const char *lang, int create)
1543 if (!lang || !*lang)
1545 n = pool_id2str(pool, id);
1546 l = strlen(n) + strlen(lang) + 2;
1547 if (l > sizeof(buf))
1548 p = solv_malloc(strlen(n) + strlen(lang) + 2);
1551 sprintf(p, "%s:%s", n, lang);
1552 id = pool_str2id(pool, p, create);
1559 pool_alloctmpspace(Pool *pool, int len)
1561 int n = pool->tmpspace.n;
1564 if (len > pool->tmpspace.len[n])
1566 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1567 pool->tmpspace.len[n] = len + 32;
1569 pool->tmpspace.n = (n + 1) % POOL_TMPSPACEBUF;
1570 return pool->tmpspace.buf[n];
1574 pool_alloctmpspace_free(Pool *pool, const char *space, int len)
1579 n = oldn = pool->tmpspace.n;
1583 n = POOL_TMPSPACEBUF - 1;
1586 if (pool->tmpspace.buf[n] != space)
1588 if (len > pool->tmpspace.len[n])
1590 pool->tmpspace.buf[n] = solv_realloc(pool->tmpspace.buf[n], len + 32);
1591 pool->tmpspace.len[n] = len + 32;
1593 return pool->tmpspace.buf[n];
1600 pool_freetmpspace(Pool *pool, const char *space)
1602 int n = pool->tmpspace.n;
1605 n = (n + (POOL_TMPSPACEBUF - 1)) % POOL_TMPSPACEBUF;
1606 if (pool->tmpspace.buf[n] == space)
1607 pool->tmpspace.n = n;
1611 pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3)
1615 l1 = str1 ? strlen(str1) : 0;
1616 l2 = str2 ? strlen(str2) : 0;
1617 l3 = str3 ? strlen(str3) : 0;
1618 s = str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1639 pool_tmpappend(Pool *pool, const char *str1, const char *str2, const char *str3)
1644 l1 = str1 ? strlen(str1) : 0;
1645 l2 = str2 ? strlen(str2) : 0;
1646 l3 = str3 ? strlen(str3) : 0;
1647 str = pool_alloctmpspace_free(pool, str1, l1 + l2 + l3 + 1);
1651 str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
1674 pool_bin2hex(Pool *pool, const unsigned char *buf, int len)
1679 s = pool_alloctmpspace(pool, 2 * len + 1);
1680 solv_bin2hex(buf, len, s);
1685 pool_lookup_str(Pool *pool, Id entry, Id keyname)
1687 if (entry == SOLVID_POS && pool->pos.repo)
1688 return repo_lookup_str(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
1691 return solvable_lookup_str(pool->solvables + entry, keyname);
1695 pool_lookup_id(Pool *pool, Id entry, Id keyname)
1697 if (entry == SOLVID_POS && pool->pos.repo)
1698 return repo_lookup_id(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
1701 return solvable_lookup_id(pool->solvables + entry, keyname);
1705 pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned long long notfound)
1707 if (entry == SOLVID_POS && pool->pos.repo)
1708 return repo_lookup_num(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, notfound);
1711 return solvable_lookup_num(pool->solvables + entry, keyname, notfound);
1715 pool_lookup_void(Pool *pool, Id entry, Id keyname)
1717 if (entry == SOLVID_POS && pool->pos.repo)
1718 return repo_lookup_void(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname);
1721 return solvable_lookup_void(pool->solvables + entry, keyname);
1724 const unsigned char *
1725 pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
1727 if (entry == SOLVID_POS && pool->pos.repo)
1728 return repo_lookup_bin_checksum(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, typep);
1731 return solvable_lookup_bin_checksum(pool->solvables + entry, keyname, typep);
1735 pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
1737 if (entry == SOLVID_POS && pool->pos.repo)
1738 return repo_lookup_checksum(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, typep);
1741 return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
1745 pool_lookup_idarray(Pool *pool, Id entry, Id keyname, Queue *q)
1747 if (entry == SOLVID_POS && pool->pos.repo)
1748 return repo_lookup_idarray(pool->pos.repo, pool->pos.repodataid ? entry : pool->pos.solvid, keyname, q);
1751 return solvable_lookup_idarray(pool->solvables + entry, keyname, q);
1755 pool_lookup_deltalocation(Pool *pool, Id entry, unsigned int *medianrp)
1760 if (entry != SOLVID_POS)
1762 loc = pool_lookup_str(pool, entry, DELTA_LOCATION_DIR);
1763 loc = pool_tmpjoin(pool, loc, loc ? "/" : 0, pool_lookup_str(pool, entry, DELTA_LOCATION_NAME));
1764 loc = pool_tmpappend(pool, loc, "-", pool_lookup_str(pool, entry, DELTA_LOCATION_EVR));
1765 loc = pool_tmpappend(pool, loc, ".", pool_lookup_str(pool, entry, DELTA_LOCATION_SUFFIX));
1770 add_new_provider(Pool *pool, Id id, Id p)
1775 while (ISRELDEP(id))
1777 Reldep *rd = GETRELDEP(pool, id);
1782 for (pp = pool->whatprovidesdata + pool->whatprovides[id]; *pp; pp++)
1794 queue_push(&q, *pp);
1798 pool->whatprovides[id] = pool_queuetowhatprovides(pool, &q);
1799 if (id < pool->whatprovidesauxoff)
1800 pool->whatprovidesaux[id] = 0; /* sorry */
1805 pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
1807 int hadhashes = pool->relhashtbl ? 1 : 0;
1813 if (!conflicts->count)
1815 for (i = 0; i < conflicts->count; i += 6)
1817 fn = conflicts->elements[i];
1818 p = conflicts->elements[i + 1];
1819 md5 = conflicts->elements[i + 2];
1820 q = conflicts->elements[i + 4];
1821 id = pool_rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
1822 s = pool->solvables + p;
1825 s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
1826 if (pool->whatprovides)
1827 add_new_provider(pool, fn, p);
1828 if (pool->whatprovides_rel)
1829 pool->whatprovides_rel[GETRELID(id)] = 0; /* clear cache */
1830 s = pool->solvables + q;
1833 s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
1836 pool_freeidhashes(pool);
1840 pool_prepend_rootdir(Pool *pool, const char *path)
1845 return solv_strdup(path);
1846 return solv_dupjoin(pool->rootdir, "/", *path == '/' ? path + 1 : path);
1850 pool_prepend_rootdir_tmp(Pool *pool, const char *path)
1856 return pool_tmpjoin(pool, pool->rootdir, "/", *path == '/' ? path + 1 : path);
1860 pool_set_rootdir(Pool *pool, const char *rootdir)
1862 solv_free(pool->rootdir);
1863 pool->rootdir = solv_strdup(rootdir);
1867 pool_get_rootdir(Pool *pool)
1869 return pool->rootdir;
1872 /* only used in libzypp */
1874 pool_set_custom_vendorcheck(Pool *pool, int (*vendorcheck)(Pool *, Solvable *, Solvable *))
1876 pool->custom_vendorcheck = vendorcheck;