2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
20 #include "pooltypes.h"
27 // see initpool_data[] in pool.c
30 #define ID_NULL STRID_NULL
31 #define ID_EMPTY STRID_EMPTY
32 #define SOLVABLE_NAME 2
33 #define SOLVABLE_ARCH 3
34 #define SOLVABLE_EVR 4
35 #define SOLVABLE_VENDOR 5
36 #define SOLVABLE_PROVIDES 6
37 #define SOLVABLE_OBSOLETES 7
38 #define SOLVABLE_CONFLICTS 8
39 #define SOLVABLE_REQUIRES 9
40 #define SOLVABLE_RECOMMENDS 10
41 #define SOLVABLE_SUGGESTS 11
42 #define SOLVABLE_SUPPLEMENTS 12
43 #define SOLVABLE_ENHANCES 13
44 #define SOLVABLE_FRESHENS 14
45 #define RPM_RPMDBID 15
46 #define SOLVABLE_PREREQMARKER 16 // normal requires before this, prereqs after this
47 #define SOLVABLE_FILEMARKER 17 // normal provides before this, generated file provides after this
48 #define NAMESPACE_INSTALLED 18
49 #define NAMESPACE_MODALIAS 19
50 #define SYSTEM_SYSTEM 20
53 #define ARCH_NOARCH 23
55 /* well known solvable */
56 #define SYSTEMSOLVABLE 1
59 /* how many strings to maintain (round robin) */
62 //-----------------------------------------------
65 int verbose; // pool is used everywhere, so put the verbose flag here
67 struct _Stringpool ss;
69 Reldep *rels; // table of rels: Id -> Reldep
70 int nrels; // number of unique rels
71 Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id
80 int promoteepoch; /* 0/1 */
82 Id *id2arch; /* map arch ids to scores */
83 Id lastarch; /* last valid entry in id2arch */
84 Queue vendormap; /* map vendor to vendorclasses mask */
86 /* providers data, as two-step indirect list
87 * whatprovides[Id] -> Offset into whatprovidesdata for name
88 * whatprovidesdata[Offset] -> ID_NULL-terminated list of solvables providing Id
90 Offset *whatprovides; /* Offset to providers of a specific name, Id -> Offset */
91 Id *whatprovidesdata; /* Ids of solvable providing Id */
92 Offset whatprovidesdataoff; /* next free slot within whatprovidesdata */
93 int whatprovidesdataleft; /* number of 'free slots' within whatprovidesdata */
95 Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
98 /* our dep2str string space */
99 char *dep2strbuf[DEP2STRBUF];
100 int dep2strlen[DEP2STRBUF];
105 #define TYPE_IDARRAY 2
108 #define TYPE_BITMAP 128
111 //-----------------------------------------------
114 // "foo" -> Id -> lookup in table, returns offset into whatprovidesdata where array of Ids providing 'foo' are located, 0-terminated
117 #define GET_PROVIDESP(d, v) (ISRELDEP(d) ? \
118 (v = GETRELID(pool, d), pool->whatprovides[v] ? \
119 pool->whatprovidesdata + pool->whatprovides[v] : \
120 pool_addrelproviders(pool, d) \
122 (pool->whatprovidesdata + pool->whatprovides[d]))
124 /* loop over all providers of d */
125 #define FOR_PROVIDES(v, vp, d) \
126 for (vp = GET_PROVIDESP(d, v) ; (v = *vp++) != ID_NULL; )
128 /* mark dependencies with relation by setting bit31 */
130 #define MAKERELDEP(id) ((id) | 0x80000000)
131 #define ISRELDEP(id) (((id) & 0x80000000) != 0)
132 #define GETRELID(pool, id) ((pool)->ss.nstrings + ((id) ^ 0x80000000)) /* returns Id */
133 #define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000)) /* returns Reldep* */
142 #define REL_NAMESPACE 19
147 extern Pool *pool_create(void);
151 extern void pool_free(Pool *pool);
153 * Prepares a pool for solving
155 extern void pool_prepare(Pool *pool);
156 extern void pool_freewhatprovides(Pool *pool);
157 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
159 extern Id *pool_addrelproviders(Pool *pool, Id d);
161 static inline int pool_installable(Pool *pool, Solvable *s)
163 if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
165 if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))