Add script to populate release directory
This commit is contained in:
parent
28ac26aca7
commit
779e966914
1 changed files with 107 additions and 0 deletions
107
scripts/xx_populate_release_directory.sh
Executable file
107
scripts/xx_populate_release_directory.sh
Executable file
|
@ -0,0 +1,107 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Populates directory <base_prefix>/release/<release_tag> with the release tagged as <release_tag>.
|
||||
#
|
||||
# Input arguments:
|
||||
# - release_tag: tag/branch/commit in repo
|
||||
# - base_prefix: prefix to base directory for softweare installation; e.g. /opt/hlrs
|
||||
#
|
||||
# Environment variables: $TMPDIR must be set
|
||||
#
|
||||
#
|
||||
# Release directory structure:
|
||||
# ${HLRS_SOFTWARE_STACK_RELEASE_ROOT}/
|
||||
# ├── opt-non-spack/
|
||||
# │ ├── modulefiles
|
||||
# │ └── ...
|
||||
# ├── opt-spack (${HLRS_SOFTWARE_STACK_SPACK_INSTALL_TREE})/
|
||||
# │ ├── modulefiles
|
||||
# │ └── ...
|
||||
# ├── hlrs-spack (${HLRS_SOFTWARE_STACK_HLRS_SPACK_ROOT})/
|
||||
# │ ├── spack (${SPACK_ROOT})
|
||||
# │ ├── config-hlrs
|
||||
# │ ├── config-user
|
||||
# │ ├── repos
|
||||
# │ ├── environments
|
||||
# │ └── ...
|
||||
# └── hlrs-plumbing
|
||||
# ├── scripts
|
||||
# ├── envs
|
||||
# ├── ci-cd
|
||||
# └── ...
|
||||
#
|
||||
|
||||
_VERBOSITY=1
|
||||
|
||||
if [[ "$#" -ne 2 ]]; then
|
||||
echo "Syntax: $0 release_tag base_prefix"
|
||||
echo "Populates directory <base_prefix>/release/<release_tag> with the release tagged as <release_tag>."
|
||||
# TODO: exit with error code
|
||||
fi
|
||||
|
||||
echo "TODO: check for $TMPDIR"
|
||||
|
||||
arg_tag=$1
|
||||
arg_prefix=$2
|
||||
|
||||
log () {
|
||||
local msg=$1
|
||||
if [[ -n $_VERBOSITY ]]; then
|
||||
echo $msg
|
||||
fi
|
||||
}
|
||||
|
||||
# modify tag by stripping "hlrs-release-" prefix
|
||||
canonize_tag () {
|
||||
echo ${1##hlrs-release-}
|
||||
}
|
||||
|
||||
# create and prepare destination directory
|
||||
# or return existing directory
|
||||
create_dir () {
|
||||
local dir=$1
|
||||
local rc
|
||||
|
||||
if [[ -d $dir ]]; then
|
||||
rc=$dir
|
||||
else
|
||||
mkdir -p $dir
|
||||
chmod g=u $dir
|
||||
rc=$dir
|
||||
fi
|
||||
echo $rc
|
||||
}
|
||||
|
||||
|
||||
# process input arguments
|
||||
HLRS_SOFTWARE_STACK_RELEASE_VERSION__USER=$(canonize_tag $arg_tag)
|
||||
HLRS_OPT_PREFIX__USER=$(create_dir $arg_prefix)
|
||||
|
||||
# Define various repo locations
|
||||
_HLRS_SPACK_REPO=file://$HOME/spack-test/dummy_repo/spack-v0.21.2.git
|
||||
_HLRS_SPACK_PLUMBING_REPO=file://$HOME/spack-test/dummy_repo/hawk-spack-env.git
|
||||
_HLRS_SPACK_CONFIG_REPO=
|
||||
|
||||
# bootstrap environment variables
|
||||
# (using [bash process substitution](https://tldp.org/LDP/abs/html/process-sub.html))
|
||||
source <(curl $_HLRS_SPACK_PLUMBING_REPO/envs/00_base_prefix.env)
|
||||
source <(curl $_HLRS_SPACK_PLUMBING_REPO/envs/01_release_root.env)
|
||||
source <(curl $_HLRS_SPACK_PLUMBING_REPO/envs/02_hlrs_spack_root.env)
|
||||
|
||||
# setup plumbing directory
|
||||
curl $_HLRS_SPACK_PLUMBING_REPO/scripts/xx_checkout_repo.sh | \
|
||||
bash -s -- $_HLRS_SPACK_PLUMBING_REPO \
|
||||
$HLRS_SOFTWARE_STACK_RELEASE_VERSION $HLRS_SOFTWARE_STACK_RELEASE_ROOT hlrs-plumbing
|
||||
_HLRS_PLUMBING_DIR=$HLRS_SOFTWARE_STACK_RELEASE_ROOT/hlrs-plumbing
|
||||
|
||||
# setup hlrs-spack directory
|
||||
mkdir -p $HLRS_SOFTWARE_STACK_HLRS_SPACK_ROOT
|
||||
# TODO: checkout repo as soon as available; in the meantime do
|
||||
# setup hlrs-config directory
|
||||
ln -s spack/config-hlrs $HLRS_SOFTWARE_STACK_HLRS_SPACK_ROOT/config-hlrs
|
||||
# setup $SPACK_ROOT directory
|
||||
$_HLRS_PLUMBING_DIR/scripts/xx_checkout_repo.sh $_HLRS_SPACK_REPO \
|
||||
$HLRS_SOFTWARE_STACK_RELEASE_VERSION $HLRS_SOFTWARE_STACK_HLRS_SPACK_ROOT spack
|
||||
|
||||
# setup opt-non-spack
|
||||
# TODO
|
Loading…
Reference in a new issue