mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 <changbin.du@gmail.com> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
		
							parent
							
								
									09d5873e4d
								
							
						
					
					
						commit
						c027b02d89
					
				
					 3 changed files with 32 additions and 2 deletions
				
			
		| 
						 | 
					@ -209,15 +209,22 @@ Configuring the kernel
 | 
				
			||||||
                           store the lsmod of that machine into a file
 | 
					                           store the lsmod of that machine into a file
 | 
				
			||||||
                           and pass it in as a LSMOD parameter.
 | 
					                           and pass it in as a LSMOD parameter.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                           Also, you can preserve modules in certain folders
 | 
				
			||||||
 | 
					                           or kconfig files by specifying their paths in
 | 
				
			||||||
 | 
					                           parameter LMC_KEEP.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                   target$ lsmod > /tmp/mylsmod
 | 
					                   target$ lsmod > /tmp/mylsmod
 | 
				
			||||||
                   target$ scp /tmp/mylsmod host:/tmp
 | 
					                   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.
 | 
					                           The above also works when cross compiling.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     "make localyesconfig" Similar to localmodconfig, except it will convert
 | 
					     "make localyesconfig" Similar to localmodconfig, except it will convert
 | 
				
			||||||
                           all module options to built in (=y) options.
 | 
					                           all module options to built in (=y) options. You can
 | 
				
			||||||
 | 
					                           also preserve modules by LMC_KEEP.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     "make kvmconfig"   Enable additional options for kvm guest kernel support.
 | 
					     "make kvmconfig"   Enable additional options for kvm guest kernel support.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +123,9 @@ help:
 | 
				
			||||||
	@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
 | 
						@echo  '  gconfig	  - Update current config utilising a GTK+ based front-end'
 | 
				
			||||||
	@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
 | 
						@echo  '  oldconfig	  - Update current config utilising a provided .config as base'
 | 
				
			||||||
	@echo  '  localmodconfig  - Update current config disabling modules not loaded'
 | 
						@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  '  localyesconfig  - Update current config converting local mods to core'
 | 
				
			||||||
 | 
						@echo  '                    except those preserved by LMC_KEEP environment variable'
 | 
				
			||||||
	@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
 | 
						@echo  '  defconfig	  - New config with default from ARCH supplied defconfig'
 | 
				
			||||||
	@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
 | 
						@echo  '  savedefconfig   - Save current config as ./defconfig (minimal config)'
 | 
				
			||||||
	@echo  '  allnoconfig	  - New config where all options are answered with no'
 | 
						@echo  '  allnoconfig	  - New config where all options are answered with no'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -143,6 +143,7 @@ my %depends;
 | 
				
			||||||
my %selects;
 | 
					my %selects;
 | 
				
			||||||
my %prompts;
 | 
					my %prompts;
 | 
				
			||||||
my %objects;
 | 
					my %objects;
 | 
				
			||||||
 | 
					my %config2kfile;
 | 
				
			||||||
my $var;
 | 
					my $var;
 | 
				
			||||||
my $iflevel = 0;
 | 
					my $iflevel = 0;
 | 
				
			||||||
my @ifdeps;
 | 
					my @ifdeps;
 | 
				
			||||||
| 
						 | 
					@ -201,6 +202,7 @@ sub read_kconfig {
 | 
				
			||||||
	if (/^\s*(menu)?config\s+(\S+)\s*$/) {
 | 
						if (/^\s*(menu)?config\s+(\S+)\s*$/) {
 | 
				
			||||||
	    $state = "NEW";
 | 
						    $state = "NEW";
 | 
				
			||||||
	    $config = $2;
 | 
						    $config = $2;
 | 
				
			||||||
 | 
						    $config2kfile{"CONFIG_$config"} = $kconfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    # Add depends for 'if' nesting
 | 
						    # Add depends for 'if' nesting
 | 
				
			||||||
	    for (my $i = 0; $i < $iflevel; $i++) {
 | 
						    for (my $i = 0; $i < $iflevel; $i++) {
 | 
				
			||||||
| 
						 | 
					@ -591,6 +593,20 @@ while ($repeat) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my %setconfigs;
 | 
					my %setconfigs;
 | 
				
			||||||
 | 
					my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sub in_preserved_kconfigs {
 | 
				
			||||||
 | 
					    my $kconfig = $config2kfile{$_[0]};
 | 
				
			||||||
 | 
					    if (!defined($kconfig)) {
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    foreach my $excl (@preserved_kconfigs) {
 | 
				
			||||||
 | 
					        if($kconfig =~ /^$excl/) {
 | 
				
			||||||
 | 
					            return 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Finally, read the .config file and turn off any module enabled that
 | 
					# Finally, read the .config file and turn off any module enabled that
 | 
				
			||||||
# we could not find a reason to keep enabled.
 | 
					# we could not find a reason to keep enabled.
 | 
				
			||||||
| 
						 | 
					@ -644,6 +660,11 @@ foreach my $line (@config_file) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (/^(CONFIG.*)=(m|y)/) {
 | 
					    if (/^(CONFIG.*)=(m|y)/) {
 | 
				
			||||||
 | 
					        if (in_preserved_kconfigs($1)) {
 | 
				
			||||||
 | 
					            dprint "Preserve config $1";
 | 
				
			||||||
 | 
					            print;
 | 
				
			||||||
 | 
					            next;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
	if (defined($configs{$1})) {
 | 
						if (defined($configs{$1})) {
 | 
				
			||||||
	    if ($localyesconfig) {
 | 
						    if ($localyesconfig) {
 | 
				
			||||||
	        $setconfigs{$1} = 'y';
 | 
						        $setconfigs{$1} = 'y';
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue