Skip to content
Snippets Groups Projects
setup_spack.sh 1.53 KiB
Newer Older
#!/usr/bin/env sh

SPACK_VERSION=$(jq -r .spack.version config.json)

echo "Setting up spack"
if [ ! -d spack/.git ]; then
  git clone https://github.com/spack/spack.git -b $SPACK_VERSION spack
else
  git -C spack fetch
  git -C spack checkout $SPACK_VERSION
  git -C spack pull
fi

echo "Setting up extra repos"
mkdir -p /stack/extra_repos/

EXTERNAL_REPOS=$(jq -r '.spack.repos | keys[]' config.json)

for repo in ${EXTERNAL_REPOS}
do
  repo_branch=$(jq -r ".spack.repos.\"${repo}\".branch" config.json)
  if [ ! -d /stack/extra_repos/${repo} ]; then
    echo "Cloning repo: ${repo}"
    url_branch=$(jq -r ".spack.repos.\"${repo}\".url" config.json)
    git clone -b ${repo_branch} ${url_branch} /stack/extra_repos/$repo
  else
    echo "Update repo: ${repo}"
    git -C /stack/extra_repos/$repo fetch
    git -C /stack/extra_repos/$repo checkout ${repo_branch}
    git -C /stack/extra_repos/$repo pull
  fi
done

echo "Adding spack system config file"
mkdir -p ${SPACK_SYSTEM_CONFIG_PATH}

for file in mirrors.yaml repos.yaml packages.yaml concretizer.yaml config.yaml
do
    if [ -e ${file} ]; then
        cp ${file} ${SPACK_SYSTEM_CONFIG_PATH}
    fi
done

echo "Setting up buildcache"

spack/bin/spack gpg trust \
    $GPG_PRIVATE_KEY

spack/bin/spack mirror add \
    --type binary \
    --scope system \
    buildcache file:///buildcache

if [ ! -d /buildcache/build_cache ]; then
  spack/bin/spack gpg publish \
      -d /buildcache
fi

spack/bin/spack buildcache keys \
    --install \
    --trust

spack/bin/spack buildcache update-index /buildcache