You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/20 13:07:43 UTC
[incubator-nuttx] 03/09: tools/refresh.sh: Save defconfig and exit
with 1 only when the difference exist
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 c153c31fbdf930c3c090438d750a4c19fc011146
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Apr 19 15:44:02 2020 +0800
tools/refresh.sh: Save defconfig and exit with 1 only when the difference exist
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
tools/cmpconfig.c | 19 ++++++++++++-------
tools/refresh.sh | 33 +++++++++++++++++++--------------
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/tools/cmpconfig.c b/tools/cmpconfig.c
index a5a5394..e4e94da 100644
--- a/tools/cmpconfig.c
+++ b/tools/cmpconfig.c
@@ -63,11 +63,12 @@ static void show_usage(const char *progname)
exit(EXIT_FAILURE);
}
-static void compare_variables(struct variable_s *list1, struct variable_s *list2)
+static int compare_variables(struct variable_s *list1,
+ struct variable_s *list2)
{
char *varval1;
char *varval2;
- int result;
+ int ret = 0;
while (list1 || list2)
{
@@ -94,27 +95,33 @@ static void compare_variables(struct variable_s *list1, struct variable_s *list2
printf("file1:\n");
printf("file2: %s=%s\n\n", list2->var, varval2);
list2 = list2->flink;
+ ret = EXIT_FAILURE;
}
else if (!list2)
{
printf("file1: %s=%s\n", list1->var, varval1);
printf("file2:\n\n");
list1 = list1->flink;
+ ret = EXIT_FAILURE;
}
else
{
+ int result;
+
result = strcmp(list1->var, list2->var);
if (result < 0)
{
printf("file1: %s=%s\n", list1->var, varval1);
printf("file2:\n\n");
list1 = list1->flink;
+ ret = EXIT_FAILURE;
}
else if (result > 0)
{
printf("file1:\n");
printf("file2: %s=%s\n\n", list2->var, varval2);
list2 = list2->flink;
+ ret = EXIT_FAILURE;
}
else /* if (result == 0) */
{
@@ -130,6 +137,8 @@ static void compare_variables(struct variable_s *list1, struct variable_s *list2
}
}
}
+
+ return ret;
}
/****************************************************************************
@@ -171,9 +180,5 @@ int main(int argc, char **argv, char **envp)
fclose(stream1);
fclose(stream2);
- printf("Comparing:\n\n");
- printf(" file1 = %s\n", argv[1]);
- printf(" file2 = %s\n\n", argv[2]);
- compare_variables(list1, list2);
- return EXIT_SUCCESS;
+ return compare_variables(list1, list2);
}
diff --git a/tools/refresh.sh b/tools/refresh.sh
index 9dda1dc..0e7e4ea 100755
--- a/tools/refresh.sh
+++ b/tools/refresh.sh
@@ -38,6 +38,7 @@ USAGE="USAGE: $0 [options] <board>:<config>+"
ADVICE="Try '$0 --help' for more information"
unset CONFIGS
+diff=0
debug=n
defaults=n
prompt=y
@@ -154,7 +155,7 @@ if [ "X${CONFIGS}" == "Xall" ]; then
fi
for CONFIG in ${CONFIGS}; do
- echo "Refresh ${CONFIG}"
+ echo " Normalize ${CONFIG}"
# Set up the environment
@@ -256,28 +257,30 @@ for CONFIG in ${CONFIGS}; do
make savedefconfig 1>/dev/null
fi
- # Save the refreshed configuration
+ # Show differences
- if [ "X${prompt}" == "Xy" ]; then
+ if ! $CMPCONFIG $DEFCONFIG defconfig; then
- # Show differences
+ # Save the refreshed configuration
- $CMPCONFIG $DEFCONFIG defconfig
+ if [ "X${prompt}" == "Xy" ]; then
- read -p "Save the new configuration (y/n)?" -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- 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
+
+ diff=1
fi
# Restore any previous .config and Make.defs files
@@ -292,3 +295,5 @@ for CONFIG in ${CONFIGS}; do
{ echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
fi
done
+
+exit $diff