]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - kernel/scripts/merge.pl
kernel: Update to Linux 3.2.
[people/arne_f/ipfire-3.x.git] / kernel / scripts / merge.pl
CommitLineData
4c928ab7
MT
1#! /usr/bin/perl
2
3my @args=@ARGV;
4my %configvalues;
5my @configoptions;
6my $configcounter = 0;
7
8# optionally print out the architecture as the first line of our output
9my $arch = $args[2];
10if (defined $arch) {
11 print "# $arch\n";
12}
13
14# first, read the override file
15
16open (FILE,"$args[0]") || die "Could not open $args[0]";
17while (<FILE>) {
18 my $str = $_;
19 my $configname;
20
21 if (/\# ([\w]+) is not set/) {
22 $configname = $1;
23 } elsif (/([\w]+)=/) {
24 $configname = $1;
25 }
26
27 if (defined($configname) && !exists($configvalues{$configname})) {
28 $configvalues{$configname} = $str;
29 $configoptions[$configcounter] = $configname;
30 $configcounter ++;
31 }
32};
33
34# now, read and output the entire configfile, except for the overridden
35# parts... for those the new value is printed.
36
37open (FILE2,"$args[1]") || die "Could not open $args[1]";
38while (<FILE2>) {
39 my $configname;
40
41 if (/\# ([\w]+) is not set/) {
42 $configname = $1;
43 } elsif (/([\w]+)=/) {
44 $configname = $1;
45 }
46
47 if (defined($configname) && exists($configvalues{$configname})) {
48 print "$configvalues{$configname}";
49 delete($configvalues{$configname});
50 } else {
51 print "$_";
52 }
53}
54
55# now print the new values from the overridden configfile
56my $counter = 0;
57
58while ($counter < $configcounter) {
59 my $configname = $configoptions[$counter];
60 if (exists($configvalues{$configname})) {
61 print "$configvalues{$configname}";
62 }
63 $counter++;
64}
65
661;