File size: 1,654 Bytes
784ee2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

set -euo pipefail

# allow this script to be invoked from any folder
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [[ "$OSTYPE" == "darwin"* ]] && [[ $EUID -eq 0 ]]; then
  echo "Do NOT run this script with sudo on macOS"
  exit 1
fi

if [[ "$OSTYPE" != "darwin"* ]] && [[ $EUID -ne 0 ]]; then
  echo "This script must be run with sudo on Linux"
  exit 1
fi

tmpfile=$(mktemp)
# any error messages from this command will stand out
# more clearly when run as a separate command rather than
# being piped
git submodule status --recursive > "$tmpfile"

if grep -q "^-" "$tmpfile"; then
  if [[ "$OSTYPE" == "darwin"* ]]; then
    git submodule update --init --recursive
  else
    sudo -u $SUDO_USER git submodule update --init --recursive
  fi
elif grep -q "^+" "$tmpfile"; then
  # Make it easy for users who are not hacking ORFS to do the right thing,
  # run with current submodules, at the cost of having ORFS
  # hackers disable this test manually when hacking setup.sh
  echo "Submodules are not up to date, run 'git submodule update --recursive' and try again"
  exit 1
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
  if [[ ! -d "$DIR/.venv" ]]; then
    echo "Creating Python virtual environment at $DIR/.venv"
    python3 -m venv "$DIR/.venv"
  fi

  echo "Activating virtual environment"
  source "$DIR/.venv/bin/activate"

  python -m pip install --upgrade pip
fi

"$DIR/etc/DependencyInstaller.sh" -base
if [[ "$OSTYPE" == "darwin"* ]]; then
  "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
else
  sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
fi