@@ -89,6 +89,8 @@ display_help() {
89
89
echo " -n | --nvidia MODE - configure the container to work with NVIDIA GPUs,"
90
90
echo " MODE==install for a CUDA installation, MODE==run to"
91
91
echo " attach a GPU, MODE==all for both [default: false]"
92
+ echo " -p | --pass-through ARG - argument to pass through to the launch of the"
93
+ echo " container; can be given multiple times [default: not set]"
92
94
echo " -r | --repository CFG - configuration file or identifier defining the"
93
95
echo " repository to use; can be given multiple times;"
94
96
echo " CFG may include a suffix ',access={ro,rw}' to"
@@ -126,6 +128,7 @@ VERBOSE=0
126
128
STORAGE=
127
129
LIST_REPOS=0
128
130
MODE=" shell"
131
+ PASS_THROUGH=()
129
132
SETUP_NVIDIA=0
130
133
REPOSITORIES=()
131
134
RESUME=
@@ -182,6 +185,10 @@ while [[ $# -gt 0 ]]; do
182
185
NVIDIA_MODE=" $2 "
183
186
shift 2
184
187
;;
188
+ -p|--pass-through)
189
+ PASS_THROUGH+=(" $2 " )
190
+ shift 2
191
+ ;;
185
192
-r|--repository)
186
193
REPOSITORIES+=(" $2 " )
187
194
shift 2
363
370
# 2. set up host storage/tmp if necessary
364
371
# if session to be resumed from a previous one (--resume ARG) and ARG is a directory
365
372
# just reuse ARG, define environment variables accordingly and skip creating a new
366
- # eessi.XXXXXXXXXXX tempdir within TMPDIR
367
-
368
- # But before we call mktemp, we need to potentially set or create TMPDIR
369
- # as location for temporary data use in the following order
370
- # a. command line argument -l|--host-storage
371
- # b. env var TMPDIR
372
- # c. /tmp
373
- # note, we ensure that (a) takes precedence by setting TMPDIR to STORAGE
374
- # if STORAGE is not empty
375
- # note, (b) & (c) are automatically ensured by using 'mktemp -d --tmpdir' to
376
- # create a temporary directory
377
- if [[ ! -z ${STORAGE} ]]; then
378
- export TMPDIR=${STORAGE}
379
- # mktemp fails if TMPDIR does not exist, so let's create it
380
- mkdir -p ${TMPDIR}
381
- fi
382
- if [[ ! -z ${TMPDIR} ]]; then
383
- # TODO check if TMPDIR already exists
384
- # mktemp fails if TMPDIR does not exist, so let's create it
385
- mkdir -p ${TMPDIR}
386
- fi
387
- if [[ -z ${TMPDIR} ]]; then
388
- # mktemp falls back to using /tmp if TMPDIR is empty
389
- # TODO check if /tmp is writable, large enough and usable (different
390
- # features for ro-access and rw-access)
391
- [[ ${VERBOSE} -eq 1 ]] && echo " skipping sanity checks for /tmp"
392
- fi
393
-
394
- # Now, set the EESSI_HOST_STORAGE either baed on the resumed directory, or create a new one with mktemp
373
+ # tmp storage
395
374
if [[ ! -z ${RESUME} && -d ${RESUME} ]]; then
396
375
# resume from directory ${RESUME}
397
376
# skip creating a new tmp directory, just set environment variables
398
377
echo " Resuming from previous run using temporary storage at ${RESUME} "
399
378
EESSI_HOST_STORAGE=${RESUME}
400
379
else
380
+ # we need a tmp location (and possibly init it with ${RESUME} if it was not
381
+ # a directory
382
+
383
+ # as location for temporary data use in the following order
384
+ # a. command line argument -l|--host-storage
385
+ # b. env var TMPDIR
386
+ # c. /tmp
387
+ # note, we ensure that (a) takes precedence by setting TMPDIR to STORAGE
388
+ # if STORAGE is not empty
389
+ # note, (b) & (c) are automatically ensured by using 'mktemp -d --tmpdir' to
390
+ # create a temporary directory
391
+ if [[ ! -z ${STORAGE} ]]; then
392
+ export TMPDIR=${STORAGE}
393
+ # mktemp fails if TMPDIR does not exist, so let's create it
394
+ mkdir -p ${TMPDIR}
395
+ fi
396
+ if [[ ! -z ${TMPDIR} ]]; then
397
+ # TODO check if TMPDIR already exists
398
+ # mktemp fails if TMPDIR does not exist, so let's create it
399
+ mkdir -p ${TMPDIR}
400
+ fi
401
+ if [[ -z ${TMPDIR} ]]; then
402
+ # mktemp falls back to using /tmp if TMPDIR is empty
403
+ # TODO check if /tmp is writable, large enough and usable (different
404
+ # features for ro-access and rw-access)
405
+ [[ ${VERBOSE} -eq 1 ]] && echo " skipping sanity checks for /tmp"
406
+ fi
401
407
EESSI_HOST_STORAGE=$( mktemp -d --tmpdir eessi.XXXXXXXXXX)
402
408
echo " Using ${EESSI_HOST_STORAGE} as tmp directory (to resume session add '--resume ${EESSI_HOST_STORAGE} ')."
403
409
fi
404
410
405
- # if ${RESUME} is a file, unpack it into ${EESSI_HOST_STORAGE}
411
+ # if ${RESUME} is a file (assume a tgz) , unpack it into ${EESSI_HOST_STORAGE}
406
412
if [[ ! -z ${RESUME} && -f ${RESUME} ]]; then
407
- if [[ " ${RESUME} " == * .tgz ]]; then
408
- tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
409
- # Add support for resuming from zstd-compressed tarballs
410
- elif [[ " ${RESUME} " == * .zst && -x " $( command -v zstd) " ]]; then
411
- zstd -dc ${RESUME} | tar -xf - -C ${EESSI_HOST_STORAGE}
412
- elif [[ " ${RESUME} " == * .zst && ! -x " $( command -v zstd) " ]]; then
413
- fatal_error " Trying to resume from tarball ${RESUME} which was compressed using zstd, but zstd command not found"
414
- fi
413
+ tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
415
414
echo " Resuming from previous run using temporary storage ${RESUME} unpacked into ${EESSI_HOST_STORAGE} "
416
415
fi
417
416
@@ -850,6 +849,11 @@ if [ ! -z ${EESSI_SOFTWARE_SUBDIR_OVERRIDE} ]; then
850
849
export APPTAINERENV_EESSI_SOFTWARE_SUBDIR_OVERRIDE=${EESSI_SOFTWARE_SUBDIR_OVERRIDE}
851
850
fi
852
851
852
+ # add pass through arguments
853
+ for arg in " ${PASS_THROUGH[@]} " ; do
854
+ ADDITIONAL_CONTAINER_OPTIONS+=(${arg} )
855
+ done
856
+
853
857
echo " Launching container with command (next line):"
854
858
echo " singularity ${RUN_QUIET} ${MODE} ${ADDITIONAL_CONTAINER_OPTIONS[@]} ${EESSI_FUSE_MOUNTS[@]} ${CONTAINER} $@ "
855
859
singularity ${RUN_QUIET} ${MODE} " ${ADDITIONAL_CONTAINER_OPTIONS[@]} " " ${EESSI_FUSE_MOUNTS[@]} " ${CONTAINER} " $@ "
@@ -861,31 +865,17 @@ if [[ ! -z ${SAVE} ]]; then
861
865
# ARCH which might have been used internally, eg, when software packages
862
866
# were built ... we rather keep the script here "stupid" and leave the handling
863
867
# of these aspects to where the script is used
864
-
865
- # Compression with zlib may be quite slow. On some systems, the pipeline takes ~20 mins for a 2 min build because of this.
866
- # Check if zstd is present for faster compression and decompression
867
868
if [[ -d ${SAVE} ]]; then
868
869
# assume SAVE is name of a directory to which tarball shall be written to
869
870
# name format: tmp_storage-{TIMESTAMP}.tgz
870
871
ts=$( date +%s)
871
- if [[ -x " $( command -v zstd) " ]]; then
872
- TARBALL=${SAVE} /tmp_storage-${ts} .zst
873
- tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
874
- else
875
- TARBALL=${SAVE} /tmp_storage-${ts} .tgz
876
- tar czf ${TARBALL} -C ${EESSI_TMPDIR} .
877
- fi
872
+ TGZ=${SAVE} /tmp_storage-${ts} .tgz
878
873
else
879
874
# assume SAVE is the full path to a tarball's name
880
- TARBALL=${SAVE}
881
- # if zstd is present and a .zst extension is asked for, use it
882
- if [[ " ${SAVE} " == * .zst && -x " $( command -v zstd) " ]]; then
883
- tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
884
- else
885
- tar czf ${TARBALL} -C ${EESSI_TMPDIR}
886
- fi
875
+ TGZ=${SAVE}
887
876
fi
888
- echo " Saved contents of tmp directory '${EESSI_TMPDIR} ' to tarball '${TARBALL} ' (to resume session add '--resume ${TARBALL} ')"
877
+ tar czf ${TGZ} -C ${EESSI_TMPDIR} .
878
+ echo " Saved contents of tmp directory '${EESSI_TMPDIR} ' to tarball '${TGZ} ' (to resume session add '--resume ${TGZ} ')"
889
879
fi
890
880
891
881
# TODO clean up tmp by default? only retain if another option provided (--retain-tmp)
0 commit comments