Skip to content

Commit e79734a

Browse files
committed
Finish strict repo priority support
- add flag to bindings - support flag/ruletype in testcases - support strict repo prio problems in solution generation - implement automatic disabling of strict repo rules due to install jobs - add a testcase
1 parent aa7dcd9 commit e79734a

7 files changed

Lines changed: 153 additions & 51 deletions

File tree

bindings/solv.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3571,6 +3571,7 @@ returnself(matchsolvable)
35713571
static const int SOLVER_FLAG_STRONG_RECOMMENDS = SOLVER_FLAG_STRONG_RECOMMENDS;
35723572
static const int SOLVER_FLAG_INSTALL_ALSO_UPDATES = SOLVER_FLAG_INSTALL_ALSO_UPDATES;
35733573
static const int SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED = SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED;
3574+
static const int SOLVER_FLAG_STRICT_REPO_PRIORITY = SOLVER_FLAG_STRICT_REPO_PRIORITY;
35743575

35753576
static const int SOLVER_REASON_UNRELATED = SOLVER_REASON_UNRELATED;
35763577
static const int SOLVER_REASON_UNIT_RULE = SOLVER_REASON_UNIT_RULE;

ext/testcase.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static struct solverflags2str {
135135
{ SOLVER_FLAG_STRONG_RECOMMENDS, "strongrecommends", 0 },
136136
{ SOLVER_FLAG_INSTALL_ALSO_UPDATES, "installalsoupdates", 0 },
137137
{ SOLVER_FLAG_ONLY_NAMESPACE_RECOMMENDED, "onlynamespacerecommended", 0 },
138+
{ SOLVER_FLAG_STRICT_REPO_PRIORITY, "strictrepopriority", 0 },
138139
{ 0, 0, 0 }
139140
};
140141

@@ -1194,6 +1195,7 @@ static struct rclass2str {
11941195
{ SOLVER_RULE_YUMOBS, "yumobs" },
11951196
{ SOLVER_RULE_BLACK, "black" },
11961197
{ SOLVER_RULE_RECOMMENDS, "recommends" },
1198+
{ SOLVER_RULE_STRICT_REPO_PRIORITY, "strictrepoprio" },
11971199
{ 0, 0 }
11981200
};
11991201

src/problems.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,12 @@ convertsolution(Solver *solv, Id why, Queue *solutionq)
725725
assert(solv->rules[why].p < 0);
726726
queue_push(solutionq, -solv->rules[why].p);
727727
}
728+
if (why >= solv->strictrepopriorules && why < solv->strictrepopriorules_end)
729+
{
730+
queue_push(solutionq, SOLVER_SOLUTION_STRICTREPOPRIORITY);
731+
assert(solv->rules[why].p < 0);
732+
queue_push(solutionq, -solv->rules[why].p);
733+
}
728734
}
729735

