cache.mk: Avoid recaching stale variable values
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m5s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m0s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m41s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m33s
CI / Packaging test (push) Successful in 0s

If $(CACHE_PROJECT_MK) AKA .cache-project.mk already exists but needs
to be remade because of dependencies, it is included, its content
read, then the content cached again to the same file. That way stale
variables can leak into the refreshed cache.

This commit fixes the situation by removing it, then invoking make
again to remake it, thereby clearing the variable database and
forcing make to fill the variables afresh.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-08-07 19:51:34 +02:00
commit 2b04e387df
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -32,6 +32,10 @@ clean.cache:
cache: $(CACHE_PROJECT_MK) cache: $(CACHE_PROJECT_MK)
$(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk $(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk
ifneq ($(wildcard $(CACHE_PROJECT_MK)),)
rm -f $@
make $@
else
@echo 'ifneq ($$(JW_PKG_NO_CACHE),true)' | tee $@.tmp @echo 'ifneq ($$(JW_PKG_NO_CACHE),true)' | tee $@.tmp
@echo $(foreach v,$(CACHED_VARS),$v = $(value $(v)) EOL) | \ @echo $(foreach v,$(CACHED_VARS),$v = $(value $(v)) EOL) | \
$(SED) 's/\s\+EOL/\n/g;' | \ $(SED) 's/\s\+EOL/\n/g;' | \
@ -42,3 +46,4 @@ $(CACHE_PROJECT_MK): $(CACHED_FILES) $(JWBDIR)/make/cache.mk
tee -a $@.tmp tee -a $@.tmp
@echo 'endif # ifneq ($$(JW_PKG_NO_CACHE),true)' | tee -a $@.tmp @echo 'endif # ifneq ($$(JW_PKG_NO_CACHE),true)' | tee -a $@.tmp
mv $@.tmp $@ mv $@.tmp $@
endif