build: add support for virtual provides

Allow defining virtual provides using the PROVIDES field by prefixing
them with @, e.g.:

PROVIDES:=@ca-certs

Virtual provides don't own the provided name and multiple packages with
the same virtual provides can be installed side-by-side. Packages must
still take care not to override each other's files.

Add an implicit self-provide to packages. apk can't handle self
provides, be it versioned or virtual, so opt for a suffix instead. This
allows several variants to provide the same virtual package without
adding extra provides to the default one, e.g. wget implicitly provides
wget-any and is marked as default, so wget-ssl can explicitly provide
@wget-any as well.

Filter out virtual provides when generating metadata.

Filter out virtual provides prefix and self provide where appropriate.

Signed-off-by: George Sapkin <george@sapk.in>
Link: https://github.com/openwrt/openwrt/pull/21288
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
George Sapkin
2025-12-25 15:32:29 +02:00
committed by Robert Marko
parent cefbf1184f
commit 5ed650acbf
3 changed files with 51 additions and 5 deletions
+3
View File
@@ -263,6 +263,9 @@ sub parse_package_metadata($) {
/^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
/^Provides: \s*(.+)\s*$/ and do {
my @vpkg = split /\s+/, $1;
foreach (@vpkg) {
s/^@//;
}
@{$pkg->{provides}} = ($pkg->{name}, @vpkg);
foreach my $vpkg (@vpkg) {
next if ($vpkg eq $pkg->{name});