Show a summary of libretro-fetch success.

This commit is contained in:
zoltanvb 2025-03-11 07:07:17 +01:00
parent 8c6284ac2f
commit 4aeeaa9cbd
2 changed files with 50 additions and 0 deletions

View file

@ -28,6 +28,30 @@ fi
. "$BASE_DIR/rules.d/lutro-rules.sh"
. "$BASE_DIR/build-config.sh"
summary_fetch() {
# fmt is external and may not be available
fmt_output="$(find_tool "fmt")"
local num_success="$(numwords $fetch_success)"
local fmt_success="${fmt_output:+$(echo " $fetch_success" | $fmt_output)}"
local num_fail="$(numwords $fetch_fail)"
local fmt_fail="${fmt_output:+$(echo " $fetch_fail" | $fmt_output)}"
if [[ -z "$fetch_success" && -z "$fetch_fail" ]]; then
secho "No fetch actions performed."
return
fi
if [ -n "$fetch_success" ]; then
secho "$(color 32)$num_success core(s)$(color) successfully processed:"
secho "$fmt_success"
fi
if [ -n "$fetch_fail" ]; then
secho "$(color 31)$num_fail core(s)$(color) failed:"
secho "$fmt_fail"
fi
}
# libretro_fetch: Download the given core using its fetch rules
#
# $1 Name of the core to fetch
@ -66,6 +90,10 @@ libretro_fetch() {
# TODO: Don't depend on fetch_rule being git
echo "Fetching ${1}..."
fetch_git "$git_url" "$module_dir" "$git_submodules"
if [ $? -ne 0 ]; then
return 1
fi
;;
*)
@ -78,6 +106,9 @@ libretro_fetch() {
if [ -n "$post_fetch_cmd" ]; then
echo_cmd "cd \"$WORKDIR/$module_dir\""
echo_cmd "$post_fetch_cmd"
if [ $? -ne 0 ]; then
exit 1
fi
fi
}
@ -126,4 +157,10 @@ done
for a in $fetch_cores; do
libretro_fetch "${a%%:*}"
if [ $? -eq 0 ]; then
export fetch_success="$fetch_success$a "
else
export fetch_fail="$fetch_fail$a "
fi
done
summary_fetch

View file

@ -14,18 +14,31 @@ fetch_git() {
if [ -d "$fetch_dir/.git" ]; then
echo_cmd "cd \"$fetch_dir\""
echo_cmd "git pull"
if [ $? -ne 0 ]; then
return 1
fi
if [ "$3" = "yes" ]; then
echo_cmd "git submodule foreach git pull origin master"
if [ $? -ne 0 ]; then
return 1
fi
fi
else
clone_type=
[ -n "$SHALLOW_CLONE" ] && depth="--depth 1 "
echo_cmd "git clone $depth\"$1\" \"$WORKDIR/$2\""
if [ $? -ne 0 ]; then
return 1
fi
if [[ "$3" = "yes" || "$3" = "clone" ]]; then
echo_cmd "cd \"$fetch_dir\""
echo_cmd "git submodule update --init --recursive"
if [ $? -ne 0 ]; then
return 1
fi
fi
fi
return $?
}
# fetch_revision_git: Output the hash of the last commit in a git repository