2017-12-01 17:17:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
GIT_ROOT=$(git rev-parse --show-toplevel)
|
2018-07-11 16:43:52 +00:00
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
function download_url() {
|
2018-09-13 09:44:33 +00:00
|
|
|
if program_exists "aria2c"; then
|
|
|
|
aria2c --max-connection-per-server=16 --split=16 --dir="$1" -o "$2" "$3"
|
|
|
|
else
|
|
|
|
wget --show-progress --output-document="$1/$2" "$3"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
function install_nix() {
|
|
|
|
if ! program_exists nix; then
|
|
|
|
local required_version=$(toolversion nix)
|
2019-04-11 06:42:00 +00:00
|
|
|
NIX_INSTALLER_NO_MODIFY_PROFILE=1 bash <(curl https://nixos.org/releases/nix/nix-${required_version}/install) --no-daemon
|
2019-02-01 10:44:51 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2019-04-11 06:42:00 +00:00
|
|
|
echo -e "${YELLOW}**********************************************************************************************************"
|
|
|
|
echo "The Nix package manager was successfully installed."
|
|
|
|
echo -e "**********************************************************************************************************${NC}"
|
2017-12-01 17:17:25 +00:00
|
|
|
else
|
2019-02-01 10:44:51 +00:00
|
|
|
echo "Please see https://nixos.org/nix/manual/#chap-installation"
|
2017-12-01 17:17:25 +00:00
|
|
|
fi
|
2019-02-01 10:44:51 +00:00
|
|
|
exit
|
2017-12-01 17:17:25 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install_android_sdk() {
|
2019-03-05 17:36:40 +00:00
|
|
|
if [ -z "$ANDROID_SDK_ROOT" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
if [ -d "$ANDROID_SDK_ROOT" ]; then
|
|
|
|
cecho "@green[[Android SDK already installed.]]"
|
2019-01-26 15:36:12 +00:00
|
|
|
else
|
2019-02-01 10:44:51 +00:00
|
|
|
local required_version=$(toolversion android-sdk)
|
|
|
|
mkdir -p $ANDROID_SDK_ROOT
|
|
|
|
cecho "@cyan[[Downloading Android SDK.]]"
|
2017-12-01 17:17:25 +00:00
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
local PLATFORM=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
|
|
|
|
download_url . sdk-tools-${PLATFORM}.zip https://dl.google.com/android/repository/sdk-tools-${PLATFORM}-${required_version}.zip && \
|
|
|
|
cecho "@cyan[[Extracting Android SDK to $ANDROID_SDK_ROOT.]]" && \
|
|
|
|
unzip -q -o ./sdk-tools-${PLATFORM}.zip -d "$ANDROID_SDK_ROOT" && \
|
|
|
|
rm -f ./sdk-tools-${PLATFORM}.zip && \
|
|
|
|
cecho "@blue[[Android SDK installation completed in $ANDROID_SDK_ROOT.]]" || \
|
|
|
|
exit $?
|
2017-12-01 17:17:25 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
[ $? -eq 0 ] && use_android_sdk
|
2017-12-01 17:17:25 +00:00
|
|
|
|
2019-02-01 10:44:51 +00:00
|
|
|
return 0
|
2017-12-01 17:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function dependency_setup() {
|
|
|
|
cecho "@b@blue[[\$ $@]]"
|
|
|
|
echo
|
|
|
|
|
|
|
|
cd "$(repo_path)"
|
2019-01-26 15:36:12 +00:00
|
|
|
eval "$@" || (cecho "@b@red[[Error running dependency install '$@']]" && exit 1)
|
2017-12-01 17:17:25 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo " + done"
|
|
|
|
echo
|
|
|
|
}
|
2018-07-10 15:56:26 +00:00
|
|
|
|
|
|
|
function use_android_sdk() {
|
2019-02-01 10:44:51 +00:00
|
|
|
if [ -d "$ANDROID_SDK_ROOT" ]; then
|
2019-01-26 15:36:12 +00:00
|
|
|
local ANDROID_BUILD_TOOLS_VERSION=$(toolversion android-sdk-build-tools)
|
|
|
|
local ANDROID_PLATFORM_VERSION=$(toolversion android-sdk-platform)
|
2019-01-10 18:32:30 +00:00
|
|
|
touch ~/.android/repositories.cfg
|
|
|
|
echo y | sdkmanager "platform-tools" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platforms;$ANDROID_PLATFORM_VERSION"
|
2019-01-26 15:36:12 +00:00
|
|
|
yes | sdkmanager --licenses
|
2018-07-10 15:56:26 +00:00
|
|
|
else
|
2019-01-05 12:01:22 +00:00
|
|
|
local _docUrl="https://status.im/build_status/"
|
2018-07-30 19:44:44 +00:00
|
|
|
cecho "@yellow[[ANDROID_SDK_ROOT environment variable not defined, please install the Android SDK.]]"
|
2018-07-10 15:56:26 +00:00
|
|
|
cecho "@yellow[[(see $_docUrl).]]"
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-01-26 15:36:12 +00:00
|
|
|
|
|
|
|
scripts/generate-keystore.sh
|
2018-07-10 15:56:26 +00:00
|
|
|
}
|