status-react/scripts/lib/setup/installers.sh

85 lines
2.6 KiB
Bash
Raw Normal View History

2017-12-01 17:17:25 +00:00
#!/usr/bin/env bash
GIT_ROOT=$(git rev-parse --show-toplevel)
function download_url() {
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
}
function install_nix() {
if ! program_exists nix; then
local required_version=$(toolversion nix)
NIX_INSTALLER_NO_MODIFY_PROFILE=1 bash <(curl https://nixos.org/releases/nix/nix-${required_version}/install) --no-daemon
if [ $? -eq 0 ]; then
echo -e "${YELLOW}**********************************************************************************************************"
echo "The Nix package manager was successfully installed."
echo -e "**********************************************************************************************************${NC}"
2017-12-01 17:17:25 +00:00
else
echo "Please see https://nixos.org/nix/manual/#chap-installation"
2017-12-01 17:17:25 +00:00
fi
exit
2017-12-01 17:17:25 +00:00
fi
}
function install_android_sdk() {
if [ -z "$ANDROID_SDK_ROOT" ]; then
return 0
fi
if [ -d "$ANDROID_SDK_ROOT" ]; then
cecho "@green[[Android SDK already installed.]]"
else
local required_version=$(toolversion android-sdk)
mkdir -p $ANDROID_SDK_ROOT
cecho "@cyan[[Downloading Android SDK.]]"
2017-12-01 17:17:25 +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
[ $? -eq 0 ] && use_android_sdk
2017-12-01 17:17:25 +00:00
return 0
2017-12-01 17:17:25 +00:00
}
function dependency_setup() {
cecho "@b@blue[[\$ $@]]"
echo
cd "$(repo_path)"
eval "$@" || (cecho "@b@red[[Error running dependency install '$@']]" && exit 1)
2017-12-01 17:17:25 +00:00
echo
echo " + done"
echo
}
function use_android_sdk() {
if [ -d "$ANDROID_SDK_ROOT" ]; then
local ANDROID_BUILD_TOOLS_VERSION=$(toolversion android-sdk-build-tools)
local ANDROID_PLATFORM_VERSION=$(toolversion android-sdk-platform)
touch ~/.android/repositories.cfg
echo y | sdkmanager "platform-tools" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" "platforms;$ANDROID_PLATFORM_VERSION"
yes | sdkmanager --licenses
else
2019-01-05 12:01:22 +00:00
local _docUrl="https://status.im/build_status/"
cecho "@yellow[[ANDROID_SDK_ROOT environment variable not defined, please install the Android SDK.]]"
cecho "@yellow[[(see $_docUrl).]]"
echo
exit 1
fi
scripts/generate-keystore.sh
}