From ddaceef5111d03c3057a24d900aa90aad448ea1e Mon Sep 17 00:00:00 2001 From: Troy Kisky <troy.kisky@boundarydevices.com> Date: Tue, 18 Apr 2017 20:42:49 -0700 Subject: [PATCH] boundary_insert: add script to add CONFIG to all boundary boards boundary_insert: make more resilient Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- boundary_insert | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 boundary_insert diff --git a/boundary_insert b/boundary_insert new file mode 100755 index 00000000000..0cb73a252a0 --- /dev/null +++ b/boundary_insert @@ -0,0 +1,76 @@ +#!/bin/bash +# syntax ./boundary_insert CONFIG_1 CONFIG_2 ... CONFIG_n + +insert_configs=$*; +boards=`ls -d board/boundary/* | sed 's.board/boundary/..'`; + +numboards=0; +numsuccess=0; +numfailures=0; +skipped=0; +for board in ${boards} ; do + update_cnt=0; + already_there=0; + if [ -e board/boundary/${board}/Kconfig ] ; then + target=`grep TARGET_ board/boundary/${board}/Kconfig | sed 's.if ..'`; + defconfigs=`git grep -w CONFIG_${target} configs/ | sed 's.configs/..'| sed 's/_defconfig:.*$//'`; + else + defconfigs=""; + fi + board_cfgs=":" + for defconfig in ${defconfigs} ; do + cfgs="" + for insert_config in ${insert_configs} ; do + cnt=`sed -n "/${insert_config}=/=" configs/${defconfig}_defconfig` + if [ "${cnt}" != "" ] ; then + already_there=`expr $already_there + 1`; + else + cfgs="${cfgs} ${insert_config}" + fi + done + + if [ "${cfgs}" != "" ] ; then + make ${defconfig}_defconfig; + for insert_config in ${cfgs} ; do + echo "${insert_config}=y" >>.config; + done + make savedefconfig; + diff -q defconfig configs/${defconfig}_defconfig; + if [ $? -eq 0 ] ; then + already_there=`expr $already_there + 1`; + else + if [ $? -eq 1 ] ; then + cp defconfig configs/${defconfig}_defconfig; + echo updated ${defconfig}_defconfig; + git update-index configs/${defconfig}_defconfig; + update_cnt=`expr $update_cnt + 1`; + for insert_config in ${cfgs} ; do + if [ `expr "${board_cfgs}" : "[A-Z0-9_:]*:${insert_config}:"` -eq 0 ] ; then + cnt=`sed -n "/${insert_config}=/=" configs/${defconfig}_defconfig` + if [ "${cnt}" != "" ] ; then + board_cfgs="${board_cfgs}:${insert_config}:" + fi + fi + done + else + numfailures=`expr $numfailures + 1`; + echo -e "\n\n\n!!!!!!!! insert failure for ${defconfig}_defconfig !!!!!!!!!!!!\n\n"; + read line; + fi + fi + fi + done + if [ ${update_cnt} != "0" ] ; then + echo "${board}: ${update_cnt} defconfigs updated, ${already_there} already there"; + numsuccess=`expr $numsuccess + 1`; + if [ ${board_cfgs} != ":" ] ; then + git c -m"${board}: add ${board_cfgs//::/ } to defconfigs"; + else + git c -m"${board}: reorder defconfigs"; + fi + else + skipped=`expr $skipped + 1`; + fi + numboards=`expr $numboards + 1`; +done +echo "\n\ninsert for ${numboards} boards. ${numsuccess} succeeded and ${numfailures} failed, ${skipped} skipped"; -- GitLab