13 #include "pooltypes.h"
19 // see initpool_data[] in pool.c
24 #define SOLVABLE_NAME 2
25 #define SOLVABLE_ARCH 3
26 #define SOLVABLE_EVR 4
27 #define SOLVABLE_VENDOR 5
28 #define SOLVABLE_PROVIDES 6
29 #define SOLVABLE_OBSOLETES 7
30 #define SOLVABLE_CONFLICTS 8
31 #define SOLVABLE_REQUIRES 9
32 #define SOLVABLE_RECOMMENDS 10
33 #define SOLVABLE_SUGGESTS 11
34 #define SOLVABLE_SUPPLEMENTS 12
35 #define SOLVABLE_ENHANCES 13
36 #define SOLVABLE_FRESHENS 14
37 #define RPM_RPMDBID 15
38 #define SOLVABLE_PREREQMARKER 16 // normal requires before this, prereqs after this
39 #define SOLVABLE_FILEMARKER 17 // normal provides before this, generated file provides after this
40 #define NAMESPACE_INSTALLED 18
41 #define NAMESPACE_MODALIAS 19
42 #define SYSTEM_SYSTEM 20
45 #define ARCH_NOARCH 23
47 /* well known solvable */
48 #define SYSTEMSOLVABLE 1
51 /* how many strings to maintain (round robin) */
55 //-----------------------------------------------
58 int verbose; // pool is used everywhere, so put the verbose flag here
60 Offset *strings; // table of offsets into stringspace, indexed by Id: Id -> Offset
61 int nstrings; // number of unique strings in stringspace
62 char *stringspace; // space for all unique strings: stringspace + Offset = string
63 Offset sstrings; // next free pos in stringspace
65 Hashtable stringhashtbl; // hash table: (string ->) Hash -> Id
66 Hashmask stringhashmask; // modulo value for hash table (size of table - 1)
68 Reldep *rels; // table of rels: Id -> Reldep
69 int nrels; // number of unique rels
70 Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id
79 int promoteepoch; /* 0/1 */
81 Id *id2arch; /* map arch ids to scores */
82 Id lastarch; /* last valid entry in id2arch */
83 Queue vendormap; /* map vendor to vendorclasses mask */
85 /* providers data, as two-step indirect list
86 * whatprovides[Id] -> Offset into whatprovidesdata for name
87 * whatprovidesdata[Offset] -> ID_NULL-terminated list of solvables providing Id
89 Offset *whatprovides; /* Offset to providers of a specific name, Id -> Offset */
90 Id *whatprovidesdata; /* Ids of solvable providing Id */
91 Offset whatprovidesdataoff; /* next free slot within whatprovidesdata */
92 int whatprovidesdataleft; /* number of 'free slots' within whatprovidesdata */
94 Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
97 /* our dep2str string space */
98 char *dep2strbuf[DEP2STRBUF];
99 int dep2strlen[DEP2STRBUF];
104 #define TYPE_IDARRAY 2
107 #define TYPE_BITMAP 128
110 //-----------------------------------------------
113 // "foo" -> Id -> lookup in table, returns offset into whatprovidesdata where array of Ids providing 'foo' are located, 0-terminated
116 #define GET_PROVIDESP(d, v) (ISRELDEP(d) ? \
117 (v = GETRELID(pool, d), pool->whatprovides[v] ? \
118 pool->whatprovidesdata + pool->whatprovides[v] : \
119 pool_addrelproviders(pool, d) \
121 (pool->whatprovidesdata + pool->whatprovides[d]))
123 /* loop over all providers of d */
124 #define FOR_PROVIDES(v, vp, d) \
125 for (vp = GET_PROVIDESP(d, v) ; (v = *vp++) != ID_NULL; )
127 /* mark dependencies with relation by setting bit31 */
129 #define MAKERELDEP(id) ((id) | 0x80000000)
130 #define ISRELDEP(id) (((id) & 0x80000000) != 0)
131 #define GETRELID(pool, id) ((pool)->nstrings + ((id) ^ 0x80000000)) /* returns Id */
132 #define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000)) /* returns Reldep* */
141 #define REL_NAMESPACE 19
146 extern Pool *pool_create(void);
150 extern void pool_free(Pool *pool);
152 * Prepares a pool for solving
154 extern void pool_prepare(Pool *pool);
155 extern void pool_freewhatprovides(Pool *pool);
156 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
158 extern Id *pool_addrelproviders(Pool *pool, Id d);
160 static inline int pool_installable(Pool *pool, Solvable *s)
162 if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
164 if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))