streamline_config.pl: add LMC_KEEP to preserve some kconfigs
Subsystems (3)
PATCH v3 1/1 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
---
v3: rename LOCALMODCONFIG_PRESERVE to shorter LMC_KEEP.
v2: fix typo in documentation. (Randy Dunlap)
--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/Makefile | 1 + scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)
Documentation/admin-guide/README.rst +7 -1
@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certain folders + or kconfig files by spcifying their paths in + parameter LMC_KEEP. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LMC_KEEP="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.
scripts/kconfig/Makefile +1 -0
@@ -123,6 +123,7 @@ help: @echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' localmodconfig - Update current config disabling modules not loaded' + @echo ' except those preserved by LMC_KEEP environment variable' @echo ' localyesconfig - Update current config converting local mods to core' @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
scripts/kconfig/streamline_config.pl +23 -0
@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;
@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {
@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs; +@presevered_kconfigs = split(/;/,$ENV{LMC_KEEP}) if (defined($ENV{LMC_KEEP})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {
@@ -644,6 +662,11 @@ foreach my $line (@config_file) { } if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';
Signature · 1 line
2.25.1
Randy Dunlap
reviewerQuoted 22 lines · Changbin Du
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" localmodconfigSigned-off-by Changbin Du <[email protected]>---
v3: renameLOCALMODCONFIG_PRESERVEto shorterLMC_KEEP.
v2: fix typo in documentation. (Randy Dunlap)--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/Makefile | 1 + scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +0
-0
Documentation/admin-guide/README.rst Configuring the kernel · line 213
Quoted 5 lines
Documentation/admin-guide/README.rst +2
-0@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter. + Also, you can preserve modules in certain folders + or kconfig files by spcifying their paths in
specifying
More below.
Quoted 45 lines
Documentation/admin-guide/README.rst +5
-1+ parameter LMC_KEEP. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LMC_KEEP="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/Makefile +1
-0@@ -123,6 +123,7 @@ help: @echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' localmodconfig - Update current config disabling modules not loaded' + @echo ' except those preserved by LMC_KEEP environment variable' @echo ' localyesconfig - Update current config converting local mods to core' @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'scripts/kconfig/streamline_config.pl +2
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {
scripts/kconfig/streamline_config.pl while ($repeat) { · line 597
Quoted 4 lines
scripts/kconfig/streamline_config.pl +1
-0@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs;
s/presevered/preserved/g (g means globally, throughout this script)
Quoted 21 lines
scripts/kconfig/streamline_config.pl +15
-0+@presevered_kconfigs = split(/;/,$ENV{LMC_KEEP}) if (defined($ENV{LMC_KEEP})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { }
scripts/kconfig/streamline_config.pl foreach my $line (@config_file) { · line 672
Quoted 10 lines
scripts/kconfig/streamline_config.pl +5
-0if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';
thanks.
Signature · 1 line
~Randy
Quoted 26 lines · Randy Dunlap
Quoted 25 lines · Changbin Du
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" localmodconfigSigned-off-by Changbin Du <[email protected]>---
v3: renameLOCALMODCONFIG_PRESERVEto shorterLMC_KEEP.
v2: fix typo in documentation. (Randy Dunlap)--- Documentation/admin-guide/README.rst | 8 +++++++- scripts/kconfig/Makefile | 1 + scripts/kconfig/streamline_config.pl | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-)Documentation/admin-guide/README.rst +0
-0@@ -209,10 +209,16 @@ Configuring the kernel store the lsmod of that machine into a file and pass it in as a LSMOD parameter.
Quoted 7 lines
Documentation/admin-guide/README.rst Configuring the kernel · line 213
Quoted 2 lines
Documentation/admin-guide/README.rst +2
-0+ Also, you can preserve modules in certain folders + or kconfig files by spcifying their paths inspecifying
More below.
Will fix them, thank you!
Quoted 89 lines
Quoted 46 lines
Documentation/admin-guide/README.rst +5
-1+ parameter LMC_KEEP. + target$ lsmod > /tmp/mylsmod target$ scp /tmp/mylsmod host:/tmp - host$ make LSMOD=/tmp/mylsmod localmodconfig + host$ make LSMOD=/tmp/mylsmod \ + LMC_KEEP="drivers/usb;drivers/gpu;fs" \ + localmodconfig The above also works when cross compiling.scripts/kconfig/Makefile +1
-0@@ -123,6 +123,7 @@ help: @echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' localmodconfig - Update current config disabling modules not loaded' + @echo ' except those preserved by LMC_KEEP environment variable' @echo ' localyesconfig - Update current config converting local mods to core' @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'scripts/kconfig/streamline_config.pl +2
-0@@ -143,6 +143,7 @@ my %depends; my %selects; my %prompts; my %objects; +my %config2kfile; my $var; my $iflevel = 0; my @ifdeps;@@ -201,6 +202,7 @@ sub read_kconfig { if (/^\s*(menu)?config\s+(\S+)\s*$/) { $state = "NEW"; $config = $2; + $config2kfile{"CONFIG_$config"} = $kconfig; # Add depends for 'if' nesting for (my $i = 0; $i < $iflevel; $i++) {scripts/kconfig/streamline_config.pl while ($repeat) { · line 597
Quoted 4 lines
scripts/kconfig/streamline_config.pl +1
-0@@ -592,6 +594,22 @@ while ($repeat) { my %setconfigs; +my @presevered_kconfigs;s/presevered/preserved/g (g means globally, throughout this script)
Quoted 21 lines
scripts/kconfig/streamline_config.pl +15
-0+@presevered_kconfigs = split(/;/,$ENV{LMC_KEEP}) if (defined($ENV{LMC_KEEP})); + +sub in_presevered_kconfigs { + my $kconfig = $config2kfile{$_[0]}; + if (!defined($kconfig)) { + return 0; + } + foreach my $excl (@presevered_kconfigs) { + if($kconfig =~ /^$excl/) { + return 1; + } + } + return 0; +} + # Finally, read the .config file and turn off any module enabled that # we could not find a reason to keep enabled. foreach my $line (@config_file) {@@ -644,6 +662,11 @@ foreach my $line (@config_file) { }scripts/kconfig/streamline_config.pl foreach my $line (@config_file) { · line 672
Quoted 10 lines
scripts/kconfig/streamline_config.pl +5
-0if (/^(CONFIG.*)=(m|y)/) { + if (in_presevered_kconfigs($1)) { + dprint "Preserve config $1"; + print; + next; + } if (defined($configs{$1})) { if ($localyesconfig) { $setconfigs{$1} = 'y';thanks.
Signature · 1 line
~Randy
Signature · 2 lines
Cheers, Changbin Du