Newer
Older
#!/bin/bash
################################################################################
# Copyright 2018-2022, Barcelona Supercomputing Center (BSC), Spain #
# Copyright 2015-2022, Johannes Gutenberg Universitaet Mainz, Germany #
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
# #
# This software was partially supported by the #
# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). #
# #
# This software was partially supported by the #
# ADA-FS project under the SPPEXA project funded by the DFG. #
# #
# This file is part of GekkoFS. #
# #
# GekkoFS is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# GekkoFS is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with GekkoFS. If not, see <https://www.gnu.org/licenses/>. #
# #
# SPDX-License-Identifier: GPL-3.0-or-later #
################################################################################
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage_short() {
echo "
usage: compile_dep.sh -h |
-p PROFILE_NAME[:PROFILE_VERSION] |
-d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] |
-l [PROFILE_NAME:[PROFILE_VERSION]] |
-h
[ -P PROFILES_DIR ] [ -j COMPILE_CORES] [ -n ] [ -v ]
SOURCES_PATH INSTALL_PATH
"
}
help_msg() {
usage_short
echo "
This script downloads and compiles all GekkoFS dependencies (excluding the fs itself)
positional arguments:
SOURCES_PATH path to the downloaded sources for the dependencies
INSTALL_PATH path to the installation directory for the built dependencies
optional arguments:
-h, --help Shows this help message and exits
-l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION]
List dependencies available for building and installation
-p, --profile PROFILE_NAME[:PROFILE_VERSION]
Allows installing a pre-defined set of dependencies as defined
in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to
deploy specific library versions and/or configurations,
using a recognizable name. Optionally, PROFILE_NAME may include
a specific version for the profile, e.g. 'mogon2:latest' or
'ngio:0.9.1', which will download the dependencies defined for
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
that specific version. If unspecified, the 'default:latest' profile
will be used, which should include all the possible dependencies.
-d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]]
Build and install a specific dependency, ignoring any --profile
option provided. If PROFILE_NAME is unspecified, the 'default'
profile will be used. Similarly, if PROFILE_VERSION is
unspecified, the 'latest' version of the specified profile will
be used.
-j, --compilecores COMPILE_CORES
Set the number of cores that will be used to compile the
dependencies. If unspecified, defaults to the number of
available cores.
-t, --test Perform libraries tests.
-P, --profiles-dir PROFILES_DIR
Choose the directory to be used when searching for profiles.
If unspecified, PROFILES_DIR defaults to \${PWD}/profiles.
-n, --dry-run
Do not actually run, print only what would be done.
-v, --verbose Increase download verbosity
"
}
PROFILE=""
DEPENDENCY=""
VERBOSE=""
DL_ARGS=""
COMPILE_ARGS=""
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"
case ${key} in
-p | --profile)
PROFILE="$2"
shift # past argument
shift # past value
;;
-d | --dependency)
DEPENDENCY="$2"
shift # past argument
shift # past value
;;
-j | --compilecores)
COMPILE_ARGS="$COMPILE_ARGS -j $2"
shift # past argument
shift # past value
;;
-t | --test)
COMPILE_ARGS="$COMPILE_ARGS -t"
shift
;;
-P | --profiles-dir)
DL_ARGS="$DL_ARGS -P $2"
COMPILE_ARGS="$COMPILE_ARGS -P $2"
shift # past argument
shift # past value
;;
-l | --list-dependencies)
"${SCRIPT_DIR}"/dl_dep.sh -l
exit
;;
-v | --verbose)
DL_ARGS="$DL_ARGS -v"
VERBOSE=true
shift # past argument
;;
-h | --help)
help_msg
exit
;;
-n | --dry-run)
DL_ARGS="$DL_ARGS -n"
COMPILE_ARGS="$COMPILE_ARGS -n"
shift
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# deal with positional arguments
if [[ (-z ${1+x}) || (-z ${2+x}) ]]; then
echo "ERROR: Positional arguments missing."
usage_short
exit 1
fi
SOURCE_DIR="$(readlink -mn "${1}")"
INSTALL_DIR="$(readlink -mn "${2}")"
# build arguments
if [[ -n $DEPENDENCY ]]; then
PROFILE_STR="-d $DEPENDENCY"
if [[ -n $PROFILE ]]; then
PROFILE_STR="$PROFILE_STR@$PROFILE"
fi
elif [[ -n $PROFILE ]]; then
PROFILE_STR="-p $PROFILE"
fi
if [[ -n $PROFILE_STR ]]; then
DL_ARGS="$DL_ARGS $PROFILE_STR"
COMPILE_ARGS="$COMPILE_ARGS $PROFILE_STR"
fi
DL_CMD="$SCRIPT_DIR/dl_dep.sh $DL_ARGS $SOURCE_DIR"
COMPILE_CMD="$SCRIPT_DIR/compile_dep.sh $COMPILE_ARGS $SOURCE_DIR $INSTALL_DIR"
echo "################################"
echo "# Downloading dependencies ... #"
echo "################################"
[[ "$VERBOSE" == true ]] && echo "# DL_CMD: $DL_CMD"
$DL_CMD || exit 1
echo -e "\n\n##############################"
echo "# Compiling dependencies ... #"
echo "##############################"
[[ "$VERBOSE" == true ]] && echo "# COMPILE_CMD: $COMPILE_CMD"
$COMPILE_CMD || exit 1