- mountpoint = mptree[pos].mountpoint;
- for (i = mptree[pos].child; i; i = mptree[i].sibling)
- propagate_mountpoints(mptree, i, mountpoint);
-}
-
-#define MPTREE_BLOCK 15
-
-void
-pool_calc_duchanges(Pool *pool, Map *installedmap, DUChanges *mps, int nmps)
-{
- char *p;
- const char *path, *compstr;
- struct mptree *mptree;
- int i, nmptree;
- int pos, compl;
- int mp;
- struct ducbdata cbd;
- Solvable *s;
- Id sp;
- Map ignoredu;
- Repo *oldinstalled = pool->installed;
-
- memset(&ignoredu, 0, sizeof(ignoredu));
- cbd.mps = mps;
- cbd.addsub = 0;
- cbd.dirmap = 0;
- cbd.nmap = 0;
- cbd.olddata = 0;
-
- mptree = sat_extend_resize(0, 1, sizeof(struct mptree), MPTREE_BLOCK);
-
- /* our root node */
- mptree[0].sibling = 0;
- mptree[0].child = 0;
- mptree[0].comp = 0;
- mptree[0].compl = 0;
- mptree[0].mountpoint = -1;
- nmptree = 1;
-
- /* create component tree */
- for (mp = 0; mp < nmps; mp++)
- {
- mps[mp].kbytes = 0;
- mps[mp].files = 0;
- pos = 0;
- path = mps[mp].path;
- while(*path == '/')
- path++;
- while (*path)
- {
- if ((p = strchr(path, '/')) == 0)
- {
- compstr = path;
- compl = strlen(compstr);
- path += compl;
- }
- else
- {
- compstr = path;
- compl = p - path;
- path = p + 1;
- while(*path == '/')
- path++;
- }
- for (i = mptree[pos].child; i; i = mptree[i].sibling)
- if (mptree[i].compl == compl && !strncmp(mptree[i].comp, compstr, compl))
- break;
- if (!i)
- {
- /* create new node */
- mptree = sat_extend(mptree, nmptree, 1, sizeof(struct mptree), MPTREE_BLOCK);
- i = nmptree++;
- mptree[i].sibling = mptree[pos].child;
- mptree[i].child = 0;
- mptree[i].comp = compstr;
- mptree[i].compl = compl;
- mptree[i].mountpoint = -1;
- mptree[pos].child = i;
- }
- pos = i;
- }
- mptree[pos].mountpoint = mp;
- }
-
- propagate_mountpoints(mptree, 0, mptree[0].mountpoint);
-
-#if 0
- for (i = 0; i < nmptree; i++)
- {
- printf("#%d sibling: %d\n", i, mptree[i].sibling);
- printf("#%d child: %d\n", i, mptree[i].child);
- printf("#%d comp: %s\n", i, mptree[i].comp);
- printf("#%d compl: %d\n", i, mptree[i].compl);
- printf("#%d mountpont: %d\n", i, mptree[i].mountpoint);
- }
-#endif
-
- cbd.mptree = mptree;
- cbd.addsub = 1;
- for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
- {
- if (!s->repo || (oldinstalled && s->repo == oldinstalled))
- continue;
- if (!MAPTST(installedmap, sp))
- continue;
- cbd.hasdu = 0;
- repo_search(s->repo, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
- if (!cbd.hasdu && oldinstalled)
- {
- Id op, opp;
- /* no du data available, ignore data of all installed solvables we obsolete */
- if (!ignoredu.map)
- map_init(&ignoredu, oldinstalled->end - oldinstalled->start);
- if (s->obsoletes)
- {
- Id obs, *obsp = s->repo->idarraydata + s->obsoletes;
- while ((obs = *obsp++) != 0)
- FOR_PROVIDES(op, opp, obs)
- if (op >= oldinstalled->start && op < oldinstalled->end)
- MAPSET(&ignoredu, op - oldinstalled->start);
- }
- FOR_PROVIDES(op, opp, s->name)
- if (pool->solvables[op].name == s->name)
- if (op >= oldinstalled->start && op < oldinstalled->end)
- MAPSET(&ignoredu, op - oldinstalled->start);
- }
- }
- cbd.addsub = -1;
- if (oldinstalled)
- {
- /* assumes we allways have du data for installed solvables */
- FOR_REPO_SOLVABLES(oldinstalled, sp, s)
- {
- if (MAPTST(installedmap, sp))
- continue;
- if (ignoredu.map && MAPTST(&ignoredu, sp - oldinstalled->start))
- continue;
- repo_search(oldinstalled, sp, SOLVABLE_DISKUSAGE, 0, 0, solver_fill_DU_cb, &cbd);
- }
- }
- if (ignoredu.map)
- map_free(&ignoredu);
- sat_free(cbd.dirmap);
- sat_free(mptree);
-}
-
-int
-pool_calc_installsizechange(Pool *pool, Map *installedmap)
-{
- Id sp;
- Solvable *s;
- int change = 0;
- Repo *oldinstalled = pool->installed;
-
- for (sp = 1, s = pool->solvables + sp; sp < pool->nsolvables; sp++, s++)
- {
- if (!s->repo || (oldinstalled && s->repo == oldinstalled))
- continue;
- if (!MAPTST(installedmap, sp))
- continue;
- change += solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
- }
- if (oldinstalled)
- {
- FOR_REPO_SOLVABLES(oldinstalled, sp, s)
- {
- if (MAPTST(installedmap, sp))
- continue;
- change -= solvable_lookup_num(s, SOLVABLE_INSTALLSIZE, 0);
- }
- }
- return change;
-}
-
-/* map:
- * 1: installed
- * 2: conflicts with installed
- * 8: interesting (only true if installed)
- * 16: undecided
- */
-
-static inline Id dep2name(Pool *pool, Id dep)
-{
- while (ISRELDEP(dep))
- {
- Reldep *rd = rd = GETRELDEP(pool, dep);
- dep = rd->name;
- }
- return dep;
-}
-
-static int providedbyinstalled_multiversion(Pool *pool, unsigned char *map, Id n, Id con)
-{
- Id p, pp;
- Solvable *sn = pool->solvables + n;
-
- FOR_PROVIDES(p, pp, sn->name)
- {
- Solvable *s = pool->solvables + p;
- if (s->name != sn->name || s->arch != sn->arch)
- continue;
- if ((map[p] & 9) != 9)
- continue;
- if (pool_match_nevr(pool, pool->solvables + p, con))
- continue;
- return 1; /* found installed package that doesn't conflict */
- }
- return 0;
-}
-
-static inline int providedbyinstalled(Pool *pool, unsigned char *map, Id dep, int ispatch, Map *noobsoletesmap)
-{
- Id p, pp;
- int r = 0;
- FOR_PROVIDES(p, pp, dep)
- {
- if (p == SYSTEMSOLVABLE)
- return 1; /* always boring, as never constraining */
- if (ispatch && !pool_match_nevr(pool, pool->solvables + p, dep))
- continue;
- if (ispatch && noobsoletesmap && noobsoletesmap->size && MAPTST(noobsoletesmap, p) && ISRELDEP(dep))
- if (providedbyinstalled_multiversion(pool, map, p, dep))
- continue;
- if ((map[p] & 9) == 9)
- return 9;
- r |= map[p] & 17;
- }
- return r;
-}
-
-/*
- * pool_trivial_installable - calculate if a set of solvables is
- * trivial installable without any other installs/deinstalls of
- * packages not belonging to the set.
- *
- * the state is returned in the result queue:
- * 1: solvable is installable without any other package changes
- * 0: solvable is not installable
- * -1: solvable is installable, but doesn't constrain any installed packages
- */
-
-void
-pool_trivial_installable_noobsoletesmap(Pool *pool, Map *installedmap, Queue *pkgs, Queue *res, Map *noobsoletesmap)
-{
- int i, r, m, did;
- Id p, *dp, con, *conp, req, *reqp;
- unsigned char *map;
- Solvable *s;
-
- map = sat_calloc(pool->nsolvables, 1);
- for (p = 1; p < pool->nsolvables; p++)