Something like (untested, may not even compile):
my %config_settings = (
CONFIG_NET => 'y',
CONFIG_HOTPLUG => 'y',
# whatever else you want to set
)
open(KERNEL_CONFIG, '<', '/usr/src/linux2.4/.config');
open(NEW_CONFIG, '>', '/usr/src/linux2.4/.config.new');
while my $config_line (<KERNEL_CONFIG>) {
$config_line =~ /([A-Z0-9_])/;
$config_line = $1 . '=' . $config_settings{$1} . "\n" if exists $con
+fig_settings{$1};
print NEW_CONFIG $config_line;
}
close KERNEL_CONFIG;
This will (well, should...) create a new configuration in .config.new with the entries given in %config_settings changed to match the settings in the hash and all other lines left untouched. After verifying the results, you can then just rename .config.new to .config and you should be ready to rebuild the kernel.
Update: Initially forgot to include the \n when constructing a new $config_line. |