730736
/*
@@ -1360,7 +1366,7 @@ solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, Id source, Id targ
13601366
case SOLVER_RULE_BLACK:
13611367
return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " can only be installed by a direct request");
13621368
case SOLVER_RULE_STRICT_REPO_PRIORITY:
1363-
return pool_tmpjoin(pool, "package '", pool_solvid2str(pool, source), "' is excluded by strict repo priority");
1369+
return pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), " is excluded by strict repo priority");
13641370
case SOLVER_RULE_PKG_CONSTRAINS:
13651371
s = pool_tmpjoin(pool, "package ", pool_solvid2str(pool, source), 0);
13661372
s = pool_tmpappend(pool, s, " has constraint ", pool_dep2str(pool, dep));
@@ -1426,6 +1432,11 @@ solver_solutionelement2str(Solver *solv, Id p, Id rp)
14261432
}
14271433
else if (p > 0 && rp == 0)
14281434
return pool_tmpjoin(pool, "allow deinstallation of ", pool_solvid2str(pool, p), 0);
1435+
else if (p == SOLVER_SOLUTION_STRICTREPOPRIORITY)
1436+
{
1437+
Solvable *s = pool->solvables + rp;
1438+
return pool_tmpjoin(pool, "install ", pool_solvable2str(pool, s), " despite the repo priority");
1439+
}
14291440
else if (p > 0 && rp > 0)
14301441
{
14311442
const char *sp = pool_solvid2str(pool, p);

src/problems.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct s_Solver;
2828
#define SOLVER_SOLUTION_BEST (-3)
2929
#define SOLVER_SOLUTION_POOLJOB (-4)
3030
#define SOLVER_SOLUTION_BLACK (-5)
31+
#define SOLVER_SOLUTION_STRICTREPOPRIORITY (-6)
3132

3233
void solver_recordproblem(struct s_Solver *solv, Id rid);
3334
void solver_fixproblem(struct s_Solver *solv, Id rid);

src/rules.c

Lines changed: 114 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,89 @@ solver_addblackrules(Solver *solv)
22552255
solv->blackrules_end = solv->nrules;
22562256
}
22572257

2258+
/***********************************************************************
2259+
***
2260+
*** Strict repo prio rule part
2261+
***/
2262+
2263+
/* add rules to exclude solvables provided by lower
2264+
* precedence repositories */
2265+
void solver_addstrictrepopriorules(struct s_Solver *solv, Map *addedmap)
2266+
{
2267+
Pool *pool = solv->pool;
2268+
Solvable *s;
2269+
Id p, p2, pp2;
2270+
Map priomap;
2271+
int max_prio;
2272+
2273+
map_init_clone(&priomap, addedmap);
2274+
solv->strictrepopriorules = solv->nrules;
2275+
2276+
FOR_POOL_SOLVABLES(p)
2277+
{
2278+
if (!MAPTST(&priomap, p))
2279+
continue;
2280+
2281+
s = pool->solvables + p;
2282+
max_prio = s->repo->priority;
2283+
FOR_PROVIDES(p2, pp2, s->name)
2284+
{
2285+
Solvable *s2 = pool->solvables + p2;
2286+
if (s->name != s2->name)
2287+
continue;
2288+
if (s2->repo->priority > max_prio)
2289+
max_prio = s2->repo->priority;
2290+
}
2291+
2292+
FOR_PROVIDES(p2, pp2, s->name)
2293+
{
2294+
Solvable *s2 = pool->solvables + p2;
2295+
if (s->name != s2->name || !MAPTST(&priomap, p2))
2296+
continue;
2297+
MAPCLR(&priomap, p2);
2298+
if (pool->installed && s2->repo == pool->installed)
2299+
continue;
2300+
if (s2->repo->priority < max_prio)
2301+
solver_addrule(solv, -p2, 0, 0);
2302+
}
2303+
}
2304+
solv->strictrepopriorules_end = solv->nrules;
2305+
map_free(&priomap);
2306+
}
2307+
2308+
static inline void
2309+
disablerepopriorule(Solver *solv, Id name)
2310+
{
2311+
Pool *pool = solv->pool;
2312+
Rule *r;
2313+
int i;
2314+
for (i = solv->strictrepopriorules, r = solv->rules + i; i < solv->strictrepopriorules_end; i++, r++)
2315+
{
2316+
if (r->p < 0 && r->d >= 0 && pool->solvables[-r->p].name == name)
2317+
solver_disablerule(solv, r);
2318+
}
2319+
}
2320+
2321+
static inline void
2322+
reenablerepopriorule(Solver *solv, Id name)
2323+
{
2324+
Pool *pool = solv->pool;
2325+
Rule *r;
2326+
int i;
2327+
for (i = solv->strictrepopriorules, r = solv->rules + i; i < solv->strictrepopriorules_end; i++, r++)
2328+
{
2329+
if (r->p < 0 && r->d < 0 && pool->solvables[-r->p].name == name)
2330+
{
2331+
solver_enablerule(solv, r);
2332+
IF_POOLDEBUG (SOLV_DEBUG_SOLUTIONS)
2333+
{
2334+
POOL_DEBUG(SOLV_DEBUG_SOLUTIONS, "@@@ re-enabling ");
2335+
solver_printruleclass(solv, SOLV_DEBUG_SOLUTIONS, r);
2336+
}
2337+
}
2338+
}
2339+
}
2340+
22582341
/***********************************************************************
22592342
***
22602343
*** Policy rule disabling/reenabling
@@ -2264,10 +2347,11 @@ solver_addblackrules(Solver *solv)
22642347
***
22652348
***/
22662349

2267-
#define DISABLE_UPDATE 1
2268-
#define DISABLE_INFARCH 2
2269-
#define DISABLE_DUP 3
2270-
#define DISABLE_BLACK 4
2350+
#define DISABLE_UPDATE 1
2351+
#define DISABLE_INFARCH 2
2352+
#define DISABLE_DUP 3
2353+
#define DISABLE_BLACK 4
2354+
#define DISABLE_REPOPRIO 5
22712355

