Skip to content

Commit 2784457

Browse files
committed
Improve TMP selection, success check and output
1 parent 5e831c2 commit 2784457

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

juhpc

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ info() {
3131
echo -e "$JUHPC $message" >&2
3232
}
3333

34+
info_start() {
35+
local message="$1"
36+
info "$message..."
37+
}
38+
39+
info_end() {
40+
local message="$1"
41+
info "... done. $message completed."
42+
}
43+
3444
cleanup() {
3545
info "cleaning up temporary juliaup installation in $TMP_JULIAUP_ROOTDIR."
3646
rm -rf "$TMP_JULIAUP_ROOTDIR"
@@ -70,7 +80,15 @@ export JUHPC_POST_INSTALL_JL="$3"
7080
# Set (derived) general environment variables
7181

7282
export JULIAUP_BINDIR=$JULIAUP_INSTALLDIR/bin # juliaup and julia binaries
73-
export TMP=/dev/shm/$USER
83+
84+
if [ -d "/dev/shm" ]; then
85+
export TMP="/dev/shm/$USER"
86+
elif [ -d "/tmp" ]; then
87+
export TMP="/tmp/$USER"
88+
else
89+
error "Neither /dev/shm nor /tmp directories exist. Cannot set TMP environment variable."
90+
fi
91+
7492
export TMP_JULIAUP_ROOTDIR=$TMP/juliaup
7593

7694

@@ -84,7 +102,8 @@ check_dir "$JUHPC_SETUP_INSTALLDIR"
84102

85103
# Download and install julia in /tmp using juliaup
86104

87-
info "Installing temporary juliaup installation in $TMP_JULIAUP_ROOTDIR..."
105+
INFO_MSG="Installing temporary juliaup installation in $TMP_JULIAUP_ROOTDIR"
106+
info_start $INFO_MSG
88107

89108
export TMP_JULIAUP_BINDIR=$TMP_JULIAUP_ROOTDIR/bin # juliaup and julia binaries
90109
export JULIAUP_DEPOT_PATH=$TMP_JULIAUP_ROOTDIR/depot
@@ -98,12 +117,13 @@ curl -fsSL https://install.julialang.org | sh -s -- --add-to-path=no --yes --pat
98117

99118
if [ ! -f "$TMP_JULIAUP_BINDIR/juliaup" ]; then error "temporary juliaup installation failed."; fi
100119

101-
info "... done."
120+
info_end $INFO_MSG
102121

103122

104123
# Create preferences for HPC key packages that require system libraries (MPI.jl, CUDA.jl, AMDGPU.jl, HDF5.jl, ADIOS2.jl, ...)
105124

106-
info "Creating preferences for HPC key packages..."
125+
INFO_MSG="Creating preferences for HPC key packages"
126+
info_start $INFO_MSG
107127

108128
export JULIA_PREFDIR=$JUHPC_SETUP_INSTALLDIR/julia_preferences
109129
export JULIA_PREF_PROJECT=$JULIA_PREFDIR/Project.toml
@@ -154,12 +174,13 @@ if [ -n "${JUHPC_HDF5_HOME}" ]; then
154174
julia --project=$JULIA_PREFDIR -e 'using HDF5; HDF5.API.set_libraries!("$(ENV["JUHPC_HDF5_HOME"])/lib/libhdf5.so", "$(ENV["JUHPC_HDF5_HOME"])/lib/libhdf5_hl.so")'
155175
fi
156176

157-
info "... done."
177+
info_end $INFO_MSG
158178

159179

160180
# Create a wrapper for juliaup that installs juliaup (and latest julia) on scratch if it is not already installed
161181

162-
info "Creating wrapper for juliaup..."
182+
INFO_MSG="Creating wrapper for juliaup"
183+
info_start $INFO_MSG
163184

164185
export JULIAUP_WRAPPER_BINDIR=$JUHPC_SETUP_INSTALLDIR/juliaup_wrapper
165186
export JULIAUP_WRAPPER=$JULIAUP_WRAPPER_BINDIR/juliaup
@@ -177,27 +198,32 @@ info() {
177198
echo -e "$(ENV["JUHPC"]) \$message" >&2
178199
}
179200
180-
if [ ! -f $(ENV["JULIAUP_BINDIR"])/juliaup ]; then
201+
JULIAUP_EXE=$(ENV["JULIAUP_BINDIR"])/juliaup
202+
203+
if [ ! -f "$JULIAUP_EXE" ]; then
181204
print_logo
182205
info "This is the first call to juliaup; juliaup and the latest julia will now be installed. After that, you can use juliaup and julia normally. Installing in $(ENV["JULIAUP_INSTALLDIR"])..."
206+
sleep 3
183207
PATH_OLD=\$PATH
184208
export PATH=\$(echo \$PATH | perl -pe "s|[^:]*juliaup(?:_wrapper)?[^:]*:?||g") # Remove all juliaup paths from PATH
185209
curl -fsSL https://install.julialang.org | sh -s -- --add-to-path=no --yes --path=$(ENV["JULIAUP_INSTALLDIR"]) --background-selfupdate 0 --startup-selfupdate 0 || { echo "Failed to install Juliaup (and Julia)." >&2; exit 1; }
186210
export PATH=\$PATH_OLD
187-
info "... done."
211+
if [ ! -f "$JULIAUP_EXE" ]; then error "juliaup installation failed."; fi
212+
info "... done. Installation of juliaup and the latest julia in $(ENV["JULIAUP_INSTALLDIR"]) completed. You can use juliaup and julia normally."
188213
else
189-
$(ENV["JULIAUP_BINDIR"])/juliaup \$@
214+
$JULIAUP_EXE \$@
190215
fi
191216
""")
192217
' > $JULIAUP_WRAPPER
193218
chmod +x $JULIAUP_WRAPPER
194219

195-
info "... done."
220+
info_end $INFO_MSG
196221

197222

198223
# Create an activation script that sets environment variables for juliaup, julia and HPC key packages
199224

200-
info "Creating activation script..."
225+
INFO_MSG="Creating activation script"
226+
info_start $INFO_MSG
201227

202228
export JULIAUP_DEPOT=$JULIAUP_INSTALLDIR/depot
203229
export JULIA_DEPOT=$JULIAUP_INSTALLDIR/depot
@@ -233,15 +259,16 @@ $(haskey(ENV,"JUHPC_ADIOS2_HOME") && ENV["JUHPC_ADIOS2_HOME"] != "" ? """
233259
""" : "")
234260
""")' > $ACTIVATE_SCRIPT
235261

236-
info "... done."
262+
info_end $INFO_MSG
237263

238264

239265
# Optionally execute a site-specific post installation julia script (if passed a third argument)
240266

241267
if [ -n "${JUHPC_POST_INSTALL_JL}" ]; then
242-
info "Executing site-specific post installation julia script (using the project where preferences were set)..."
268+
INFO_MSG="Executing site-specific post installation julia script (using the project where preferences were set)"
269+
info_start $INFO_MSG
243270
julia --project=$JULIA_PREFDIR $JUHPC_POST_INSTALL_JL
244-
info "... done."
271+
info_end $INFO_MSG
245272
fi
246273

247274

@@ -250,4 +277,4 @@ fi
250277
cleanup
251278
rm -f $JULIA_PREFDIR/Manifest.toml
252279

253-
info "... Installation of HPC setup for juliaup, julia and HPC key packages requiring system libraries is complete."
280+
info "... Installation of HPC setup for juliaup, julia and HPC key packages requiring system libraries is complete.\n\n"

0 commit comments

Comments
 (0)