scripts/package-metadata.pl: honour DEFAULT_VARIANT
authorJo-Philipp Wich <jo@mein.io>
Wed, 2 Nov 2016 00:45:06 +0000 (01:45 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 2 Nov 2016 01:02:44 +0000 (02:02 +0100)
So far, package-metadata.pl always considered the first provider of a virtual
package to be the default variant which might deviate from what buildroot
considers to be the default.

Change the Kconfig dependency / select code generation for virtual package
providers to consider the DEFAULT_VARIANT to be the primary provider and only
fall back to the first provider if no default variant was explicitely tagged.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
scripts/package-metadata.pl

index 1a4f103810a6b66a620377f18199a84d4d971601..f8f16f07fa8bb67a037e86473233343e7d2ced0a 100755 (executable)
@@ -176,8 +176,21 @@ sub mconf_depends {
                next if $package{$depend} and $package{$depend}->{buildonly};
                if ($flags =~ /\+/) {
                        if ($vdep = $package{$depend}->{vdepends}) {
-                               my @vdeps = @$vdep;
-                               $depend = shift @vdeps;
+                               my @vdeps;
+                               $depend = undef;
+
+                               foreach my $v (@$vdep) {
+                                       if ($package{$v} && $package{$v}->{variant_default}) {
+                                               $depend = $v;
+                                       } else {
+                                               push @vdeps, $v;
+                                       }
+                               }
+
+                               if (!$depend) {
+                                       $depend = shift @vdeps;
+                               }
+
                                if (@vdeps > 1) {
                                        $condition = ($condition ? "$condition && " : '') . '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
                                } elsif (@vdeps > 0) {