diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 2e99d2b5f1c89b31d092e1da31648fc3ccfca045..49adefd19fbf47ef8506b65a9e90ac115858a1f5 100755 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -59,13 +59,16 @@ pipeline { skipDefaultCheckout() } + environment { + YASHCHIKI_INSTALL = "${WORKSPACE}/yashchiki" + YASHCHIKI_META_DIR = "${WORKSPACE}/meta" + } + stages { stage('Container Build') { // TODO: remove once unused environment { CONTAINER_STYLE = "${params.CONTAINER_STYLE}" - YASHCHIKI_INSTALL = "${WORKSPACE}/yashchiki" - YASHCHIKI_META_DIR = "${WORKSPACE}/meta" YASHCHIKI_CACHES_ROOT = "${HOME}" YASHCHIKI_SPACK_PATH = "${env.WORKSPACE}/spack" YASHCHIKI_SANDBOXES = "sandboxes" @@ -130,7 +133,6 @@ pipeline { "--meta-dir=${YASHCHIKI_META_DIR} " + "--caches-dir=${YASHCHIKI_CACHES_ROOT} " + "--sandboxes-dir=${YASHCHIKI_SANDBOXES} " + - "--host-env-filename=${WORKSPACE}/host.env " + "--build-cache-name=${BUILD_CACHE_NAME} " + ("${CONTAINER_BUILD_TYPE}" == "stable" ? "--update-build-cache " : "") + "--recipe-filename=${WORKSPACE}/visionary_recipe.def " + @@ -169,7 +171,6 @@ pipeline { } } cleanup { - archiveArtifacts "host.env" archiveArtifacts "out_singularity_build_recipe.txt" } } diff --git a/bin/yashchiki b/bin/yashchiki index 9f412e7d585d74ab9578bd4b7f79fe3e3f0d4728..003661c1e5dd4405a34fce0ee1d30f1161d8f41c 100644 --- a/bin/yashchiki +++ b/bin/yashchiki @@ -81,10 +81,6 @@ parser.add_argument( "--meta-dir", type=pathlib.Path, help="Folder where to store meta information to be copied into the " "container. If not provided, a temporary directory is used.") -parser.add_argument( - "--host-env-filename", type=pathlib.Path, - help="Location of host environment storage file to use within container " - "build. If not provided, a temporary location is used.") parser.add_argument( "--tmp-subdir", type=pathlib.Path, default="", help=f"Directory under {tempfile.gettempdir()} which to use as root for " @@ -133,7 +129,6 @@ paths = [ args.log_dir, args.sandboxes_dir, args.meta_dir, - args.host_env_filename, args.tmp_subdir, args.recipe_filename ] @@ -257,14 +252,6 @@ with tempfile.TemporaryDirectory(prefix="spack-", dir=env["TMPDIR"]) \ meta_dir.mkdir(parents=True) env = env | {"YASHCHIKI_META_DIR": meta_dir} - # host environment storage filename defaults to temporary file - if args.host_env_filename is not None: - host_env_filename = args.host_env_filename - else: - host_env_filename = temporary_directory.joinpath("host.env") - env = env | {"YASHCHIKI_HOST_ENV_PATH": host_env_filename} - - run("lib/yashchiki/store_environment.sh", env) run("lib/yashchiki/create_spack_user.sh", env) run("lib/yashchiki/create_caches.sh", env) run("lib/yashchiki/fetch.sh", env) diff --git a/lib/yashchiki/commons.sh b/lib/yashchiki/commons.sh index 5bb6c2a37dcff0a8325a01aff9c5b91422a1982a..4cefda69d5d53eeea3181742ede4a3ff8c3376d8 100755 --- a/lib/yashchiki/commons.sh +++ b/lib/yashchiki/commons.sh @@ -6,64 +6,13 @@ shopt -s inherit_errexit 2>/dev/null || true ROOT_DIR="$(dirname "$(dirname "$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")")")" SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" -HOST_ENV_FILE_INSIDE="/tmp/spack/host.env" -if [ -n "${WORKSPACE:-}" ]; then - # we are not in container - HOST_ENV_FILE="${YASHCHIKI_HOST_ENV_PATH}" -else - HOST_ENV_FILE="${HOST_ENV_FILE_INSIDE}" -fi - -# Usage: -# get_host_env <variable-name> [<default>] -# -# Get <variable-name> from the host environment dumped at the start of the -# host job. If the host environment was not dumped at the beginning of -# the host job, the regular environment is taken. -# -# If the variable is not found and no default value is specified, return 1. -get_host_env() { - # match on variable name at the beginning of line and then delete everyting - # up to and including the first equal sign - local default default_specified name - if (( $# < 0 )); then - echo "ERR: Did not specify variable name to query from host env.">&2 - return 1 - else - name="$1" - fi - - if (( $# > 1 )); then - default="$2" - default_specified=1 - else - default="" - default_specified=0 - fi - - if ! { - if [ -f "${HOST_ENV_FILE}" ]; then - cat "${HOST_ENV_FILE}" - else - env - fi - } | grep "^${name}=" | sed -e "s:^[^=]*=::"; then - if (( default_specified )); then - echo "${default}" - else - echo "Variable not found in environment: ${name}" >&2 - return 1 - fi - fi -} - ##################### # SETUP ENVIRONMENT # ##################### set_debug_output_from_env() { # Enable debug if YASHCHIKI_DEBUG is NOT (-n) empty string - if [ -n "$(get_host_env YASHCHIKI_DEBUG "")" ]; then + if [ -n "${YASHCHIKI_DEBUG:-}" ]; then set -x else set +x @@ -78,38 +27,35 @@ export MY_SPACK_VIEW_PREFIX="/opt/spack_views" export LOCK_FILENAME=lock -BUILD_CACHE_NAME="$(get_host_env BUILD_CACHE_NAME visionary_manual)" -export BUILD_CACHE_NAME - # NOTE: build caches contain relavite symlinks to preserved_packages, so the # relation that build_caches and preserved_packages are in the same folder # should be maintained inside the container! # --obreitwi, 17-06-20 12:53:20 -BASE_BUILD_CACHE_OUTSIDE="$(get_host_env YASHCHIKI_CACHES_ROOT)/build_caches" -BASE_BUILD_CACHE_FAILED_OUTSIDE="$(get_host_env YASHCHIKI_CACHES_ROOT)/build_caches/failed" -BUILD_CACHE_OUTSIDE="${BASE_BUILD_CACHE_OUTSIDE}/${BUILD_CACHE_NAME}" +BASE_BUILD_CACHE_OUTSIDE="${YASHCHIKI_CACHES_ROOT}/build_caches" +BASE_BUILD_CACHE_FAILED_OUTSIDE="${YASHCHIKI_CACHES_ROOT}/build_caches/failed" +BUILD_CACHE_OUTSIDE="${BASE_BUILD_CACHE_OUTSIDE}/${YASHCHIKI_BUILD_CACHE_NAME}" export BASE_BUILD_CACHE_OUTSIDE export BASE_BUILD_CACHE_FAILED_OUTSIDE export BUILD_CACHE_OUTSIDE BASE_BUILD_CACHE_INSIDE="/opt/build_cache" -BUILD_CACHE_INSIDE="${BASE_BUILD_CACHE_INSIDE}/${BUILD_CACHE_NAME}" +BUILD_CACHE_INSIDE="${BASE_BUILD_CACHE_INSIDE}/${YASHCHIKI_BUILD_CACHE_NAME}" BUILD_CACHE_LOCK="${BUILD_CACHE_INSIDE}/${LOCK_FILENAME}" export BASE_BUILD_CACHE_INSIDE export BUILD_CACHE_INSIDE export BUILD_CACHE_LOCK -SOURCE_CACHE_DIR="$(get_host_env YASHCHIKI_CACHES_ROOT)/download_cache" +SOURCE_CACHE_DIR="${YASHCHIKI_CACHES_ROOT}/download_cache" export SOURCE_CACHE_DIR PRESERVED_PACKAGES_INSIDE="/opt/preserved_packages" -PRESERVED_PACKAGES_OUTSIDE="$(get_host_env YASHCHIKI_CACHES_ROOT)/preserved_packages" +PRESERVED_PACKAGES_OUTSIDE="${YASHCHIKI_CACHES_ROOT}/preserved_packages" export PRESERVED_PACKAGES_INSIDE export PRESERVED_PACKAGES_OUTSIDE META_DIR_INSIDE="/opt/meta" -META_DIR_OUTSIDE="$(get_host_env YASHCHIKI_META_DIR)" +META_DIR_OUTSIDE="${YASHCHIKI_META_DIR:-}" export META_DIR_INSIDE export META_DIR_OUTSIDE @@ -177,7 +123,7 @@ SPACK_ARGS_INSTALL=() SPACK_ARGS_REINDEX=() SPACK_ARGS_VIEW=() -if [ -n "$(get_host_env YASHCHIKI_SPACK_VERBOSE)" ]; then +if [ -n "${YASHCHIKI_SPACK_VERBOSE:-}" ]; then SPACK_ARGS_INSTALL+=("--verbose") SPACK_ARGS_VIEW+=("--verbose") SPACK_ARGS_REINDEX+=("--verbose") diff --git a/lib/yashchiki/get_host_env.sh b/lib/yashchiki/get_host_env.sh deleted file mode 100755 index 8cbe52abf9c0b0bc3fe47de383c2f480759e339e..0000000000000000000000000000000000000000 --- a/lib/yashchiki/get_host_env.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -euo pipefail -shopt -s inherit_errexit - -# Usage: -# get_host_env.sh <variable-name> -# -# Stand-alone shell variant to the corresponding function from commons.sh to -# allow retrieval of environment information in Jenkinsfile. -# -# Get <variable-name> from the host environment dumped at the start of the -# host job. If the host environment was not dumped at the beginning of -# the host job, the regular environment is taken. -# -# If the variable is not found, return 1. - -if (( $# > 1 || $# == 0 )); then - echo "ERROR: $0 expects exactly one argument!" >&2 - exit 1 -fi - -SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" -source "${SOURCE_DIR}/commons.sh" - -get_host_env "$1" diff --git a/lib/yashchiki/store_environment.sh b/lib/yashchiki/store_environment.sh deleted file mode 100755 index 9a459f10e8b9ae7977352446566273f8fb7987aa..0000000000000000000000000000000000000000 --- a/lib/yashchiki/store_environment.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -euo pipefail -shopt -s inherit_errexit - -# store environment for usage within container -echo "# Host environment set to:" >&2 -env | tee "${YASHCHIKI_HOST_ENV_PATH}" diff --git a/share/yashchiki/styles/asic/create_recipe.sh b/share/yashchiki/styles/asic/create_recipe.sh index a35cc0c7ebba33f9dba1141c6726126a172ae93b..8b4bfd14e8900386b281a3753a37ff5bd8357f07 100755 --- a/share/yashchiki/styles/asic/create_recipe.sh +++ b/share/yashchiki/styles/asic/create_recipe.sh @@ -54,7 +54,6 @@ From: ${DOCKER_BASE_IMAGE} ${ROOT_DIR}/share/yashchiki/misc-files/locale.gen /etc/locale.gen ${ROOT_DIR}/share/yashchiki/misc-files/locale.alias /etc/locale.alias ${ROOT_DIR}/share/yashchiki/misc-files/sudoers /etc/sudoers - ${HOST_ENV_FILE} ${HOST_ENV_FILE_INSIDE} %post # ECM: drop docker image caches (often outdated) @@ -238,6 +237,10 @@ From: ${DOCKER_BASE_IMAGE} export YASHCHIKI_SPACK_GCC_VERSION="${YASHCHIKI_SPACK_GCC_VERSION}" export YASHCHIKI_JOBS="${YASHCHIKI_JOBS}" export YASHCHIKI_SPACK_CONFIG="/tmp/spack_config" + export YASHCHIKI_CACHES_ROOT="${YASHCHIKI_CACHES_ROOT}" + export YASHCHIKI_BUILD_CACHE_NAME="${YASHCHIKI_BUILD_CACHE_NAME}" + export YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME="${YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME}" + export YASHCHIKI_SPACK_VERBOSE="${YASHCHIKI_SPACK_VERBOSE}" export CONTAINER_STYLE="${CONTAINER_STYLE}" "${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post_as_root.sh" wait diff --git a/share/yashchiki/styles/visionary/create_recipe.sh b/share/yashchiki/styles/visionary/create_recipe.sh index 3895c95a8f2dc54c034ea0079b937d648ebb7a16..6fa8e3fdd6d34218f2db8e39ffce7fbb2c89ed2c 100755 --- a/share/yashchiki/styles/visionary/create_recipe.sh +++ b/share/yashchiki/styles/visionary/create_recipe.sh @@ -59,7 +59,6 @@ From: ${DOCKER_BASE_IMAGE} ${ROOT_DIR}/share/yashchiki/misc-files/locale.gen /etc/locale.gen ${ROOT_DIR}/share/yashchiki/misc-files/locale.alias /etc/locale.alias ${ROOT_DIR}/share/yashchiki/misc-files/sudoers /etc/sudoers - ${HOST_ENV_FILE} ${HOST_ENV_FILE_INSIDE} %post # create a fingerprint by which we can identify the container from within @@ -80,6 +79,9 @@ From: ${DOCKER_BASE_IMAGE} export YASHCHIKI_JOBS="${YASHCHIKI_JOBS}" export YASHCHIKI_SPACK_CONFIG="/tmp/spack_config" export YASHCHIKI_CACHES_ROOT="${YASHCHIKI_CACHES_ROOT}" + export YASHCHIKI_BUILD_CACHE_NAME="${YASHCHIKI_BUILD_CACHE_NAME}" + export YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME="${YASHCHIKI_BUILD_CACHE_ON_FAILURE_NAME}" + export YASHCHIKI_SPACK_VERBOSE="${YASHCHIKI_SPACK_VERBOSE}" export CONTAINER_STYLE="${CONTAINER_STYLE}" # Improve efficiency by installing system packages in the background (even # though we set the number of worker to \${YASHCHIKI_JOBS}, often times - e.g. when