summaryrefslogtreecommitdiffstats
path: root/configs/merge.pl
diff options
context:
space:
mode:
authorJustin M. Forbes <jforbes@fedoraproject.org>2020-08-12 08:03:24 -0500
committerJustin M. Forbes <jforbes@fedoraproject.org>2020-08-12 08:03:24 -0500
commit47a895f435cccb2cb14eb5d0c52d2f6d4d904907 (patch)
tree628be9cf983bcdfedd940131f8f7187020cff5f2 /configs/merge.pl
parent29d3f64f7e887d5cf9ae5f496febe5954fc49117 (diff)
downloadkernel-47a895f435cccb2cb14eb5d0c52d2f6d4d904907.tar.gz
kernel-47a895f435cccb2cb14eb5d0c52d2f6d4d904907.tar.xz
kernel-47a895f435cccb2cb14eb5d0c52d2f6d4d904907.zip
Linux v5.8.1
Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
Diffstat (limited to 'configs/merge.pl')
-rwxr-xr-xconfigs/merge.pl66
1 files changed, 66 insertions, 0 deletions
diff --git a/configs/merge.pl b/configs/merge.pl
new file mode 100755
index 000000000..8c318156a
--- /dev/null
+++ b/configs/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;