@@ -3203,6 +3203,48 @@ queue_removeelement(Queue *q, Id el)
32033203 }
32043204}
32053205
3206+ static Id
3207+ choicerule_find_installed (Pool * pool , Id p )
3208+ {
3209+ Solvable * s = pool -> solvables + p ;
3210+ Id p2 , pp2 ;
3211+
3212+ if (!s -> repo )
3213+ return 0 ;
3214+ if (s -> repo == pool -> installed )
3215+ return p ;
3216+ FOR_PROVIDES (p2 , pp2 , s -> name )
3217+ {
3218+ Solvable * s2 = pool -> solvables + p2 ;
3219+ if (s2 -> repo != pool -> installed )
3220+ continue ;
3221+ if (!pool -> implicitobsoleteusesprovides && s -> name != s2 -> name )
3222+ continue ;
3223+ if (pool -> implicitobsoleteusescolors && !pool_colormatch (pool , s , s2 ))
3224+ continue ;
3225+ return p2 ;
3226+ }
3227+ if (s -> obsoletes )
3228+ {
3229+ Id obs , * obsp = s -> repo -> idarraydata + s -> obsoletes ;
3230+ while ((obs = * obsp ++ ) != 0 )
3231+ {
3232+ FOR_PROVIDES (p2 , pp2 , obs )
3233+ {
3234+ Solvable * s2 = pool -> solvables + p2 ;
3235+ if (s2 -> repo != pool -> installed )
3236+ continue ;
3237+ if (!pool -> obsoleteusesprovides && !pool_match_nevr (pool , pool -> solvables + p2 , obs ))
3238+ continue ;
3239+ if (pool -> obsoleteusescolors && !pool_colormatch (pool , s , s2 ))
3240+ continue ;
3241+ return p2 ;
3242+ }
3243+ }
3244+ }
3245+ return 0 ;
3246+ }
3247+
32063248void
32073249solver_addchoicerules (Solver * solv )
32083250{
@@ -3211,9 +3253,8 @@ solver_addchoicerules(Solver *solv)
32113253 Rule * r ;
32123254 Queue q , qi , qcheck , infoq ;
32133255 int i , j , rid , havechoice , negcnt ;
3214- Id p , d , pp ;
3215- Id p2 , pp2 ;
3216- Solvable * s , * s2 ;
3256+ Id p , d , pp , p2 ;
3257+ Solvable * s ;
32173258 Id lastaddedp , lastaddedd ;
32183259 int lastaddedcnt ;
32193260 unsigned int now ;
@@ -3263,74 +3304,18 @@ solver_addchoicerules(Solver *solv)
32633304 queue_push (& q , p );
32643305 continue ;
32653306 }
3266- /* check if this package is "blocked" by a installed package */
3267- s2 = 0 ;
3268- FOR_PROVIDES (p2 , pp2 , s -> name )
3269- {
3270- s2 = pool -> solvables + p2 ;
3271- if (s2 -> repo != pool -> installed )
3272- continue ;
3273- if (!pool -> implicitobsoleteusesprovides && s -> name != s2 -> name )
3274- continue ;
3275- if (pool -> implicitobsoleteusescolors && !pool_colormatch (pool , s , s2 ))
3276- continue ;
3277- break ;
3278- }
3307+ /* find an installed package p2 that we can update/downgrade to p */
3308+ p2 = choicerule_find_installed (pool , p );
32793309 if (p2 )
32803310 {
3281- /* found installed package p2 that we can update to p */
32823311 if (MAPTST (& mneg , p ))
32833312 continue ;
3284- if (policy_is_illegal (solv , s2 , s , 0 ))
3285- continue ;
3286- #if 0
3287- if (solver_choicerulecheck (solv , p2 , r , & m ))
3313+ if (policy_is_illegal (solv , pool -> solvables + p2 , s , 0 ))
32883314 continue ;
3289- queue_push (& qi , p2 );
3290- #else
32913315 queue_push2 (& qi , p2 , p );
3292- #endif
32933316 queue_push (& q , p );
32943317 continue ;
32953318 }
3296- if (s -> obsoletes )
3297- {
3298- Id obs , * obsp = s -> repo -> idarraydata + s -> obsoletes ;
3299- s2 = 0 ;
3300- while ((obs = * obsp ++ ) != 0 )
3301- {
3302- FOR_PROVIDES (p2 , pp2 , obs )
3303- {
3304- s2 = pool -> solvables + p2 ;
3305- if (s2 -> repo != pool -> installed )
3306- continue ;
3307- if (!pool -> obsoleteusesprovides && !pool_match_nevr (pool , pool -> solvables + p2 , obs ))
3308- continue ;
3309- if (pool -> obsoleteusescolors && !pool_colormatch (pool , s , s2 ))
3310- continue ;
3311- break ;
3312- }
3313- if (p2 )
3314- break ;
3315- }
3316- if (obs )
3317- {
3318- /* found installed package p2 that we can update to p */
3319- if (MAPTST (& mneg , p ))
3320- continue ;
3321- if (policy_is_illegal (solv , s2 , s , 0 ))
3322- continue ;
3323- #if 0
3324- if (solver_choicerulecheck (solv , p2 , r , & m ))
3325- continue ;
3326- queue_push (& qi , p2 );
3327- #else
3328- queue_push2 (& qi , p2 , p );
3329- #endif
3330- queue_push (& q , p );
3331- continue ;
3332- }
3333- }
33343319 /* package p is independent of the installed ones */
33353320 havechoice = 1 ;
33363321 }
0 commit comments