/*
* bitmap.c
- *
+ *
*/
#include <stdlib.h>
solv_chksum_len(Id type)
{
switch (type)
- {
+ {
case REPOKEY_TYPE_MD5:
- return 16;
+ return 16;
case REPOKEY_TYPE_SHA1:
- return 20;
+ return 20;
case REPOKEY_TYPE_SHA256:
- return 32;
+ return 32;
default:
return 0;
- }
+ }
}
void *
* 10 "bar"
* 11 -3 5 [parent 3, /usr, block #1]
* 12 "games"
- *
+ *
* to find all children of dirid 3 ("/usr"), follow the
* dirtraverse link to 12 -> "games". Then follow the
* dirtraverse link of this block to 5 -> "bin", "lib"
}
#endif /* HAIKU */
-
-
-/*
+
+
+/*
* the solv_vercmp variant your system uses.
*/
int
trj->nstack = stackstart; /* empty stack */
}
}
-
+
/*
* remove entries from plist that are obsoleted by other entries
* with different name.
struct trj_data trj;
int i, j;
Solvable *s;
-
+
if (plist->count <= 16)
{
memset(data_buf, 0, sizeof(data_buf));
}
/*-------------------------------------------------------------------
- *
+ *
* create reverse obsoletes map for installed solvables
*
* For each installed solvable find which packages with *different* names
/*
* find update candidates
- *
+ *
* s: installed solvable to be updated
* qs: [out] queue to hold Ids of candidates
* allow_all: 0 = dont allow downgrades, 1 = allow all candidates
* 2 = dup mode
- *
+ *
*/
void
policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int allow_all)
/*
* pool.c
- *
+ *
* The pool contains information about solvables
* stored optimized for memory consumption and fast retrieval.
*/
int i;
pool_freewhatprovides(pool);
- for (i = 1; i < pool->nrepos; i++)
+ for (i = 1; i < pool->nrepos; i++)
if (pool->repos[i])
repo_freedata(pool->repos[i]);
pool->repos = solv_free(pool->repos);
- pool->nrepos = 0;
- pool->urepos = 0;
+ pool->nrepos = 0;
+ pool->urepos = 0;
/* the first two solvables don't belong to a repo */
pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids);
}
/*
* pool_createwhatprovides()
- *
+ *
* create hashes over pool of solvables to ease provide lookups
- *
+ *
*/
void
pool_createwhatprovides(Pool *pool)
/*
* pool_queuetowhatprovides - add queue contents to whatprovidesdata
- *
+ *
* used for whatprovides, jobs, learnt rules, selections
* input: q: queue of Ids
* returns: Offset into whatprovidesdata
/*
* addstdproviders
- *
+ *
* lazy populating of the whatprovides array, non relation case
*/
static Id
/*
* addrelproviders
- *
+ *
* add packages fulfilling the relation to whatprovides array
- *
+ *
*/
Id
pool_addrelproviders(Pool *pool, Id d)
mptree[0].compl = 0;
mptree[0].mountpoint = -1;
nmptree = 1;
-
+
/* create component tree */
for (mp = 0; mp < nmps; mp++)
{
* 8: interesting (only true if installed)
* 16: undecided
*/
-
+
static inline Id dep2name(Pool *pool, Id dep)
{
while (ISRELDEP(dep))
return dep;
}
-static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
+static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
{
Id p, pp;
- Solvable *sn = pool->solvables + n;
+ Solvable *sn = pool->solvables + n;
FOR_PROVIDES(p, pp, sn->name)
- {
- Solvable *s = pool->solvables + p;
+ {
+ Solvable *s = pool->solvables + p;
if (s->name != sn->name || s->arch != sn->arch)
continue;
if ((map[p] & 9) != 9)
hashmask = pool->relhashmask;
hashtbl = pool->relhashtbl;
ran = pool->rels;
-
+
/* extend hashtable if needed */
if (pool->nrels * 2 > hashmask)
{
hashtbl[h] = i;
}
}
-
+
/* compute hash and check for match */
h = relhash(name, evr, flags) & hashmask;
hh = HASHCHAIN_START;
/* Id -> String
* for rels (returns name only) and strings
- */
+ */
const char *
pool_id2str(const Pool *pool, Id id)
{
/*-------------------------------------------------------------------
* enable weak rules
- *
+ *
* Reenable all disabled weak rules (marked in weakrulemap)
- *
+ *
*/
static void
/*-------------------------------------------------------------------
- *
+ *
* refine_suggestion
- *
+ *
* at this point, all rules that led to conflicts are disabled.
* we re-enable all rules of a problem set but rule "sug", then
* continue to disable more rules until there as again a solution.
idx = solv->solutions.count;
queue_push(&solv->solutions, -1); /* unrefined */
/* proofidx stays in position, thus we start with 1 */
- for (i = 1; i < solv->problems.count; i++)
- {
+ for (i = 1; i < solv->problems.count; i++)
+ {
Id p = solv->problems.elements[i];
- queue_push(&solv->solutions, p);
- if (p)
+ queue_push(&solv->solutions, p);
+ if (p)
continue;
/* end of problem reached */
- solv->problems.elements[j++] = idx;
+ solv->problems.elements[j++] = idx;
if (i + 1 >= solv->problems.count)
break;
/* start another problem */
idx = solv->solutions.count;
queue_push(&solv->solutions, -1); /* unrefined */
}
- solv->problems.count = j;
+ solv->problems.count = j;
return j / 2;
}
solv->cleandeps_mistakes = solv_free(solv->cleandeps_mistakes);
}
}
-
+
POOL_DEBUG(SOLV_DEBUG_STATS, "create_solutions for problem #%d took %d ms\n", probnr, solv_timems(now));
}
* pkgid (> 0) pkgid (> 0)
* -> add (SOLVER_INSTALL|SOLVER_SOLVABLE, rp) to the job
* (this will replace package p)
- *
+ *
* Thus, the solver will either ask the application to remove
* a specific job from the job queue, or ask to add an install/erase
* job to it.
/*-------------------------------------------------------------------
- *
+ *
* find problem rule
*/
*sysrp = lsysr;
}
-/*
+/*
* find problem rule
*
* search for a rule that describes the problem to the
swap_cnt = 0;
if (n < 7) {
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
- for (pl = pm;
+ for (pl = pm;
pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
pl -= es)
swap(pl, pl - es);
}
if (swap_cnt == 0) { /* Switch to insertion sort */
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
- for (pl = pm;
+ for (pl = pm;
pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
pl -= es)
swap(pl, pl - es);
repo->start = repo->end = p;
/* warning: sidedata must be extended before adapting start/end */
if (repo->rpmdbid)
- repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, 1);
+ repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, 1);
if (p < repo->start)
repo->start = p;
if (p + 1 > repo->end)
repo_add_solvable_block(Repo *repo, int count)
{
Id p;
- Solvable *s;
+ Solvable *s;
if (!count)
return 0;
p = pool_add_solvable_block(repo->pool, count);
#define REPO_ADDID_DEP_HASHTHRES 64
#define REPO_ADDID_DEP_HASHMIN 128
-/*
+/*
* Optimization for packages with an excessive amount of provides/requires:
* if the number of deps exceed a threshold, we build a hash of the already
* seen ids.
return repo->repodata + i;
}
if (!repo->nrepodata)
- {
+ {
repo->nrepodata = 2; /* start with id 1 */
repo->repodata = solv_calloc(repo->nrepodata, sizeof(*data));
- }
- else
- {
+ }
+ else
+ {
repo->nrepodata++;
repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata, sizeof(*data));
- }
- data = repo->repodata + repo->nrepodata - 1;
+ }
+ data = repo->repodata + repo->nrepodata - 1;
repodata_initdata(data, repo, (flags & REPO_LOCALPOOL) ? 1 : 0);
return data;
}
/*
* repo_solv.c
- *
+ *
* Add a repo in solv format
- *
+ *
*/
extendstart = repo->start;
extendend = repo->end;
}
-
+
memset(&data, 0, sizeof(data));
data.repo = repo;
data.fp = fp;
/*
* read strings and Ids
- *
+ *
*/
-
+
/*
* alloc buffers
*/
spool = &pool->ss;
/* alloc max needed string buffer and string pointers, will shrink again later */
#if 0
- spool->stringspace = solv_realloc(spool->stringspace, spool->sstrings + sizeid + 1);
+ spool->stringspace = solv_realloc(spool->stringspace, spool->sstrings + sizeid + 1);
spool->strings = solv_realloc2(spool->strings, spool->nstrings + numid, sizeof(Offset));
#else
spool->sstrings += sizeid + 1;
{
data.localpool = 1;
spool = &data.spool;
- spool->stringspace = solv_malloc(7 + sizeid + 1);
+ spool->stringspace = solv_malloc(7 + sizeid + 1);
spool->strings = solv_malloc2(numid < 2 ? 2 : numid, sizeof(Offset));
strcpy(spool->stringspace, "<NULL>");
spool->sstrings = 7;
/*
* read string data and append to old string space
*/
-
+
strsp = spool->stringspace + spool->sstrings; /* append new entries */
if ((solvflags & SOLV_FLAG_PREFIX_POOL) == 0)
{
stringpool_shrink(spool); /* vacuum */
}
-
+
/******* Part 2: Relation IDs ***************************************/
/*
* read RelDeps
- *
+ *
*/
-
+
if (numrel)
{
/* extend rels */
/* cannot handle mapped ids in vertical */
if (!(flags & REPO_LOCALPOOL) && keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET && (type == REPOKEY_TYPE_ID || type == REPOKEY_TYPE_IDARRAY))
data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "mapped ids are not supported for STORAGE_VERTICAL_OFFSET");
-
+
if (keys[i].type == REPOKEY_TYPE_CONSTANTID && idmap)
keys[i].size = idmap[keys[i].size];
#if 0
}
/******* Part 5: Schemata ********************************************/
-
+
id = read_id(&data, 0);
schemadata = solv_calloc(id + 1, sizeof(Id));
schemadatap = schemadata + 1;
case REPOKEY_TYPE_ID:
dp = data_read_id_max(dp, &did, idmap, numid + numrel, &data);
if (s && id == SOLVABLE_NAME)
- s->name = did;
+ s->name = did;
else if (s && id == SOLVABLE_ARCH)
- s->arch = did;
+ s->arch = did;
else if (s && id == SOLVABLE_EVR)
- s->evr = did;
+ s->evr = did;
else if (s && id == SOLVABLE_VENDOR)
- s->vendor = did;
+ s->vendor = did;
else if (keys[key].storage == KEY_STORAGE_INCORE)
incore_add_id(&data, did);
#if 0
{
Id fileoffset = 0;
unsigned int pagesize;
-
+
/* we have vertical data, make it available */
data.verticaloffset = solv_calloc(numkeys, sizeof(Id));
for (i = 1; i < numkeys; i++)
/*
The format is tailored for fast decompression (i.e. only byte based),
and skewed to ASCII content (highest bit often not set):
-
+
a 0LLLLLLL
- self-describing ASCII character hex L
b 100lllll <l+1 bytes>
read_u32(FILE *fp)
{
int c, i;
- unsigned int x = 0;
+ unsigned int x = 0;
- for (i = 0; i < 4; i++)
- {
+ for (i = 0; i < 4; i++)
+ {
c = getc(fp);
- if (c == EOF)
+ if (c == EOF)
return 0;
- x = (x << 8) | c;
- }
+ x = (x << 8) | c;
+ }
return x;
}
/*-------------------------------------------------------------------
* Check if dependency is possible
- *
+ *
* mirrors solver_dep_fulfilled but uses map m instead of the decisionmap.
* used in solver_addrpmrulesforweak and solver_createcleandepsmap.
*/
/*-------------------------------------------------------------------
- *
+ *
*/
/*
* Updates: p > 0, d > 0 (A|B1|B2|...) d: <list of updates for solvable p>
* Conflicts: p < 0, d < 0 (-A|-B) either p (conflict issuer) or d (conflict provider) (binary rule)
* also used for obsoletes
- * ?: p > 0, d < 0 (A|-B)
+ * ?: p > 0, d < 0 (A|-B)
* No-op ?: p = 0, d = 0 (null) (used as policy rule placeholder)
*
* resulting watches:
int n = 0; /* number of literals in rule - 1
0 = direct assertion (single literal)
1 = binary rule
- >1 =
+ >1 =
*/
/* it often happenes that requires lead to adding the same rpm rule
/*
* compute number of literals (n) in rule
*/
-
+
if (d < 0)
{
/* always a binary rule */
/*
* check for duplicate
*/
-
+
/* check if the last added rule (r) is exactly the same as what we're looking for. */
if (r && n == 1 && !r->d && r->p == p && r->w2 == d)
return r; /* binary rule */
/*
* r = new rule
*/
-
+
r->p = p;
if (n == 0)
{
#endif
/*-------------------------------------------------------------------
- *
+ *
* add (install) rules for solvable
- *
+ *
* s: Solvable for which to add rules
* m: m[s] = 1 for solvables which have rules, prevent rule duplication
- *
+ *
* Algorithm: 'visit all nodes of a graph'. The graph nodes are
* solvables, the edges their dependencies.
* Starting from an installed solvable, this will create all rules
* representing the graph created by the solvables dependencies.
- *
+ *
* for unfulfilled requirements, conflicts, obsoletes,....
* add a negative assertion for solvables that are not installable
- *
+ *
* It will also create rules for all solvables referenced by 's'
* i.e. descend to all providers of requirements of 's'
*
And buffer for it. */
Queue workq;
Id workqbuf[64];
-
+
int i;
/* if to add rules for broken deps ('rpm -V' functionality)
* 0 = yes, 1 = no
if (!dontfix)
{
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC
- ? pool_disabled_solvable(pool, s)
+ ? pool_disabled_solvable(pool, s)
: !pool_installable(pool, s))
{
POOL_DEBUG(SOLV_DEBUG_RULE_CREATION, "package %s [%d] is not installable\n", pool_solvable2str(pool, s), (Id)(s - pool->solvables));
* that are already broken. so if we find one provider
* that was already installed, we know that the
* dependency was not broken before so we enforce it */
-
+
/* check if any of the providers for 'req' is installed */
for (i = 0; (p = dp[i]) != 0; i++)
{
/* foreach obsoletes */
while ((obs = *obsp++) != 0)
{
- /* foreach provider of an obsoletes of 's' */
+ /* foreach provider of an obsoletes of 's' */
FOR_PROVIDES(p, pp, obs)
{
Solvable *ps = pool->solvables + p;
#endif
/*-------------------------------------------------------------------
- *
+ *
* Add rules for packages possibly selected in by weak dependencies
*
* m: already added solvables
/*-------------------------------------------------------------------
- *
+ *
* add package rules for possible updates
- *
+ *
* s: solvable
* m: map of already visited solvables
* allow_all: 0 = dont allow downgrades, 1 = allow all candidates
}
/*-------------------------------------------------------------------
- *
+ *
* add rule for update
* (A|A1|A2|A3...) An = update candidates for A
*
solver_addrule(solv, p, d); /* allow update of s */
}
-static inline void
+static inline void
disableupdaterule(Solver *solv, Id p)
{
Rule *r;
}
}
-static inline void
+static inline void
reenableupdaterule(Solver *solv, Id p)
{
Pool *pool = solv->pool;
MAPCLR(&solv->noupdate, p - solv->installed->start);
r = solv->rules + solv->updaterules + (p - solv->installed->start);
if (r->p)
- {
+ {
if (r->d < 0)
{
solver_enablerule(solv, r);
***
***/
-static inline void
+static inline void
add_cleandeps_package(Solver *solv, Id p)
{
if (!solv->cleandeps_updatepkgs)
- {
+ {
solv->cleandeps_updatepkgs = solv_calloc(1, sizeof(Queue));
queue_init(solv->cleandeps_updatepkgs);
- }
- queue_pushunique(solv->cleandeps_updatepkgs, p);
+ }
+ queue_pushunique(solv->cleandeps_updatepkgs, p);
}
static inline void
Pool *pool = solv->pool;
Rule *r;
int i;
- for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
- {
+ for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
+ {
if (r->p < 0 && r->d >= 0 && pool->solvables[-r->p].name == name)
solver_disablerule(solv, r);
- }
+ }
}
-static inline void
+static inline void
reenableduprule(Solver *solv, Id name)
{
Pool *pool = solv->pool;
Rule *r;
int i;
- for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
- {
+ for (i = solv->duprules, r = solv->rules + i; i < solv->duprules_end; i++, r++)
+ {
if (r->p < 0 && r->d < 0 && pool->solvables[-r->p].name == name)
{
solver_enablerule(solv, r);
#define DISABLE_INFARCH 2
#define DISABLE_DUP 3
-/*
+/*
* add all installed packages that package p obsoletes to Queue q.
* Package p is not installed. Also, we know that if
* solv->keepexplicitobsoletes is not set, p is not in the multiversion map.
continue;
if (!pool->implicitobsoleteusesprovides && ps->name != s->name)
continue;
- if (pool->implicitobsoleteusescolors && !pool_colormatch(pool, s, ps))
+ if (pool->implicitobsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
queue_push(q, p2);
lastp2 = p2;
return;
obsp = s->repo->idarraydata + s->obsoletes;
while ((obs = *obsp++) != 0)
- FOR_PROVIDES(p2, pp2, obs)
+ FOR_PROVIDES(p2, pp2, obs)
{
Solvable *ps = pool->solvables + p2;
if (ps->repo != installed)
continue;
if (!pool->obsoleteusesprovides && !pool_match_nevr(pool, ps, obs))
continue;
- if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
+ if (pool->obsoleteusescolors && !pool_colormatch(pool, s, ps))
continue;
if (p2 == lastp2)
continue;
{
if (j)
{
- if (rq->elements[i] == rq->elements[j - 4] &&
+ if (rq->elements[i] == rq->elements[j - 4] &&
rq->elements[i + 1] == rq->elements[j - 3] &&
rq->elements[i + 2] == rq->elements[j - 2] &&
rq->elements[i + 3] == rq->elements[j - 1])
prune_to_update_targets(Solver *solv, Id *cp, Queue *q)
{
int i, j;
- Id p, *cp2;
+ Id p, *cp2;
for (i = j = 0; i < q->count; i++)
- {
+ {
p = q->elements[i];
for (cp2 = cp; *cp2; cp2++)
if (*cp2 == p)
}
}
}
-
+
/* add all positive elements (e.g. locks) to "userinstalled" */
for (rid = solv->jobrules; rid < solv->jobrules_end; rid++)
{
}
}
}
-
+
queue_free(&iq);
/* make sure the updatepkgs and mistakes are not in the cleandeps map */
if (solv->cleandeps_updatepkgs)
dataiterator_free(&di);
if (!q.count)
return 0;
- if (q.count > 1)
+ if (q.count > 1)
queue_push2(selection, SOLVER_SOLVABLE_ONE_OF, pool_queuetowhatprovides(pool, &q));
else
queue_push2(selection, SOLVER_SOLVABLE | SOLVER_NOAUTOSET, q.elements[0]);
{
int nend = r - rname;
int rflags = 0;
- if (nend && *r == '=' && r[-1] == '!')
+ if (nend && *r == '=' && r[-1] == '!')
{
nend--;
r++;
rflags = REL_LT|REL_GT;
}
- for (; *r; r++)
+ for (; *r; r++)
{
- if (*r == '<')
+ if (*r == '<')
rflags |= REL_LT;
- else if (*r == '=')
+ else if (*r == '=')
rflags |= REL_EQ;
- else if (*r == '>')
+ else if (*r == '>')
rflags |= REL_GT;
else
break;
r++;
while (nend && (rname[nend - 1] == ' ' || rname[nend - 1] == '\t'))
nend--;
- if (!*rname || !*r)
+ if (!*rname || !*r)
return 0;
*rflagsp = rflags;
- rname[nend] = 0;
+ rname[nend] = 0;
return r;
}
{
int ret, rflags = 0;
char *r, *rname;
-
+
/* relation case, support:
* depglob rel
* depglob.arch rel
return 0;
rname = solv_strdup(name); /* so we can modify it */
r = rname + (r - name);
- *r = 0;
+ *r = 0;
/* split off potential arch part from version */
if ((r2 = strrchr(r + 1, '.')) != 0 && r2[1] && (archid = str2archid(pool, r2 + 1)) != 0)
solv_free(rname);
return 0;
}
- *r = '-';
- *r2 = 0;
+ *r = '-';
+ *r2 = 0;
r = r2;
if ((ret = selection_depglob(pool, selection, rname, flags)) == 0)
{
return 1;
n = pool_id2str(pool, name);
if (kind != 1)
- {
+ {
const char *kn = pool_id2str(pool, kind);
int knl = strlen(kn);
- return !strncmp(n, kn, knl) && n[knl] == ':' ? 1 : 0;
- }
- else
- {
- if (*n == ':')
+ return !strncmp(n, kn, knl) && n[knl] == ':' ? 1 : 0;
+ }
+ else
+ {
+ if (*n == ':')
return 1;
- while(*n >= 'a' && *n <= 'z')
+ while(*n >= 'a' && *n <= 'z')
n++;
- return *n == ':' ? 0 : 1;
- }
+ return *n == ':' ? 0 : 1;
+ }
}
void
sel1->elements[j] = sel1->elements[i] | setflags;
sel1->elements[j + 1] = sel1->elements[i + 1];
}
- else if (q1.count > 1)
+ else if (q1.count > 1)
{
sel1->elements[j] = (sel1->elements[i] & ~SOLVER_SELECTMASK) | SOLVER_SOLVABLE_ONE_OF | setflags;
sel1->elements[j + 1] = pool_queuetowhatprovides(pool, &q1);
/*
* FILE: sha2.c
* AUTHOR: Aaron D. Gifford <me@aarongifford.com>
- *
+ *
* Copyright (c) 2000-2001, Aaron D. Gifford
* All rights reserved.
*
* 3. Neither the name of the copyright holder nor the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
*
* And for little-endian machines, add:
*
- * #define BYTE_ORDER LITTLE_ENDIAN
+ * #define BYTE_ORDER LITTLE_ENDIAN
*
* Or for big-endian machines:
*
s1 = sigma1_256(s1);
/* Apply the SHA-256 compression function to update a..h */
- T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
(W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
T2 = Sigma0_256(a) + Maj(a, b, c);
h = g;
str = pool_tmpappend(pool, str, ".", pool_id2str(pool, archid));
return pool_tmpappend(pool, str, ".rpm", 0);
}
- else
+ else
return name; /* FIXME */
}
return dep;
}
-static int providedbyinstalled_multiversion(Pool *pool, Map *installed, Id n, Id con)
+static int providedbyinstalled_multiversion(Pool *pool, Map *installed, Id n, Id con)
{
Id p, pp;
- Solvable *sn = pool->solvables + n;
+ Solvable *sn = pool->solvables + n;
FOR_PROVIDES(p, pp, sn->name)
- {
- Solvable *s = pool->solvables + p;
+ {
+ Solvable *s = pool->solvables + p;
if (s->name != sn->name || s->arch != sn->arch)
continue;
if (!MAPTST(installed, p))
if (pool_match_nevr(pool, pool->solvables + p, con))
continue;
return 1; /* found installed package that doesn't conflict */
- }
+ }
return 0;
}
static int
pool_illegal_vendorchange(Pool *pool, Solvable *s1, Solvable *s2)
{
- Id v1, v2;
+ Id v1, v2;
Id vendormask1, vendormask2;
if (pool->custom_vendorcheck)
/* treat a missing vendor as empty string */
v1 = s1->vendor ? s1->vendor : ID_EMPTY;
v2 = s2->vendor ? s2->vendor : ID_EMPTY;
- if (v1 == v2)
+ if (v1 == v2)
return 0;
vendormask1 = pool_vendor2mask(pool, v1);
if (!vendormask1)
/*
* Create maps containing the state of each solvable. Input is a "installed" queue,
* it contains all solvable ids that are considered to be installed.
- *
+ *
* The created maps can be used for solvable_trivial_installable_map(),
* pool_calc_duchanges(), pool_calc_installsizechange().
*
/************************************************************************/
/*
- * enable/disable learnt rules
+ * enable/disable learnt rules
*
* we have enabled or disabled some of our rules. We now reenable all
* of our learnt rules except the ones that were learnt from rules that
/*
* make assertion rules into decisions
- *
+ *
* Go through rules and add direct assertions to the decisionqueue.
* If we find a conflict, disable rules and add them to problem queue.
*/
{
ri = solv->ruleassertions.elements[ii];
r = solv->rules + ri;
-
+
if (havedisabled && ri >= solv->learntrules)
{
/* just started with learnt rule assertions. If we have disabled
enabledisablelearntrules(solv);
havedisabled = 0;
}
-
+
if (r->d < 0 || !r->p || r->w2) /* disabled, dummy or no assertion */
continue;
v = r->p;
vv = v > 0 ? v : -v;
-
+
if (!solv->decisionmap[vv]) /* if not yet decided */
{
queue_push(&solv->decisionq, v);
continue;
if (v < 0 && solv->decisionmap[vv] < 0) /* ok to remove */
continue;
-
+
/*
* found a conflict!
- *
+ *
* The rule (r) we're currently processing says something
* different (v = r->p) than a previous decision (decisionmap[abs(v)])
* on this literal
*/
-
+
if (ri >= solv->learntrules)
{
/* conflict with a learnt rule */
solver_disablerule(solv, r);
continue;
}
-
+
/*
* find the decision which is the "opposite" of the rule
*/
break;
assert(i < solv->decisionq.count); /* assert that we found it */
oldproblemcount = solv->problems.count;
-
+
/*
* conflict with system solvable ?
*/
/*
* conflict with another job or update/feature rule
*/
-
+
/* record proof */
if (record_proof)
{
continue;
if (v < 0 && solv->decisionmap[vv] < 0)
continue;
-
+
POOL_DEBUG(SOLV_DEBUG_UNSOLVABLE, "assertion conflict, but I am weak, disabling ");
solver_printrule(solv, SOLV_DEBUG_UNSOLVABLE, r);
*
* add watches (for a new learned rule)
* sets up watches for a single rule
- *
+ *
* see also makewatches() above.
*/
#define DECISIONMAP_UNDEF(p) (decisionmap[(p) > 0 ? (p) : -(p)] == 0)
/*-------------------------------------------------------------------
- *
+ *
* propagate
*
* make decision and propagate to all rules
- *
+ *
* Evaluate each term affected by the decision (linked through watches).
* If we find unit rules we make new decisions based on them.
- *
+ *
* return : 0 = everything is OK
* rule = conflict found in this rule
*/
Id p, pkg, other_watch;
Id *dp;
Id *decisionmap = solv->decisionmap;
-
+
Id *watches = solv->watches + pool->nsolvables; /* place ptr in middle */
POOL_DEBUG(SOLV_DEBUG_PROPAGATE, "----- propagate -----\n");
}
/* 'pkg' was just decided (was set to FALSE)
- *
+ *
* now find other literal watch, check clause
* and advance on linked list
*/
other_watch = r->w1;
next_rp = &r->n2;
}
-
- /*
+
+ /*
* This term is already true (through the other literal)
* so we have nothing to do
*/
/*
* The other literal is FALSE or UNDEF
- *
+ *
*/
-
+
if (r->d)
{
/* Not a binary clause, try to move our watch.
- *
+ *
* Go over all literals and find one that is
* not other_watch
* and not FALSE
- *
+ *
* (TRUE is also ok, in that case the rule is fulfilled)
*/
if (r->p /* we have a 'p' */
else
POOL_DEBUG(SOLV_DEBUG_PROPAGATE," -> move w%d to !%s\n", (pkg == r->w1 ? 1 : 2), pool_solvid2str(pool, -p));
}
-
+
*rp = *next_rp;
next_rp = rp;
-
+
if (pkg == r->w1)
{
r->w1 = p;
/* search failed, thus all unwatched literals are FALSE */
} /* not binary */
-
+
/*
* unit clause found, set literal other_watch to TRUE
*/
if (DECISIONMAP_FALSE(other_watch)) /* check if literal is FALSE */
return r; /* eek, a conflict! */
-
+
IF_POOLDEBUG (SOLV_DEBUG_PROPAGATE)
{
POOL_DEBUG(SOLV_DEBUG_PROPAGATE, " unit ");
decisionmap[other_watch] = level; /* install! */
else
decisionmap[-other_watch] = -level; /* remove! */
-
+
queue_push(&solv->decisionq, other_watch);
queue_push(&solv->decisionq_why, r - solv->rules);
else
POOL_DEBUG(SOLV_DEBUG_PROPAGATE, " -> decided to conflict %s\n", pool_solvid2str(pool, -other_watch));
}
-
+
} /* foreach rule involving 'pkg' */
} /* while we have non-decided decisions */
-
+
POOL_DEBUG(SOLV_DEBUG_PROPAGATE, "----- propagate end-----\n");
return 0; /* all is well */
/* Analysis */
/*-------------------------------------------------------------------
- *
+ *
* analyze
* and learn
*/
/*-------------------------------------------------------------------
- *
+ *
* solver_reset
- *
+ *
* reset all solver decisions
* called after rules have been enabled/disabled
*/
/*-------------------------------------------------------------------
- *
+ *
* analyze_unsolvable_rule
*
* recursion helper used by analyze_unsolvable
/*-------------------------------------------------------------------
- *
+ *
* analyze_unsolvable
*
* We know that the problem is not solvable. Record all involved
/* Decision revert */
/*-------------------------------------------------------------------
- *
+ *
* revert
* revert decisionq to a level
*/
}
solv->recommends_index = -1;
if (solv->decisionq.count < solv->decisioncnt_update)
- solv->decisioncnt_update = 0;
+ solv->decisioncnt_update = 0;
if (solv->decisionq.count < solv->decisioncnt_keep)
- solv->decisioncnt_keep = 0;
+ solv->decisioncnt_keep = 0;
if (solv->decisionq.count < solv->decisioncnt_resolve)
- solv->decisioncnt_resolve = 0;
+ solv->decisioncnt_resolve = 0;
if (solv->decisionq.count < solv->decisioncnt_weak)
solv->decisioncnt_weak= 0;
if (solv->decisionq.count < solv->decisioncnt_orphan)
- solv->decisioncnt_orphan = 0;
+ solv->decisioncnt_orphan = 0;
}
/*-------------------------------------------------------------------
- *
+ *
* watch2onhighest - put watch2 on literal with highest level
*/
/*-------------------------------------------------------------------
- *
+ *
* setpropagatelearn
*
* add free decision (solvable to install) to decisionq
}
/*-------------------------------------------------------------------
- *
+ *
* select and install
- *
+ *
* install best package from the queue. We add an extra package, inst, if
* provided. See comment in weak install section.
*
/*-------------------------------------------------------------------
- *
+ *
* solver_create
* create solver structure
*
/*-------------------------------------------------------------------
- *
+ *
* solver_free
*/
}
/*-------------------------------------------------------------------
- *
+ *
* solver_run_sat
*
* all rules have been set up, now actually run the solver
* if we encounter a problem, we rewind to a safe level and restart
* with step 1
*/
-
+
minimizationsteps = 0;
for (;;)
{
int pass;
POOL_DEBUG(SOLV_DEBUG_SOLVER, "resolving installed packages\n");
- /* we use two passes if we need to update packages
+ /* we use two passes if we need to update packages
* to create a better user experience */
for (pass = solv->updatemap.size ? 0 : 1; pass < 2; pass++)
{
/*-------------------------------------------------------------------
- *
+ *
* remove disabled conflicts
*
* purpose: update the decisionmap after some rules were disabled.
Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
while ((obs = *obsp++) != 0)
{
- FOR_PROVIDES(pi, pip, obs)
+ FOR_PROVIDES(pi, pip, obs)
{
Solvable *si = pool->solvables + pi;
if (si->repo != installed)
j++;
}
-static void
+static void
deduceq2addedmap(Solver *solv, Map *addedmap)
{
int j;
map_free(&solv->cleandepsmap);
map_init(&solv->cleandepsmap, 0);
}
-
+
queue_empty(&solv->weakruleq);
solv->watches = solv_free(solv->watches);
queue_empty(&solv->ruletojob);
solv->recommends_index = 0;
}
solv->multiversionupdaters = solv_free(solv->multiversionupdaters);
-
+
/*
* create basic rule set of all involved packages
solver_shrinkrules(solv, initialnrules);
solv->nrules = initialnrules;
solv->rpmrules_end = 0;
-
+
if (installed)
{
/* check for update/verify jobs as they need to be known early */
* create rules for all packages involved in the job
* (to be installed or removed)
*/
-
+
oldnrules = solv->nrules;
for (i = 0; i < job->count; i += 2)
{
}
POOL_DEBUG(SOLV_DEBUG_STATS, "added %d rpm rules for packages involved in a job\n", solv->nrules - oldnrules);
-
+
/*
* add rules for suggests, enhances
*/
/*
* create feature rules
- *
+ *
* foreach installed:
* create assertion (keep installed, if no update available)
* or
* create update rule (A|update1(A)|update2(A)|...)
- *
+ *
* those are used later on to keep a version of the installed packages in
* best effort mode
*/
-
+
solv->featurerules = solv->nrules; /* mark start of feature rules */
if (installed)
{
/*
* Add update rules for installed solvables
- *
+ *
* almost identical to feature rules
* except that downgrades/archchanges/vendorchanges are not allowed
*/
-
+
solv->updaterules = solv->nrules;
if (installed)
* --------------------------------------------------------------
* prepare for solving
*/
-
+
/* free unneeded memory */
map_free(&addedmap);
map_free(&installcandidatemap);
map_grow(&solv->cleandepsmap, installed->end - installed->start);
/* no mistakes */
if (solv->cleandeps_mistakes)
- {
+ {
queue_free(solv->cleandeps_mistakes);
solv->cleandeps_mistakes = solv_free(solv->cleandeps_mistakes);
- }
+ }
/* all new rules are learnt after this point */
solv->learntrules = solv->nrules;
* solve!
* ********************************************
*/
-
+
now = solv_timems(0);
solver_run_sat(solv, 1, solv->dontinstallrecommended ? 0 : 1);
POOL_DEBUG(SOLV_DEBUG_STATS, "solver took %d ms\n", solv_timems(now));
solver_disablerule(solv, r);
goterase++;
}
-
+
if (goterase)
{
enabledisablelearntrules(solv);
/*
* find suggested packages
*/
-
+
if (suggestionsq)
{
Id sug, *sugp, p, pp;
if (redoq.count)
undo_removedisabledconflicts(solv, &redoq);
queue_free(&redoq);
-
+
/* undo job rule disabling */
for (i = 0; i < disabledq.count; i++)
solver_enablerule(solv, solv->rules + disabledq.elements[i]);
/* disk usage computations */
/*-------------------------------------------------------------------
- *
+ *
* calculate DU changes
*/
/*-------------------------------------------------------------------
- *
+ *
* calculate changes in install size
*/
}
/*-------------------------------------------------------------------
- *
+ *
* decision introspection
*/
{
int i;
Id pp, why;
-
+
if (infop)
*infop = 0;
if (!solv->decisionmap[p])
Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
while ((obs = *obsp++) != 0)
{
- FOR_PROVIDES(pi, pip, obs)
+ FOR_PROVIDES(pi, pip, obs)
{
Solvable *si = pool->solvables + pi;
if (si->repo != pool->installed)
Pool *pool = solv->pool;
Queue in, out;
Id p;
- const char *n;
- Solvable *s;
+ const char *n;
+ Solvable *s;
int i;
queue_init(&in);
for (p = 1, s = pool->solvables + p; p < solv->pool->nsolvables; p++, s++)
- {
+ {
n = pool_id2str(pool, s->name);
if (strncmp(n, "patch:", 6) != 0 && strncmp(n, "pattern:", 8) != 0)
continue;
- queue_push(&in, p);
- }
+ queue_push(&in, p);
+ }
if (!in.count)
{
queue_free(&in);
if (id || !create) /* exit here if string found */
return id;
- /* this should be a test for a flag that tells us if the
+ /* this should be a test for a flag that tells us if the
* correct blocking is used, but adding a flag would break
* the ABI. So we use the existance of the hash area as
* indication instead */
return SOLVER_TRANSACTION_INSTALL;
}
}
-
+
/* if there's a match, p will be shown when q
* is processed */
if (transaction_obs_pkg(trans, q) == p)
}
if (s2->repo != installed && !MAPTST(&trans->transactsmap, p2))
continue; /* package stays uninstalled */
-
+
if (s->repo == installed)
{
/* s gets uninstalled */
#if 0
dump_tes(&od);
#endif
-
+
now = solv_timems(0);
/* kill all cycles */
queue_init(&todo);
queue_empty(tr);
queue_init(&obsq);
-
+
lastrepo = 0;
lastmedia = 0;
temedianr = solv_calloc(numte, sizeof(Id));