From 46bd2b2e4ca2b6ead2d53666fe76d4863078bcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 19 Feb 2020 14:15:28 +0100 Subject: [PATCH] cleanup of shell scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Add missing lazy assignment for OS_NAME, fixes double Nix shells - Moved `scripts/add-nix-gcroots.sh` to `nix/scripts/gcroots.sh` - Moved Nix package manager setup to `nix/scripts/setup.sh` - Created `nix/scripts/source.sh` to reuse in all Nix scripts - Created `STARTING_GUIDE.md` with instructions for contributors - Created `scripts/colors.sh` for definition of shell colors - Removed `scripts/setup` in favor of `nix/scripts/setup.sh` - Removed all of `scripts/lib` since it was useless Signed-off-by: Jakub SokoĊ‚owski --- Makefile | 8 +- STARTING_GUIDE.md | 50 ++++++++++++ nix/README.md | 8 ++ nix/scripts/build.sh | 15 ++-- nix/scripts/clean.sh | 5 +- .../scripts/gcroots.sh | 8 +- nix/scripts/setup.sh | 47 +++++++++++ nix/scripts/shell.sh | 28 ++----- nix/scripts/source.sh | 26 +++++++ scripts/build-desktop.sh | 8 +- scripts/colors.sh | 7 ++ scripts/download-package-files.sh | 8 -- scripts/generate-keystore.sh | 47 ++++++++--- scripts/inotify_fix.sh | 15 ++-- scripts/lib/setup/output.sh | 78 ------------------- scripts/lib/setup/packages.sh | 27 ------- scripts/lib/setup/path-support.sh | 19 ----- scripts/lib/setup/platform.sh | 33 -------- scripts/lib/setup/properties.sh | 9 --- scripts/release-android.sh | 15 ++-- scripts/setup | 51 ------------ 21 files changed, 214 insertions(+), 298 deletions(-) create mode 100644 STARTING_GUIDE.md rename scripts/add-nix-gcroots.sh => nix/scripts/gcroots.sh (75%) create mode 100755 nix/scripts/setup.sh create mode 100755 nix/scripts/source.sh create mode 100644 scripts/colors.sh delete mode 100755 scripts/download-package-files.sh delete mode 100755 scripts/lib/setup/output.sh delete mode 100755 scripts/lib/setup/packages.sh delete mode 100644 scripts/lib/setup/path-support.sh delete mode 100755 scripts/lib/setup/platform.sh delete mode 100755 scripts/lib/setup/properties.sh delete mode 100755 scripts/setup diff --git a/Makefile b/Makefile index 3acb13784f..1b80222fd4 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ export _NIX_ROOT = /opt/nix endif # Useful for checking if we are on NixOS -OS_NAME = $(shell grep -oP '^NAME=\K\w(.*)' /etc/os-release) +OS_NAME ?= $(shell source /etc/os-release && echo $${NAME}) #---------------- # Nix targets @@ -91,7 +91,7 @@ endif nix-add-gcroots: export TARGET := default nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected - scripts/add-nix-gcroots.sh + nix/scripts/gcroots.sh nix-update-gradle: ##@nix Update maven nix expressions based on current gradle setup nix/mobile/android/maven-and-npm-deps/maven/generate-nix.sh @@ -160,8 +160,8 @@ release: release-android release-ios ##@build build release for Android and iOS release-android: export TARGET ?= android release-android: export BUILD_ENV ?= prod release-android: export BUILD_TYPE ?= nightly -release-android: export BUILD_NUMBER ?= 9999 -release-android: export STORE_FILE ?= $(HOME)/.gradle/status-im.keystore +release-android: export BUILD_NUMBER ?= $(shell ./scripts/version/gen_build_no.sh | cut -c1-10) +release-android: export KEYSTORE_FILE ?= $(HOME)/.gradle/status-im.keystore release-android: export ANDROID_ABI_SPLIT ?= false release-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86 release-android: ##@build build release for Android diff --git a/STARTING_GUIDE.md b/STARTING_GUIDE.md new file mode 100644 index 0000000000..acfd941560 --- /dev/null +++ b/STARTING_GUIDE.md @@ -0,0 +1,50 @@ +# Description + +This document provides information on how to start developing Status App. + +# Getting Started + +To start developing start a shell for platform you are interested in. +``` +make shell TARGET=android +``` +This step will take a while the first time as it will download all dependencies. + +To build the app, your can simply run on of the following: +``` +make release-android +make release-ios +``` +For more `make` targets run `make help`. + +# Manual Steps + +There are a few manual steps you might want to do in order to start contributing. + +## Genymotion Virtualization + +Optionally set up Genymotion if you don't want to use Android Virtual Device: + +https://www.genymotion.com + +## Android Development Environment + +You can also setup Android Development Environment + Simulator: + +https://facebook.github.io/react-native/docs/getting-started.html + +## Configure GitHub Account + +The optimal way of pushing to GitHubis using SSH instead of user/pass auth. + +It's recommented that you [add your public SSH key to your GitHub account](https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account). + +## Configure GPG Keys for signing commits + +In order to increase security we require all commits in `status-react` repo to be signed with a GPG key. + +Steps: +1. [Generate a new GPG key](https://help.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key) +2. [Setup Git to use your GPG key](https://help.github.com/en/github/authenticating-to-github/telling-git-about-your-signing-key) +3. [Setup Git to sign commits](https://help.github.com/en/github/authenticating-to-github/signing-commits) +4. [Setup GitHub to validate commits](https://help.github.com/en/github/authenticating-to-github/adding-a-new-gpg-key-to-your-github-account) diff --git a/nix/README.md b/nix/README.md index 51fa98dfba..b00c37152c 100644 --- a/nix/README.md +++ b/nix/README.md @@ -106,3 +106,11 @@ If copying from Nix Cache times out you can adjust the timeout by changing [`nix ```conf stalled-download-timeout = 9001 ``` + +### `extra-sandbox-paths` Is a Restricted Setting + +When building Android on NixOS you might encounter the following error: +``` +ignoring the user-specified setting 'extra-sandbox-paths', because it is a restricted setting and you are not a trusted user +``` +You can mitigate this by setting the [`nix.trustedUsers`](https://nixos.org/nixos/options.html#nix.trustedusers) property. diff --git a/nix/scripts/build.sh b/nix/scripts/build.sh index 8ad1fe64a8..cab9112513 100755 --- a/nix/scripts/build.sh +++ b/nix/scripts/build.sh @@ -4,6 +4,8 @@ set -e GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) resultPath="${GIT_ROOT}/result/" +source "${GIT_ROOT}/scripts/colors.sh" +source "${GIT_ROOT}/nix/scripts/source.sh" # cleanup for artifacts created during builds function cleanup() { @@ -11,12 +13,12 @@ function cleanup() { trap - EXIT ERR INT QUIT # do the actual cleanup, ignore failure if ${GIT_ROOT}/nix/scripts/clean.sh "${nixResultPath}"; then - echo "Successful cleanup!" + echo -e "${GRN}Successful cleanup!${RST}" elif [[ -n "${JENKINS_URL}" ]]; then # in CI removing some paths can fail due to parallel builds - echo "Ignoring cleanup failure in CI." + echo -e "${YLW}Ignoring cleanup failure in CI.${RST}" else - echo "Failed cleanup!" + echo -e "${RED}Failed cleanup!${RST}" exit 1 fi } @@ -32,14 +34,11 @@ function extractResults() { ls -l "${resultPath}" } -# Load Nix profile -. ~/.nix-profile/etc/profile.d/nix.sh - targetAttr="${1}" shift if [[ -z "${targetAttr}" ]]; then - echo "First argument is mandatory and has to specify the Nix attribute!" + echo -e "${RED}First argument is mandatory and has to specify the Nix attribute!${RST}" exit 1 fi @@ -68,4 +67,4 @@ nixResultPath=$(nix-build ${nixOpts[@]}) echo "Extracting result: ${nixResultPath}" extractResults "${nixResultPath}" -echo "SUCCESS" +echo -e "${GRN}SUCCESS${RST}" diff --git a/nix/scripts/clean.sh b/nix/scripts/clean.sh index f8f0cce05c..2948d43b39 100755 --- a/nix/scripts/clean.sh +++ b/nix/scripts/clean.sh @@ -2,6 +2,9 @@ set -e +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) +source "${GIT_ROOT}/nix/scripts/source.sh" + function log() { echo "$@" 1>&2; } # helpers for getting related paths in Nix store @@ -93,4 +96,4 @@ fi toDelete=$(printf '%s\n' "${toDelete[@]}" | sort | uniq) log "Deleting..." -nix-store --ignore-liveness --delete ${toDelete[@]} +nix-store --delete ${toDelete[@]} diff --git a/scripts/add-nix-gcroots.sh b/nix/scripts/gcroots.sh similarity index 75% rename from scripts/add-nix-gcroots.sh rename to nix/scripts/gcroots.sh index 707ba6e6dd..2e8749ade7 100755 --- a/scripts/add-nix-gcroots.sh +++ b/nix/scripts/gcroots.sh @@ -1,12 +1,10 @@ #!/usr/bin/env bash -if [[ -z "${IN_NIX_SHELL}" ]]; then - echo "Remember to call 'make shell'!" - exit 1 -fi - set -Eeu +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) +source "${GIT_ROOT}/nix/scripts/source.sh" + GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) rm -rf .nix-gcroots diff --git a/nix/scripts/setup.sh b/nix/scripts/setup.sh new file mode 100755 index 0000000000..5783d1d3ec --- /dev/null +++ b/nix/scripts/setup.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) +source "${GIT_ROOT}/scripts/colors.sh" + +NIX_VERSION="2.3.2" +NIX_INSTALL_URL="https://nixos.org/releases/nix/nix-${NIX_VERSION}/install" + +function install_nix() { + # Don't break people's profiles + export NIX_INSTALLER_NO_MODIFY_PROFILE=1 + # Fix for installing on MacOS Catalina + export NIX_IGNORE_SYMLINK_STORE=1 + bash <(curl "${NIX_INSTALL_URL}") --no-daemon + if [ $? -eq 0 ]; then + echo -e "${GRN}The Nix package manager was successfully installed.${RST}" + else + echo -e "${RED}Failed to install Nix package manager!${RST}" > /dev/stderr + echo "Please see: https://nixos.org/nix/manual/#chap-installation" > /dev/stderr + exit 1 + fi +} + +if [[ ! -x "$(command -v git)" ]]; then + echo -e "${RED}The 'curl' utility is required for Nix installation.${RST}" > /dev/stderr + exit 1 +fi + +if [[ "$(uname -v)" == *NixOS* ]]; then + echo -e "${GRN}Already running NixOS.${RST}" + exit +fi + +if [[ -x "$(command -v nix)" ]]; then + echo -e "${GRN}Nix package manager already installed.${RST}" + exit +fi + +if [[ "${IN_NIX_SHELL}" == 'pure' ]]; then + echo -e "${GRN}Already in a pure Nix shell.${RST}" + exit +fi + +# If none of the checks before succeeded we need to install Nix +echo -e "${GRN}Setting up Nix package manager...${RST}" +install_nix +echo -e "${YLW}See STARTING_GUIDE.md if you're new here.${RST}" diff --git a/nix/scripts/shell.sh b/nix/scripts/shell.sh index 6faab02216..e7a4fb75fc 100755 --- a/nix/scripts/shell.sh +++ b/nix/scripts/shell.sh @@ -11,29 +11,13 @@ # Take note that this makes Nix tools like `nix-build` unavailable in the shell. # - _NIX_KEEP: This variable allows specifying which env vars to keep for Nix pure shell. -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) +source "${GIT_ROOT}/scripts/colors.sh" +source "${GIT_ROOT}/nix/scripts/source.sh" export TERM=xterm # fix for colors shift # we remove the first -c from arguments -if ! command -v "nix" >/dev/null 2>&1; then - if [ -f ~/.nix-profile/etc/profile.d/nix.sh ]; then - . ~/.nix-profile/etc/profile.d/nix.sh - elif [ "$IN_NIX_SHELL" != 'pure' ]; then - echo -e "${GREEN}Setting up environment...${NC}" > /dev/stderr - ./scripts/setup - - . ~/.nix-profile/etc/profile.d/nix.sh - fi -fi - -if !command -v "nix" >/dev/null 2>&1; then - echo "Nix not available, sourcing profile failed!" > /dev/stderr - exit 1 -fi - shellArgs=( "--show-trace" ) @@ -41,7 +25,7 @@ shellArgs=( if [[ -n "${TARGET}" ]]; then shellArgs+=("--argstr target ${TARGET}") else - echo -e "${YELLOW}Env is missing TARGET, assuming default target.${NC} See nix/README.md for more details." 1>&2 + echo -e "${YLW}Env is missing TARGET, assuming default target.${RST} See nix/README.md for more details." 1>&2 fi if [[ "$TARGET" =~ (linux|windows|darwin|macos) ]]; then @@ -74,7 +58,7 @@ fi # ENTER_NIX_SHELL is the fake command used when `make shell` is run. # It is just a special string, not a variable, and a marker to not use `--run`. if [[ $@ == "ENTER_NIX_SHELL" ]]; then - echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET:-default}'...${NC}" 1>&2 + echo -e "${GRN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET:-default}'...${RST}" 1>&2 exec nix-shell ${shellArgs[@]} ${entryPoint} else # Not all builds are ready to be run in a pure environment @@ -87,6 +71,6 @@ else if [[ -n "${_NIX_KEEP}" ]]; then shellArgs+=("--keep ${_NIX_KEEP//;/ --keep }") fi - echo -e "${GREEN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET}'...${NC}" 1>&2 + echo -e "${GRN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET}'...${RST}" 1>&2 exec nix-shell ${shellArgs[@]} --run "$@" ${entryPoint} fi diff --git a/nix/scripts/source.sh b/nix/scripts/source.sh new file mode 100755 index 0000000000..8cd5bc9e0f --- /dev/null +++ b/nix/scripts/source.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# This script makes sure we have Nix tools available + +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) + +function source_nix() { + # Just stop if Nix is already available + if [[ -x $(command -v nix) ]]; then + return + elif [[ -f "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]]; then + # Load Nix profile if it exists + source "${HOME}/.nix-profile/etc/profile.d/nix.sh" + else + # Setup Nix if not available + ${GIT_ROOT}/nix/scripts/setup.sh + fi + + # Verify Nix is available + if [[ ! -x $(command -v nix) ]]; then + echo "Nix not available, sourcing profile failed!" > /dev/stderr + exit 1 + fi +} + +source_nix diff --git a/scripts/build-desktop.sh b/scripts/build-desktop.sh index 5c44c943be..5c9f76340c 100755 --- a/scripts/build-desktop.sh +++ b/scripts/build-desktop.sh @@ -67,7 +67,7 @@ function init() { fi fi - if is_linux; then + if [[ "$OS" =~ Linux ]]; then rm -rf ./desktop/toolchain/ # TODO: Use Conan for Linux and MacOS builds too if is_windows_target; then @@ -267,7 +267,7 @@ function bundleLinux() { echo "" } -if is_macos; then +if [[ "$OS" =~ Darwin ]]; then function copyDylibNixDependenciesToPackage() { local dylib="$1" local contentsDir="$2" @@ -441,9 +441,9 @@ function bundleMacOS() { } function bundle() { - if is_macos; then + if [[ "$OS" =~ Darwin ]]; then bundleMacOS - elif is_linux; then + elif [[ "$OS" =~ Linux ]]; then if is_windows_target; then bundleWindows else diff --git a/scripts/colors.sh b/scripts/colors.sh new file mode 100644 index 0000000000..360634bb5c --- /dev/null +++ b/scripts/colors.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Colors +YLW='\033[1;33m' +RED='\033[0;31m' +GRN='\033[0;32m' +RST='\033[0m' diff --git a/scripts/download-package-files.sh b/scripts/download-package-files.sh deleted file mode 100755 index 45198b4f11..0000000000 --- a/scripts/download-package-files.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -filename=$1 -#fileid="1yPTGcPe5DZd3ubzAgUBp3aAQRAOK9eKQ" -fileid=$2 -rm -rf ./cookie -curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null -curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename} \ No newline at end of file diff --git a/scripts/generate-keystore.sh b/scripts/generate-keystore.sh index 0cef180517..86f1f16cd4 100755 --- a/scripts/generate-keystore.sh +++ b/scripts/generate-keystore.sh @@ -2,22 +2,45 @@ set -euf pipefail +GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) +source "${GIT_ROOT}/scripts/colors.sh" + +function property() { + grep "${2}" "${1}" | cut -d'=' -f2 +} + +function property_gradle() { + property ${GIT_ROOT}/android/gradle.properties ${1} +} + TARGET=${1:-debug} -CURRENT_DIR="$( cd "$( dirname "$0" )" && pwd )" -. "$CURRENT_DIR/lib/setup/path-support.sh" -source_lib "properties.sh" - -STORE_FILE=$(property_gradle 'STATUS_RELEASE_STORE_FILE') -STORE_FILE="${STORE_FILE/#\~/$HOME}" +CURRENT_DIR=$(cd "$(dirname "$0")" && pwd) +KEYSTORE_FILE=$(property_gradle 'STATUS_RELEASE_STORE_FILE') +KEYSTORE_FILE=${KEYSTORE_FILE/#\~/$HOME} STATUS_RELEASE_STORE_PASSWORD=$(property_gradle 'STATUS_RELEASE_STORE_PASSWORD') STATUS_RELEASE_KEY_ALIAS=$(property_gradle 'STATUS_RELEASE_KEY_ALIAS') STATUS_RELEASE_KEY_PASSWORD=$(property_gradle 'STATUS_RELEASE_KEY_PASSWORD') -[[ -e "$STORE_FILE" ]] && exit 0 +if [[ -e "${KEYSTORE_FILE}" ]]; then + echo -e "${YLW}Keystore file already exists:${RST} ${KEYSTORE_FILE}" > /dev/stderr + exit 0 +fi -echo "Generating keystore $STORE_FILE" -keydirname="$( dirname "$STORE_FILE" )" -[ -d $keydirname ] || mkdir -p $keydirname -keytool -genkey -v -keystore ${STORE_FILE} -keyalg RSA -keysize 2048 -validity 10000 -alias ${STATUS_RELEASE_KEY_ALIAS} \ - -storepass ${STATUS_RELEASE_STORE_PASSWORD} -keypass ${STATUS_RELEASE_KEY_PASSWORD} -dname "CN=, OU=, O=, L=, S=, C=" \ No newline at end of file +KEYSTORE_DIR=$(dirname "${KEYSTORE_FILE}") +[[ -d $KEYSTORE_DIR ]] || mkdir -p $KEYSTORE_DIR + +echo "Generating keystore ${KEYSTORE_FILE}" > /dev/stderr + +keytool -genkey -v \ + -keyalg RSA \ + -keysize 2048 \ + -validity 10000 \ + -dname "CN=, OU=, O=, L=, S=, C=" + -keystore "${KEYSTORE_FILE}" \ + -alias "${STATUS_RELEASE_KEY_ALIAS}" \ + -storepass "${STATUS_RELEASE_STORE_PASSWORD}" \ + -keypass "${STATUS_RELEASE_KEY_PASSWORD}" \ + > /dev/stderr + +echo "${KEYSTORE_FILE}" diff --git a/scripts/inotify_fix.sh b/scripts/inotify_fix.sh index c8be54d70f..f326f2717f 100755 --- a/scripts/inotify_fix.sh +++ b/scripts/inotify_fix.sh @@ -3,21 +3,20 @@ # If this is not run on some machines react-native builds fail. GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) -source "$GIT_ROOT/scripts/lib/setup/path-support.sh" +source "${GIT_ROOT}/scripts/colors.sh" -source_lib "output.sh" -source_lib "platform.sh" - -if ! is_linux; then +if [[ "$(uname -s)" != Linux ]]; then echo "inotify fix not applicable on non-linux OS" - return + exit fi watches=$(cat /proc/sys/fs/inotify/max_user_watches) required_watches=524288 if [ $watches -lt $required_watches ]; then - cecho "@b@cyan[[fs.inotify.max_user_watches limit is too low ($watches), increasing it]]" - echo fs.inotify.max_user_watches=$required_watches | sudo tee -a /etc/sysctl.conf + echo -e "${YLW}fs.inotify.max_user_watches limit is too low ($watches). Increasing it.${RST}" + echo "fs.inotify.max_user_watches = $required_watches" | sudo tee -a /etc/sysctl.conf sudo sysctl -p +else + echo -e "${GRN}fs.inotify.max_user_watches limit is high enough.${RST}" fi diff --git a/scripts/lib/setup/output.sh b/scripts/lib/setup/output.sh deleted file mode 100755 index d827a74d21..0000000000 --- a/scripts/lib/setup/output.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -function load_color_support() { - # Check if we're in a terminal - if test -t 1; then - local color_count=$(tput colors) - - # Only load colors if our terminal supports them - if test -n "$color_count" && test $color_count -ge 8; then - _color_bold="$(tput bold)" - _color_underline="$(tput sgr 0 1)" - _color_red="$(tput setaf 1)" - _color_green="$(tput setaf 2)" - _color_yellow="$(tput setaf 3)" - _color_blue="$(tput setaf 4)" - _color_magenta="$(tput setaf 5)" - _color_cyan="$(tput setaf 6)" - _color_white="$(tput setaf 7)" - _color_reset="$(tput sgr0)" - fi - fi -} - -load_color_support - -function cecho() { - local colorized=$( - echo "$@" | sed -E \ - -e 's/((@(red|green|yellow|blue|magenta|cyan|white|reset|b|u))+)[[]{2}(.*)[]]{2}/\1\4@reset/g' \ - -e "s/@red/${_color_red}/g" \ - -e "s/@green/${_color_green}/g" \ - -e "s/@yellow/${_color_yellow}/g" \ - -e "s/@blue/${_color_blue}/g" \ - -e "s/@magenta/${_color_magenta}/g" \ - -e "s/@cyan/${_color_cyan}/g" \ - -e "s/@white/${_color_white}/g" \ - -e "s/@reset/${_color_reset}/g" \ - -e "s/@b/${_color_bold}/g" \ - -e "s/@u/${_color_underline}/g" - ) - - echo "$colorized" -} - -function setup_header() { - local header=$1 - - cecho "@b@green[[$header]]" - echo -} - -function already_installed() { - local package=$1 - - cecho "+ $package already installed... skipping" -} - -function setup_complete() { - cecho "@b@blue[[Setup complete!]] -=============== - -There are a few @b[[manual steps]] you might want to do: - -1. Optionally set up Genymotion if you don't want to use Android Virtual Device: - - @blue[[https://www.genymotion.com]] - -2. Setup Android Development Environment + Simulator: - - @blue[[https://facebook.github.io/react-native/docs/getting-started.html]] - -3. Add your SSH public key to Github if it isn't already in there. - -To build the app, please run one of the @b[[make release-*]] commands. -" - - echo -} diff --git a/scripts/lib/setup/packages.sh b/scripts/lib/setup/packages.sh deleted file mode 100755 index 6c09418a1c..0000000000 --- a/scripts/lib/setup/packages.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -######## -# Install checks -######## - -GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) - -function program_exists() { - local program=$1 - command -v "$program" >/dev/null 2>&1 -} - -function program_version_exists() { - local program=$1 - if ! program_exists "$program"; then - $(exit 1) - return - fi - - local required_version=$2 - if echo "$($program --version)" | grep -q -wo "$required_version\|$required_version[^\.]"; then - $(exit 0) - return - fi - $(exit 1) -} diff --git a/scripts/lib/setup/path-support.sh b/scripts/lib/setup/path-support.sh deleted file mode 100644 index 32a1c930ec..0000000000 --- a/scripts/lib/setup/path-support.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd) -_scripts_dir=$(cd "$_current_dir/../.." && pwd) -_repo_dir=$(cd "$_scripts_dir/.." && pwd) - -function scripts_path() { - echo $_scripts_dir -} - -function repo_path() { - echo $_repo_dir -} - -function source_lib() { - local library_path=$1 - - source "$_current_dir/$library_path" -} diff --git a/scripts/lib/setup/platform.sh b/scripts/lib/setup/platform.sh deleted file mode 100755 index 8b313978cb..0000000000 --- a/scripts/lib/setup/platform.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -OS=$(uname -s) - -function is_macos() { - [[ "$OS" =~ Darwin ]] -} - -function is_linux() { - [[ "$OS" =~ Linux ]] -} - -function is_nixos() { - is_linux && [[ "$(uname -v)" == *NixOS* ]] -} - -function exit_unless_os_supported() { - if [ "$IN_NIX_SHELL" == 'pure' ]; then - cecho "@red[[This install script is not supported in a pure Nix shell]]" - - echo - exit 1 - fi - - if ! is_macos && ! is_linux; then - cecho "@red[[This install script currently supports Mac OS X and Linux \ -via apt. To manually install, please visit the docs for more information:]] - - @blue[[https://status.im/build_status]]" - echo - exit 1 - fi -} diff --git a/scripts/lib/setup/properties.sh b/scripts/lib/setup/properties.sh deleted file mode 100755 index c9970ee50e..0000000000 --- a/scripts/lib/setup/properties.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -function property() { - grep "${2}" ${1}|cut -d'=' -f2 -} - -function property_gradle() { - property $(repo_path)/android/gradle.properties ${1} -} \ No newline at end of file diff --git a/scripts/release-android.sh b/scripts/release-android.sh index a1fddae950..a632380bb2 100755 --- a/scripts/release-android.sh +++ b/scripts/release-android.sh @@ -1,10 +1,6 @@ #!/usr/bin/env bash GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) -_current_dir=$(cd "${BASH_SOURCE%/*}" && pwd) -source "$_current_dir/lib/setup/path-support.sh" - -source_lib "platform.sh" config='' config+="status-im.build-type=\"${BUILD_TYPE}\";" @@ -15,23 +11,24 @@ if [ -n "${NIMBUS_SRC_OVERRIDE}" ]; then config+="status-im.nimbus.src-override=\"${NIMBUS_SRC_OVERRIDE}\";" fi config+="status-im.status-react.build-number=\"${BUILD_NUMBER}\";" -config+="status-im.status-react.keystore-file=\"${STORE_FILE}\";" +config+="status-im.status-react.keystore-file=\"${KEYSTORE_FILE}\";" nixOpts=( "--arg config {${config}}" "--arg env {BUILD_ENV=\"${BUILD_ENV}\";ANDROID_ABI_SPLIT=\"${ANDROID_ABI_SPLIT}\";ANDROID_ABI_INCLUDE=\"${ANDROID_ABI_INCLUDE}\";}" ) -if is_macos; then +if [[ "$OS" =~ Darwin ]]; then # Start a watchman instance if not started already and store its socket path. - # In order to get access to the right versions of watchman and jq, we start an ad-hoc nix-shell that imports the packages from nix/nixpkgs-bootstrap. + # In order to get access to the right versions of watchman and jq, + # we start an ad-hoc nix-shell that imports the packages from nix/nixpkgs-bootstrap. WATCHMAN_SOCKFILE=$(watchman get-sockname --no-pretty | jq -r .sockname) nixOpts+=( "--argstr watchmanSockPath ${WATCHMAN_SOCKFILE}" - "--option extra-sandbox-paths ${STORE_FILE};${WATCHMAN_SOCKFILE}" + "--option extra-sandbox-paths ${KEYSTORE_FILE};${WATCHMAN_SOCKFILE}" ) else nixOpts+=( - "--option extra-sandbox-paths ${STORE_FILE}" + "--option extra-sandbox-paths ${KEYSTORE_FILE}" ) fi diff --git a/scripts/setup b/scripts/setup deleted file mode 100755 index c015e5dd06..0000000000 --- a/scripts/setup +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash - -######################################################################## -# This install script will setup your development dependencies on OS X -# or Ubuntu. Ubuntu 18.04 is the only tested version. -# It is not required or supported in NixOS. -# -# Usage: scripts/setup -######################################################################## - -GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel) -source "$GIT_ROOT/scripts/lib/setup/path-support.sh" - -source_lib "output.sh" -source_lib "packages.sh" -source_lib "platform.sh" - -exit_unless_os_supported - -#### -setup_header "Checking prerequisites..." - -_need_curl=0 -! is_nixos && ! program_exists nix && _need_curl=1 - -if [ $_need_curl -eq 1 ] && ! program_exists "curl"; then - cecho "@b@yellow[[Please install curl before running setup.]]" - exit 1 -fi - -# bump max watches limit to avoid issues with RN builds -$GIT_ROOT/scripts/inotify_fix.sh - -#### -setup_header "Installing requirements..." - -if [ "$IN_NIX_SHELL" != 'pure' ] && ! is_nixos && ! program_exists nix; then - required_version="2.3.2" - NIX_INSTALLER_NO_MODIFY_PROFILE=1 NIX_IGNORE_SYMLINK_STORE=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}" - else - echo "Please see https://nixos.org/nix/manual/#chap-installation" - exit - fi -fi - -#### -setup_complete