@@ -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
22722356static void
22732357jobtodisablelist (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-
41894254void
41904255solver_breakorphans (Solver * solv )
41914256{
0 commit comments