forked from equinor/komodo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·133 lines (113 loc) · 3.43 KB
/
bootstrap.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
set -eux
function usage {
echo "Usage: $0 [TARGET PYTHON EXECUTABLE]"
exit 1
}
[ -z "${1:-}" ] && usage
[[ ! -f "$1" ]] && usage
python_bin=$1
function cleanup {
if [ -d "boot" ]; then
echo "boot/ exists, deleting"
rm -r boot
fi
if [ -f "runkmd.sh" ]; then
echo "runkmd.sh exists, deleting"
rm runkmd.sh
fi
}
function install_komodo {
# Install the environment that the kmd executable will run in. We also
# install the virtualenv package because the user might specify to target
# Python 2.7, where the 'venv' module doesn't exist.
python3_bin=/usr/bin/python3
if [[ -n "${TRAVIS:-}" ]]; then
# Travis provides Python via a virtualenv, lets respect that
python3_bin=/opt/python/${TRAVIS_PYTHON_VERSION}/bin/python3
fi
if [[ ! -f "${python3_bin}" ]]; then
# Lets assume we're on an Equinor machine
python3_bin=/prog/sdpsoft/python3.6.4/bin/python3
fi
if [[ ! -f "${python3_bin}" ]]; then
echo "Couldn't find a Python 3 binary"
exit 1
fi
echo "Installing Komodo"
$python3_bin -m venv boot/kmd-env
boot/kmd-env/bin/python -m pip install --upgrade pip pytest virtualenv
boot/kmd-env/bin/python -m pip install .
}
function install_devtoolset {
# Install devtoolset simply by symlinking everything from its bin. Note that
# we don't need to use LD_LIBRARY_PATH or any other environment variables to
# get this to work.
if [[ -n "${TRAVIS:-}" ]]; then
# Travis uses Ubuntu which doesn't have devtoolset, but the build tools
# are new enough
return
fi
if [[ ! -d "/opt/rh/devtoolset-8" ]]; then
echo "Couldn't find Devtoolset 8"
exit 1
fi
echo "Using devtoolset-8"
for binfile in /opt/rh/devtoolset-8/root/usr/bin/*; do
ln -s $binfile boot/bintools/
done
boot/bintools/gcc --version
}
function install_cmake {
# The RHEL /usr/bin/cmake is CMake 2.8, which is positively ancient,
# Use /usr/bin/cmake3 instead.
cmake_bin=/usr/bin/cmake3
if [[ -n "${TRAVIS:-}" ]]; then
# On Ubuntu 18.04 (bionic), the 'cmake' package is CMake 3.10
cmake_bin=/usr/bin/cmake
fi
if [[ ! -f "${cmake_bin}" ]]; then
echo "Couldn't find a CMake3 executable"
exit 1
fi
echo "Using CMake3"
ln -s ${cmake_bin} boot/bintools/cmake
boot/bintools/cmake --version
}
function install_git {
# git is too old for both RHEL6 and RHEL7, prefer the one from SDPSoft
git_bin=/prog/sdpsoft/git-2.8.0/bin/git
if [[ ! -f "${git_bin}" ]]; then
echo "Couldn't find SDPSoft git, falling back to system git"
git_bin=/usr/bin/git
fi
if [[ ! -f "${git_bin}" ]]; then
echo "Couldn't find system git either, failing"
exit 1
fi
echo "Using git"
ln -s ${git_bin} boot/bintools/git
boot/bintools/git --version
}
function install_build_env {
echo "Using ${python_bin} for target"
boot/kmd-env/bin/virtualenv --python=${python_bin} boot/build-env
boot/build-env/bin/pip install --upgrade pip
ln -s $PWD/boot/build-env/bin/pip boot/bintools/
}
function create_runkmd {
cat << EOF > runkmd.sh
#!/bin/bash
export PATH=$PWD/boot/bintools:\$PATH
$PWD/boot/kmd-env/bin/kmd "\$@"
EOF
chmod +x runkmd.sh
}
cleanup
mkdir -p boot/bintools
install_komodo
install_build_env
install_devtoolset
install_cmake
install_git
create_runkmd