summaryrefslogtreecommitdiff
path: root/debian/scripts/misc/kernelconfig
blob: aa74e20c1809a2da6ce249a07a6d38d200ee2dea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash

. debian/debian.env

# Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
# Then split the configs into distro-commmon and flavour-specific parts

# We have to be in the top level kernel source directory
if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
	echo "This does not appear to be the kernel source directory." 1>&2
	exit 1
fi

mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
case "$mode" in
    oldconfig)  ;; # All is good
    defaultconfig)  ;; # All is good
    editconfig) ;; # All is good
    genconfig)  ;; # All is good
    *) echo "$0 called with invalid mode" 1>&2
       exit 1 ;;
esac
kerneldir="`pwd`"
confdir="$kerneldir/${DEBIAN}/config"
sharedconfdir="$kerneldir/debian.linaro/config"
variant="$2"

. $DEBIAN/etc/kernelconfig

bindir="`pwd`/${DROOT}/scripts/misc"
common_conf="$confdir/config.common.$family"
tmpdir=`mktemp -d`
mkdir "$tmpdir/CONFIGS"

if [ "$mode" = "genconfig" ]; then
	keep=1
	mode="oldconfig"
	test -d CONFIGS || mkdir CONFIGS
fi

for arch in $archs; do
	rm -rf build
	mkdir build

	# Map debian archs to kernel archs
	case "$arch" in
		amd64)	kernarch="x86_64"	;;
		lpia)   kernarch="x86" 		;;
		sparc)	kernarch="sparc64"	;;
		armel)	kernarch="arm"		;;
		*)	kernarch="$arch"	;;
	esac

	archconfdir=$confdir/$arch
	flavourconfigs=$(cd $archconfdir && ls config.flavour.*)

	# Merge configs
	# We merge config.common.ubuntu + config.common.<arch> +
	# config.flavour.<flavour>

	for config in $flavourconfigs; do
		fullconf="$tmpdir/$arch-$config-full"
		case $config in
		*)
			: >"$fullconf"
			if [ -f $common_conf ]; then
				cat $common_conf >> "$fullconf"
			fi
			if [ -f $archconfdir/config.common.$arch ]; then
				cat $archconfdir/config.common.$arch >> "$fullconf"
			fi
			cat "$archconfdir/$config" >>"$fullconf"
			if [ -f $confdir/OVERRIDES ]; then
				cat $confdir/OVERRIDES >> "$fullconf"
			fi
			;;
		esac
	done

	for config in $flavourconfigs; do
		if [ -f $archconfdir/$config ]; then
			fullconf="$tmpdir/$arch-$config-full"
			cat "$fullconf" > build/.config
			# Call oldconfig or menuconfig
			case "$mode" in
			    oldconfig)
				# Weed out incorrect config parameters
				echo "* Run silentoldconfig on $arch/$config ..."
				make O=`pwd`/build ARCH=$kernarch silentoldconfig ;;
			    defaultconfig)
				# Weed out incorrect config parameters
				echo "* Run oldconfig on $arch/$config ..."
				make O=`pwd`/build ARCH=$kernarch oldconfig ;;
			    editconfig)
				# Interactively edit config parameters
				while : ; do
					echo -n "Do you want to edit config: $arch/$config? [Y/n] "
					read choice

					case "$choice" in
					y* | Y* | "" )
						make O=`pwd`/build ARCH=$kernarch menuconfig
						break ;;
					n* | N* )
						break ;;
					*)
						echo "Entry not valid"
					esac
				done
				;;
			    *)  # Bad!
				exit 1 ;;
			esac
			cat build/.config > $archconfdir/$config
			cat build/.config > "$tmpdir/CONFIGS/$arch-$config"
			if [ "$keep" = "1" ]; then
				cat build/.config > CONFIGS/$arch-$config
			fi
		else
			echo "!! Config not found $archconfdir/$config..."
		fi
	done

	echo "Running splitconfig.pl for $arch"
	echo

	# Can we make this more robust by avoiding $tmpdir completely?
	# This approach was used for now because I didn't want to change
	# splitconfig.pl
	(cd $archconfdir; $bindir/splitconfig.pl; mv config.common \
	 config.common.$arch; cp config.common.$arch $tmpdir)
done

rm -f $common_conf

# Now run splitconfig.pl on all the config.common.<arch> copied to
# $tmpdir
(cd $tmpdir; $bindir/splitconfig.pl)
(
	cd $confdir;
	rm -f *-full
	grep -v 'is UNMERGABLE' <$tmpdir/config.common >$common_conf
	for arch in $archs; do
		grep -v 'is UNMERGABLE' <$tmpdir/config.common.$arch \
			>$arch/config.common.$arch
	done
)

echo ""
echo "Running config-check for all configurations ..."
echo ""
fail=0
for arch in $archs; do
	archconfdir=$confdir/$arch
	flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
	for config in $flavourconfigs; do
		if [ -f $archconfdir/$config ]; then
			fullconf="$tmpdir/CONFIGS/$arch-$config"
			"$bindir/../config-check" "$fullconf" "$arch" "$config" "$sharedconfdir" "0" || let "fail=$fail+1"
		fi
	done
done

if [ "$fail" != 0 ]; then
	echo ""
	echo "*** ERROR: $fail config-check failures detected"
	echo ""
fi

rm -rf build