.. | .. |
---|
1 | 1 | #!/usr/bin/env perl |
---|
| 2 | +# SPDX-License-Identifier: GPL-2.0 |
---|
2 | 3 | # |
---|
3 | 4 | # Copyright 2005-2009 - Steven Rostedt |
---|
4 | | -# Licensed under the terms of the GNU GPL License version 2 |
---|
5 | 5 | # |
---|
6 | 6 | # It's simple enough to figure out how this works. |
---|
7 | 7 | # If not, then you can ask me at stripconfig@goodmis.org |
---|
.. | .. |
---|
55 | 55 | return if (!$debugprint); |
---|
56 | 56 | print STDERR @_; |
---|
57 | 57 | } |
---|
58 | | - |
---|
59 | | -my $config = ".config"; |
---|
60 | 58 | |
---|
61 | 59 | my $uname = `uname -r`; |
---|
62 | 60 | chomp $uname; |
---|
.. | .. |
---|
145 | 143 | my %selects; |
---|
146 | 144 | my %prompts; |
---|
147 | 145 | my %objects; |
---|
| 146 | +my %config2kfile; |
---|
148 | 147 | my $var; |
---|
149 | 148 | my $iflevel = 0; |
---|
150 | 149 | my @ifdeps; |
---|
.. | .. |
---|
203 | 202 | if (/^\s*(menu)?config\s+(\S+)\s*$/) { |
---|
204 | 203 | $state = "NEW"; |
---|
205 | 204 | $config = $2; |
---|
| 205 | + $config2kfile{"CONFIG_$config"} = $kconfig; |
---|
206 | 206 | |
---|
207 | 207 | # Add depends for 'if' nesting |
---|
208 | 208 | for (my $i = 0; $i < $iflevel; $i++) { |
---|
.. | .. |
---|
374 | 374 | $lsmod = "$dir/lsmod"; |
---|
375 | 375 | last; |
---|
376 | 376 | } |
---|
377 | | -} |
---|
| 377 | + } |
---|
378 | 378 | if (!defined($lsmod)) { |
---|
379 | 379 | # try just the path |
---|
380 | 380 | $lsmod = "lsmod"; |
---|
.. | .. |
---|
593 | 593 | } |
---|
594 | 594 | |
---|
595 | 595 | 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 | +} |
---|
596 | 613 | |
---|
597 | 614 | # Finally, read the .config file and turn off any module enabled that |
---|
598 | 615 | # we could not find a reason to keep enabled. |
---|
.. | .. |
---|
646 | 663 | } |
---|
647 | 664 | |
---|
648 | 665 | if (/^(CONFIG.*)=(m|y)/) { |
---|
| 666 | + if (in_preserved_kconfigs($1)) { |
---|
| 667 | + dprint "Preserve config $1"; |
---|
| 668 | + print; |
---|
| 669 | + next; |
---|
| 670 | + } |
---|
649 | 671 | if (defined($configs{$1})) { |
---|
650 | 672 | if ($localyesconfig) { |
---|
651 | 673 | $setconfigs{$1} = 'y'; |
---|