Skip to content

Commit 43e9018

Browse files
baltzelltongtongcao
authored andcommitted
build script improvements (#985)
* check deeper in cvmfs path before trying to use it, and check for git-lfs up front * fix * fix
1 parent d1175a6 commit 43e9018

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

build-coatjava.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ do
8080
esac
8181
done
8282

83+
# check if a command exists
84+
command_exists () {
85+
type "$1" &> /dev/null
86+
}
87+
8388
# count how many data-retrieval options are set
8489
count_download_opts() {
8590
local n=0
@@ -92,11 +97,11 @@ count_download_opts() {
9297
# if the user did not choose a data retrieval method, choose a reasonable one
9398
if [[ $(count_download_opts) -eq 0 ]]; then
9499
echo 'INFO: no data-retrieval option set; choosing a default...'
95-
if ! [[ $(hostname) == *.jlab.org ]]; then
96-
echo 'INFO: ... using `--lfs` since you are likely offsite'
97-
useLfs=true
98-
elif [ -d /cvmfs ]; then
99-
echo 'INFO: ... using `--cvmfs` since you are likely onsite and have /cvmfs'
100+
if ! [[ $(hostname) == *.jlab.org ]] && command_exists git-lfs ; then
101+
echo 'INFO: ... using `--lfs` since you are likely offsite and have git-lfs installed'
102+
useLfs=true
103+
elif [ -d /cvmfs/oasis.opensciencegrid.org/jlab ]; then
104+
echo 'INFO: ... using `--cvmfs` since you appear to have /cvmfs/oasis.opensciencegrid.org'
100105
useCvmfs=true
101106
else
102107
echo 'WARNING: default data-retrieval option cannot be determined; use `--help` for guidance' >&2
@@ -134,6 +139,10 @@ source libexec/env.sh --no-classpath
134139

135140
# install LFS
136141
if $useLfs; then
142+
if ! command_exists git-lfs ; then
143+
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
144+
exit 1
145+
fi
137146
git lfs install
138147
fi
139148

@@ -176,11 +185,6 @@ fi
176185
# download field maps, NN models, etc.
177186
################################################################################
178187

179-
# check if a command exists
180-
command_exists () {
181-
type "$1" &> /dev/null
182-
}
183-
184188
# print retrieval notice
185189
notify_retrieval() {
186190
echo "Retrieving $1 from $2 ..."
@@ -192,14 +196,9 @@ download_lfs() {
192196
echo 'ERROR: attempted to use LFS, but option `--lfs` not set' >&2
193197
exit 1
194198
fi
195-
if command_exists git-lfs ; then
196-
cd $src_dir > /dev/null
197-
git submodule update --init $1
198-
cd - > /dev/null
199-
else
200-
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
201-
exit 1
202-
fi
199+
cd $src_dir > /dev/null
200+
git submodule update --init $1
201+
cd - > /dev/null
203202
}
204203

205204
# download a magnetic field map

0 commit comments

Comments
 (0)