Skip to content

Commit d7e1e0e

Browse files
committed
initial commit work in progress
1 parent 05e3a32 commit d7e1e0e

22 files changed

Lines changed: 297 additions & 27 deletions

install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ BDM_PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3333

3434
# Detect the OS (or get the one the user specified)
3535
if [ -z $1 ]; then
36-
BDM_DETECTED_OS=$(DetectOs)
36+
BDM_DETECTED_GEN_OS=$(DetectOs2)
3737
else
38-
BDM_DETECTED_OS=$1
38+
BDM_DETECTED_GEN_OS=$1
3939
fi
4040

4141
# Install all prerequisites
42-
$BDM_PROJECT_DIR/prerequisites.sh all ${BDM_DETECTED_OS}
42+
$BDM_PROJECT_DIR/prerequisites.sh all ${BDM_DETECTED_GEN_OS}
4343
if [ $? != 0 ]; then
4444
exit 1
4545
fi
4646

4747
# call install script for the detected OS
48-
$BDM_PROJECT_DIR/util/installation/common/install.sh ${BDM_DETECTED_OS}
48+
$BDM_PROJECT_DIR/util/installation/common/install.sh ${BDM_DETECTED_GEN_OS}

util/installation/common/util.sh

100755100644
Lines changed: 129 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# (Thus reducing code duplication)
1818

1919
SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
SPECIFIC_OSES_SUPPORTED="ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, centos-7, osx"
2021

2122
#include echo.sh
2223
. $SCRIPTPATH/echo.sh
@@ -58,6 +59,29 @@ function DetectOs {
5859
fi
5960
}
6061

