00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef SATSOLVER_POOL_H
00014 #define SATSOLVER_POOL_H
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020 #include <stdio.h>
00021
00022 #include "satversion.h"
00023 #include "pooltypes.h"
00024 #include "poolid.h"
00025 #include "solvable.h"
00026 #include "bitmap.h"
00027 #include "queue.h"
00028 #include "strpool.h"
00029
00030
00031 #include "knownid.h"
00032
00033
00034 #define SYSTEMSOLVABLE 1
00035
00036
00037
00038 #define POOL_TMPSPACEBUF 16
00039
00040
00041
00042 struct _Repo;
00043 struct _Repodata;
00044 struct _Repokey;
00045 struct _KeyValue;
00046
00047 typedef struct _Repopos {
00048 struct _Repo *repo;
00049 Id solvid;
00050 Id repodataid;
00051 Id schema;
00052 Id dp;
00053 } Repopos;
00054
00055 struct _Pool {
00056 void *appdata;
00057
00058 struct _Stringpool ss;
00059
00060 Reldep *rels;
00061 int nrels;
00062 Hashtable relhashtbl;
00063 Hashmask relhashmask;
00064
00065 struct _Repo **repos;
00066 int nrepos;
00067
00068 struct _Repo *installed;
00069
00070 Solvable *solvables;
00071 int nsolvables;
00072
00073 const char **languages;
00074 int nlanguages;
00075 Id *languagecache;
00076 int languagecacheother;
00077
00078
00079 int promoteepoch;
00080 int obsoleteusesprovides;
00081 int implicitobsoleteusesprovides;
00082 int obsoleteusescolors;
00083 int novirtualconflicts;
00084 int allowselfconflicts;
00085 #ifdef MULTI_SEMANTICS
00086 int disttype;
00087 #endif
00088
00089 Id *id2arch;
00090 unsigned char *id2color;
00091 Id lastarch;
00092
00093 Queue vendormap;
00094
00095
00096
00097
00098
00099 Offset *whatprovides;
00100 Offset *whatprovides_rel;
00101
00102 Id *whatprovidesdata;
00103 Offset whatprovidesdataoff;
00104 int whatprovidesdataleft;
00105
00106
00107
00108 Map *considered;
00109
00110 Id (*nscallback)(struct _Pool *, void *data, Id name, Id evr);
00111 void *nscallbackdata;
00112
00113
00114 char *tmpspacebuf[POOL_TMPSPACEBUF];
00115 int tmpspacelen[POOL_TMPSPACEBUF];
00116 int tmpspacen;
00117
00118
00119 int debugmask;
00120 void (*debugcallback)(struct _Pool *, void *data, int type, const char *str);
00121 void *debugcallbackdata;
00122
00123
00124 int (*loadcallback)(struct _Pool *, struct _Repodata *, void *);
00125 void *loadcallbackdata;
00126
00127
00128 Repopos pos;
00129 };
00130
00131 #ifdef MULTI_SEMANTICS
00132 # define DISTTYPE_RPM 0
00133 # define DISTTYPE_DEB 1
00134 #endif
00135
00136 #define SAT_FATAL (1<<0)
00137 #define SAT_ERROR (1<<1)
00138 #define SAT_WARN (1<<2)
00139 #define SAT_DEBUG_STATS (1<<3)
00140 #define SAT_DEBUG_RULE_CREATION (1<<4)
00141 #define SAT_DEBUG_PROPAGATE (1<<5)
00142 #define SAT_DEBUG_ANALYZE (1<<6)
00143 #define SAT_DEBUG_UNSOLVABLE (1<<7)
00144 #define SAT_DEBUG_SOLUTIONS (1<<8)
00145 #define SAT_DEBUG_POLICY (1<<9)
00146 #define SAT_DEBUG_RESULT (1<<10)
00147 #define SAT_DEBUG_JOB (1<<11)
00148 #define SAT_DEBUG_SCHUBI (1<<12)
00149 #define SAT_DEBUG_SOLVER (1<<13)
00150 #define SAT_DEBUG_TRANSACTION (1<<14)
00151
00152 #define SAT_DEBUG_TO_STDERR (1<<30)
00153
00154
00155
00156
00157
00158
00159 #define MAKERELDEP(id) ((id) | 0x80000000)
00160 #define ISRELDEP(id) (((id) & 0x80000000) != 0)
00161 #define GETRELID(id) ((id) ^ 0x80000000)
00162 #define GETRELDEP(pool, id) ((pool)->rels + ((id) ^ 0x80000000))
00163
00164 #define REL_GT 1
00165 #define REL_EQ 2
00166 #define REL_LT 4
00167
00168 #define REL_AND 16
00169 #define REL_OR 17
00170 #define REL_WITH 18
00171 #define REL_NAMESPACE 19
00172 #define REL_ARCH 20
00173 #define REL_FILECONFLICT 21
00174
00175 #if !defined(__GNUC__) && !defined(__attribute__)
00176 # define __attribute__(x)
00177 #endif
00178
00182 extern Pool *pool_create(void);
00186 extern void pool_free(Pool *pool);
00187
00188 extern void pool_setdebuglevel(Pool *pool, int level);
00189 #ifdef MULTI_SEMANTICS
00190 extern void pool_setdisttype(Pool *pool, int disttype);
00191 #endif
00192
00193 extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4)));
00194
00195 extern char *pool_alloctmpspace(Pool *pool, int len);
00196 extern char *pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3);
00197
00198 extern void pool_set_installed(Pool *pool, struct _Repo *repo);
00199
00203 extern Id pool_add_solvable(Pool *pool);
00204 extern Id pool_add_solvable_block(Pool *pool, int count);
00205
00206 extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
00207 static inline Solvable *pool_id2solvable(const Pool *pool, Id p)
00208 {
00209 return pool->solvables + p;
00210 }
00211
00212 extern const char *solvable2str(Pool *pool, Solvable *s);
00213 static inline const char *solvid2str(Pool *pool, Id p)
00214 {
00215 return solvable2str(pool, pool->solvables + p);
00216 }
00217
00218 void pool_set_languages(Pool *pool, const char **languages, int nlanguages);
00219 Id pool_id2langid(Pool *pool, Id id, const char *lang, int create);
00220
00221 Id solvable_lookup_id(Solvable *s, Id keyname);
00222 unsigned int solvable_lookup_num(Solvable *s, Id keyname, unsigned int notfound);
00223 const char *solvable_lookup_str(Solvable *s, Id keyname);
00224 const char *solvable_lookup_str_poollang(Solvable *s, Id keyname);
00225 const char *solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang, int usebase);
00226 int solvable_lookup_bool(Solvable *s, Id keyname);
00227 int solvable_lookup_void(Solvable *s, Id keyname);
00228 char * solvable_get_location(Solvable *s, unsigned int *medianrp);
00229 const unsigned char *solvable_lookup_bin_checksum(Solvable *s, Id keyname, Id *typep);
00230 const char *solvable_lookup_checksum(Solvable *s, Id keyname, Id *typep);
00231 int solvable_lookup_idarray(Solvable *s, Id keyname, Queue *q);
00232 int solvable_identical(Solvable *s1, Solvable *s2);
00233 Id solvable_selfprovidedep(Solvable *s);
00234
00235 int solvable_trivial_installable_map(Solvable *s, Map *installedmap, Map *conflictsmap);
00236 int solvable_trivial_installable_repo(Solvable *s, struct _Repo *installed);
00237 int solvable_trivial_installable_queue(Solvable *s, Queue *installed);
00238
00239 void pool_create_state_maps(Pool *pool, Queue *installed, Map *installedmap, Map *conflictsmap);
00240
00241 int pool_match_nevr_rel(Pool *pool, Solvable *s, Id d);
00242 int pool_match_dep(Pool *pool, Id d1, Id d2);
00243
00244 static inline int pool_match_nevr(Pool *pool, Solvable *s, Id d)
00245 {
00246 if (!ISRELDEP(d))
00247 return d == s->name;
00248 else
00249 return pool_match_nevr_rel(pool, s, d);
00250 }
00251
00252
00256 extern void pool_createwhatprovides(Pool *pool);
00257 extern void pool_addfileprovides(Pool *pool);
00258 extern void pool_addfileprovides_ids(Pool *pool, struct _Repo *installed, Id **idp);
00259 extern void pool_freewhatprovides(Pool *pool);
00260 extern Id pool_queuetowhatprovides(Pool *pool, Queue *q);
00261
00262 extern Id pool_addrelproviders(Pool *pool, Id d);
00263
00264 static inline Id pool_whatprovides(Pool *pool, Id d)
00265 {
00266 Id v;
00267 if (!ISRELDEP(d))
00268 return pool->whatprovides[d];
00269 v = GETRELID(d);
00270 if (pool->whatprovides_rel[v])
00271 return pool->whatprovides_rel[v];
00272 return pool_addrelproviders(pool, d);
00273 }
00274
00275 static inline Id *pool_whatprovides_ptr(Pool *pool, Id d)
00276 {
00277 Id off = pool_whatprovides(pool, d);
00278 return pool->whatprovidesdata + off;
00279 }
00280
00281 static inline void pool_setdebugcallback(Pool *pool, void (*debugcallback)(struct _Pool *, void *data, int type, const char *str), void *debugcallbackdata)
00282 {
00283 pool->debugcallback = debugcallback;
00284 pool->debugcallbackdata = debugcallbackdata;
00285 }
00286
00287 static inline void pool_setdebugmask(Pool *pool, int mask)
00288 {
00289 pool->debugmask = mask;
00290 }
00291
00292 static inline void pool_setloadcallback(Pool *pool, int (*cb)(struct _Pool *, struct _Repodata *, void *), void *loadcbdata)
00293 {
00294 pool->loadcallback = cb;
00295 pool->loadcallbackdata = loadcbdata;
00296 }
00297
00298
00299
00300
00301
00302
00303 void 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);
00304
00305 void pool_clear_pos(Pool *pool);
00306
00307
00308 typedef struct _DUChanges {
00309 const char *path;
00310 int kbytes;
00311 int files;
00312 } DUChanges;
00313
00314 void pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps);
00315 int pool_calc_installsizechange(Pool *pool, Map *installedmap);
00316 void pool_trivial_installable(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res);
00317 void pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap);
00318
00319 const char *pool_lookup_str(Pool *pool, Id entry, Id keyname);
00320 Id pool_lookup_id(Pool *pool, Id entry, Id keyname);
00321 unsigned int pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned int notfound);
00322 int pool_lookup_void(Pool *pool, Id entry, Id keyname);
00323 const unsigned char *pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep);
00324 const char *pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep);
00325
00326 void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts);
00327
00328
00329
00330
00331 #define FOR_PROVIDES(v, vp, d) \
00332 for (vp = pool_whatprovides(pool, d) ; (v = pool->whatprovidesdata[vp++]) != 0; )
00333
00334
00335
00336 #define FOR_REPOS(idx, r) \
00337 for (idx = 0; idx < pool->nrepos; idx++) \
00338 if ((r = pool->repos[idx]) != 0)
00339
00340
00341 #define POOL_DEBUG(type, ...) do {if ((pool->debugmask & (type)) != 0) pool_debug(pool, (type), __VA_ARGS__);} while (0)
00342 #define IF_POOLDEBUG(type) if ((pool->debugmask & (type)) != 0)
00343
00344 #ifdef __cplusplus
00345 }
00346 #endif
00347
00348
00349 #endif