forked from EESSI/software-layer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_init_tarball.sh
executable file
·46 lines (36 loc) · 1.14 KB
/
create_init_tarball.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
SOFTWARE_LAYER_TARBALL_URL=https://github.com/EESSI/software-layer/tarball/main
set -eo pipefail
function echo_green() {
echo -e "\e[32m$1\e[0m"
}
function echo_red() {
echo -e "\e[31m$1\e[0m"
}
function error() {
echo_red "ERROR: $1" >&2
exit 1
}
if [ $# -ne 1 ]; then
echo "Usage: $0 <EESSI version>" >&2
exit 1
fi
version=$1
# Check if the EESSI version number encoded in the filename
# is valid, i.e. matches the format YYYY.DD
if ! echo "${version}" | egrep -q '^20[0-9][0-9]\.(0[0-9]|1[0-2])$'
then
error "${version} is not a valid EESSI version."
fi
tartmp=$(mktemp -t -d init.XXXXX)
mkdir "${tartmp}/${version}"
tarname="eessi-${version}-init-$(date +%s).tar.gz"
curl -Ls ${SOFTWARE_LAYER_TARBALL_URL} | tar xzf - -C "${tartmp}/${version}" --strip-components=1 --wildcards */init/
source "${tartmp}/${version}/init/minimal_eessi_env"
if [ "${EESSI_PILOT_VERSION}" != "${version}" ]
then
error "Specified version ${version} does not match version ${EESSI_PILOT_VERSION} in the init files!"
fi
tar czf "${tarname}" -C "${tartmp}" "${version}"
rm -rf "${tartmp}"
echo_green "Done! Created tarball ${tarname}."