Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ do
esac
done

# check if a command exists
command_exists () {
type "$1" &> /dev/null
}

# count how many data-retrieval options are set
count_download_opts() {
local n=0
Expand All @@ -92,11 +97,11 @@ count_download_opts() {
# if the user did not choose a data retrieval method, choose a reasonable one
if [[ $(count_download_opts) -eq 0 ]]; then
echo 'INFO: no data-retrieval option set; choosing a default...'
if ! [[ $(hostname) == *.jlab.org ]]; then
echo 'INFO: ... using `--lfs` since you are likely offsite'
useLfs=true
elif [ -d /cvmfs ]; then
echo 'INFO: ... using `--cvmfs` since you are likely onsite and have /cvmfs'
if ! [[ $(hostname) == *.jlab.org ]] && command_exists git-lfs ; then
echo 'INFO: ... using `--lfs` since you are likely offsite and have git-lfs installed'
useLfs=true
elif [ -d /cvmfs/oasis.opensciencegrid.org/jlab ]; then
echo 'INFO: ... using `--cvmfs` since you appear to have /cvmfs/oasis.opensciencegrid.org'
useCvmfs=true
else
echo 'WARNING: default data-retrieval option cannot be determined; use `--help` for guidance' >&2
Expand Down Expand Up @@ -134,6 +139,10 @@ source libexec/env.sh --no-classpath

# install LFS
if $useLfs; then
if ! command_exists git-lfs ; then
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
exit 1
fi
git lfs install
fi

Expand Down Expand Up @@ -176,11 +185,6 @@ fi
# download field maps, NN models, etc.
################################################################################

# check if a command exists
command_exists () {
type "$1" &> /dev/null
}

# print retrieval notice
notify_retrieval() {
echo "Retrieving $1 from $2 ..."
Expand All @@ -192,14 +196,9 @@ download_lfs() {
echo 'ERROR: attempted to use LFS, but option `--lfs` not set' >&2
exit 1
fi
if command_exists git-lfs ; then
cd $src_dir > /dev/null
git submodule update --init $1
cd - > /dev/null
else
echo 'ERROR: `git-lfs` not found; please install it, or use a different option other than `--lfs`' >&2
exit 1
fi
cd $src_dir > /dev/null
git submodule update --init $1
cd - > /dev/null
}

# download a magnetic field map
Expand Down