summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Marangi2025-10-19 18:43:09 +0000
committerChristian Marangi2025-10-20 11:50:15 +0000
commit330d17f52d3cbe50802101966368c45e1d822453 (patch)
treea9e8e4db8418d4299ebc30aedc632f4d36318923
parentb91b99ec18504e766d4a341f572435f7621dbb40 (diff)
downloadopenwrt-330d17f52d3cbe50802101966368c45e1d822453.tar.gz
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@gmail.com>
-rw-r--r--include/package-defaults.mk2
-rw-r--r--include/package.mk29
2 files changed, 30 insertions, 1 deletions
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