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
touch -a " ${ HOME } /.bash_profile "
2018-11-05 09:40:11 +00:00
2019-02-01 10:44:51 +00:00
local required_version = $( toolversion nix)
bash <( curl https://nixos.org/releases/nix/nix-${ required_version } /install) --no-daemon
if [ $? -eq 0 ] ; then
if is_linux && [ -f ~/.bashrc ] && ! grep -qF ".nix-profile/etc/profile.d/nix.sh" ~/.bashrc; then
# For some reason, new terminals are not started as login shells, so .profile and .bash_profile are not sourced.
# To get around it, we add Nix initialization to .bashrc as well, if it exists
echo " if [ -e ${ HOME } /.nix-profile/etc/profile.d/nix.sh ]; then . ${ HOME } /.nix-profile/etc/profile.d/nix.sh; fi # added by make setup Status script " >> ~/.bashrc
fi
2019-01-15 15:34:52 +00:00
2019-02-01 10:44:51 +00:00
. ${ HOME } /.nix-profile/etc/profile.d/nix.sh && \
NIX_CONF_DIR = $( cd " ${ BASH_SOURCE %/* } " && pwd ) /nix \
nix-build --no-out-link -A env.all ${ GIT_ROOT } /default.nix
2017-12-01 17:17:25 +00:00
2019-02-01 10:44:51 +00:00
echo -e " ${ YELLOW } ********************************************************************************************************** "
echo "The Nix package manager was successfully installed. Please run \`make shell\` to initialize the Nix environment."
echo "If this doesn't work, you might have to sign out and back in, in order for the environment to be reloaded."
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
}