diff --git a/autogen.sh b/autogen.sh index 338ea95d0..869ff6c43 100755 --- a/autogen.sh +++ b/autogen.sh @@ -12,7 +12,7 @@ ORIGDIR=`pwd` cd $srcdir . ./data/scripts/add_cl_if_not_present.sh # add --with-cuda-host-compiler= to current params (Win) -. ./data/scripts/install_speex.sh +./data/scripts/install_speex.sh # install config.guess config.sub install-sh missing echo "Running automake..." diff --git a/data/scripts/fetch_submodule.sh b/data/scripts/fetch_submodule.sh new file mode 100644 index 000000000..2af3af78d --- /dev/null +++ b/data/scripts/fetch_submodule.sh @@ -0,0 +1,41 @@ +## fetches a submodule +## +## @param $1 name +## @param $2 fallback Gzip URL +## @param $3 fallback Git URL +## @retval 1 submodule was updated +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 + 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 1 + fi + return 0 +} + diff --git a/data/scripts/install_speex.sh b/data/scripts/install_speex.sh old mode 100644 new mode 100755 index f109b00d8..c88d21437 --- a/data/scripts/install_speex.sh +++ b/data/scripts/install_speex.sh @@ -1,38 +1,20 @@ +#!/bin/sh -eu ## Install speex and speexdsp ## ## Normally try to use git submodules present in the repository. If not possible ## it tries to either clone (.git directory stripped) or to download release ## (if git not found). +. $(dirname $0)/fetch_submodule.sh + for module in speex speexdsp; do - 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 - curl -L http://downloads.us.xiph.org/releases/speex/${module}-1.2.0.tar.gz | tar -C ext-deps -xz - mv ext-deps/speex*-1.2.0 ext-deps/$module - 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 https://gitlab.xiph.org/xiph/$module ext-deps/$module - else - echo "skipped (ext-deps/$module is already present)" - fi - else - SUBMODULSE_UPDATED=`git submodule update --init ext-deps/$module` - if [ -z "$SUBMODULE_UPDATED" ]; then - echo "not needed" - fi - fi + set +e + fetch_submodule $module http://downloads.us.xiph.org/releases/speex/${module}-1.2.0.tar.gz https://gitlab.xiph.org/xiph/$module + [ $? = 1 ] && SUBMODULE_UPDATED=yes || SUBMODULE_UPDATED=no + set -e printf "Configuring ${module}... " - if [ -f ext-deps/$module/include/speex/${module}_config_types.h -a -z "$SUBMODULE_UPDATED" ]; then + if [ -f ext-deps/$module/include/speex/${module}_config_types.h -a $SUBMODULE_UPDATED = no ]; then echo "not needed" else cd ext-deps/$module