• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3RETVAL=0
4ARCHES="arm64 arm x86"
5if [ -z "$ANDROID_BUILD_TOP" ]; then
6	echo "ANDROID_BUILD_TOP not set, exiting"
7	exit 1
8fi
9AFRAGS="$ANDROID_BUILD_TOP/kernel/configs"
10KERNEL_VERSIONS=`ls -d $AFRAGS/android-* | xargs -n 1 basename`
11
12check_fragment()
13{
14	ERRORS=0
15
16	while read line; do
17		grep -q "$line" .config
18		if [ $? -ne 0 ]
19		then
20			echo "Error, $line not found in merged config."
21			ERRORS=1
22		fi
23	done < <(grep -v -E "^#  " $1)
24
25	if [ $ERRORS -ne 0 ]
26	then
27		echo "Errors encountered while checking $1"
28		RETVAL=1
29	else
30		echo "Fragment $1 is okay"
31	fi
32	echo ""
33}
34
35check_arches()
36{
37	for arch in $ARCHES; do
38		rm .config
39		make ARCH=$arch allnoconfig
40		FRAGMENTS="$AFRAGS/$version/android-base.config \
41			   $AFRAGS/$version/android-recommended.config"
42		if [ -f $AFRAGS/$version/android-base-$arch.config ]; then
43			FRAGMENTS="$FRAGMENTS $AFRAGS/$version/android-base-$arch.config"
44		fi
45		if [ -f $AFRAGS/$version/android-recommended-$arch.config ]; then
46			FRAGMENTS="$FRAGMENTS $AFRAGS/$version/android-recommended-$arch.config"
47		fi
48		ARCH=$arch scripts/kconfig/merge_config.sh .config $FRAGMENTS &> /dev/null
49		for f in $FRAGMENTS; do
50			check_fragment $f
51		done
52	done
53}
54
55check_configs()
56{
57	for version in $KERNEL_VERSIONS; do
58		echo "Changing to $KERNEL_PATH"
59		cd $KERNEL_PATH
60		git checkout $version
61		check_arches
62	done
63}
64
65show_help()
66{
67	cat << EOF
68Usage: ${0##*/} [-h] [-a arches] [-v versions] -k path-to-kernel
69Check that the kernel config fragments are consistent with the Kconfig files
70in the given kernel versions. This requires an android common kernel repo to
71be checked out and made available to this script via the -k option or the
72KERNEL_PATH environment variable. Note this script does not verify the
73configs in the conditional XML fragments.
74
75	-h		display this help and exit
76	-a arches	quote-enclosed whitespace separated list of
77                        architectures to check, valid architectures are
78			arm64, arm, and x86
79	-k kernel	path to android common kernel repo
80	-v versions	quote-enclosed whitespace separated list of
81			kernel versions to check (android-x.y)
82EOF
83}
84
85OPTIND=1
86while getopts "h?a:v:k:" opt; do
87	case "$opt" in
88		h|\?)
89			show_help
90			exit 0
91			;;
92		a)
93			ARCHES="$OPTARG"
94			;;
95		v)
96			KERNEL_VERSIONS="$OPTARG"
97			;;
98		k)
99			KERNEL_PATH="${OPTARG/#\~/$HOME}"
100			;;
101	esac
102done
103
104check_configs
105