Skip to content

Commit c027b02

Browse files
changbindumasahir0y
authored andcommitted
streamline_config.pl: add LMC_KEEP to preserve some kconfigs
Sometimes it is useful to preserve batches of configs when making localmodconfig. For example, I usually don't want any usb and fs modules to be disabled. Now we can do it by: $ make LMC_KEEP="drivers/usb:fs" localmodconfig Signed-off-by: Changbin Du <[email protected]> Acked-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 09d5873 commit c027b02

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Documentation/admin-guide/README.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,22 @@ Configuring the kernel
209209
store the lsmod of that machine into a file
210210
and pass it in as a LSMOD parameter.
211211

212+
Also, you can preserve modules in certain folders
213+
or kconfig files by specifying their paths in
214+
parameter LMC_KEEP.
215+
212216
target$ lsmod > /tmp/mylsmod
213217
target$ scp /tmp/mylsmod host:/tmp
214218

215-
host$ make LSMOD=/tmp/mylsmod localmodconfig
219+
host$ make LSMOD=/tmp/mylsmod \
220+
LMC_KEEP="drivers/usb:drivers/gpu:fs" \
221+
localmodconfig
216222

217223
The above also works when cross compiling.
218224

219225
"make localyesconfig" Similar to localmodconfig, except it will convert
220-
all module options to built in (=y) options.
226+
all module options to built in (=y) options. You can
227+
also preserve modules by LMC_KEEP.
221228

222229
"make kvmconfig" Enable additional options for kvm guest kernel support.
223230

scripts/kconfig/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ help:
123123
@echo ' gconfig - Update current config utilising a GTK+ based front-end'
124124
@echo ' oldconfig - Update current config utilising a provided .config as base'
125125
@echo ' localmodconfig - Update current config disabling modules not loaded'
126+
@echo ' except those preserved by LMC_KEEP environment variable'
126127
@echo ' localyesconfig - Update current config converting local mods to core'
128+
@echo ' except those preserved by LMC_KEEP environment variable'
127129
@echo ' defconfig - New config with default from ARCH supplied defconfig'
128130
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
129131
@echo ' allnoconfig - New config where all options are answered with no'

scripts/kconfig/streamline_config.pl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ sub read_config {
143143
my %selects;
144144
my %prompts;
145145
my %objects;
146+
my %config2kfile;
146147
my $var;
147148
my $iflevel = 0;
148149
my @ifdeps;
@@ -201,6 +202,7 @@ sub read_kconfig {
201202
if (/^\s*(menu)?config\s+(\S+)\s*$/) {
202203
$state = "NEW";
203204
$config = $2;
205+
$config2kfile{"CONFIG_$config"} = $kconfig;
204206

205207
# Add depends for 'if' nesting
206208
for (my $i = 0; $i < $iflevel; $i++) {
@@ -591,6 +593,20 @@ sub loop_select {
591593
}
592594

593595
my %setconfigs;
596+
my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
597+
598+
sub in_preserved_kconfigs {
599+
my $kconfig = $config2kfile{$_[0]};
600+
if (!defined($kconfig)) {
601+
return 0;
602+
}
603+
foreach my $excl (@preserved_kconfigs) {
604+
if($kconfig =~ /^$excl/) {
605+
return 1;
606+
}
607+
}
608+
return 0;
609+
}
594610

595611
# Finally, read the .config file and turn off any module enabled that
596612
# we could not find a reason to keep enabled.
@@ -644,6 +660,11 @@ sub loop_select {
644660
}
645661

646662
if (/^(CONFIG.*)=(m|y)/) {
663+
if (in_preserved_kconfigs($1)) {
664+
dprint "Preserve config $1";
665+
print;
666+
next;
667+
}
647668
if (defined($configs{$1})) {
648669
if ($localyesconfig) {
649670
$setconfigs{$1} = 'y';

0 commit comments

Comments
 (0)