map_free(&providedids);
}
+static void
+select_patches(Pool *pool, Queue *job)
+{
+ Id p, pp;
+ int pruneyou = 0;
+ Map installedmap;
+ Solvable *s;
+
+ map_init(&installedmap, pool->nsolvables);
+ if (pool->installed)
+ FOR_REPO_SOLVABLES(pool->installed, p, s)
+ MAPSET(&installedmap, p);
+
+ /* install all patches */
+ for (p = 1; p < pool->nsolvables; p++)
+ {
+ const char *type;
+ int r;
+ Id p2;
+
+ s = pool->solvables + p;
+ if (strncmp(pool_id2str(pool, s->name), "patch:", 6) != 0)
+ continue;
+ FOR_PROVIDES(p2, pp, s->name)
+ {
+ Solvable *s2 = pool->solvables + p2;
+ if (s2->name != s->name)
+ continue;
+ r = pool_evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
+ if (r < 0 || (r == 0 && p > p2))
+ break;
+ }
+ if (p2)
+ continue;
+ type = solvable_lookup_str(s, SOLVABLE_PATCHCATEGORY);
+ if (type && !strcmp(type, "optional"))
+ continue;
+ r = solvable_trivial_installable_map(s, &installedmap, 0);
+ if (r == -1)
+ continue;
+ if (solvable_lookup_bool(s, UPDATE_RESTART) && r == 0)
+ {
+ if (!pruneyou++)
+ queue_empty(job);
+ }
+ else if (pruneyou)
+ continue;
+ queue_push2(job, SOLVER_SOLVABLE, p);
+ }
+ map_free(&installedmap);
+}
+
#define MODE_LIST 0
#define MODE_INSTALL 1
#define MODE_ERASE 2
}
if (mainmode == MODE_PATCH)
- {
- int pruneyou = 0;
- Map installedmap;
- Solvable *s;
-
- map_init(&installedmap, pool->nsolvables);
- if (pool->installed)
- FOR_REPO_SOLVABLES(pool->installed, p, s)
- MAPSET(&installedmap, p);
-
- /* install all patches */
- for (p = 1; p < pool->nsolvables; p++)
- {
- const char *type;
- int r;
- Id p2;
-
- s = pool->solvables + p;
- if (strncmp(pool_id2str(pool, s->name), "patch:", 6) != 0)
- continue;
- FOR_PROVIDES(p2, pp, s->name)
- {
- Solvable *s2 = pool->solvables + p2;
- if (s2->name != s->name)
- continue;
- r = pool_evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
- if (r < 0 || (r == 0 && p > p2))
- break;
- }
- if (p2)
- continue;
- type = solvable_lookup_str(s, SOLVABLE_PATCHCATEGORY);
- if (type && !strcmp(type, "optional"))
- continue;
- r = solvable_trivial_installable_map(s, &installedmap, 0);
- if (r == -1)
- continue;
- if (solvable_lookup_bool(s, UPDATE_RESTART) && r == 0)
- {
- if (!pruneyou++)
- queue_empty(&job);
- }
- else if (pruneyou)
- continue;
- queue_push2(&job, SOLVER_SOLVABLE, p);
- }
- map_free(&installedmap);
- }
+ select_patches(pool, &job);
// add mode
for (i = 0; i < job.count; i += 2)