hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/scripts/kconfig/streamline_config.pl
....@@ -1,7 +1,7 @@
11 #!/usr/bin/env perl
2
+# SPDX-License-Identifier: GPL-2.0
23 #
34 # Copyright 2005-2009 - Steven Rostedt
4
-# Licensed under the terms of the GNU GPL License version 2
55 #
66 # It's simple enough to figure out how this works.
77 # If not, then you can ask me at stripconfig@goodmis.org
....@@ -55,8 +55,6 @@
5555 return if (!$debugprint);
5656 print STDERR @_;
5757 }
58
-
59
-my $config = ".config";
6058
6159 my $uname = `uname -r`;
6260 chomp $uname;
....@@ -145,6 +143,7 @@
145143 my %selects;
146144 my %prompts;
147145 my %objects;
146
+my %config2kfile;
148147 my $var;
149148 my $iflevel = 0;
150149 my @ifdeps;
....@@ -203,6 +202,7 @@
203202 if (/^\s*(menu)?config\s+(\S+)\s*$/) {
204203 $state = "NEW";
205204 $config = $2;
205
+ $config2kfile{"CONFIG_$config"} = $kconfig;
206206
207207 # Add depends for 'if' nesting
208208 for (my $i = 0; $i < $iflevel; $i++) {
....@@ -374,7 +374,7 @@
374374 $lsmod = "$dir/lsmod";
375375 last;
376376 }
377
-}
377
+ }
378378 if (!defined($lsmod)) {
379379 # try just the path
380380 $lsmod = "lsmod";
....@@ -593,6 +593,23 @@
593593 }
594594
595595 my %setconfigs;
596
+my @preserved_kconfigs;
597
+if (defined($ENV{'LMC_KEEP'})) {
598
+ @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
599
+}
600
+
601
+sub in_preserved_kconfigs {
602
+ my $kconfig = $config2kfile{$_[0]};
603
+ if (!defined($kconfig)) {
604
+ return 0;
605
+ }
606
+ foreach my $excl (@preserved_kconfigs) {
607
+ if($kconfig =~ /^$excl/) {
608
+ return 1;
609
+ }
610
+ }
611
+ return 0;
612
+}
596613
597614 # Finally, read the .config file and turn off any module enabled that
598615 # we could not find a reason to keep enabled.
....@@ -646,6 +663,11 @@
646663 }
647664
648665 if (/^(CONFIG.*)=(m|y)/) {
666
+ if (in_preserved_kconfigs($1)) {
667
+ dprint "Preserve config $1";
668
+ print;
669
+ next;
670
+ }
649671 if (defined($configs{$1})) {
650672 if ($localyesconfig) {
651673 $setconfigs{$1} = 'y';