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_PROVIDES 5
28 #define SOLVABLE_OBSOLETES 6
29 #define SOLVABLE_CONFLICTS 7
30 #define SOLVABLE_REQUIRES 8
31 #define SOLVABLE_RECOMMENDS 9
32 #define SOLVABLE_SUGGESTS 10
33 #define SOLVABLE_SUPPLEMENTS 11
34 #define SOLVABLE_ENHANCES 12
35 #define SOLVABLE_FRESHENS 13
36 #define RPM_RPMDBID 14
37 #define SOLVABLE_PREREQMARKER 15 // normal requires before this, prereqs after this
38 #define SOLVABLE_FILEMARKER 16 // normal provides before this, generated file provides after this
39 #define NAMESPACE_INSTALLED 17
40 #define NAMESPACE_MODALIAS 18
41 #define SYSTEM_SYSTEM 19
44 #define ARCH_NOARCH 22
46 /* well known solvable */
47 #define SYSTEMSOLVABLE 1
50 /* how many strings to maintain (round robin) */
54 //-----------------------------------------------
57 int verbose; // pool is used everywhere, so put the verbose flag here
59 Offset *strings; // table of offsets into stringspace, indexed by Id: Id -> Offset
60 int nstrings; // number of unique strings in stringspace
61 char *stringspace; // space for all unique strings: stringspace + Offset = string
62 Offset sstrings; // next free pos in stringspace
64 Hashtable stringhashtbl; // hash table: (string ->) Hash -> Id
65 Hashmask stringhashmask; // modulo value for hash table (size of table - 1)
67 Reldep *rels; // table of rels: Id -> Reldep
68 int nrels; // number of unique rels
69 Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id
78 int promoteepoch; /* 0/1 */
80 Id *id2arch; /* map arch ids to scores */
81 Id lastarch; /* last valid entry in id2arch */
83 /* providers data, as two-step indirect list
84 * whatprovides[Id] -> Offset into whatprovidesdata for name
85 * whatprovidesdata[Offset] -> ID_NULL-terminated list of solvables providing Id
87 Offset *whatprovides; /* Offset to providers of a specific name, Id -> Offset */
88 Id *whatprovidesdata; /* Ids of solvable providing Id */
89 Offset whatprovidesdataoff; /* next free slot within whatprovidesdata */
90 int whatprovidesdataleft; /* number of 'free slots' within whatprovidesdata */
92 Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
95 /* our dep2str string space */
96 char *dep2strbuf[DEP2STRBUF];
97 int dep2strlen[DEP2STRBUF];
102 #define TYPE_IDARRAY 2
105 #define TYPE_BITMAP 128
108 //-----------------------------------------------
111 // "foo" -> Id -> lookup in table, returns offset into whatprovidesdata where array of Ids providing 'foo' are located, 0-terminated
114 #define GET_PROVIDESP(d, v) (ISRELDEP(d) ? \
115 (v = GETRELID(pool, d), pool->whatprovides[v] ? \
116 pool->whatprovidesdata + pool->whatprovides[v] : \
117 pool_addrelproviders(pool, d) \
119 (pool->whatprovidesdata + pool->whatprovides[d]))
121 /* loop over all providers of d */
122 #define FOR_PROVIDES(v, vp, d) \
123 for (vp = GET_PROVIDESP(d, v) ; (v = *vp++) != ID_NULL; )
125 /* mark dependencies with relation by setting bit31 */
127 #define MAKERELDEP(id) ((id) | 0x80000000)
128 #define ISRELDEP(id) (((id) & 0x80000000) != 0)
129 #define GETRELID(pool, id) ((pool)->nstrings + ((id) ^ 0x80000000)) /* returns Id */
130 #define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000)) /* returns Reldep* */
139 #define REL_NAMESPACE 19
144 extern Pool *pool_create(void);
148 extern void pool_free(Pool *pool);
150 * Prepares a pool for solving
152 extern void pool_prepare(Pool *pool);
153 extern void pool_freewhatprovides(Pool *pool);
154 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
156 extern Id *pool_addrelproviders(Pool *pool, Id d);
158 static inline int pool_installable(Pool *pool, Solvable *s)
160 if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
162 if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))