Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # Copyright 2005-2009 - Steven Rostedt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #  It's simple enough to figure out how this works.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #  If not, then you can ask me at stripconfig@goodmis.org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) # What it does?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #   If you have installed a Linux kernel from a distribution
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #   that turns on way too many modules than you need, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #   you only want the modules you use, then this program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #   is perfect for you.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #   It gives you the ability to turn off all the modules that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #   not loaded on your system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) # Howto:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #  1. Boot up the kernel that you want to stream line the config on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #  2. Change directory to the directory holding the source of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #       kernel that you just booted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #  3. Copy the configuraton file to this directory as .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #  4. Have all your devices that you need modules for connected and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #      operational (make sure that their corresponding modules are loaded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #  5. Run this script redirecting the output to some other file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #       like config_strip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #  6. Back up your old config (if you want too).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #  7. copy the config_strip file to .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #  8. Run "make oldconfig"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #  Now your kernel is ready to be built with only the modules that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #  are loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) # Here's what I did with my Debian distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #    cd /usr/src/linux-2.6.10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #    cp /boot/config-2.6.10-1-686-smp .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #    ~/bin/streamline_config > config_strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #    mv .config config_sav
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #    mv config_strip .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #    make oldconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) use warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) use strict;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) use Getopt::Long;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) # set the environment variable LOCALMODCONFIG_DEBUG to get
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) # debug output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) my $debugprint = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) $debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG}));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) sub dprint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)     return if (!$debugprint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)     print STDERR @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) my $uname = `uname -r`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) chomp $uname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) my @searchconfigs = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	    "file" => ".config",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	    "exec" => "cat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	    "file" => "/proc/config.gz",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	    "exec" => "zcat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	    "file" => "/boot/config-$uname",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	    "exec" => "cat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	    "file" => "/boot/vmlinuz-$uname",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	    "exec" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	    "test" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	    "file" => "vmlinux",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	    "exec" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	    "test" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	    "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	    "exec" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	    "test" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	    "file" => "kernel/configs.ko",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	    "exec" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	    "test" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	    "file" => "kernel/configs.o",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	    "exec" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	    "test" => "scripts/extract-ikconfig",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sub read_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)     foreach my $conf (@searchconfigs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	my $file = $conf->{"file"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	next if ( ! -f "$file");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (defined($conf->{"test"})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	    `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	    next if ($?);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	my $exec = $conf->{"exec"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	print STDERR "using config: '$file'\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	my @x = <$infile>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	close $infile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return @x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)     die "No config file found";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) my @config_file = read_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) # Parse options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) my $localmodconfig = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) my $localyesconfig = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) GetOptions("localmodconfig" => \$localmodconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	   "localyesconfig" => \$localyesconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) # Get the build source and top level Kconfig file (passed in)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) my $ksource = ($ARGV[0] ? $ARGV[0] : '.');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) my $kconfig = $ARGV[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) my $lsmod_file = $ENV{'LSMOD'};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) my @makefiles = `find $ksource -name Makefile -or -name Kbuild 2>/dev/null`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) chomp @makefiles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) my %depends;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) my %selects;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) my %prompts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) my %objects;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) my %config2kfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) my $var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) my $iflevel = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) my @ifdeps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) # prevent recursion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) my %read_kconfigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sub read_kconfig {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)     my ($kconfig) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)     my $state = "NONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)     my $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)     my $cont = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)     my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)     my $source = "$ksource/$kconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)     my $last_source = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)     # Check for any environment variables used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)     while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	my $env = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	$last_source = $source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	$source =~ s/\$\($env\)/$ENV{$env}/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)     open(my $kinfile, '<', $source) || die "Can't open $kconfig";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)     while (<$kinfile>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	# Make sure that lines ending with \ continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if ($cont) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	    $_ = $line . " " . $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	if (s/\\$//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	    $cont = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	    $line = $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	    next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	$cont = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	# collect any Kconfig sources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	if (/^source\s+"?([^"]+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	    my $kconfig = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	    # prevent reading twice.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	    if (!defined($read_kconfigs{$kconfig})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		$read_kconfigs{$kconfig} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		read_kconfig($kconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	    next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	# configs found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (/^\s*(menu)?config\s+(\S+)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	    $state = "NEW";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	    $config = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	    $config2kfile{"CONFIG_$config"} = $kconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	    # Add depends for 'if' nesting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	    for (my $i = 0; $i < $iflevel; $i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		if ($i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		    $depends{$config} .= " " . $ifdeps[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		    $depends{$config} = $ifdeps[$i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		$state = "DEP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	# collect the depends for the config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	} elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	    $state = "DEP";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	    $depends{$config} = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	} elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	    $depends{$config} .= " " . $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	} elsif ($state eq "DEP" && /^\s*def(_(bool|tristate)|ault)\s+(\S.*)$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	    my $dep = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	    if ($dep !~ /^\s*(y|m|n)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		$dep =~ s/.*\sif\s+//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		$depends{$config} .= " " . $dep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		dprint "Added default depends $dep to $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	# Get the configs that select this config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	} elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	    my $conf = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	    if (defined($selects{$conf})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		$selects{$conf} .= " " . $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	    } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		$selects{$conf} = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	# configs without prompts must be selected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	} elsif ($state ne "NONE" && /^\s*(tristate\s+\S|prompt\b)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	    # note if the config has a prompt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	    $prompts{$config} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	# Check for if statements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	} elsif (/^if\s+(.*\S)\s*$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	    my $deps = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	    # remove beginning and ending non text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	    $deps =~ s/^[^a-zA-Z0-9_]*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	    $deps =~ s/[^a-zA-Z0-9_]*$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	    my @deps = split /[^a-zA-Z0-9_]+/, $deps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	    $ifdeps[$iflevel++] = join ':', @deps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	} elsif (/^endif/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	    $iflevel-- if ($iflevel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	# stop on "help" and keywords that end a menu entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	} elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	    $state = "NONE";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)     close($kinfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if ($kconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)     read_kconfig($kconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) # Makefiles can use variables to define their dependencies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) sub convert_vars {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)     my ($line, %vars) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)     my $process = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)     while ($line =~ s/^(.*?)(\$\((.*?)\))//) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	my $start = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	my $variable = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	my $var = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	if (defined($vars{$var})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	    $process .= $start . $vars{$var};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	    $process .= $start . $variable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)     $process .= $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)     return $process;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) # Read all Makefiles to map the configs to the objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) foreach my $makefile (@makefiles) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)     my $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)     my %make_vars;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)     open(my $infile, '<', $makefile) || die "Can't open $makefile";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)     while (<$infile>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	# if this line ends with a backslash, continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	chomp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	if (/^(.*)\\$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	    $line .= $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	    next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	$line .= $_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	$_ = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	$line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	my $objs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	# Convert variables in a line (could define configs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	$_ = convert_vars($_, %make_vars);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	# collect objects after obj-$(CONFIG_FOO_BAR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	    $var = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	    $objs = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	# check if variables are set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	} elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	    $make_vars{$1} = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	if (defined($objs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	    foreach my $obj (split /\s+/,$objs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		$obj =~ s/-/_/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		if ($obj =~ /(.*)\.o$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		    # Objects may be enabled by more than one config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		    # Store configs in an array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		    my @arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		    if (defined($objects{$1})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			@arr = @{$objects{$1}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		    $arr[$#arr+1] = $var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		    # The objects have a hash mapping to a reference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		    # of an array of configs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		    $objects{$1} = \@arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)     close($infile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) my %modules;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) my $linfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (defined($lsmod_file)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)     if ( ! -f $lsmod_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	if ( -f $ENV{'objtree'}."/".$lsmod_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	    $lsmod_file = $ENV{'objtree'}."/".$lsmod_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		die "$lsmod_file not found";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)     my $otype = ( -x $lsmod_file) ? '-|' : '<';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)     open($linfile, $otype, $lsmod_file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)     # see what modules are loaded on this system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)     my $lsmod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)     foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	if ( -x "$dir/lsmod" ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	    $lsmod = "$dir/lsmod";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	    last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)     if (!defined($lsmod)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	# try just the path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	$lsmod = "lsmod";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)     open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) while (<$linfile>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	next if (/^Module/);  # Skip the first line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (/^(\S+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		$modules{$1} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) close ($linfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) # add to the configs hash all configs that are needed to enable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) # a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) # where we know we need bar.o so we add FOO to the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) my %configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) foreach my $module (keys(%modules)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)     if (defined($objects{$module})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	my @arr = @{$objects{$module}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	foreach my $conf (@arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	    $configs{$conf} = $module;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	    dprint "$conf added by direct ($module)\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	    if ($debugprint) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		my $c=$conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		$c =~ s/^CONFIG_//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		if (defined($depends{$c})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		    dprint " deps = $depends{$c}\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		    dprint " no deps\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)     } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	# Most likely, someone has a custom (binary?) module loaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	print STDERR "$module config not found!!\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) # Read the current config, and see what is enabled. We want to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) # ignore configs that we would not enable anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) my %orig_configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) my $valid = "A-Za-z_0-9";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) foreach my $line (@config_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)     $_ = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)     if (/(CONFIG_[$valid]*)=(m|y)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	$orig_configs{$1} = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) my $repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) my $depconfig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) # Note, we do not care about operands (like: &&, ||, !) we want to add any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) # config that is in the depend list of another config. This script does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) # not enable configs that are not already enabled. If we come across a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) # config A that depends on !B, we can still add B to the list of depends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) # to keep on. If A was on in the original config, B would not have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) # and B would not be turned on by this script.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) sub parse_config_depends
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)     my ($p) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450)     while ($p =~ /[$valid]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	if ($p =~ /^[^$valid]*([$valid]+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	    my $conf = "CONFIG_" . $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	    $p =~ s/^[^$valid]*[$valid]+//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	    # We only need to process if the depend config is a module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	    if (!defined($orig_configs{$conf}) || $orig_configs{$conf} eq "y") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	    if (!defined($configs{$conf})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		# We must make sure that this config has its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		# dependencies met.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		$repeat = 1; # do again
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		dprint "$conf selected by depend $depconfig\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		$configs{$conf} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	    die "this should never happen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) # Select is treated a bit differently than depends. We call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) # when a config has no prompt and requires another config to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) # selected. We use to just select all configs that selected this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) # config, but found that that can balloon into enabling hundreds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) # of configs that we do not care about.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) # The idea is we look at all the configs that select it. If one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) # is already in our list of configs to enable, then there's nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) # else to do. If there isn't, we pick the first config that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) # enabled in the orignal config and use that.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) sub parse_config_selects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)     my ($config, $p) = @_;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)     my $next_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491)     while ($p =~ /[$valid]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	if ($p =~ /^[^$valid]*([$valid]+)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	    my $conf = "CONFIG_" . $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	    $p =~ s/^[^$valid]*[$valid]+//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	    # Make sure that this config exists in the current .config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	    if (!defined($orig_configs{$conf})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		dprint "$conf not set for $config select\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	    # Check if something other than a module selects this config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	    if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		dprint "$conf (non module) selects config, we are good\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		# we are good with this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	    if (defined($configs{$conf})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		dprint "$conf selects $config so we are good\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		# A set config selects this config, we are good
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	    # Set this config to be selected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	    if (!defined($next_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		$next_config = $conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 	    die "this should never happen";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)     # If no possible config selected this, then something happened.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)     if (!defined($next_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	print STDERR "WARNING: $config is required, but nothing in the\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	print STDERR "  current config selects it.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)     # If we are here, then we found no config that is set and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)     # selects this config. Repeat.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)     $repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)     # Make this config need to be selected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)     $configs{$next_config} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)     dprint "$next_config selected by select $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) my %process_selects;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) # loop through all configs, select their dependencies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) sub loop_depend {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)     $repeat = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)     while ($repeat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	$repeat = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)       forloop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	foreach my $config (keys %configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	    # If this config is not a module, we do not need to process it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	    if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 		next forloop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	    $config =~ s/^CONFIG_//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	    $depconfig = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	    if (defined($depends{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 		# This config has dependencies. Make sure they are also included
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 		parse_config_depends $depends{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	    # If the config has no prompt, then we need to check if a config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	    # that is enabled selected it. Or if we need to enable one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	    if (!defined($prompts{$config}) && defined($selects{$config})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		$process_selects{$config} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) sub loop_select {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)     foreach my $config (keys %process_selects) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	$config =~ s/^CONFIG_//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	dprint "Process select $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	# config has no prompt and must be selected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	parse_config_selects $config, $selects{$config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) while ($repeat) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)     # Get the first set of configs and their dependencies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)     loop_depend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)     $repeat = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)     # Now we need to see if we have to check selects;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)     loop_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) my %setconfigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) my @preserved_kconfigs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) if (defined($ENV{'LMC_KEEP'})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	@preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) sub in_preserved_kconfigs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)     my $kconfig = $config2kfile{$_[0]};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)     if (!defined($kconfig)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)         return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)     foreach my $excl (@preserved_kconfigs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)         if($kconfig =~ /^$excl/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)             return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)     return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) # Finally, read the .config file and turn off any module enabled that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) # we could not find a reason to keep enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) foreach my $line (@config_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)     $_ = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)     if (/CONFIG_IKCONFIG/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	if (/# CONFIG_IKCONFIG is not set/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	    # enable IKCONFIG at least as a module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	    print "CONFIG_IKCONFIG=m\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	    # don't ask about PROC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	    print "# CONFIG_IKCONFIG_PROC is not set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	    print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)     if (/CONFIG_MODULE_SIG_KEY="(.+)"/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)         my $orig_cert = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)         my $default_cert = "certs/signing_key.pem";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635)         # Check that the logic in this script still matches the one in Kconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)         if (!defined($depends{"MODULE_SIG_KEY"}) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)             $depends{"MODULE_SIG_KEY"} !~ /"\Q$default_cert\E"/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)             print STDERR "WARNING: MODULE_SIG_KEY assertion failure, ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)                 "update needed to ", __FILE__, " line ", __LINE__, "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)             print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)         } elsif ($orig_cert ne $default_cert && ! -f $orig_cert) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)             print STDERR "Module signature verification enabled but ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)                 "module signing key \"$orig_cert\" not found. Resetting ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)                 "signing key to default value.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)             print "CONFIG_MODULE_SIG_KEY=\"$default_cert\"\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646)         } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)             print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)         next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)     if (/CONFIG_SYSTEM_TRUSTED_KEYS="(.+)"/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)         my $orig_keys = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)         if (! -f $orig_keys) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)             print STDERR "System keyring enabled but keys \"$orig_keys\" ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)                 "not found. Resetting keys to default value.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)             print "CONFIG_SYSTEM_TRUSTED_KEYS=\"\"\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)         } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660)             print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)         next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)     if (/^(CONFIG.*)=(m|y)/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)         if (in_preserved_kconfigs($1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)             dprint "Preserve config $1";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)             print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)             next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 	if (defined($configs{$1})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	    if ($localyesconfig) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	        $setconfigs{$1} = 'y';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		print "$1=y\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	    } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 	        $setconfigs{$1} = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 	} elsif ($2 eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	    print "# $1 is not set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 	    next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)     print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) # Integrity check, make sure all modules that we want enabled do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) # indeed have their configs set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) loop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) foreach my $module (keys(%modules)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)     if (defined($objects{$module})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	my @arr = @{$objects{$module}};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	foreach my $conf (@arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 	    if (defined($setconfigs{$conf})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 		next loop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 	print STDERR "module $module did not have configs";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 	foreach my $conf (@arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 	    print STDERR " " , $conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 	print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)     }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) }