-sub parse_package_metadata() {
- my $pkg;
- my $makefile;
- my $preconfig;
- my $src;
- while (<>) {
- chomp;
- /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
- $makefile = $1;
- $src = $2;
- $srcpackage{$src} = [];
- undef $pkg;
- };
- /^Package:\s*(.+?)\s*$/ and do {
- $pkg = {};
- $pkg->{src} = $src;
- $pkg->{makefile} = $makefile;
- $pkg->{name} = $1;
- $pkg->{default} = "m if ALL";
- $pkg->{depends} = [];
- $pkg->{builddepends} = [];
- $package{$1} = $pkg;
- push @{$srcpackage{$src}}, $pkg;
- };
- /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
- /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
- /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
- /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
- /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
- /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
- /^Provides: \s*(.+)\s*$/ and do {
- my @vpkg = split /\s+/, $1;
- foreach my $vpkg (@vpkg) {
- $package{$vpkg} or $package{$vpkg} = { vdepends => [] };
- push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
- }
- };
- /^Depends: \s*(.+)\s*$/ and do {
- my @dep = split /\s+/, $1;
- $pkg->{depends} = \@dep;
- };
- /^Build-Depends: \s*(.+)\s*$/ and do {
- my @dep = split /\s+/, $1;
- $pkg->{builddepends} = \@dep;
- };
- /^Category: \s*(.+)\s*$/ and do {
- $pkg->{category} = $1;
- defined $category{$1} or $category{$1} = {};
- defined $category{$1}->{$src} or $category{$1}->{$src} = [];
- push @{$category{$1}->{$src}}, $pkg;
- };
- /^Description: \s*(.*)\s*$/ and do {
- my $desc = "\t\t$1\n\n";
- my $line;
- while ($line = <>) {
- last if $line =~ /^@@/;
- $desc .= "\t\t$line";
- }
- $pkg->{description} = $desc;
- };
- /^Config: \s*(.*)\s*$/ and do {
- my $conf = "$1\n";
- my $line;
- while ($line = <>) {
- last if $line =~ /^@@/;
- $conf .= "$line";
+sub gen_kconfig_overrides() {
+ my %config;
+ my %kconfig;
+ my $package;
+ my $pkginfo = shift @ARGV;
+ my $cfgfile = shift @ARGV;
+
+ # parameter 2: build system config
+ open FILE, "<$cfgfile" or return;
+ while (<FILE>) {
+ /^(CONFIG_.+?)=(.+)$/ and $config{$1} = 1;
+ }
+ close FILE;
+
+ # parameter 1: package metadata
+ open FILE, "<$pkginfo" or return;
+ while (<FILE>) {
+ /^Package:\s*(.+?)\s*$/ and $package = $1;
+ /^Kernel-Config:\s*(.+?)\s*$/ and do {
+ my @config = split /\s+/, $1;
+ foreach my $config (@config) {
+ my $val = 'm';
+ my $override;
+ if ($config =~ /^(.+?)=(.+)$/) {
+ $config = $1;
+ $override = 1;
+ $val = $2;
+ }
+ if ($config{"CONFIG_PACKAGE_$package"} and ($config ne 'n')) {
+ $kconfig{$config} = $val;
+ } elsif (!$override) {
+ $kconfig{$config} or $kconfig{$config} = 'n';
+ }