1 #!/bin/bash 2 # 3 # config_override.sh base override 4 # 5 # Combines base and override, removing any Kconfig options from base 6 # that conflict with any in override, concatenating what remains and 7 # sending the result to standard output. 8 # 9 # This program is free software; you can redistribute it and/or modify 10 # it under the terms of the GNU General Public License as published by 11 # the Free Software Foundation; either version 2 of the License, or 12 # (at your option) any later version. 13 # 14 # This program is distributed in the hope that it will be useful, 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 # GNU General Public License for more details. 18 # 19 # You should have received a copy of the GNU General Public License 20 # along with this program; if not, you can access it online at 21 # http://www.gnu.org/licenses/gpl-2.0.html. 22 # 23 # Copyright (C) IBM Corporation, 2017 24 # 25 # Authors: Paul E. McKenney <paulmck (at] linux.vnet.ibm.com> 26 27 base=$1 28 if test -r $base 29 then 30 : 31 else 32 echo Base file $base unreadable!!! 33 exit 1 34 fi 35 36 override=$2 37 if test -r $override 38 then 39 : 40 else 41 echo Override file $override unreadable!!! 42 exit 1 43 fi 44 45 T=${TMPDIR-/tmp}/config_override.sh.$$ 46 trap 'rm -rf $T' 0 47 mkdir $T 48 49 sed < $override -e 's/^/grep -v "/' -e 's/=.*$/="/' | 50 awk ' 51 { 52 if (last) 53 print last " |"; 54 last = $0; 55 } 56 END { 57 if (last) 58 print last; 59 }' > $T/script 60 sh $T/script < $base 61 cat $override 62