Blame SOURCES/merge.pl

9713b0
#! /usr/bin/perl
9713b0
9713b0
my @args=@ARGV;
9713b0
my %configvalues;
9713b0
my @configoptions;
9713b0
my $configcounter = 0;
9713b0
9713b0
# optionally print out the architecture as the first line of our output
9713b0
my $arch = $args[2];
9713b0
if (defined $arch) {
9713b0
	print "# $arch\n";
9713b0
}
9713b0
9713b0
# first, read the override file
9713b0
9713b0
open (FILE,"$args[0]") || die "Could not open $args[0]";
9713b0
while (<FILE>) {
9713b0
	my $str = $_;
9713b0
	my $configname;
9713b0
9713b0
	if (/\# ([\w]+) is not set/) {
9713b0
		$configname = $1;
9713b0
	} elsif (/^\#/) {
9713b0
		# fall through on comments like 'avoid CONFIG_FOO=y'
9713b0
		;
9713b0
	} elsif (/([\w]+)=/) {
9713b0
		$configname = $1;
9713b0
	}
9713b0
9713b0
	if (defined($configname) && !exists($configvalues{$configname})) {
9713b0
		$configvalues{$configname} = $str;
9713b0
		$configoptions[$configcounter] = $configname;
9713b0
		$configcounter ++;
9713b0
	}
9713b0
};
9713b0
9713b0
# now, read and output the entire configfile, except for the overridden
9713b0
# parts... for those the new value is printed.
9713b0
9713b0
open (FILE2,"$args[1]") || die "Could not open $args[1]";
9713b0
while (<FILE2>) {
9713b0
	my $configname;
9713b0
9713b0
	if (/\# ([\w]+) is not set/) {
9713b0
		$configname = $1;
9713b0
	} elsif (/^\#/) {
9713b0
		# fall through on comments like 'avoid CONFIG_FOO=y'
9713b0
		;
9713b0
	} elsif (/([\w]+)=/) {
9713b0
		$configname  = $1;
9713b0
	}
9713b0
9713b0
	if (defined($configname) && exists($configvalues{$configname})) {
9713b0
		print "$configvalues{$configname}";
9713b0
		delete($configvalues{$configname});
9713b0
	} else {
9713b0
		print "$_";
9713b0
	}
9713b0
}
9713b0
9713b0
# now print the new values from the overridden configfile
9713b0
my $counter = 0;
9713b0
9713b0
while ($counter < $configcounter) {
9713b0
	my $configname = $configoptions[$counter];
9713b0
	if (exists($configvalues{$configname})) {
9713b0
		print "$configvalues{$configname}";
9713b0
	}
9713b0
	$counter++;
9713b0
}
9713b0
9713b0
1;