22722356
static void
22732357
jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
@@ -2367,6 +2451,26 @@ jobtodisablelist(Solver *solv, Id how, Id what, Queue *q)
23672451
}
23682452
}
23692453
}
2454+
if ((set & SOLVER_SETREPO) != 0 && solv->strictrepopriorules != solv->strictrepopriorules_end)
2455+
{
2456+
if (select == SOLVER_SOLVABLE)
2457+
queue_push2(q, DISABLE_REPOPRIO, pool->solvables[what].name);
2458+
else
2459+
{
2460+
int qcnt = q->count;
2461+
FOR_JOB_SELECT(p, pp, select, what)
2462+
{
2463+
s = pool->solvables + p;
2464+
/* unify names */
2465+
for (i = qcnt; i < q->count; i += 2)
2466+
if (q->elements[i + 1] == s->name)
2467+
break;
2468+
if (i < q->count)
2469+
continue;
2470+
queue_push2(q, DISABLE_REPOPRIO, s->name);
2471+
}
2472+
}
2473+
}
23702474
if ((set & SOLVER_SETEVR) != 0 && solv->blackrules != solv->blackrules_end)
23712475
{
23722476
if (select == SOLVER_SOLVABLE)
@@ -2553,6 +2657,9 @@ solver_disablepolicyrules(Solver *solv)
25532657
case DISABLE_BLACK:
25542658
disableblackrule(solv, arg);
25552659
break;
2660+
case DISABLE_REPOPRIO:
2661+
disablerepopriorule(solv, arg);
2662+
break;
25562663
default:
25572664
break;
25582665
}
@@ -2659,6 +2766,9 @@ solver_reenablepolicyrules(Solver *solv, int jobidx)
26592766
case DISABLE_BLACK:
26602767
reenableblackrule(solv, arg);
26612768
break;
2769+
case DISABLE_REPOPRIO:
2770+
reenablerepopriorule(solv, arg);
2771+
break;
26622772
}
26632773
}
26642774
queue_free(&q);
@@ -4141,51 +4251,6 @@ solver_addrecommendsrules(Solver *solv)
41414251
solv->recommendsrules_end = solv->nrules;
41424252
}
41434253

4144-
/* add rules to exclude solvables provided by lower
4145-
* precedence repositories */
4146-
void solver_addstrictrepopriorules(struct s_Solver *solv, Map *addedmap)
4147-
{
4148-
Pool *pool = solv->pool;
4149-
Solvable *s;
4150-
Id p, p2, pp2;
4151-
Map priomap;
4152-
int max_prio;
4153-
4154-
map_init_clone(&priomap, addedmap);
4155-
solv->strictrepopriorules = solv->nrules;
4156-
4157-
FOR_POOL_SOLVABLES(p)
4158-
{
4159-
if (!MAPTST(&priomap, p))
4160-
continue;
4161-
4162-
s = pool->solvables + p;
4163-
max_prio = s->repo->priority;
4164-
FOR_PROVIDES(p2, pp2, s->name)
4165-
{
4166-
Solvable *s2 = pool->solvables + p2;
4167-
if (s->name != s2->name)
4168-
continue;
4169-
if (s2->repo->priority > max_prio)
4170-
max_prio = s2->repo->priority;
4171-
}
4172-
4173-
FOR_PROVIDES(p2, pp2, s->name)
4174-
{
4175-
Solvable *s2 = pool->solvables + p2;
4176-
if (s->name != s2->name || !MAPTST(&priomap, p2))
4177-
continue;
4178-
MAPCLR(&priomap, p2);
4179-
if (pool->installed && s2->repo == pool->installed)
4180-
continue;
4181-
if (s2->repo->priority < max_prio)
4182-
solver_addrule(solv, -p2, 0, 0);
4183-
}
4184-
}
4185-
solv->strictrepopriorules_end = solv->nrules;
4186-
map_free(&priomap);
4187-
}
4188-
41894254
void
41904255
solver_breakorphans(Solver *solv)
41914256
{

src/solverdebug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ solver_printruleclass(Solver *solv, int type, Rule *r)
131131
else if (p >= solv->blackrules && p < solv->blackrules_end)
132132
POOL_DEBUG(type, "BLACK ");
133133
else if (p >= solv->strictrepopriorules && p < solv->strictrepopriorules_end)
134-
POOL_DEBUG(type, "PRIOS ");
134+
POOL_DEBUG(type, "REPOPRIO ");
135135
else if (p >= solv->recommendsrules && p < solv->recommendsrules_end)
136136
POOL_DEBUG(type, "RECOMMENDS ");
137137
solver_printrule(solv, type, r);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repo system 0 empty
2+
repo available 0 testtags <inline>
3+
#>=Pkg: A 2 1 noarch
4+
repo available 1 testtags <inline>
5+
#>=Pkg: A 1 1 noarch
6+
#>=Req: B
7+
system i686 rpm system
8+
9+
solverflags strictrepopriority
10+
job install name A
11+
result transaction,problems <inline>
12+
#>problem 30c1639e info nothing provides B needed by A-1-1.noarch
13+
#>problem 30c1639e solution 23f73f5b deljob install name A
14+
#>problem 30c1639e solution 5dd1416b allow A-2-1.noarch@available
15+
16+
nextjob
17+
18+
solverflags strictrepopriority
19+
job install pkg A-2-1.noarch@available
20+
result transaction,problems <inline>
21+
#>install A-2-1.noarch@available
22+

0 commit comments

Comments
 (0)