dnsmasq: rework network interface ignore
[openwrt/staging/jow.git] / scripts / metadata.pm
index e05e400991657d8ebdf70501e0bd72a378b57ec4..ecfe42c0bc926c9a9322301fade7c73892e5e332 100644 (file)
@@ -2,7 +2,7 @@ package metadata;
 use base 'Exporter';
 use strict;
 use warnings;
-our @EXPORT = qw(%package %vpackage %srcpackage %category %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_package_manifest_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
 
 our %package;
 our %vpackage;
@@ -131,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;
@@ -139,19 +140,29 @@ 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-Broken:\s*(.+)\s*$/ and do {
+                       $profile->{broken} = 1;
+                       $profile->{default} = "n";
+               };
+               /^Target-Profile-Default:\s*(.+)\s*$/ and $profile->{default} = $1;
        }
        close FILE;
        foreach my $target (@target) {
@@ -245,11 +256,15 @@ sub parse_package_metadata($) {
                /^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
                /^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
                /^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
+               /^CPE-ID: \s*(.+)\s*$/ and $pkg->{cpe_id} = $1;
+               /^URL: \s*(.+)\s*$/ and $pkg->{url} = $1;
+               /^ABI-Version: \s*(.+)\s*$/ and $pkg->{abi_version} = $1;
                /^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;
                        }
@@ -278,17 +293,24 @@ sub parse_package_metadata($) {
                };
                /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
                /^Prereq-Check:/ and $pkg->{prereq} = 1;
+               /^Maintainer: \s*(.+)\s*$/ and $pkg->{maintainer} = [ split /, /, $1 ];
                /^Require-User:\s*(.*?)\s*$/ and do {
                        my @ugspecs = split /\s+/, $1;
 
                        for my $ugspec (@ugspecs) {
-                               my @ugspec = split /:/, $ugspec, 2;
+                               my @ugspec = split /:/, $ugspec, 3;
                                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;
                                }
+                               if ($ugspec[2]) {
+                                       my @addngroups = split /,/, $ugspec[2];
+                                       for my $addngroup (@addngroups) {
+                                               parse_package_metadata_usergroup($src->{makefile}, "group", \%groupnames, \%groupids, $addngroup) or return 0;
+                                       }
+                               }
                        }
                };
        }
@@ -296,4 +318,43 @@ sub parse_package_metadata($) {
        return 1;
 }
 
+sub parse_package_manifest_metadata($) {
+       my $file = shift;
+       my $pkg;
+       my %pkgs;
+
+       open FILE, "<$file" or do {
+               warn "Cannot open '$file': $!\n";
+               return undef;
+       };
+
+       while (<FILE>) {
+               chomp;
+               /^Package:\s*(.+?)\s*$/ and do {
+                       $pkg = {};
+                       $pkg->{name} = $1;
+                       $pkg->{depends} = [];
+                       $pkgs{$1} = $pkg;
+               };
+               /^Version:\s*(.+)\s*$/ and $pkg->{version} = $1;
+               /^Depends:\s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
+               /^Source:\s*(.+)\s*$/ and $pkg->{source} = $1;
+               /^SourceName:\s*(.+)\s*$/ and $pkg->{sourcename} = $1;
+               /^License:\s*(.+)\s*$/ and $pkg->{license} = $1;
+               /^LicenseFiles:\s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
+               /^Section:\s*(.+)\s*$/ and $pkg->{section} = $1;
+               /^SourceDateEpoch: \s*(.+)\s*$/ and $pkg->{sourcedateepoch} = $1;
+               /^CPE-ID:\s*(.+)\s*$/ and $pkg->{cpe_id} = $1;
+               /^URL:\s*(.+)\s*$/ and $pkg->{url} = $1;
+               /^Architecture:\s*(.+)\s*$/ and $pkg->{architecture} = $1;
+               /^Installed-Size:\s*(.+)\s*$/ and $pkg->{installedsize} = $1;
+               /^Filename:\s*(.+)\s*$/ and $pkg->{filename} = $1;
+               /^Size:\s*(\d+)\s*$/ and $pkg->{size} = $1;
+               /^SHA256sum:\s*(.*)\s*$/ and $pkg->{sha256sum} = $1;
+       }
+
+       close FILE;
+       return %pkgs;
+}
+
 1;