File size: 2,614 Bytes
67acd34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3204772
 
67acd34
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PYTHON_BIN="${PYTHON_BIN:-$(command -v python3 || command -v python)}"

if [[ -z "${PYTHON_BIN}" ]]; then
  echo "Python interpreter not found." >&2
  exit 1
fi

DEBIAN_MIRROR="${DEBIAN_MIRROR:-https://ftp.us.debian.org/debian}"
DEBIAN_SECURITY_MIRROR="${DEBIAN_SECURITY_MIRROR:-https://security.debian.org/debian-security}"
CPU_COUNT="$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 4)"

if command -v apt-get >/dev/null 2>&1; then
  sed -i "s|http://deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list || true
  sed -i "s|https://deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list || true
  sed -i "s|http://security.debian.org|${DEBIAN_SECURITY_MIRROR}|g" /etc/apt/sources.list || true
  sed -i "s|https://security.debian.org|${DEBIAN_SECURITY_MIRROR}|g" /etc/apt/sources.list || true
  if ls /etc/apt/sources.list.d/*.list >/dev/null 2>&1; then
    sed -i "s|http://deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/*.list
    sed -i "s|https://deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list.d/*.list
    sed -i "s|http://security.debian.org|${DEBIAN_SECURITY_MIRROR}|g" /etc/apt/sources.list.d/*.list
    sed -i "s|https://security.debian.org|${DEBIAN_SECURITY_MIRROR}|g" /etc/apt/sources.list.d/*.list
  fi

  APT_ARGS=(
    -o Acquire::Retries=5
    -o Acquire::http::Timeout=30
    -o Acquire::https::Timeout=30
  )

  apt-get update "${APT_ARGS[@]}"
  apt-get install -y --no-install-recommends "${APT_ARGS[@]}" \
    ca-certificates \
    build-essential \
    cmake \
    gcc \
    git \
    imagemagick \
    libgtk-3-dev \
    pkg-config
  rm -rf /var/lib/apt/lists/*
else
  echo "apt-get not found; skipping OS package installation and assuming build tools are already available."
fi

"${PYTHON_BIN}" -m pip install --upgrade pip setuptools wheel
"${PYTHON_BIN}" -m pip install -e "${ROOT_DIR}"
"${PYTHON_BIN}" -m pip install "pygame>=2.1.0"

pushd "${ROOT_DIR}/submodules/rlp" >/dev/null
"${PYTHON_BIN}" setup.py build_ext --inplace
popd >/dev/null

find "${ROOT_DIR}/submodules/rlp/puzzles" -type f -name "*.sh" -exec chmod +x {} +

mkdir -p "${ROOT_DIR}/submodules/rlp/rlp/lib"
pushd "${ROOT_DIR}/submodules/rlp/rlp/lib" >/dev/null
cmake ../../puzzles
make -j"${CPU_COUNT}" libbridges libgalaxies libloopy libpattern libundead
popd >/dev/null

pushd "${ROOT_DIR}/submodules/flowfree" >/dev/null
gcc -std=c11 -O2 -Wall -Wextra -o flowfree_all_solutions flowfree_all_solutions.c
popd >/dev/null

echo "TopoBench install complete."