1#!/bin/sh 2# Copyright (c) 2016 Google, Inc 3# Written by Simon Glass <sjg@chromium.org> 4# 5# Check that the u-boot.cfg file provided does not introduce any new 6# ad-hoc CONFIG options 7# 8# You can generate the list of current ad-hoc CONFIG options (those which are 9# not in Kconfig) with this command: 10# 11# export LC_ALL=C LC_COLLATE=C 12# git grep CONFIG_ |tr ' \t' '\n\n' |sed -n 's/^\(CONFIG_[A-Z0-9_]*\).*/\1/p' \ 13# |sort |uniq >scripts/config_whitelist.txt; 14# unset LC_ALL LC_COLLATE 15 16# Usage 17# check-config.sh <path to u-boot.cfg> <path to whitelist file> <source dir> 18# 19# For example: 20# scripts/check-config.sh b/chromebook_link/u-boot.cfg kconfig_whitelist.txt . 21 22path="$1" 23whitelist="$2" 24srctree="$3" 25 26# Temporary files 27configs="${path}.configs" 28suspects="${path}.suspects" 29ok="${path}.ok" 30new_adhoc="${path}.adhoc" 31 32export LC_ALL=C 33export LC_COLLATE=C 34 35cat ${path} |sed -n 's/^#define \(CONFIG_[A-Za-z0-9_]*\).*/\1/p' |sort |uniq \ 36 >${configs} 37 38comm -23 ${configs} ${whitelist} > ${suspects} 39 40cat `find ${srctree} -name "Kconfig*"` |sed -n \ 41 -e 's/^config *\([A-Za-z0-9_]*\).*$/CONFIG_\1/p' \ 42 -e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok} 43comm -23 ${suspects} ${ok} >${new_adhoc} 44if [ -s ${new_adhoc} ]; then 45 echo "Error: You must add new CONFIG options using Kconfig" 46 echo "The following new ad-hoc CONFIG options were detected:" 47 cat ${new_adhoc} 48 echo 49 echo "Please add these via Kconfig instead. Find a suitable Kconfig" 50 echo "file and add a 'config' or 'menuconfig' option." 51 # Don't delete the temporary files in case they are useful 52 exit 1 53else 54 rm ${suspects} ${ok} ${new_adhoc} 55fi 56