62+
function DetectOs2 {
63+
# detect operating system
64+
if [ `uname` = "Linux" ]; then
65+
# linux
66+
PROCVERSION=$(cat /proc/version)
67+
if echo "$PROCVERSION" | grep -Eiq 'Red Hat' ; then
68+
echo rhel;
69+
elif echo "$PROCVERSION" | grep -Eiq 'debian|buntu|mint|eepin' ; then
70+
echo debian;
71+
elif echo "$PROCVERSION" | grep -Eiq 'SUSE|suse' ; then
72+
echo suse;
73+
else
74+
echo other_distro;
75+
fi
76+
elif [ `uname` = "Darwin" ]; then
77+
# macOS
78+
echo osx
79+
else
80+
echo "ERROR: Operating system `uname` is not supported."
81+
exit 1
82+
fi
83+
}
84+
6185
# This function checks if the given operating system is supported. If not, it
6286
# prints an error message, a list of supported systems; and exits the script.
6387
# Arguments:
@@ -71,10 +95,18 @@ function CheckOsSupported {
7195

7296
local BDM_INSTALL_SRC=$1
7397
local BDM_OS=$2
74-
75-
local BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS
76-
77-
if [ ! -d "$BDM_INSTALL_OS_SRC" ]; then
98+
local BDM_INSTALL_OS_SRC=""
99+
local SPECIFIC_BDM_OS=$(DetectOs)
100+
101+
if echo "$SPECIFIC_OSES_SUPPORTED" | grep -Eiq "$SPECIFIC_BDM_OS" ; then
102+
if [ "$BDM_OS" == "osx" ]; then
103+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
104+
else
105+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/$SPECIFIC_BDM_OS
106+
fi
107+
elif [ "$BDM_OS" == "osx" ] || [ "$BDM_OS" == "rhel" ] || [ "$BDM_OS" == "debian" ] || [ "$BDM_OS" == "suse" ] ; then
108+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
109+
else
78110
echo "ERROR: This operating system (${BDM_OS}) is not supported"
79111
echo "Supported operating systems are: "
80112
pushd $BDM_INSTALL_SRC > /dev/null
@@ -108,12 +140,27 @@ function CompileListOfPackages {
108140
local BDM_INSTALL_SRC="$2"
109141
local LOCAL_OS=$3
110142

143+
local SPECIFIC_BDM_OS=$(DetectOs)
144+
local BDM_OS=$(DetectOs2)
111145
# The list of packages on Ubuntu 20.04 is identical to Ubuntu 18.04
112-
if [ $LOCAL_OS == "ubuntu-20.04" ]; then
113-
LOCAL_OS="ubuntu-18.04"
146+
if [ $SPECIFIC_BDM_OS == "ubuntu-20.04" ]; then
147+
SPECIFIC_BDM_OS="ubuntu-18.04"
114148
fi
115149

116-
local BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$LOCAL_OS
150+
local BDM_INSTALL_OS_SRC=""
151+
152+
if echo "$SPECIFIC_OSES_SUPPORTED" | grep -Eiq "$SPECIFIC_BDM_OS" ; then
153+
if [ "$BDM_OS" == "osx" ]; then
154+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
155+
else
156+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/$SPECIFIC_BDM_OS
157+
fi
158+
elif [ "$BDM_OS" == "osx" ] || [ "$BDM_OS" == "rhel" ] || [ "$BDM_OS" == "debian" ] || [ "$BDM_OS" == "suse" ]; then
159+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
160+
else
161+
echo "ERROR: This operating system (${BDM_OS}) is not supported"
162+
exit 1;
163+
fi
117164

118165
BDM_PKG_LIST=""
119166
if [ $1 == "all" ]; then
@@ -179,7 +226,65 @@ function CleanBuild {
179226
else
180227
mkdir -p $BUILD_DIR
181228
fi
229+
cd $BDM_PROJECT_DIR
230+
BDM_PROJECT_DIR_2=$(pwd)
182231
cd $BUILD_DIR
232+
233+
CLEAN_BUILD_OS=$(DetectOs2)
234+
235+
GCC_VER=$(gcc --version | grep gcc) || true
236+
#GCC_VER=$(gcc --version | grep gcc | grep -oE ' |\S+' | awk '{print $NF}' | cut -d '.' -f 1-2)
237+
if [ -n "${GCC_VER}" ]; then
238+
read -ra tokens <<< $GCC_VER
239+
result=()
240+
current_token=""
241+
for token in "${tokens[@]}"; do
242+
if [[ -n $current_token ]]; then
243+
current_token+=" $token"
244+
if [[ $current_token == *')' ]]; then
245+
result+=("$current_token")
246+
current_token=""
247+
fi
248+
else
249+
if [[ $token == '('* && $token != *')' ]]; then
250+
current_token="$token"
251+
else
252+
result+=("$token")
253+
fi
254+
fi
255+
done
256+
if [[ -n $current_token ]]; then
257+
result+=("$current_token")
258+
fi
259+
GCC_VER=${result[2]}
260+
GCC_VER=$( echo $GCC_VER | cut -d '.' -f 1-2)
261+
fi
262+
if [ "$CLEAN_BUILD_OS"!="osx" ]; then
263+
if [ -z "${GCC_VER}" ] || [ `echo "$GCC_VER >= 12" | bc -q` -ne 0 ] || [ `echo "$GCC_VER < 9" | bc -q` -ne 0 ]; then
264+
265+
266+
if $(command -v gcc-11 > /dev/null) && $(command -v g++-11 > /dev/null) && $(command -v gfortran-11 > /dev/null); then
267+
268+
echo "******************************************************************"
269+
echo "Found suitable gcc version installed (gcc-11) via your
270+
distribution's package manager.
271+
Using that."
272+
echo "******************************************************************";
273+
274+
export CC=gcc-11
275+
export CXX=g++-11
276+
export FC=gfortran-11
277+
export OMPI_CC=gcc-11
278+
export OMPI_CXX=g++-11
279+
export OMPI_FC=gfortran-11
280+
export QMAKE_CC=gcc-11
281+
export QMAKE_CXX=g++-11
282+
export LINK=g++-11
283+
284+
fi
285+
fi
286+
fi
287+
183288
echo "CMAKEFLAGS $BDM_CMAKE_FLAGS"
184289
cmake $BDM_CMAKE_FLAGS ..
185290
make -j$(CPUCount) && make install
@@ -217,15 +322,28 @@ function CallOSSpecificScript {
217322
shift
218323
local BDM_SCRIPT_FILE="$1"
219324
shift
220-
local BDM_LOCAL_OS=$(DetectOs)
325+
local SPECIFIC_BDM_OS=$(DetectOs)
326+
local BDM_OS=$(DetectOs2)
221327
local BDM_SCRIPT_ARGUMENTS=$@
222328
local BDM_INSTALL_SRC=$BDM_PROJECT_DIR/util/installation
223329

224330
# detect os
225-
local BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_LOCAL_OS
331+
local BDM_INSTALL_OS_SRC=""
332+
333+
if echo "$SPECIFIC_OSES_SUPPORTED" | grep -Eiq "$SPECIFIC_BDM_OS" ; then
334+
if [ "$BDM_OS" == "osx" ]; then
335+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
336+
else
337+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/$SPECIFIC_BDM_OS
338+
fi
339+
elif [ "$BDM_OS" == "osx" ] || [ "$BDM_OS" == "rhel" ] || [ "$BDM_OS" == "debian" ] || [ "$BDM_OS" == "suse" ]; then
340+
BDM_INSTALL_OS_SRC=$BDM_INSTALL_SRC/$BDM_OS/common
341+
else
342+
echo "ERROR: This operating system (${BDM_OS}) is not supported"
343+
exit 1;
344+
fi
226345

227346
# check if this system is supported
228-
CheckOsSupported $BDM_INSTALL_SRC $BDM_LOCAL_OS
229347

230348
# check if script exists for the detected OS
231349
local BDM_SCRIPTPATH=$BDM_INSTALL_OS_SRC/$BDM_SCRIPT_FILE
@@ -390,7 +508,7 @@ function EchoFinishInstallation {
390508
EchoNewStep "For other shells, or for more information, see:"
391509
EchoNewStep " ${BDM_ECHO_UNDERLINE}https://biodynamo.org/docs/userguide/first_steps/"
392510
echo
393-
# any warnings about users' post-install shell
511+
# any warnings about users' post-install shell
394512
# configuration may be added to the function called below
395513
WarnPossibleBadShellConfigs || true
396514
}
File renamed without changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
curl
3+
freeglut3-dev
4+
g++
5+
gcc
6+
gcc-11
7+
g++-11
8+
gfortran-11
9+
git
10+
libblas-dev
11+
libbz2-dev
12+
liblapack-dev
13+
libnuma-dev
14+
libomp5
15+
libomp-dev
16+
libopenmpi-dev
17+
libpthread-stubs0-dev
18+
make
19+
wget
20+
zlib1g-dev
21+
python3-dev
22+
libbz2-dev
23+
libffi-dev
24+
liblzma-dev
25+
libreadline-dev
26+
libsqlite3-dev
27+
libssl-dev
28+
python3-openssl
29+
tk-dev
30+
xz-utils
31+
zlib1g-dev
32+
patch
File renamed without changes.

util/installation/ubuntu-18.04/prerequisites.sh renamed to util/installation/debian/common/prerequisites.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Arguments:
2525
exit 1
2626
fi
2727

28-
BDM_PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../.."
28+
BDM_PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../.."
2929

3030
# Required to add Kitware ppa below
3131
sudo apt-get update
@@ -40,17 +40,15 @@ sudo apt-get install apt-transport-https
4040
# Update
4141
sudo apt-get update
4242

43-
44-
# Install required packages
45-
sudo apt-get install -y \
46-
$(cat $BDM_PROJECT_DIR/util/installation/ubuntu-18.04/package_list_required)
47-
4843
CMAKE_VER=3.19.3
4944
CMAKE_SH="cmake-${CMAKE_VER}-linux-x86_64.sh"
5045
curl -L -O https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/${CMAKE_SH}
5146
sudo bash "${CMAKE_SH}" --prefix=/usr/local --skip-license
5247
rm "${CMAKE_SH}"
5348

49+
# Install required packages
50+
sudo apt-get install -y \
51+
$(cat $BDM_PROJECT_DIR/util/installation/debian/common/package_list_required)
5452

5553
if [ -n "${PYENV_ROOT}" ]; then
5654
unset PYENV_ROOT
@@ -80,10 +78,10 @@ pyenv shell $PYVERS
8078
# Install optional packages
8179
if [ $1 == "all" ]; then
8280
# Don't install --user: the packages should end up in the PYENV_ROOT directory
83-
python -m pip install -r $BDM_PROJECT_DIR/util/installation/ubuntu-18.04/pip_packages.txt
81+
python -m pip install -r $BDM_PROJECT_DIR/util/installation/debian/common/pip_packages.txt
8482

8583
sudo apt-get install -y \
86-
$(cat $BDM_PROJECT_DIR/util/installation/ubuntu-18.04/package_list_extra)
84+
$(cat $BDM_PROJECT_DIR/util/installation/debian/common/package_list_extra)
8785
fi
8886

8987
exit 0
File renamed without changes.
File renamed without changes.

util/installation/ubuntu-18.04/package_list_required renamed to util/installation/debian/ubuntu-18.04/package_list_required

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)