From: Christian Marangi Date: Fri, 24 May 2024 18:13:49 +0000 (+0200) Subject: toplevel.mk: implement logic to invalidate targetinfo with some config X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9a52ec4fa0921cacf4c909ed1f542aab8f7502e6;p=openwrt%2Fstaging%2Flinusw.git toplevel.mk: implement logic to invalidate targetinfo with some config Implement some logic to invalidate targetinfo files in tmp with the changing of some config. Some config might affect DEFAULT_PACKAGES list but DEFAULT_PACKAGES is only evaluated once. This cause the interesting scenario where someone install feeds packages, targetinfo is evaluated in tmp and then add some config like CONFIG_USE_APK. Using make defconfig will still select OPKG as default package as DEFAULT_PACKAGES in targetinfo has been already evaluated in the feeds install and is never updated. To handle this add some logic in toplevel.mk to cache the current state of these special config and wipe targetinfo when these change. This cause the targetinfo to be reevaluated and handle this REALLY corner case. Link: https://github.com/openwrt/openwrt/pull/15543 Signed-off-by: Christian Marangi --- diff --git a/include/target.mk b/include/target.mk index df34f937d3..4eccff3cd9 100644 --- a/include/target.mk +++ b/include/target.mk @@ -9,8 +9,9 @@ __target_inc=1 ifneq ($(DUMP),) # Parse generic config that might be set before a .config is generated to modify the # default package configuration - GENERIC_CONFIG := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP - $(foreach config, $(GENERIC_CONFIG), \ + # Keep DYNAMIC_DEF_PKG_CONF in sync with toplevel.mk to reflect the same configs + DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP + $(foreach config, $(DYNAMIC_DEF_PKG_CONF), \ $(eval $(config) := $(shell grep "$(config)=y" $(TOPDIR)/.config 2>/dev/null)) \ ) endif diff --git a/include/toplevel.mk b/include/toplevel.mk index 4ec99b30de..f711a30614 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -75,7 +75,22 @@ endif _ignore = $(foreach p,$(IGNORE_PACKAGES),--ignore $(p)) -prepare-tmpinfo: FORCE +# Config that will invalidate the .targetinfo as they will affect +# DEFAULT_PACKAGES. +# Keep DYNAMIC_DEF_PKG_CONF in sync with target.mk to reflect the same configs +DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP +check-dynamic-def-pkg: FORCE + @+DEF_PKG_CONFS=""; \ + if [ -f $(TOPDIR)/.config ]; then \ + for config in $(DYNAMIC_DEF_PKG_CONF); do \ + DEF_PKG_CONFS="$$DEF_PKG_CONFS "$$(grep "$$config"=y $(TOPDIR)/.config); \ + done; \ + fi; \ + [ ! -f tmp/.packagedynamicdefault ] || OLD_DEF_PKG_CONFS=$$(cat tmp/.packagedynamicdefault); \ + [ "$$DEF_PKG_CONFS" = "$$OLD_DEF_PKG_CONFS" ] || rm -rf tmp/info/.targetinfo*; \ + echo "$$DEF_PKG_CONFS" > tmp/.packagedynamicdefault; + +prepare-tmpinfo: check-dynamic-def-pkg FORCE @+$(MAKE) -r -s $(STAGING_DIR_HOST)/.prereq-build $(PREP_MK) mkdir -p tmp/info feeds [ -e $(TOPDIR)/feeds/base ] || ln -sf $(TOPDIR)/package $(TOPDIR)/feeds/base