This is an automated email from the ASF dual-hosted git repository. gnutt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 4bd4f3b4246073d7e4450c7bc01fe45a549e4915 Author: Xiang Xiao <xiaoxi...@xiaomi.com> AuthorDate: Thu Jan 23 04:07:43 2020 +0800 tools/refresh.sh: support to refresh all configuration by pseudo config --- tools/refresh.sh | 231 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 120 insertions(+), 111 deletions(-) diff --git a/tools/refresh.sh b/tools/refresh.sh index 6f1f495..e08e963 100755 --- a/tools/refresh.sh +++ b/tools/refresh.sh @@ -37,7 +37,7 @@ WD=`test -d ${0%/*} && cd ${0%/*}; pwd` USAGE="USAGE: $0 [options] <board>:<config>" ADVICE="Try '$0 --help' for more information" -unset CONFIG +unset CONFIGS silent=n defaults=n prompt=y @@ -80,40 +80,17 @@ while [ ! -z "$1" ]; do echo " The board directory under nuttx/boards" echo " <config>" echo " The board configuration directory under nuttx/boards/<board>/configs" + echo " Note: all configuration is refreshed if <board>:<config> equals all." exit 0 ;; * ) - CONFIG=$1 + CONFIGS=$1 break ;; esac shift done -# Get the board configuration - -if [ -z "${CONFIG}" ]; then - echo "ERROR: No configuration provided" - echo $USAGE - echo $ADVICE - exit 1 -fi - -CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d':' -f2` -if [ -z "${CONFIGSUBDIR}" ]; then - CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d'/' -f2` - if [ -z "${CONFIGSUBDIR}" ]; then - echo "ERROR: Malformed configuration: ${CONFIG}" - echo $USAGE - echo $ADVICE - exit 1 - else - BOARDSUBDIR=`echo ${CONFIG} | cut -d'/' -f1` - fi -else - BOARDSUBDIR=`echo ${CONFIG} | cut -d':' -f1` -fi - # Where are we MYNAME=`basename $0` @@ -127,15 +104,7 @@ if [ ! -x tools/${MYNAME} ] ; then exit 1 fi -# Set up the environment - -BOARDDIR=boards/*/*/$BOARDSUBDIR -SCRIPTSDIR=$BOARDDIR/scripts -MAKEDEFS1=$SCRIPTSDIR/Make.defs - -CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR -DEFCONFIG=$CONFIGDIR/defconfig -MAKEDEFS2=$CONFIGDIR/Make.defs +# If the cmpconfig executable does not exist, then build it CMPCONFIG_TARGET=cmpconfig CMPCONFIG1=tools/cmpconfig @@ -143,36 +112,6 @@ CMPCONFIG2=tools/cmpconfig.exe CMPCONFIGMAKEFILE=Makefile.host CMPCONFIGMAKEDIR=tools -# Check the board configuration directory - -if [ ! -d $BOARDDIR ]; then - echo "No board directory found at $BOARDDIR" - exit 1 -fi - -if [ ! -d $CONFIGDIR ]; then - echo "No configuration directory found at $CONFIGDIR" - exit 1 -fi - -if [ ! -r $DEFCONFIG ]; then - echo "No readable defconfig file at $DEFCONFIG" - exit 1 -fi - -if [ -r $MAKEDEFS1 ]; then - MAKEDEFS=$MAKEDEFS1 -else - if [ -r $MAKEDEFS2 ]; then - MAKEDEFS=$MAKEDEFS2 - else - echo "No readable Make.defs file at $MAKEDEFS1 or $MAKEDEFS2" - exit 1 - fi -fi - -# If the cmpconfig executable does not exist, then build it - if [ -x ${CMPCONFIG1} ]; then CMPCONFIG=${CMPCONFIG1} else @@ -195,70 +134,140 @@ else fi fi -# Copy the .config and Make.defs to the toplevel directory +# Get the board configuration + +if [ -z "${CONFIGS}" ]; then + echo "ERROR: No configuration provided" + echo $USAGE + echo $ADVICE + exit 1 +fi -rm -f SAVEconfig -if [ -e .config ]; then - mv .config SAVEconfig || \ - { echo "ERROR: Failed to move .config to SAVEconfig"; exit 1; } +if [ "X${CONFIGS}" == "Xall" ]; then + CONFIGS=`find boards -name defconfig | cut -d'/' -f4,6` fi -cp -a $DEFCONFIG .config || \ - { echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; } +for CONFIG in ${CONFIGS}; do + echo "Refresh ${CONFIG}" -rm -f SAVEMake.defs -if [ -e Make.defs ]; then - mv Make.defs SAVEMake.defs || \ - { echo "ERROR: Failed to move Make.defs to SAVEMake.defs"; exit 1; } -fi + # Set up the environment -cp -a $MAKEDEFS Make.defs || \ - { echo "ERROR: Failed to copy $MAKEDEFS to Make.defs"; exit 1; } + CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d':' -f2` + if [ -z "${CONFIGSUBDIR}" ]; then + CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d'/' -f2` + if [ -z "${CONFIGSUBDIR}" ]; then + echo "ERROR: Malformed configuration: ${CONFIG}" + echo $USAGE + echo $ADVICE + exit 1 + else + BOARDSUBDIR=`echo ${CONFIG} | cut -d'/' -f1` + fi + else + BOARDSUBDIR=`echo ${CONFIG} | cut -d':' -f1` + fi -# Then run oldconfig or oldefconfig + BOARDDIR=boards/*/*/$BOARDSUBDIR + SCRIPTSDIR=$BOARDDIR/scripts + MAKEDEFS1=$SCRIPTSDIR/Make.defs -if [ "X${defaults}" == "Xy" ]; then - make olddefconfig -else - make oldconfig -fi + CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR + DEFCONFIG=$CONFIGDIR/defconfig + MAKEDEFS2=$CONFIGDIR/Make.defs -# Run savedefconfig to create the new defconfig file + # Check the board configuration directory -make savedefconfig + if [ ! -d $BOARDDIR ]; then + echo "No board directory found at $BOARDDIR" + exit 1 + fi -# Show differences + if [ ! -d $CONFIGDIR ]; then + echo "No configuration directory found at $CONFIGDIR" + exit 1 + fi + + if [ ! -r $DEFCONFIG ]; then + echo "No readable defconfig file at $DEFCONFIG" + exit 1 + fi -# sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" defconfig -$CMPCONFIG $DEFCONFIG defconfig + if [ -r $MAKEDEFS1 ]; then + MAKEDEFS=$MAKEDEFS1 + else + if [ -r $MAKEDEFS2 ]; then + MAKEDEFS=$MAKEDEFS2 + else + echo "No readable Make.defs file at $MAKEDEFS1 or $MAKEDEFS2" + exit 1 + fi + fi + + # Copy the .config and Make.defs to the toplevel directory + + rm -f SAVEconfig + if [ -e .config ]; then + mv .config SAVEconfig || \ + { echo "ERROR: Failed to move .config to SAVEconfig"; exit 1; } + fi -# Save the refreshed configuration + cp -a $DEFCONFIG .config || \ + { echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; } -if [ "X${prompt}" == "Xy" ]; then - read -p "Save the new configuration (y/n)?" -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ ]] - then + rm -f SAVEMake.defs + if [ -e Make.defs ]; then + mv Make.defs SAVEMake.defs || \ + { echo "ERROR: Failed to move Make.defs to SAVEMake.defs"; exit 1; } + fi + + cp -a $MAKEDEFS Make.defs || \ + { echo "ERROR: Failed to copy $MAKEDEFS to Make.defs"; exit 1; } + + # Then run oldconfig or oldefconfig + + if [ "X${defaults}" == "Xy" ]; then + make olddefconfig + else + make oldconfig + fi + + # Run savedefconfig to create the new defconfig file + + make savedefconfig + + # Show differences + + # sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" defconfig + $CMPCONFIG $DEFCONFIG defconfig + + # Save the refreshed configuration + + if [ "X${prompt}" == "Xy" ]; then + read -p "Save the new configuration (y/n)?" -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]] + then + echo "Saving the new configuration file" + mv defconfig $DEFCONFIG || \ + { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; } + chmod 644 $DEFCONFIG + fi + else echo "Saving the new configuration file" mv defconfig $DEFCONFIG || \ { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; } chmod 644 $DEFCONFIG fi -else - echo "Saving the new configuration file" - mv defconfig $DEFCONFIG || \ - { echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; } - chmod 644 $DEFCONFIG -fi -# Restore any previous .config and Make.defs files + # Restore any previous .config and Make.defs files -if [ -e SAVEconfig ]; then - mv SAVEconfig .config || \ - { echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; } -fi + if [ -e SAVEconfig ]; then + mv SAVEconfig .config || \ + { echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; } + fi -if [ -e SAVEMake.defs ]; then - mv SAVEMake.defs Make.defs || \ - { echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; } -fi + if [ -e SAVEMake.defs ]; then + mv SAVEMake.defs Make.defs || \ + { echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; } + fi +done