mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 12:40:05 +00:00
45 lines
1.7 KiB
Bash
45 lines
1.7 KiB
Bash
## fetches a submodule
|
|
##
|
|
## @param $1 name
|
|
## @param $2 fallback Gzip URL
|
|
## @param $3 fallback Git URL
|
|
## @param $4 if set to 1, report submodule update
|
|
## @retval 1 submodule was updated (and $4 was set to 1)
|
|
## @retval 0 otherwise
|
|
fetch_submodule() {
|
|
MODULE=$1
|
|
FALLBACK_URL=$2
|
|
FALLBACK_GIT_URL=$3
|
|
SUBMODULE_UPDATED= # assume that submodule have not been updated
|
|
printf "Downloading ${MODULE}... "
|
|
if ! command -v git >/dev/null; then
|
|
if [ ! -d ext-deps/$MODULE ]; then
|
|
echo "git not found - trying to download a release"
|
|
mkdir -p ext-deps/tmp
|
|
curl -L $FALLBACK_URL | tar -C ext-deps/tmp -xz
|
|
[ -d ext-deps/$MODULE ] && rmdir ext-deps/$MODULE
|
|
mv ext-deps/tmp/* ext-deps/$MODULE
|
|
rmdir ext-deps/tmp
|
|
else
|
|
echo "skipped (ext-deps/$MODULE is already present)"
|
|
fi
|
|
elif ! git branch >/dev/null 2>&1; then
|
|
# we are not in UltraGrid git repository but can use git to download
|
|
if [ ! -d ext-deps/$MODULE ]; then
|
|
echo "git submodule found - trying to clone"
|
|
git clone $FALLBACK_GIT_URL ext-deps/$MODULE
|
|
else
|
|
echo "skipped (ext-deps/$MODULE is already present)"
|
|
fi
|
|
else
|
|
SUBMODULE_UPDATED=`git submodule update --init ext-deps/$MODULE`
|
|
if [ -z "$SUBMODULE_UPDATED" ]; then
|
|
echo "not needed"
|
|
return 0
|
|
fi
|
|
return ${4:-0}
|
|
fi
|
|
return 0
|
|
}
|
|
|