xref: /linux/tools/testing/selftests/rcutorture/bin/config_override.sh (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# config_override.sh base override
5#
6# Combines base and override, removing any Kconfig options from base
7# that conflict with any in override, concatenating what remains and
8# sending the result to standard output.
9#
10# Copyright (C) IBM Corporation, 2017
11#
12# Authors: Paul E. McKenney <paulmck@linux.ibm.com>
13
14base=$1
15if test -r $base
16then
17	:
18else
19	echo Base file $base unreadable!!!
20	exit 1
21fi
22
23override=$2
24if test -r $override
25then
26	:
27else
28	echo Override file $override unreadable!!!
29	exit 1
30fi
31
32T=${TMPDIR-/tmp}/config_override.sh.$$
33trap 'rm -rf $T' 0
34mkdir $T
35
36sed < $override -e 's/^/grep -v "/' -e 's/=.*$/="/' |
37	awk '
38	{
39		if (last)
40			print last " |";
41		last = $0;
42	}
43	END {
44		if (last)
45			print last;
46	}' > $T/script
47sh $T/script < $base
48cat $override
49