]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
build: don't auto mark all provides as virtual
authorGeorge Sapkin <george@sapk.in>
Fri, 2 Jan 2026 15:10:00 +0000 (17:10 +0200)
committerRobert Marko <robimarko@gmail.com>
Mon, 12 Jan 2026 13:28:52 +0000 (14:28 +0100)
Don't mark all provides as virtual when ALTERNATIVES is set.
Automatically marking all provides as virtual prevents variants from
conflicting between each other. Alternatives have nothing to do with
packaging and packages are expected to manage their own provides.

Updated internal provides explanation.

Remove unnecessary back slashes from FormatProvides.

Fixes: 18029977 ("build: fix apk packaging and ABI-versioning")
Signed-off-by: George Sapkin <george@sapk.in>
Link: https://github.com/openwrt/openwrt/pull/21369
Signed-off-by: Robert Marko <robimarko@gmail.com>
include/package-pack.mk

index c648ead53b958d27f90185da5e9ffe281c46bdd9..84c21a95bac6252fc246aa7d4e6cd871d4a889e8 100644 (file)
@@ -118,14 +118,8 @@ endef
 #   - package implicitly provides `${package_name}=${package_version}`
 #     this implies that only one version of a package can be installed at the
 #     same time
-#   - if `alternatives` is defined
-#     - for each `provides`, provide `${provide}`
-#       this implies that multiple versions of a provide can be installed at the
-#       same time
-#   - else if `alternatives` is _not_ defined
-#     - for each `provides`, provide `${provide}=${package_version}`
-#       this implies that only one version of a provide can be installed at the
-#       same time
+#   - for each `provides`, provide `${provide}=${package_version}` this implies
+#     that only one version of a provide can be installed at the same time
 #
 # - Both with and without an ABI, if a provide starts with an @, treat it as a
 #   virtual provide, that doesn't own the name by not appending version.
@@ -141,24 +135,49 @@ endef
 # - kmods implicitly add a virtual @kmod-${package_name}-any provide in
 #   KernelPackage.
 #
+# - Aside from the two aforementioned implicit provides, packages are expected
+#   to manage their provides themselves.
+#
+# - When multiple variants inside the same package have the same provide, a
+#   default variant must be set using DEFAULT_VARIANT:=1.
+#
+# - Cross-package provides must be virtual and a default variant must be set. If
+#   different packages provide the same versioned (i.e. non-virtual) provide the
+#   package with a higher version will be preferred, which results in unintended
+#   behavior, because the order might change with package updates.
+#
+#   Example:
+#   - both uclient-fetch and wget provide wget
+#   - wget doesn't have a default variant called wget that would provide an
+#     implicit @wget-any
+#     - add wget to PROVIDES for both wget-ssl and wget-nossl variants so they
+#       can't be installed at the same time
+#     - add @wget-any to both packages so packages outside of wget can provide
+#       it
+#   - uclient-fetch has only one variant
+#     - add @wget-any to PROVIDES
+#     - mark uclient-fetch as the default variant using DEFAULT_VARIANT:=1
+#   - switch wget consumer that don't depend on a specific version like apk to
+#     depend on @wget-any
+#
+# - Alternatives don't affect the packaging.
+#
 # 1: package name
 # 2: package version
 # 3: list of provides
-# 4: list of alternatives
 define FormatProvides
-$(strip $(if $(ABIV_$(1)), \
-  $(1) $(foreach provide, \
-    $(filter-out $(1),$(3)), \
-    $(call AddProvide,$(provide),$(2),$(ABIV_$(1))) \
-  ), \
-  $(if $(4), \
-    $(filter-out $(1),$(3)), \
-    $(foreach provide, \
-      $(filter-out $(1),$(3)), \
-      $(call AddProvide,$(provide),$(2)) \
-    ) \
-  ) \
-))
+$(strip
+  $(if $(ABIV_$(1)),
+    $(1) $(foreach provide,
+      $(filter-out $(1),$(3)),
+      $(call AddProvide,$(provide),$(2),$(ABIV_$(1)))
+    ),
+    $(foreach provide,
+      $(filter-out $(1),$(3)),
+      $(call AddProvide,$(provide),$(2))
+    )
+  )
+)
 endef
 
 ifneq ($(PKG_NAME),toolchain)
@@ -328,7 +347,7 @@ endif
       Package/$(1)/PROVIDES := $$(patsubst @%,%,$(PROVIDES))
       Package/$(1)/PROVIDES := $$(filter-out $(1)$$(ABIV_$(1)),$$(Package/$(1)/PROVIDES)$$(if $$(ABIV_$(1)), $(1) $$(foreach provide,$$(Package/$(1)/PROVIDES),$$(provide)$$(ABIV_$(1)))))
     else
-      Package/$(1)/PROVIDES := $$(call FormatProvides,$(1),$(VERSION),$(PROVIDES),$(ALTERNATIVES))
+      Package/$(1)/PROVIDES := $$(call FormatProvides,$(1),$(VERSION),$(PROVIDES))
     endif
 
 $(_define) Package/$(1)/CONTROL