tools/refresh.sh: Save defconfig and exit with 1 only when the difference exist
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
5c1497aeb1
commit
c153c31fbd
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user