new: implement --checkpoint for mp-check

This commit is contained in:
ngn 2024-08-21 02:02:26 +03:00
parent 8f1a7f5e27
commit dd18ae23de

View File

@ -70,6 +70,7 @@ help_cmd() {
info "MatterLinux package check script (mtsc ${MTSC_VERSION})" # sourced from mtsc-common
info "Usage: ${0} <options> [archive file/source dir]"
info "Options:"
echo_color " $BOLD--checkpoint$RESET: specify a starting point for the check"
echo_color " $BOLD--fail-warn$RESET: fail on a warning"
echo_color " $BOLD--no-warn$RESET: ignore warnings"
echo
@ -316,6 +317,7 @@ check_source(){
#################
## main script ##
#################
OPT_CHECKPOINT=""
OPT_FAIL_WARN=0
OPT_NO_WARN=0
OPT_TARGET=()
@ -325,6 +327,8 @@ for arg in "$@"; do
"--help")
help_cmd
exit 0 ;;
"--checkpoint"*)
OPT_CHECKPOINT="$(echo "${arg}" | cut -d '=' -f2)" ;;
"--fail-warn")
OPT_FAIL_WARN=1 ;;
"--no-warn")
@ -348,8 +352,13 @@ if [ $OPT_FAIL_WARN -eq 1 ] && [ $OPT_NO_WARN -eq 1 ]; then
fi
info "Running mp-check with the options:"
print " $BOLD FAIL_WARN = $(itoyn $OPT_FAIL_WARN)"
print " $BOLD NO_WARN = $(itoyn $OPT_NO_WARN)"
if [ -z "${OPT_CHECKPOINT}" ]; then
print " $BOLD CHECKPOINT = NONE"
else
print " $BOLD CHECKPOINT = ${OPT_CHECKPOINT}"
fi
print " $BOLD FAIL_WARN = $(itoyn $OPT_FAIL_WARN)"
print " $BOLD NO_WARN = $(itoyn $OPT_NO_WARN)"
for target in "${OPT_TARGET[@]}"; do
if [ ! -f "${target}" ] && [ ! -d "${target}" ]; then
@ -359,12 +368,19 @@ for target in "${OPT_TARGET[@]}"; do
done
tc="${#OPT_TARGET[@]}"
got_checkpoint=0
ti=0
for target in "${OPT_TARGET[@]}"; do
unset_indent
ti=$((ti + 1))
if [ -z "${OPT_CHECKPOINT}" ] || [ "${target}" == "${OPT_CHECKPOINT}" ]; then
got_checkpoint=1
fi
[ $got_checkpoint -eq 0 ] && continue
if [ -f "${target}" ]; then
info "(${ti}/${tc}) Checking the archive: ${target}"
set_indent