2015-02-13 17:55:27 -08:00
|
|
|
#! /usr/bin/env bash
|
|
|
|
# vim: set ts=3 sw=3 noet ft=sh : bash
|
2011-11-02 16:27:23 +01:00
|
|
|
|
2015-02-13 18:05:50 -08:00
|
|
|
SCRIPT="${0#./}"
|
|
|
|
BASE_DIR="${SCRIPT%/*}"
|
2015-02-21 16:55:31 -08:00
|
|
|
WORKDIR="$PWD"
|
2015-02-02 09:33:50 -08:00
|
|
|
|
2015-02-13 18:05:50 -08:00
|
|
|
if [ "$BASE_DIR" = "$SCRIPT" ]; then
|
|
|
|
BASE_DIR="$WORKDIR"
|
|
|
|
else
|
2015-02-15 14:34:42 -08:00
|
|
|
if [[ "$0" != /* ]]; then
|
|
|
|
# Make the path absolute
|
|
|
|
BASE_DIR="$WORKDIR/$BASE_DIR"
|
|
|
|
fi
|
2015-02-13 18:05:50 -08:00
|
|
|
fi
|
2015-02-02 09:33:50 -08:00
|
|
|
|
2015-02-21 16:55:31 -08:00
|
|
|
. "$BASE_DIR/libretro-config.sh"
|
2015-03-27 16:45:38 -07:00
|
|
|
. "$BASE_DIR/script-modules/log.sh"
|
2015-02-26 00:14:05 -08:00
|
|
|
. "$BASE_DIR/script-modules/util.sh"
|
2015-02-21 16:55:31 -08:00
|
|
|
. "$BASE_DIR/script-modules/fetch-rules.sh"
|
2015-04-12 14:56:10 -07:00
|
|
|
. "$BASE_DIR/script-modules/module_base.sh"
|
2013-05-01 04:11:22 +02:00
|
|
|
|
2015-03-01 03:42:45 -08:00
|
|
|
# Rules for fetching things are in these files:
|
|
|
|
. "$BASE_DIR/rules.d/core-rules.sh"
|
|
|
|
. "$BASE_DIR/rules.d/player-rules.sh"
|
|
|
|
. "$BASE_DIR/rules.d/devkit-rules.sh"
|
|
|
|
# TODO: Read these programmatically
|
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
# libretro_fetch: Download the given core using its fetch rules
|
2015-02-21 00:55:22 -08:00
|
|
|
#
|
|
|
|
# $1 Name of the core to fetch
|
2015-03-01 02:25:06 -08:00
|
|
|
libretro_fetch() {
|
|
|
|
local module_name
|
|
|
|
local module_dir
|
|
|
|
local fetch_rule
|
|
|
|
local post_fetch_cmd
|
2015-02-21 00:55:22 -08:00
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
eval "module_name=\$libretro_${1}_name"
|
|
|
|
[ -z "$module_name" ] && module_name="$1"
|
2015-03-03 00:13:02 -08:00
|
|
|
echo "$(color 34)=== $(color 1)$module_name$(color)"
|
2015-02-21 00:55:22 -08:00
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
eval "fetch_rule=\$libretro_${1}_fetch_rule"
|
2015-03-01 12:34:02 -08:00
|
|
|
[ -z "$fetch_rule" ] && fetch_rule=git
|
2015-02-21 00:55:22 -08:00
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
eval "module_dir=\$libretro_${1}_dir"
|
|
|
|
[ -z "$module_dir" ] && module_dir="libretro-$1"
|
|
|
|
|
|
|
|
case "$fetch_rule" in
|
2015-03-01 03:42:45 -08:00
|
|
|
git)
|
2015-03-01 02:25:06 -08:00
|
|
|
local git_url
|
|
|
|
local git_submodules
|
|
|
|
eval "git_url=\$libretro_${1}_git_url"
|
|
|
|
if [ -z "$git_url" ]; then
|
|
|
|
echo "libretro_fetch:No URL set to fetch $1 via git."
|
2015-02-21 00:55:22 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
eval "git_submodules=\$libretro_${1}_git_submodules"
|
2015-02-21 00:55:22 -08:00
|
|
|
|
2015-02-26 00:14:05 -08:00
|
|
|
# TODO: Don't depend on fetch_rule being git
|
2015-02-21 00:55:22 -08:00
|
|
|
echo "Fetching ${1}..."
|
2015-03-01 03:42:45 -08:00
|
|
|
fetch_git "$git_url" "$module_dir" "$git_submodules"
|
2015-02-21 00:55:22 -08:00
|
|
|
;;
|
2015-03-01 03:42:45 -08:00
|
|
|
|
2015-02-21 00:55:22 -08:00
|
|
|
*)
|
2015-03-01 02:25:06 -08:00
|
|
|
echo "libretro_fetch:Unknown fetch rule for $1: \"$fetch_rule\"."
|
2015-02-21 00:55:22 -08:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2015-03-01 02:25:06 -08:00
|
|
|
eval "post_fetch_cmd=\$libretro_${1}_post_fetch_cmd"
|
|
|
|
if [ -n "$post_fetch_cmd" ]; then
|
|
|
|
echo_cmd "cd \"$WORKDIR/$module_dir\""
|
|
|
|
echo_cmd "$post_fetch_cmd"
|
|
|
|
fi
|
2015-02-01 20:24:14 -08:00
|
|
|
}
|
|
|
|
|
2015-03-10 07:20:11 -07:00
|
|
|
libretro_players="retroarch"
|
|
|
|
|
2015-02-17 23:17:47 -08:00
|
|
|
if [ -n "$1" ]; then
|
2015-03-01 12:34:02 -08:00
|
|
|
no_more_args=""
|
2015-02-17 23:17:47 -08:00
|
|
|
while [ -n "$1" ]; do
|
2015-03-10 07:20:11 -07:00
|
|
|
if [[ "$1" = -* && -z "$no_more_args" ]]; then
|
2015-03-01 03:42:45 -08:00
|
|
|
case "$1" in
|
2015-03-10 07:20:11 -07:00
|
|
|
--) no_more_args=1 ;;
|
|
|
|
--cores) fetch_cores="$libretro_cores" ;;
|
|
|
|
--devkit) fetch_devkits="$libretro_devkits" ;;
|
|
|
|
--players) fetch_players="$libretro_players" ;;
|
|
|
|
--retroarch) fetch_players="retroarch" ;;
|
|
|
|
*) ;;
|
2015-03-01 03:42:45 -08:00
|
|
|
esac
|
2015-03-10 07:20:11 -07:00
|
|
|
shift
|
|
|
|
continue
|
2015-03-01 03:42:45 -08:00
|
|
|
fi
|
2015-03-10 07:20:11 -07:00
|
|
|
|
|
|
|
fetch_cores="$fetch_cores $1"
|
|
|
|
# Handle non-commands
|
2015-02-13 17:27:24 -08:00
|
|
|
shift
|
|
|
|
done
|
2015-02-01 20:35:22 -08:00
|
|
|
else
|
2015-03-10 07:20:11 -07:00
|
|
|
# Make libretro-fetch.sh with no args behave traditionally by default
|
|
|
|
fetch_cores="$libretro_cores"
|
2015-04-05 23:23:06 -07:00
|
|
|
fetch_players="$libretro_players"
|
|
|
|
fetch_devkit="$libretro_devkits"
|
2015-03-10 07:20:11 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
for a in $fetch_players; do
|
2015-04-05 23:23:06 -07:00
|
|
|
libretro_fetch "${a%%:*}"
|
2015-03-10 07:20:11 -07:00
|
|
|
done
|
2015-02-28 22:12:30 -08:00
|
|
|
|
2015-03-10 07:20:11 -07:00
|
|
|
for a in $fetch_devkits; do
|
2015-04-05 23:23:06 -07:00
|
|
|
libretro_fetch "${a%%:*}"
|
2015-03-10 07:20:11 -07:00
|
|
|
done
|
|
|
|
|
|
|
|
for a in $fetch_cores; do
|
2015-04-05 22:43:15 -07:00
|
|
|
libretro_fetch "${a%%:*}"
|
2015-03-10 07:20:11 -07:00
|
|
|
done
|