@@ -408,6 +408,19 @@ else
408408 echo " Using ${EESSI_HOST_STORAGE} as tmp directory (to resume session add '--resume ${EESSI_HOST_STORAGE} ')."
409409fi
410410
411+ # if ${RESUME} is a file, unpack it into ${EESSI_HOST_STORAGE}
412+ if [[ ! -z ${RESUME} && -f ${RESUME} ]]; then
413+ if [[ " ${RESUME} " == * .tgz ]]; then
414+ tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
415+ # Add support for resuming from zstd-compressed tarballs
416+ elif [[ " ${RESUME} " == * .zst && -x " $( command -v zstd) " ]]; then
417+ zstd -dc ${RESUME} | tar -xf - -C ${EESSI_HOST_STORAGE}
418+ elif [[ " ${RESUME} " == * .zst && ! -x " $( command -v zstd) " ]]; then
419+ fatal_error " Trying to resume from tarball ${RESUME} which was compressed using zstd, but zstd command not found"
420+ fi
421+ echo " Resuming from previous run using temporary storage ${RESUME} unpacked into ${EESSI_HOST_STORAGE} "
422+ fi
423+
411424# if ${RESUME} is a file (assume a tgz), unpack it into ${EESSI_HOST_STORAGE}
412425if [[ ! -z ${RESUME} && -f ${RESUME} ]]; then
413426 tar xf ${RESUME} -C ${EESSI_HOST_STORAGE}
@@ -865,17 +878,30 @@ if [[ ! -z ${SAVE} ]]; then
865878 # ARCH which might have been used internally, eg, when software packages
866879 # were built ... we rather keep the script here "stupid" and leave the handling
867880 # of these aspects to where the script is used
881+ # Compression with zlib may be quite slow. On some systems, the pipeline takes ~20 mins for a 2 min build because of this.
882+ # Check if zstd is present for faster compression and decompression
868883 if [[ -d ${SAVE} ]]; then
869884 # assume SAVE is name of a directory to which tarball shall be written to
870885 # name format: tmp_storage-{TIMESTAMP}.tgz
871886 ts=$( date +%s)
872- TGZ=${SAVE} /tmp_storage-${ts} .tgz
887+ if [[ -x " $( command -v zstd) " ]]; then
888+ TARBALL=${SAVE} /tmp_storage-${ts} .zst
889+ tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
890+ else
891+ TARBALL=${SAVE} /tmp_storage-${ts} .tgz
892+ tar czf ${TARBALL} -C ${EESSI_TMPDIR} .
893+ fi
873894 else
874895 # assume SAVE is the full path to a tarball's name
875- TGZ=${SAVE}
896+ TARBALL=${SAVE}
897+ # if zstd is present and a .zst extension is asked for, use it
898+ if [[ " ${SAVE} " == * .zst && -x " $( command -v zstd) " ]]; then
899+ tar -cf - -C ${EESSI_TMPDIR} . | zstd -T0 > ${TARBALL}
900+ else
901+ tar czf ${TARBALL} -C ${EESSI_TMPDIR}
902+ fi
876903 fi
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} ')"
904+ echo " Saved contents of tmp directory '${EESSI_TMPDIR} ' to tarball '${TARBALL} ' (to resume session add '--resume ${TARBALL} ')"
879905fi
880906
881907# TODO clean up tmp by default? only retain if another option provided (--retain-tmp)
0 commit comments