]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
build: handle --root feeds script feature 20459/head
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 19 Oct 2025 18:43:09 +0000 (20:43 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Mon, 20 Oct 2025 11:50:15 +0000 (13:50 +0200)
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>
include/package-defaults.mk
include/package.mk

index 6a401dde2c9ea543158c3ce0ab7d3fc1b6acf898..af2db4712c96629e839dfb4dbf29ad7c453b6ae0 100644 (file)
@@ -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)
index 7fbecf98dc7c9a5b11ce1958e254578f7e4d9c73..5392bdf4652b14e7413c982814fd5568fa826f84 100644 (file)
@@ -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