diff options
author | Richard Yao <ryao@gentoo.org> | 2014-08-17 18:04:49 -0400 |
---|---|---|
committer | Richard Yao <ryao@gentoo.org> | 2015-07-31 14:43:38 -0400 |
commit | 3b2a190062f6a15af1aba3565e9bdb8fcdc5056a (patch) | |
tree | f491af9701a05095171c99625f13e452e8d6dde7 /merge.pl | |
parent | Bump version to 3.4.51.4 (diff) | |
download | genkernel-3b2a190062f6a15af1aba3565e9bdb8fcdc5056a.tar.gz genkernel-3b2a190062f6a15af1aba3565e9bdb8fcdc5056a.tar.bz2 genkernel-3b2a190062f6a15af1aba3565e9bdb8fcdc5056a.zip |
Initial kernel config infrastructure
The merge.pl script and initial configuration files for ppc, ppc64 x86
and x86_64 are from RHEL6. The merge.pl is intended to be replaced in
the future. We will use it for now because Rick Farina of Gentoo QA
wants this merged regardless of whether we have a substitute ready or
not.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Diffstat (limited to 'merge.pl')
-rwxr-xr-x | merge.pl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/merge.pl b/merge.pl new file mode 100755 index 00000000..8c318156 --- /dev/null +++ b/merge.pl @@ -0,0 +1,66 @@ +#! /usr/bin/perl + +my @args=@ARGV; +my %configvalues; +my @configoptions; +my $configcounter = 0; + +# optionally print out the architecture as the first line of our output +my $arch = $args[2]; +if (defined $arch) { + print "# $arch\n"; +} + +# first, read the override file + +open (FILE,"$args[0]") || die "Could not open $args[0]"; +while (<FILE>) { + my $str = $_; + my $configname; + + if (/\# ([\w]+) is not set/) { + $configname = $1; + } elsif (/([\w]+)=/) { + $configname = $1; + } + + if (defined($configname) && !exists($configvalues{$configname})) { + $configvalues{$configname} = $str; + $configoptions[$configcounter] = $configname; + $configcounter ++; + } +}; + +# now, read and output the entire configfile, except for the overridden +# parts... for those the new value is printed. + +open (FILE2,"$args[1]") || die "Could not open $args[1]"; +while (<FILE2>) { + my $configname; + + if (/\# ([\w]+) is not set/) { + $configname = $1; + } elsif (/([\w]+)=/) { + $configname = $1; + } + + if (defined($configname) && exists($configvalues{$configname})) { + print "$configvalues{$configname}"; + delete($configvalues{$configname}); + } else { + print "$_"; + } +} + +# now print the new values from the overridden configfile +my $counter = 0; + +while ($counter < $configcounter) { + my $configname = $configoptions[$counter]; + if (exists($configvalues{$configname})) { + print "$configvalues{$configname}"; + } + $counter++; +} + +1; |