build: fix provides logic when ABI version is set

Same as for the base package name, when a package has an ABI version,
provide both unversioned provider in addition to one with ABI version
and version.

So for each provide instead of providing only:

$provide$ABI_version=$package_version

now provide:

$provide $provide$ABI_version=$package_version

When a provide ends in a number, the ABI version will be prefixed with
a - sign, e.g.: provide1-0

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
(cherry picked from commit 952c918028)
Link: https://github.com/openwrt/openwrt/pull/21547
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
George Sapkin 2026-01-04 19:50:52 +02:00 committed by Robert Marko
parent b4e537e9cd
commit 953ef12689

View file

@ -130,11 +130,22 @@ endef
# Format provide and add ABI and version if it's not a virtual provide marked
# with an @.
#
# Same as for the base package name, if ABI version is set, provide both
# unversioned provide and one with ABI version and version.
#
# 1: provide name
# 2: provide version
# 3: (optional) ABI preformatted by FormatABISuffix
# 3: (optional) ABI version
define AddProvide
$(if $(filter @%,$(1)),$(patsubst @%,%,$(1)),$(1)$(3)=$(2))
$(strip
$(if $(filter @%,$(1)),
$(patsubst @%,%,$(1)),
$(if $(3),
$(1) $(1)$(call FormatABISuffix,$(1),$(3))=$(2),
$(1)=$(2)
)
)
)
endef
# Remove virtual provides prefix and self. apk doesn't like it when packages
@ -158,9 +169,14 @@ endef
# at the same time
# - additionally provide `${package_name}` so multiple packages can be looked
# up by its base name
# - for each `provides`, provide `${provide}${ABI_version}=${package_version}`
# this implies that only one version of a provide can be installed at the
# same time
# - for each `provides`:
# - provide `${provide}${ABI_version}=${package_version}`
# this implies that only one version of a provide can be installed at the
# same time
# - if a `provide` ends in a number, the `ABI_version` will be prefixed with
# a - sign, e.g.: provide1-0
# - additionally provide `${provide}` so multiple packages can be looked up
# by its base name
#
# - else if ABI version is _not_ defined
# - package is named `${package_name}`
@ -213,16 +229,17 @@ endef
#
# 1: package name
# 2: package version
# 3: list of provides
# 3: ABI version
# 4: list of provides
define FormatProvides
$(strip
$(if $(ABIV_$(1)),
$(if $(call FormatABISuffix,$(1),$(3)),
$(1) $(foreach provide,
$(filter-out $(1),$(3)),
$(call AddProvide,$(provide),$(2),$(ABIV_$(1)))
$(filter-out $(1),$(4)),
$(call AddProvide,$(provide),$(2),$(3))
),
$(foreach provide,
$(filter-out $(1),$(3)),
$(filter-out $(1),$(4)),
$(call AddProvide,$(provide),$(2))
)
)
@ -367,7 +384,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))
Package/$(1)/PROVIDES := $$(call FormatProvides,$(1),$(VERSION),$(ABI_VERSION),$(PROVIDES))
endif
$(_define) Package/$(1)/CONTROL