Skip to content

Commit 470e030

Browse files
GeorgeSapkinrobimarko
authored andcommitted
build: add default priority to ABI-versioned packages
If a package has an ABI version defined, set priority to 10. The enables packages with an ABI version to be installed by their base name instead of a name and an ABI version, e.g.: libfoo3, where 3 is the ABI version can be installed by just libfoo. This affects manual installation only, as the dependency resolution takes care of ABI versions. Refactor apk priority logic into a helper define. Signed-off-by: George Sapkin <george@sapk.in> Link: openwrt/openwrt#21369 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 1dec468 commit 470e030

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

‎include/package-pack.mk‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,29 @@ $(strip
245245
)
246246
endef
247247

248+
# Get apk provider priority
249+
#
250+
# - if a package is marked as a default variant, set it to 100.
251+
#
252+
# - if a package has an ABI version defined, set it to 10.
253+
# The enables packages with an ABI version to be installed by their base name
254+
# instead of a name and an ABI version, e.g.:
255+
# libfoo3, where 3 is the ABI version can be installed by just libfoo.
256+
# This affects manual installation only, as the dependency resolution takes
257+
# care of ABI versions.
258+
#
259+
# - otherwise return nothing, i.e. package will have the default priority 0.
260+
#
261+
# 1: Default variant
262+
# 2: ABI version
263+
define GetProviderPriority
264+
$(strip
265+
$(if $(1),100,
266+
$(if $(2),10)
267+
)
268+
)
269+
endef
270+
248271
ifneq ($(PKG_NAME),toolchain)
249272
define CheckDependencies
250273
@( \
@@ -384,6 +407,7 @@ endif
384407
Package/$(1)/PROVIDES := $$(filter-out $(1)$$(ABIV_$(1)),$$(Package/$(1)/PROVIDES)$$(if $$(ABIV_$(1)), $(1) $$(foreach provide,$$(Package/$(1)/PROVIDES),$$(provide)$$(ABIV_$(1)))))
385408
else
386409
Package/$(1)/PROVIDES := $$(call FormatProvides,$(1),$(VERSION),$(ABI_VERSION),$(PROVIDES))
410+
Package/$(1)/PRIORITY := $$(call GetProviderPriority,$(DEFAULT_VARIANT),$(ABI_VERSION))
387411
endif
388412

389413
$(_define) Package/$(1)/CONTROL
@@ -577,7 +601,7 @@ else
577601
--info "url:$(URL)" \
578602
--info "maintainer:$(MAINTAINER)" \
579603
$$(if $$(Package/$(1)/PROVIDES),--info "provides:$$(Package/$(1)/PROVIDES)") \
580-
$(if $(DEFAULT_VARIANT),--info "provider-priority:100") \
604+
$$(if $$(Package/$(1)/PRIORITY),--info "provider-priority:$$(Package/$(1)/PRIORITY)") \
581605
$$(APK_SCRIPTS_$(1)) \
582606
--info "depends:$$(foreach depends,$$(subst $$(comma),$$(space),$$(subst $$(space),,$$(subst $$(paren_right),,$$(subst $$(paren_left),,$$(Package/$(1)/DEPENDS))))),$$(depends))" \
583607
--files "$$(IDIR_$(1))" \

0 commit comments

Comments
 (0)