Skip to content

Commit 3b8f6f5

Browse files
committed
add possibility for generating zstd-compressed tarballs
1 parent 41f3775 commit 3b8f6f5

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

create_tarball.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ eessi_tmpdir=$1
1212
eessi_version=$2
1313
cpu_arch_subdir=$3
1414
accel_subdir=$4
15-
target_tgz=$5
15+
target_tarball=$5
1616

1717
tmpdir=`mktemp -d`
1818
echo ">> tmpdir: $tmpdir"
@@ -114,10 +114,29 @@ fi
114114

115115
topdir=${cvmfs_repo}/versions/
116116

117-
echo ">> Creating tarball ${target_tgz} from ${topdir}..."
118-
tar cfvz ${target_tgz} -C ${topdir} --files-from=${files_list}
119-
120-
echo ${target_tgz} created!
117+
echo ">> Creating tarball ${target_tarball} from ${topdir}..."
118+
target_tarball_ext="${target_tarball##*.}"
119+
if [ "${target_tarball_ext}" = "zst" ]; then
120+
if [ -x "$(command -v zstd)" ]; then
121+
tar -cf - -C ${topdir} --files-from=${files_list} | zstd -T0 > ${target_tarball}
122+
else
123+
echo "Zstd compression requested, but zstd command is not available." >&2
124+
exit 4
125+
fi
126+
elif [ "${target_tarball_ext}" = "gz" ]; then
127+
if [[ -x "$(command -v gzip)" ]]; then
128+
tar -cfvz ${target_tarball} -C ${topdir} --files-from=${files_list}
129+
else
130+
echo "Gzip compression requested, but gzip command is not available." >&2
131+
exit 4
132+
fi
133+
elif [ "${target_tarball_ext}" = "tar" ]; then
134+
tar -cfv ${target_tarball} -C ${topdir} --files-from=${files_list}
135+
else
136+
echo "Unknown tarball type (${target_tarball_ext}) requested."
137+
exit 4
138+
fi
139+
echo ${target_tarball} created!
121140

122141
echo ">> Cleaning up tmpdir ${tmpdir}..."
123142
rm -r ${tmpdir}

0 commit comments

Comments
 (0)