diff --git a/hlrs-plumbing/scripts/xx_populate_release_directory.sh b/hlrs-plumbing/scripts/xx_populate_release_directory.sh index 728ddce..9b723ef 100755 --- a/hlrs-plumbing/scripts/xx_populate_release_directory.sh +++ b/hlrs-plumbing/scripts/xx_populate_release_directory.sh @@ -31,23 +31,10 @@ # └── ... # -_VERBOSITY=1 - -if [[ "$#" -ne 2 ]]; then - echo "Syntax: $0 release_tag base_prefix" - echo "Populates directory /release/ with the release tagged as ." - # 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 + echo "### $msg" fi } @@ -73,42 +60,88 @@ create_dir () { } -# process input arguments -HLRS_SOFTWARE_STACK_RELEASE_VERSION__USER=$(canonize_tag $arg_tag) -HLRS_OPT_PREFIX__USER=$(create_dir $arg_prefix) +_VERBOSITY=1 + +if [[ "$#" -ne 2 ]]; then + echo "Syntax: $0 release_tag base_prefix" + echo "Populates directory /release/ with the release tagged as ." + # TODO: exit with error code +fi + +echo "TODO: check for \$TMPDIR and execution bit in \$TMPDIR" + + +# process script arguments +arg_tag=$(canonize_tag $1) +arg_prefix=$2 # 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/software-stack-plumbing.git -_HLRS_SPACK_CONFIG_REPO=file://$HOME/spack-test/dummy_repo/software-stack-hlrs-spack.git +_HLRS_SPACK_REPO=file://$HOME/spack-test/dummy_repo/spack.git +_HLRS_SPACK_PLUMBING_REPO=file://$HOME/spack-test/dummy_repo/release_root.git +_HLRS_SPACK_CONFIG_REPO=file://$HOME/spack-test/dummy_repo/hlrs-spack.git -# bootstrap environment variables -# (using [bash process substitution](https://tldp.org/LDP/abs/html/process-sub.html)) -log "### bootstrap environment variables" -source <(curl -L $_HLRS_SPACK_PLUMBING_REPO/hlrs-plumbing/envs/00_base_prefix.env) -source <(curl -L $_HLRS_SPACK_PLUMBING_REPO/hlrs-plumbing/envs/01_release_root.env) -source <(curl -L $_HLRS_SPACK_PLUMBING_REPO/hlrs-plumbing/envs/02_hlrs_spack_root.env) -log "### ... done" -# setup plumbing directory -log "### setup plumbing directory" +# bootstrap staging area +log "setup staging area at:" +staging_dir=$(mktemp -d)/staging +log " $staging_dir" + +# bootstrap plumbing directory +log "bootstrap plumbing directory ..." curl -L $_HLRS_SPACK_PLUMBING_REPO/hlrs-plumbing/scripts/xx_checkout_repo.sh | \ bash -s -- $_HLRS_SPACK_PLUMBING_REPO \ + $arg_tag $staging_dir . +plumbing_dir=$staging_dir/hlrs-plumbing +log "... done" + + +# set anchors for environment variables to staging area +HLRS_SOFTWARE_STACK_RELEASE_VERSION__USER=$arg_tag +HLRS_OPT_PREFIX__USER=$(create_dir $staging_dir/prefix) + +# bootstrap environment variables +log "bootstrap environment variables ..." +source $plumbing_dir/envs/00_base_prefix.env +source $plumbing_dir/envs/01_release_root.env +source $plumbing_dir/envs/02_hlrs_spack_root.env +log "... done" + +# setup plumbing directory +log "setup plumbing directory ..." +$plumbing_dir/scripts/xx_checkout_repo.sh $_HLRS_SPACK_PLUMBING_REPO \ $HLRS_SOFTWARE_STACK_RELEASE_VERSION $HLRS_SOFTWARE_STACK_RELEASE_ROOT . -_HLRS_PLUMBING_DIR=$HLRS_SOFTWARE_STACK_RELEASE_ROOT/hlrs-plumbing -log "### ... done" +log "... done" # setup hlrs-spack directory -log "### setup hlrs-spack directory" -$_HLRS_PLUMBING_DIR/scripts/xx_checkout_repo.sh $_HLRS_SPACK_CONFIG_REPO \ +log "setup hlrs-spack directory ..." +$plumbing_dir/scripts/xx_checkout_repo.sh $_HLRS_SPACK_CONFIG_REPO \ $HLRS_SOFTWARE_STACK_RELEASE_VERSION $HLRS_SOFTWARE_STACK_RELEASE_ROOT hlrs-spack -log "### ... done" +log "... done" # setup $SPACK_ROOT directory -log "### setup $SPACK_ROOT directory" -$_HLRS_PLUMBING_DIR/scripts/xx_checkout_repo.sh $_HLRS_SPACK_REPO \ +log "setup $SPACK_ROOT directory ..." +$plumbing_dir/scripts/xx_checkout_repo.sh $_HLRS_SPACK_REPO \ $HLRS_SOFTWARE_STACK_RELEASE_VERSION $HLRS_SOFTWARE_STACK_HLRS_SPACK_ROOT spack -log "### ... done" +log "... done" # setup opt-non-spack -# TODO \ No newline at end of file +# TODO + +# re-evaluate environment variables +log "bootstrap final environment variables ..." +staging_release_root=$HLRS_SOFTWARE_STACK_RELEASE_ROOT +source $plumbing_dir/envs/xx_unload_env.env +HLRS_OPT_PREFIX__USER=$(create_dir $arg_prefix) +source $plumbing_dir/envs/00_base_prefix.env +source $plumbing_dir/envs/01_release_root.env +log "... done" + +# move to final destination +log "move release root to final destination at:" +log " $HLRS_SOFTWARE_STACK_RELEASE_ROOT" +final_release_root=$(create_dir $HLRS_SOFTWARE_STACK_RELEASE_ROOT) +## TODO: check dir above; refuse to overwrite +mv $staging_release_root/{*,.git} $final_release_root + + +## TODO: remove staging dir