Home Home > GIT Browse > SLE12-SP5
summaryrefslogtreecommitdiff
blob: c5766dfe41bda9fc66bf40b59a5cd812bd318c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w
use strict;

if (@ARGV < 2) {
	print STDERR "Usage: $0 <config1> <config2>\n";
	print STDERR "Merge kernel config files config1 and config2. " .
		     "Differences will be selected from config2.\n";
	exit 1;
}

my %config;
my @lines;

open CONFIG1, $ARGV[0]
    or die $ARGV[0] . ": $!\n";
while (<CONFIG1>) {
    push(@lines, $_);
    next unless /^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/;
    $config{$1} = $_;
}
close(CONFIG1);

open CONFIG2, $ARGV[1]
    or die $ARGV[1] . ": $!\n";
while (<CONFIG2>) {
    next unless /^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/;
    $config{$1} = $_;
}
close(CONFIG2);

foreach (@lines) {
    if (/^(CONFIG_[A-Za-z0-9_]+)/ || /^# (CONFIG_[A-Za-z0-9_]+) is not set/) {
	if (exists($config{$1})) {
	    print $config{$1};
	    delete $config{$1};
	}
    } else {
	print;
    }

}

foreach my $value (sort(values(%config))) {
	print $value;
}