-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
executable file
·127 lines (102 loc) · 2.82 KB
/
install.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
#!/bin/bash
# Copyright (C) 2019-2022, CNES and contributors (for the Euclid Science Ground Segment)
# This file is part of EleFits <github.com/CNES/EleFits>
# SPDX-License-Identifier: LGPL-3.0-or-later
# Adapted from bash script template from https://github.com/leogtzr/minimal-safe-bash-template/blob/main/template-v1.sh
set -o errexit
set -o nounset
set -o pipefail
readonly script_name="${0##*/}"
readonly error_parsing_options=81
trap clean_up ERR EXIT SIGINT SIGTERM
# By default build in /tmp
build_dir="/tmp/build_elefits"
parallel_build=1
build_dir_option_flag=0
j_option_flag=0
usage() {
cat <<USAGE_TEXT
Usage: ${script_name} [-h | --help] [-d | --build_dir] [-j | --parallel]
DESCRIPTION
Installation script for Elefits (downloads, builds and installs Elements first, then EleFits)
OPTIONS:
-h, --help
Print this help and exit.
-d, --build_dir
Build directory (/tmp/build_elefits by default).
-j, --parallel
Specifies the number of jobs to run simultaneously.
USAGE_TEXT
}
clean_up() {
trap - ERR EXIT SIGINT SIGTERM
# Remove temporary build directories
echo "Remove ${build_dir}..."
if [ -d "${build_dir}" ]; then rm -Rf ${build_dir}; fi
}
parse_user_options() {
local -r args=("${@}")
local opts
# The following code works perfectly for
opts=$(getopt --options d:,h,j: --long help:,build_dir,parallel -- "${args[@]}" 2> /dev/null) || {
usage
die "error: parsing options" "${error_parsing_options}"
}
eval set -- "${opts}"
while true; do
case "${1}" in
--help|-h)
usage
exit 0
shift
;;
-d|--build_dir)
build_dir_option_flag=1
readonly d_arg="${2}"
shift
shift
;;
-j|--parallel)
j_option_flag=1
readonly j_arg="${2}"
echo "parallel build with nb_jobs= ${2}"
shift
shift
;;
--)
shift
break
;;
*)
break
;;
esac
done
}
parse_user_options "${@}"
if ((build_dir_option_flag)); then
echo "Using --build_dir option -> arg: [${d_arg}]"
build_dir="${d_arg}"
fi
if ((j_option_flag)); then
echo "Using -j option -> arg: [${j_arg}]"
parallel_build="${j_arg}"
fi
mkdir -p "${build_dir}"
cd "${build_dir}"
cd "${build_dir}"
git clone https://github.com/astrorama/Elements.git
cd Elements
git checkout 6.2.1
mkdir build ; cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j "${parallel_build}"
make install
cd "${build_dir}"
git clone -b release-5.3 https://github.com/CNES/EleFits.git
cd EleFits
mkdir build ; cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_PREFIX_PATH=/usr/local ..
make -j "${parallel_build}"
make install
exit 0