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