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
18*c211ae9cSPaul E. McKenneyT="`mktemp -d ${TMPDIR-/tmp}/configinit.sh.XXXXXX`"
19c87b9c60SPaul E. McKenneytrap 'rm -rf $T' 0
20c87b9c60SPaul E. McKenney
21c87b9c60SPaul E. McKenney# Capture config spec file.
22c87b9c60SPaul E. McKenney
23c87b9c60SPaul E. McKenneyc=$1
246dc82595SPaul E. McKenneyresdir=$2
25c87b9c60SPaul E. McKenney
26c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*\)=.*$/grep -v "^# \1" |/' < $c > $T/u.sh
27c87b9c60SPaul E. McKenneysed -e 's/^\(CONFIG[0-9A-Z_]*=\).*$/grep -v \1 |/' < $c >> $T/u.sh
28c87b9c60SPaul E. McKenneygrep '^grep' < $T/u.sh > $T/upd.sh
29c87b9c60SPaul E. McKenneyecho "cat - $c" >> $T/upd.sh
30b93c765fSPaul E. McKenneyif test -z "$TORTURE_TRUST_MAKE"
31b93c765fSPaul E. McKenneythen
326dc82595SPaul E. McKenney	make clean > $resdir/Make.clean 2>&1
33b93c765fSPaul E. McKenneyfi
34603d11adSMarco Elvermake $TORTURE_KMAKE_ARG $TORTURE_DEFCONFIG > $resdir/Make.defconfig.out 2>&1
356dc82595SPaul E. McKenneymv .config .config.sav
366dc82595SPaul E. McKenneysh $T/upd.sh < .config.sav > .config
376dc82595SPaul E. McKenneycp .config .config.new
38603d11adSMarco Elveryes '' | make $TORTURE_KMAKE_ARG oldconfig > $resdir/Make.oldconfig.out 2> $resdir/Make.oldconfig.err
39c87b9c60SPaul E. McKenney
40c87b9c60SPaul E. McKenney# verify new config matches specification.
416dc82595SPaul E. McKenneyconfigcheck.sh .config $c
42c87b9c60SPaul E. McKenney
43c87b9c60SPaul E. McKenneyexit 0
44