11a5e31fbSPranith Kumar#!/bin/bash 2fef141f6SPaul E. McKenney# SPDX-License-Identifier: GPL-2.0+ 3c87b9c60SPaul E. McKenney# 46dc82595SPaul E. McKenney# Usage: configinit.sh config-spec-file results-dir 5c87b9c60SPaul E. McKenney# 6c87b9c60SPaul E. McKenney# Create a .config file from the spec file. Run from the kernel source tree. 7c87b9c60SPaul E. McKenney# Exits with 0 if all went well, with 1 if all went well but the config 8c87b9c60SPaul E. McKenney# did not match, and some other number for other failures. 9c87b9c60SPaul E. McKenney# 10c87b9c60SPaul E. McKenney# The first argument is the .config specification file, which contains 11c87b9c60SPaul E. McKenney# desired settings, for example, "CONFIG_NO_HZ=y". For best results, 12c87b9c60SPaul E. McKenney# this should be a full pathname. 13c87b9c60SPaul E. McKenney# 140e342a87SPaul E. McKenney# Copyright (C) IBM Corporation, 2013 150e342a87SPaul E. McKenney# 16fef141f6SPaul E. McKenney# Authors: Paul E. McKenney <paulmck@linux.ibm.com> 17c87b9c60SPaul E. McKenney 18b038c58bSPaul E. McKenneyT=${TMPDIR-/tmp}/configinit.sh.$$ 19c87b9c60SPaul E. McKenneytrap 'rm -rf $T' 0 20c87b9c60SPaul E. McKenneymkdir $T 21c87b9c60SPaul E. McKenney 22c87b9c60SPaul E. McKenney# Capture config spec file. 23c87b9c60SPaul E. McKenney 24c87b9c60SPaul E. McKenneyc=$1 256dc82595SPaul E. McKenneyresdir=$2 26c87b9c60SPaul E. McKenney 27c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh 28c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh 29c87b9c60SPaul E. McKenneygrep '^grep' < $T/u.sh > $T/upd.sh 30c87b9c60SPaul E. McKenneyecho "cat - $c" >> $T/upd.sh 31b93c765fSPaul E. McKenneyif test -z "$TORTURE_TRUST_MAKE" 32b93c765fSPaul E. McKenneythen 336dc82595SPaul E. McKenney make clean > $resdir/Make.clean 2>&1 34b93c765fSPaul E. McKenneyfi 356dc82595SPaul E. McKenneymake $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1 366dc82595SPaul E. McKenneymv .config .config.sav 376dc82595SPaul E. McKenneysh $T/upd.sh < .config.sav > .config 386dc82595SPaul E. McKenneycp .config .config.new 396dc82595SPaul E. McKenneyyes '' | make oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err 40c87b9c60SPaul E. McKenney 41c87b9c60SPaul E. McKenney# verify new config matches specification. 426dc82595SPaul E. McKenneyconfigcheck.sh .config $c 43c87b9c60SPaul E. McKenney 44c87b9c60SPaul E. McKenneyexit 0 45