forked from equinor/komodo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·109 lines (91 loc) · 2.68 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
#!/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.
python3_bin=/usr/bin/python3.8
if [[ ! -f "${python3_bin}" ]]; then
# Lets assume we're on a RHEL 7 machine
python3_bin=/opt/rh/rh-python38/root/usr/bin/python3.8
fi
if [[ ! -f "${python3_bin}" ]]; then
echo "Couldn't find a Python 3.8 binary"
exit 1
fi
echo "Installing Komodo"
$python3_bin -m venv boot/kmd-env
boot/kmd-env/bin/python -m pip install virtualenv pytest .
}
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 "${GITHUB_ACTIONS:-}" ]]; then
# Github Actions 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 "${GITHUB_ACTIONS:-}" ]]; then
# On Ubuntu 18.04 (bionic), the 'cmake' package is CMake 3.10
cmake_bin=/usr/local/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_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 setuptools wheel virtualenv
ln -s $PWD/boot/build-env/bin/pip boot/bintools/
}
function create_runkmd {
cat << EOF > runkmd.sh
#!/bin/bash
export PATH=$PWD/boot/bintools:$PWD/boot/build-env/bin:\$PATH
export VIRTUAL_ENV=$PWD/boot/build-env
$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
create_runkmd