Home Home > GIT Browse
summaryrefslogtreecommitdiff
blob: 2083a6c45342fc4ac3433ff08f0bfe302768e2e8 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/perl -w

#############################################################################
# Copyright (c) 2007 Novell, Inc.
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail,
# you may find current contact information at www.novell.com
#############################################################################

if (@ARGV < 2) {
    print STDERR "Usage: $0 <config1> <config2> [<config3>]\n";
    print STDERR "Diff kernel config files config1 and config2, or " .
		 "apply those differences to config3\n";
    exit 1;
}

open CONFIG1, $ARGV[0]
    or die $ARGV[0] . ": $!\n";
while (<CONFIG1>) {
    next unless /^(CONFIG_\w+)/a || /^# (CONFIG_\w+) is not set/a;
    $config1{$1} = $_;
}

open CONFIG2, $ARGV[1]
    or die $ARGV[1] . ": $!\n";
while (<CONFIG2>) {
    next unless /^(CONFIG_\w+)/a || /^# (CONFIG_\w+) is not set/a;
    $config2{$1} = $_;
}

while (($key, $value) = each %config2) {
    if (!exists $config1{$key} || $config1{$key} ne $value) {
	$diff{$key} = $value;
    }
}

if (@ARGV >= 3) {
    open OLD, $ARGV[2]
	or die $ARGV[2] . ": $!\n";
    while (<OLD>) {
	if (/^(CONFIG_\w+)/a || /^# (CONFIG_\w+) is not set/a) {
	    if (exists $diff{$1}) {
		print $diff{$1};
		$diff_used{$1} = 1;
		next;
   	    }
	}
	print;
    }
}

foreach my $key (sort(keys(%diff))) {
    next if exists $diff_used{$key};
    print $diff{$key};
}