xref: /linux/tools/testing/selftests/rcutorture/bin/config_override.sh (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
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="`mktemp -d ${TMPDIR-/tmp}/config_override.sh.XXXXXX`"
33trap 'rm -rf $T' 0
34
35sed < $override -e 's/^/grep -v "/' -e 's/=.*$/="/' |
36	awk '
37	{
38		if (last)
39			print last " |";
40		last = $0;
41	}
42	END {
43		if (last)
44			print last;
45	}' > $T/script
46sh $T/script < $base
47cat $override
48