You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/09 13:06:09 UTC

[mynewt-newt] branch master updated: Fix restrictions evaluation

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 096a094  Fix restrictions evaluation
096a094 is described below

commit 096a0946ca5d17d9388c119c41c85a80d9bbf29c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Mar 7 18:10:01 2022 +0100

    Fix restrictions evaluation
    
    The resolving process seems to not update restrictions properly in some
    cases. Here's how it fails to update them:
    
    1. reloadCfg loads settings and restrictions (and other data too, but
       that's not relevant here) for all packages resolved in previous pass
    2. configuration change is detected
    3. dependencies are resolved
    
    At this point package X is added due to pkg.deps constraints based on
    syscfg Y.
    
    4. reloadCfg loads settings and restrictions again
    5. configuration change is detected
    6. dependencies are resolved one more time
    
    At this point, syscfg Y changed and package X is removed as previous
    pkg.deps constraints do not apply anymore. Removing package X means
    r.cfg.Settings is updated - this is crucial here.
    
    7. reloadCfg load settings and restrictions one more time
    
    And here's the problem: it does not detect that settings have changed
    since those from removed package were already removed in previous pass.
    Consequently it does not update r.cfg so restrictions state is kept
    from previous pass, i.e. before package X was removed.
    
    This can be fixed by always updating r.cfg to latest configuration as
    load by reloadCfg.
---
 newt/resolve/resolve.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index 6e04cad..684b3c1 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -619,6 +619,8 @@ func (r *Resolver) reloadCfg() (bool, error) {
 		}
 	}
 
+	r.cfg = cfg
+
 	return false, nil
 }