build: allow overriding default selection state for devices
[openwrt/openwrt.git] / scripts / metadata.pm
index 7c82cec809d2c75869e6b18eb20774e0e9feec36..1826a040a1165032f49a64f10de40ed0d75f97fe 100644 (file)
@@ -2,13 +2,12 @@ package metadata;
 use base 'Exporter';
 use strict;
 use warnings;
-our @EXPORT = qw(%package %vpackage %srcpackage %category %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
+our @EXPORT = qw(%package %vpackage %srcpackage %category %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
 
 our %package;
 our %vpackage;
 our %srcpackage;
 our %category;
-our %features;
 our %overrides;
 our @ignore;
 
@@ -132,6 +131,7 @@ sub parse_target_metadata($) {
                /^Target-Optimization:\s*(.+)\s*$/ and $target->{cflags} = $1;
                /^CPU-Type:\s*(.+)\s*$/ and $target->{cputype} = $1;
                /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
+               /^Linux-Testing-Version:\s*(.+)\s*$/ and $target->{testing_version} = $1;
                /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
                /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
                /^Default-Subtarget:\s*(.+)\s*$/ and $target->{def_subtarget} = $1;
@@ -140,19 +140,25 @@ sub parse_target_metadata($) {
                        $profile = {
                                id => $1,
                                name => $1,
+                               has_image_metadata => 0,
+                               supported_devices => [],
                                priority => 999,
-                               packages => []
+                               packages => [],
+                               default => "y if TARGET_ALL_PROFILES"
                        };
                        $1 =~ /^DEVICE_/ and $target->{has_devices} = 1;
                        push @{$target->{profiles}}, $profile;
                };
                /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
+               /^Target-Profile-hasImageMetadata:\s*(\d+)\s*$/ and $profile->{has_image_metadata} = $1;
+               /^Target-Profile-SupportedDevices:\s*(.+)\s*$/ and $profile->{supported_devices} = [ split(/\s+/, $1) ];
                /^Target-Profile-Priority:\s*(\d+)\s*$/ and do {
                        $profile->{priority} = $1;
                        $target->{sort} = 1;
                };
                /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
                /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
+               /^Target-Profile-Default:\s*(.+)\s*$/ and $profile->{default} = $1;
        }
        close FILE;
        foreach my $target (@target) {
@@ -181,7 +187,6 @@ sub clear_packages() {
        %vpackage = ();
        %srcpackage = ();
        %category = ();
-       %features = ();
        %overrides = ();
        %usernames = ();
        %groupnames = ();
@@ -190,7 +195,6 @@ sub clear_packages() {
 sub parse_package_metadata($) {
        my $file = shift;
        my $pkg;
-       my $feature;
        my $src;
        my $override;
        my %ignore = map { $_ => 1 } @ignore;
@@ -221,13 +225,13 @@ sub parse_package_metadata($) {
                };
                next unless $src;
                /^Package:\s*(.+?)\s*$/ and do {
-                       undef $feature;
                        $pkg = {};
                        $pkg->{src} = $src;
                        $pkg->{name} = $1;
                        $pkg->{title} = "";
                        $pkg->{depends} = [];
                        $pkg->{mdepends} = [];
+                       $pkg->{provides} = [$1];
                        $pkg->{tristate} = 1;
                        $pkg->{override} = $override;
                        $package{$1} = $pkg;
@@ -236,28 +240,12 @@ sub parse_package_metadata($) {
                        $vpackage{$1} or $vpackage{$1} = [];
                        unshift @{$vpackage{$1}}, $pkg;
                };
-               /^Feature:\s*(.+?)\s*$/ and do {
-                       undef $pkg;
-                       $feature = {};
-                       $feature->{name} = $1;
-                       $feature->{priority} = 0;
-               };
-               $feature and do {
-                       /^Target-Name:\s*(.+?)\s*$/ and do {
-                               $features{$1} or $features{$1} = [];
-                               push @{$features{$1}}, $feature unless $src->{ignore};
-                       };
-                       /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1;
-                       /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1;
-                       /^Feature-Name:\s*(.+?)\s*$/ and $feature->{title} = $1;
-                       /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t");
-                       next;
-               };
                /^Build-Depends: \s*(.+)\s*$/ and $src->{builddepends} = [ split /\s+/, $1 ];
                /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $src->{"builddepends/$1"} = [ split /\s+/, $2 ];
                /^Build-Types:\s*(.+)\s*$/ and $src->{buildtypes} = [ split /\s+/, $1 ];
                next unless $pkg;
                /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
+               /^ABIVersion: \s*(.+)\s*$/ and $pkg->{abiversion} = $1;
                /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
                /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
                /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
@@ -268,7 +256,9 @@ sub parse_package_metadata($) {
                /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
                /^Provides: \s*(.+)\s*$/ and do {
                        my @vpkg = split /\s+/, $1;
+                       @{$pkg->{provides}} = ($pkg->{name}, @vpkg);
                        foreach my $vpkg (@vpkg) {
+                               next if ($vpkg eq $pkg->{name});
                                $vpackage{$vpkg} or $vpackage{$vpkg} = [];
                                push @{$vpackage{$vpkg}}, $pkg;
                        }
@@ -302,8 +292,10 @@ sub parse_package_metadata($) {
 
                        for my $ugspec (@ugspecs) {
                                my @ugspec = split /:/, $ugspec, 2;
-                               parse_package_metadata_usergroup($src->{makefile}, "user", \%usernames, \%userids, $ugspec[0]) or return 0;
-                               if (@ugspec > 1) {
+                               if ($ugspec[0]) {
+                                       parse_package_metadata_usergroup($src->{makefile}, "user", \%usernames, \%userids, $ugspec[0]) or return 0;
+                               }
+                               if ($ugspec[1]) {
                                        parse_package_metadata_usergroup($src->{makefile}, "group", \%groupnames, \%groupids, $ugspec[1]) or return 0;
                                }
                        }