From 330d17f52d3cbe50802101966368c45e1d822453 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Sun, 19 Oct 2025 20:43:09 +0200 Subject: [PATCH] build: handle --root feeds script feature Rework the package SOURCE entry handling to account for the --root feeds script feature. Move the SOURCE entry string manipulation logic outside package-defaults.mk in package.mk and limit only to non DUMP scenario to not pollute the .mk too much. Restructure the previous logic and add a new additional condition. If we detect the package comes from a feed, replace any feed path that have the _root prefix to the feed name with the non-root variant (the feeds script create a symbolic link to it) and point the package SOURCE entry to what the symbolic link points to. Example: Feed link: feeds/base_root/package -> feeds/base Package: feeds/base_root/package/system/uci -> feeds/base/system/uci Link: https://github.com/openwrt/openwrt/pull/20459 Signed-off-by: Christian Marangi --- include/package-defaults.mk | 2 +- include/package.mk | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/package-defaults.mk b/include/package-defaults.mk index 6a401dde2c9..af2db4712c9 100644 --- a/include/package-defaults.mk +++ b/include/package-defaults.mk @@ -20,7 +20,7 @@ define Package/Default PROVIDES:= EXTRA_DEPENDS:= MAINTAINER:=$(PKG_MAINTAINER) - SOURCE:=$(patsubst $(TOPDIR)/%,%,$(patsubst $(TOPDIR)/package/%,feeds/base/%,$(CURDIR))) + SOURCE:=$(patsubst $(TOPDIR)/%,%,$(if $(__pkg_source_makefile),$(__pkg_source_makefile),$(CURDIR))) ifneq ($(PKG_VERSION),) ifneq ($(PKG_RELEASE),) VERSION:=$(PKG_VERSION)-r$(PKG_RELEASE) diff --git a/include/package.mk b/include/package.mk index 7fbecf98dc7..5392bdf4652 100644 --- a/include/package.mk +++ b/include/package.mk @@ -134,6 +134,35 @@ endef PKG_INSTALL_STAMP:=$(PKG_INFO_DIR)/$(PKG_DIR_NAME).$(if $(BUILD_VARIANT),$(BUILD_VARIANT),default).install +# Normalize package SOURCE entry to pack reproducible package +# If we are packing a package with OpenWrt buildroot: +# - Replace package/... with feeds/base/... +# If we are packing a package with SDK: +# - Replace feeds/.*_root/... with feeds/.*/... and remove +# the intermediate directory to reflect what the symbolic link +# points to. +# Example: +# Feed link: feeds/base_root/package -> feeds/base +# Package: feeds/base_root/package/system/uci -> feeds/base/system/uci +ifeq ($(DUMP),) + __pkg_base_path:=$(patsubst $(TOPDIR)/%,%,$(CURDIR)) + __pkg_provider_path:=$(word 1,$(subst /, ,$(__pkg_base_path))) + ifeq ($(__pkg_provider_path), feeds) + __pkg_feed_path:=$(word 2,$(subst /, ,$(__pkg_base_path))) + __pkg_feed_name:=$(patsubst %_root,%,$(__pkg_feed_path)) + ifneq (__pkg_feed_path, __pkg_feed_name) + __pkg_feed_realpath:=$(realpath $(TOPDIR)/feeds/$(__pkg_feed_name)) + __pkg_feed_dir:=$(patsubst $(TOPDIR)/feeds/$(__pkg_feed_path)/%,%,$(__pkg_feed_realpath)) + __pkg_path:=$(patsubst feeds/$(__pkg_feed_path)/$(__pkg_feed_dir)/%,%,$(__pkg_base_path)) + else + __pkg_path:=$(patsubst feeds/$(__pkg_feed_path)/%,%,$(__pkg_base_path)) + endif + __pkg_source_makefile:=$(TOPDIR)/feeds/$(__pkg_feed_name)/$(__pkg_path) + else ifeq ($(__pkg_provider_path), package) + __pkg_source_makefile:=$(TOPDIR)/feeds/base/$(patsubst package/%,%,$(__pkg_base_path)) + endif +endif + include $(INCLUDE_DIR)/package-defaults.mk include $(INCLUDE_DIR)/package-dumpinfo.mk include $(INCLUDE_DIR)/package-pack.mk