mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
tools/refresh.sh: support to refresh all configuration by pseudo config
This commit is contained in:
+120
-111
@@ -37,7 +37,7 @@ WD=`test -d ${0%/*} && cd ${0%/*}; pwd`
|
|||||||
USAGE="USAGE: $0 [options] <board>:<config>"
|
USAGE="USAGE: $0 [options] <board>:<config>"
|
||||||
ADVICE="Try '$0 --help' for more information"
|
ADVICE="Try '$0 --help' for more information"
|
||||||
|
|
||||||
unset CONFIG
|
unset CONFIGS
|
||||||
silent=n
|
silent=n
|
||||||
defaults=n
|
defaults=n
|
||||||
prompt=y
|
prompt=y
|
||||||
@@ -80,40 +80,17 @@ while [ ! -z "$1" ]; do
|
|||||||
echo " The board directory under nuttx/boards"
|
echo " The board directory under nuttx/boards"
|
||||||
echo " <config>"
|
echo " <config>"
|
||||||
echo " The board configuration directory under nuttx/boards/<board>/configs"
|
echo " The board configuration directory under nuttx/boards/<board>/configs"
|
||||||
|
echo " Note: all configuration is refreshed if <board>:<config> equals all."
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
CONFIG=$1
|
CONFIGS=$1
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
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
|
# Where are we
|
||||||
|
|
||||||
MYNAME=`basename $0`
|
MYNAME=`basename $0`
|
||||||
@@ -127,15 +104,7 @@ if [ ! -x tools/${MYNAME} ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up the environment
|
# If the cmpconfig executable does not exist, then build it
|
||||||
|
|
||||||
BOARDDIR=boards/*/*/$BOARDSUBDIR
|
|
||||||
SCRIPTSDIR=$BOARDDIR/scripts
|
|
||||||
MAKEDEFS1=$SCRIPTSDIR/Make.defs
|
|
||||||
|
|
||||||
CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR
|
|
||||||
DEFCONFIG=$CONFIGDIR/defconfig
|
|
||||||
MAKEDEFS2=$CONFIGDIR/Make.defs
|
|
||||||
|
|
||||||
CMPCONFIG_TARGET=cmpconfig
|
CMPCONFIG_TARGET=cmpconfig
|
||||||
CMPCONFIG1=tools/cmpconfig
|
CMPCONFIG1=tools/cmpconfig
|
||||||
@@ -143,36 +112,6 @@ CMPCONFIG2=tools/cmpconfig.exe
|
|||||||
CMPCONFIGMAKEFILE=Makefile.host
|
CMPCONFIGMAKEFILE=Makefile.host
|
||||||
CMPCONFIGMAKEDIR=tools
|
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
|
if [ -x ${CMPCONFIG1} ]; then
|
||||||
CMPCONFIG=${CMPCONFIG1}
|
CMPCONFIG=${CMPCONFIG1}
|
||||||
else
|
else
|
||||||
@@ -195,70 +134,140 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the .config and Make.defs to the toplevel directory
|
# Get the board configuration
|
||||||
|
|
||||||
rm -f SAVEconfig
|
if [ -z "${CONFIGS}" ]; then
|
||||||
if [ -e .config ]; then
|
echo "ERROR: No configuration provided"
|
||||||
mv .config SAVEconfig || \
|
echo $USAGE
|
||||||
{ echo "ERROR: Failed to move .config to SAVEconfig"; exit 1; }
|
echo $ADVICE
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -a $DEFCONFIG .config || \
|
if [ "X${CONFIGS}" == "Xall" ]; then
|
||||||
{ echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; }
|
CONFIGS=`find boards -name defconfig | cut -d'/' -f4,6`
|
||||||
|
|
||||||
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
|
fi
|
||||||
|
|
||||||
cp -a $MAKEDEFS Make.defs || \
|
for CONFIG in ${CONFIGS}; do
|
||||||
{ echo "ERROR: Failed to copy $MAKEDEFS to Make.defs"; exit 1; }
|
echo "Refresh ${CONFIG}"
|
||||||
|
|
||||||
# Then run oldconfig or oldefconfig
|
# Set up the environment
|
||||||
|
|
||||||
if [ "X${defaults}" == "Xy" ]; then
|
CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d':' -f2`
|
||||||
make olddefconfig
|
if [ -z "${CONFIGSUBDIR}" ]; then
|
||||||
else
|
CONFIGSUBDIR=`echo ${CONFIG} | cut -s -d'/' -f2`
|
||||||
make oldconfig
|
if [ -z "${CONFIGSUBDIR}" ]; then
|
||||||
fi
|
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
|
||||||
|
|
||||||
# Run savedefconfig to create the new defconfig file
|
BOARDDIR=boards/*/*/$BOARDSUBDIR
|
||||||
|
SCRIPTSDIR=$BOARDDIR/scripts
|
||||||
|
MAKEDEFS1=$SCRIPTSDIR/Make.defs
|
||||||
|
|
||||||
make savedefconfig
|
CONFIGDIR=$BOARDDIR/configs/$CONFIGSUBDIR
|
||||||
|
DEFCONFIG=$CONFIGDIR/defconfig
|
||||||
|
MAKEDEFS2=$CONFIGDIR/Make.defs
|
||||||
|
|
||||||
# Show differences
|
# Check the board configuration directory
|
||||||
|
|
||||||
# sed -i -e "s/^CONFIG_APPS_DIR/# CONFIG_APPS_DIR/g" defconfig
|
if [ ! -d $BOARDDIR ]; then
|
||||||
$CMPCONFIG $DEFCONFIG defconfig
|
echo "No board directory found at $BOARDDIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Save the refreshed configuration
|
if [ ! -d $CONFIGDIR ]; then
|
||||||
|
echo "No configuration directory found at $CONFIGDIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "X${prompt}" == "Xy" ]; then
|
if [ ! -r $DEFCONFIG ]; then
|
||||||
read -p "Save the new configuration (y/n)?" -n 1 -r
|
echo "No readable defconfig file at $DEFCONFIG"
|
||||||
echo
|
exit 1
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
fi
|
||||||
then
|
|
||||||
|
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
|
||||||
|
|
||||||
|
cp -a $DEFCONFIG .config || \
|
||||||
|
{ echo "ERROR: Failed to copy $DEFCONFIG to .config"; exit 1; }
|
||||||
|
|
||||||
|
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"
|
echo "Saving the new configuration file"
|
||||||
mv defconfig $DEFCONFIG || \
|
mv defconfig $DEFCONFIG || \
|
||||||
{ echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
|
{ echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
|
||||||
chmod 644 $DEFCONFIG
|
chmod 644 $DEFCONFIG
|
||||||
fi
|
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
|
if [ -e SAVEconfig ]; then
|
||||||
mv SAVEconfig .config || \
|
mv SAVEconfig .config || \
|
||||||
{ echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; }
|
{ echo "ERROR: Failed to move SAVEconfig to .config"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e SAVEMake.defs ]; then
|
if [ -e SAVEMake.defs ]; then
|
||||||
mv SAVEMake.defs Make.defs || \
|
mv SAVEMake.defs Make.defs || \
|
||||||
{ echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
|
{ echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user