-sub parse_package_metadata() {
- my $pkg;
- my $makefile;
- my $preconfig;
- my $subdir;
- my $src;
- while (<>) {
- chomp;
- /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
- $makefile = $1;
- $subdir = $2;
- $src = $3;
- $subdir =~ s/^package\///;
- $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} = [];
- $pkg->{subdir} = $subdir;
- $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};
+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';
+ }