Avoid triggering autovivification of %config entries, which would result in

an empty addenda section.

Handle kernel configs that lack a "machine" line by guessing at the location
of GENERIC (assuming that it is in the same directory as the config file)
This commit is contained in:
Dag-Erling Smørgrav 2006-01-30 10:46:01 +00:00
parent 9e6b35bff3
commit 5b5139a9da

View file

@ -46,7 +46,6 @@ MAIN:{
chomp();
s/\s*(\#.*)?$//;
next unless $_;
#print("$_\n");
my ($keyword, $values) = split(' ', $_, 2);
foreach my $value (split(/,\s*/, $values)) {
if ($keyword eq 'machine') {
@ -61,7 +60,12 @@ MAIN:{
}
}
my $generic = "/usr/src/sys/$machine/conf/GENERIC";
my $generic;
if ($machine) {
$generic = "/usr/src/sys/$machine/conf/GENERIC";
} else {
($generic = $ARGV) =~ s|([^/])+$|GENERIC|;
}
local *GENERIC;
open(GENERIC, "<", $generic)
or die("$generic: $!\n");
@ -87,7 +91,7 @@ MAIN:{
} elsif ($keyword eq 'ident') {
$line =~ s/$value/$ident/;
} elsif ($keyword eq 'options' && $value =~ m/(\w+)=(.+)/ &&
defined($config{$keyword}->{$1}) &&
$config{$keyword} && $config{$keyword}->{$1} &&
$config{$keyword}->{$1} != \&EMPTY) {
$value = $1;
if ($config{$keyword}->{$value} ne $2) {
@ -97,7 +101,7 @@ MAIN:{
delete($config{$keyword}->{$value});
delete($config{$keyword})
unless %{$config{$keyword}};
} elsif (defined($config{$keyword}->{$value})) {
} elsif ($config{$keyword} && $config{$keyword}->{$value}) {
delete($config{$keyword}->{$value});
delete($config{$keyword})
unless %{$config{$keyword}};