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"
26 // see initpool_data[] in pool.c
31 #define SOLVABLE_NAME 2
32 #define SOLVABLE_ARCH 3
33 #define SOLVABLE_EVR 4
34 #define SOLVABLE_VENDOR 5
35 #define SOLVABLE_PROVIDES 6
36 #define SOLVABLE_OBSOLETES 7
37 #define SOLVABLE_CONFLICTS 8
38 #define SOLVABLE_REQUIRES 9
39 #define SOLVABLE_RECOMMENDS 10
40 #define SOLVABLE_SUGGESTS 11
41 #define SOLVABLE_SUPPLEMENTS 12
42 #define SOLVABLE_ENHANCES 13
43 #define SOLVABLE_FRESHENS 14
44 #define RPM_RPMDBID 15
45 #define SOLVABLE_PREREQMARKER 16 // normal requires before this, prereqs after this
46 #define SOLVABLE_FILEMARKER 17 // normal provides before this, generated file provides after this
47 #define NAMESPACE_INSTALLED 18
48 #define NAMESPACE_MODALIAS 19
49 #define SYSTEM_SYSTEM 20
52 #define ARCH_NOARCH 23
54 /* well known solvable */
55 #define SYSTEMSOLVABLE 1
58 /* how many strings to maintain (round robin) */
62 //-----------------------------------------------
65 int verbose; // pool is used everywhere, so put the verbose flag here
67 Offset *strings; // table of offsets into stringspace, indexed by Id: Id -> Offset
68 int nstrings; // number of unique strings in stringspace
69 char *stringspace; // space for all unique strings: stringspace + Offset = string
70 Offset sstrings; // next free pos in stringspace
72 Hashtable stringhashtbl; // hash table: (string ->) Hash -> Id
73 Hashmask stringhashmask; // modulo value for hash table (size of table - 1)
75 Reldep *rels; // table of rels: Id -> Reldep
76 int nrels; // number of unique rels
77 Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id
86 int promoteepoch; /* 0/1 */
88 Id *id2arch; /* map arch ids to scores */
89 Id lastarch; /* last valid entry in id2arch */
90 Queue vendormap; /* map vendor to vendorclasses mask */
92 /* providers data, as two-step indirect list
93 * whatprovides[Id] -> Offset into whatprovidesdata for name
94 * whatprovidesdata[Offset] -> ID_NULL-terminated list of solvables providing Id
96 Offset *whatprovides; /* Offset to providers of a specific name, Id -> Offset */
97 Id *whatprovidesdata; /* Ids of solvable providing Id */
98 Offset whatprovidesdataoff; /* next free slot within whatprovidesdata */
99 int whatprovidesdataleft; /* number of 'free slots' within whatprovidesdata */
101 Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
102 void *nscallbackdata;
104 /* our dep2str string space */
105 char *dep2strbuf[DEP2STRBUF];
106 int dep2strlen[DEP2STRBUF];
111 #define TYPE_IDARRAY 2
114 #define TYPE_BITMAP 128
117 //-----------------------------------------------
120 // "foo" -> Id -> lookup in table, returns offset into whatprovidesdata where array of Ids providing 'foo' are located, 0-terminated
123 #define GET_PROVIDESP(d, v) (ISRELDEP(d) ? \
124 (v = GETRELID(pool, d), pool->whatprovides[v] ? \
125 pool->whatprovidesdata + pool->whatprovides[v] : \
126 pool_addrelproviders(pool, d) \
128 (pool->whatprovidesdata + pool->whatprovides[d]))
130 /* loop over all providers of d */
131 #define FOR_PROVIDES(v, vp, d) \
132 for (vp = GET_PROVIDESP(d, v) ; (v = *vp++) != ID_NULL; )
134 /* mark dependencies with relation by setting bit31 */
136 #define MAKERELDEP(id) ((id) | 0x80000000)
137 #define ISRELDEP(id) (((id) & 0x80000000) != 0)
138 #define GETRELID(pool, id) ((pool)->nstrings + ((id) ^ 0x80000000)) /* returns Id */
139 #define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000)) /* returns Reldep* */
148 #define REL_NAMESPACE 19
153 extern Pool *pool_create(void);
157 extern void pool_free(Pool *pool);
159 * Prepares a pool for solving
161 extern void pool_prepare(Pool *pool);
162 extern void pool_freewhatprovides(Pool *pool);
163 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
165 extern Id *pool_addrelproviders(Pool *pool, Id d);
167 static inline int pool_installable(Pool *pool, Solvable *s)
169 if (!s->arch || s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
171 if (pool->id2arch && (s->arch > pool->lastarch || !pool->id2arch[s->arch]))