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);
|
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 *varval1;
|
||||||
char *varval2;
|
char *varval2;
|
||||||
int result;
|
int ret = 0;
|
||||||
|
|
||||||
while (list1 || list2)
|
while (list1 || list2)
|
||||||
{
|
{
|
||||||
@ -94,27 +95,33 @@ static void compare_variables(struct variable_s *list1, struct variable_s *list2
|
|||||||
printf("file1:\n");
|
printf("file1:\n");
|
||||||
printf("file2: %s=%s\n\n", list2->var, varval2);
|
printf("file2: %s=%s\n\n", list2->var, varval2);
|
||||||
list2 = list2->flink;
|
list2 = list2->flink;
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else if (!list2)
|
else if (!list2)
|
||||||
{
|
{
|
||||||
printf("file1: %s=%s\n", list1->var, varval1);
|
printf("file1: %s=%s\n", list1->var, varval1);
|
||||||
printf("file2:\n\n");
|
printf("file2:\n\n");
|
||||||
list1 = list1->flink;
|
list1 = list1->flink;
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
result = strcmp(list1->var, list2->var);
|
result = strcmp(list1->var, list2->var);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
printf("file1: %s=%s\n", list1->var, varval1);
|
printf("file1: %s=%s\n", list1->var, varval1);
|
||||||
printf("file2:\n\n");
|
printf("file2:\n\n");
|
||||||
list1 = list1->flink;
|
list1 = list1->flink;
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else if (result > 0)
|
else if (result > 0)
|
||||||
{
|
{
|
||||||
printf("file1:\n");
|
printf("file1:\n");
|
||||||
printf("file2: %s=%s\n\n", list2->var, varval2);
|
printf("file2: %s=%s\n\n", list2->var, varval2);
|
||||||
list2 = list2->flink;
|
list2 = list2->flink;
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else /* if (result == 0) */
|
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(stream1);
|
||||||
fclose(stream2);
|
fclose(stream2);
|
||||||
|
|
||||||
printf("Comparing:\n\n");
|
return compare_variables(list1, list2);
|
||||||
printf(" file1 = %s\n", argv[1]);
|
|
||||||
printf(" file2 = %s\n\n", argv[2]);
|
|
||||||
compare_variables(list1, list2);
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ USAGE="USAGE: $0 [options] <board>:<config>+"
|
|||||||
ADVICE="Try '$0 --help' for more information"
|
ADVICE="Try '$0 --help' for more information"
|
||||||
|
|
||||||
unset CONFIGS
|
unset CONFIGS
|
||||||
|
diff=0
|
||||||
debug=n
|
debug=n
|
||||||
defaults=n
|
defaults=n
|
||||||
prompt=y
|
prompt=y
|
||||||
@ -154,7 +155,7 @@ if [ "X${CONFIGS}" == "Xall" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for CONFIG in ${CONFIGS}; do
|
for CONFIG in ${CONFIGS}; do
|
||||||
echo "Refresh ${CONFIG}"
|
echo " Normalize ${CONFIG}"
|
||||||
|
|
||||||
# Set up the environment
|
# Set up the environment
|
||||||
|
|
||||||
@ -256,28 +257,30 @@ for CONFIG in ${CONFIGS}; do
|
|||||||
make savedefconfig 1>/dev/null
|
make savedefconfig 1>/dev/null
|
||||||
fi
|
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
|
read -p "Save the new configuration (y/n)?" -n 1 -r
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
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"
|
diff=1
|
||||||
mv defconfig $DEFCONFIG || \
|
|
||||||
{ echo "ERROR: Failed to move defconfig to $DEFCONFIG"; exit 1; }
|
|
||||||
chmod 644 $DEFCONFIG
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Restore any previous .config and Make.defs files
|
# 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; }
|
{ echo "ERROR: Failed to move SAVEMake.defs to Make.defs"; exit 1; }
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
exit $diff
|
||||||
|
Loading…
x
Reference in New Issue
Block a user