ooni-probe-cli/MOBILE/android/setup
Simone Basso 342a74cad8
fix(MOBILE/android): make scripts monorepo compatible (#866)
This diff contains minor changes to make the build scripts in here
compatible with https://github.com/bassosimone/monorepo.

See 5e4c797380
2022-08-17 18:47:09 +02:00

52 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
force=0
if [[ $# -eq 1 && $1 == "--force" ]]; then
force=1
fi
ANDROID_HOME=$(./MOBILE/android/home --no-check)
__clitools_version=8512546
__clitools_file=commandlinetools-linux-${__clitools_version}_latest.zip
__clitools_sha256=2ccbda4302db862a28ada25aa7425d99dce9462046003c1714b059b5c47970d8
cmdlinetools=$ANDROID_HOME/cmdline-tools
cmdlinetoolslatest=$cmdlinetools/latest
if [[ $force == 0 && -d $cmdlinetoolslatest ]]; then
echo "$0: already installed... run '$0 --force' to reinstall" 1>&2
exit 0
fi
printf "checking for curl... "
command -v curl || {
echo "not found"
exit 1
}
printf "checking for shasum... "
command -v shasum || {
echo "not found"
exit 1
}
printf "checking for unzip... "
command -v unzip || {
echo "not found"
exit 1
}
set -x
rm -rf $cmdlinetoolslatest
curl -fsSLO https://dl.google.com/android/repository/$__clitools_file
echo "$__clitools_sha256 $__clitools_file" >__SHA256
shasum --check __SHA256
rm -f __SHA256
unzip $__clitools_file
rm $__clitools_file
mkdir -p $cmdlinetools
# See https://stackoverflow.com/a/61176718 to understand why
# we need to reorganize the directories like this:
mv cmdline-tools $cmdlinetoolslatest