[openwrt/openwrt] build: handle --root feeds script feature
LEDE Commits
lede-commits at lists.infradead.org
Mon Oct 20 04:50:27 PDT 2025
ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/330d17f52d3cbe50802101966368c45e1d822453
commit 330d17f52d3cbe50802101966368c45e1d822453
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Sun Oct 19 20:43:09 2025 +0200
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 <ansuelsmth at gmail.com>
---
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 6a401dde2c..af2db4712c 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 7fbecf98dc..5392bdf465 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
More information about the lede-commits
mailing list