diff --git a/bin/yashchiki b/bin/yashchiki index 818e3a780e5f9ccf6915d23b2e76a9fbe6cf0604..68521702fed79e2d31a9bef07536f153928cf785 100644 --- a/bin/yashchiki +++ b/bin/yashchiki @@ -267,7 +267,6 @@ else: meta_dir.mkdir(parents=True) env = env | {"YASHCHIKI_META_DIR": meta_dir} -run("lib/yashchiki/create_spack_user.sh", env) run("lib/yashchiki/create_caches.sh", env) run("lib/yashchiki/fetch.sh", env) run(str(pathlib.Path("share", "yashchiki", "styles", args.style, @@ -277,7 +276,6 @@ run("lib/yashchiki/build_sandbox.sh", env) run("lib/yashchiki/build_image.sh", env) if args.update_build_cache: run("lib/yashchiki/update_build_cache.sh", env, ["-c", args.output]) -run("lib/yashchiki/restore_host_user_ownership.sh", env) if args.tmpdir is None: shutil.rmtree(tmpdir) diff --git a/lib/yashchiki/build_image.sh b/lib/yashchiki/build_image.sh index 30531bdbe83614a3e14d76fd9d957d24cf3c8ebb..6d490c21bb3a1e7e36162cf98f5c6b1cd879105f 100755 --- a/lib/yashchiki/build_image.sh +++ b/lib/yashchiki/build_image.sh @@ -5,21 +5,9 @@ shopt -s inherit_errexit 2>/dev/null || true TARGET_FOLDER="${YASHCHIKI_SANDBOXES}/${CONTAINER_STYLE}" -# We want the spack folder to be available inside the container image -# -> it needs to be bind mounted to the sandbox folder -sudo mount --bind "${YASHCHIKI_SPACK_PATH}" "${TARGET_FOLDER}/opt/spack" - if test -f "${YASHCHIKI_IMAGE_NAME}"; then echo "Image at ${YASHCHIKI_IMAGE_NAME} exists." exit 1 fi -# TODO: singularity 3.1 produces SIF w/o setuid flags on files, using a newer -# singularity for the image build -#sudo singularity build ${YASHCHIKI_IMAGE_NAME} "${TARGET_FOLDER}" -sudo /usr/local/singularity/sif_builder/bin/singularity build ${YASHCHIKI_IMAGE_NAME} "${TARGET_FOLDER}" - -# umount spack folder afterwards -sudo umount "${TARGET_FOLDER}/opt/spack" - -sudo chown -R $(id -un) ${YASHCHIKI_IMAGE_NAME} +/skretch/opt/apptainer/1.2.5/bin/apptainer build --fakeroot ${YASHCHIKI_IMAGE_NAME} "${TARGET_FOLDER}" diff --git a/lib/yashchiki/build_sandbox.sh b/lib/yashchiki/build_sandbox.sh index 48b78e1aa5186d513359cfa49c5559383d115a93..19d3e2d16ceed9105feb98b6159baacdc9d80e76 100755 --- a/lib/yashchiki/build_sandbox.sh +++ b/lib/yashchiki/build_sandbox.sh @@ -18,5 +18,11 @@ TARGET_FOLDER="${YASHCHIKI_SANDBOXES}/${CONTAINER_STYLE}" mkdir -p ${YASHCHIKI_SANDBOXES} -# Do not change: special sudo permit for the host user... -sudo -E singularity build --sandbox "${TARGET_FOLDER}" "${YASHCHIKI_RECIPE_PATH}" | tee out_singularity_build_recipe.txt +/skretch/opt/apptainer/1.2.5/bin/apptainer build \ + --bind ${YASHCHIKI_CACHES_ROOT}/download_cache:/opt/spack/var/spack/cache \ + --bind ${YASHCHIKI_CACHES_ROOT}/spack_ccache:/opt/ccache \ + --bind ${YASHCHIKI_CACHES_ROOT}/build_caches:/opt/build_cache \ + --bind ${YASHCHIKI_CACHES_ROOT}/preserved_packages:/opt/preserved_packages \ + --bind ${JOB_TMP_SPACK}:/tmp/spack \ + --bind ${YASHCHIKI_SPACK_CONFIG}:/tmp/spack_config \ + --fakeroot --sandbox "${TARGET_FOLDER}" "${YASHCHIKI_RECIPE_PATH}" | tee out_singularity_build_recipe.txt diff --git a/lib/yashchiki/complete_spack_install_routine_called_in_post_as_root.sh b/lib/yashchiki/complete_spack_install_routine_called_in_post.sh similarity index 52% rename from lib/yashchiki/complete_spack_install_routine_called_in_post_as_root.sh rename to lib/yashchiki/complete_spack_install_routine_called_in_post.sh index 321a0894d21c4d849f65ee3d1994b9aaa4081ec2..51483bad74b0de654f9e9768d318fca55d2d354c 100755 --- a/lib/yashchiki/complete_spack_install_routine_called_in_post_as_root.sh +++ b/lib/yashchiki/complete_spack_install_routine_called_in_post.sh @@ -11,18 +11,17 @@ shopt -s inherit_errexit 2>/dev/null || true SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" source "${SOURCE_DIR}/commons.sh" -"${SPACK_INSTALL_SCRIPTS}/prepare_spack_as_root.sh" -sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/install_dependencies.sh" +"${SPACK_INSTALL_SCRIPTS}/prepare_spack.sh" +"${SPACK_INSTALL_SCRIPTS}/install_dependencies.sh" -sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/install_spack_packages.sh" && \ -sudo -Eu spack ${MY_SPACK_CMD} compiler add --scope site /usr/bin && \ -sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/restore_spack_user_settings.sh" && \ +"${SPACK_INSTALL_SCRIPTS}/install_spack_packages.sh" && \ +${MY_SPACK_CMD} compiler add --scope site /usr/bin && \ +"${SPACK_INSTALL_SCRIPTS}/restore_spack_user_settings.sh" && \ # remove temporary cache folder rm -rfv /opt/spack/.spack -"${SPACK_INSTALL_SCRIPTS}/restore_spack_user_settings_as_root.sh" && \ "${SPACK_INSTALL_SCRIPTS}/generate_modules.sh" || \ ( -sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && + "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && exit 1 # propagate the error ) diff --git a/lib/yashchiki/create_caches.sh b/lib/yashchiki/create_caches.sh index 88180700d04b9937f61b02f083c058209d15aabc..ceedf67ca4122c3f4c72c1f7d6d3ddf37e3eb4e4 100755 --- a/lib/yashchiki/create_caches.sh +++ b/lib/yashchiki/create_caches.sh @@ -22,7 +22,3 @@ fi if [ ! -d "${YASHCHIKI_CACHES_ROOT}/preserved_packages" ]; then mkdir -p "${YASHCHIKI_CACHES_ROOT}/preserved_packages" fi - -# spack requires ccache and preserved packages to be accessible within the container -sudo chown -R spack:nogroup "${YASHCHIKI_CACHES_ROOT}/spack_ccache" -sudo chown -R spack:nogroup "${YASHCHIKI_CACHES_ROOT}/preserved_packages" diff --git a/lib/yashchiki/create_spack_user.sh b/lib/yashchiki/create_spack_user.sh deleted file mode 100755 index 2807fd1b3d1e4b3f1d98e9877b4c630154903a1e..0000000000000000000000000000000000000000 --- a/lib/yashchiki/create_spack_user.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -euo pipefail -shopt -s inherit_errexit 2>/dev/null || true - -# we need the spack user outside of the container, create it here if it is not present already -if [ id spack &>/dev/null ]; then - sudo useradd spack --uid 888 --no-create-home --system --shell /bin/bash -fi diff --git a/lib/yashchiki/fetch.sh b/lib/yashchiki/fetch.sh index 31cef238e003c0df45425c0f71b8cc60d2371e09..a1e8195fc0c87d7dd05d7934a854f4fce527e4a3 100755 --- a/lib/yashchiki/fetch.sh +++ b/lib/yashchiki/fetch.sh @@ -6,11 +6,6 @@ shopt -s inherit_errexit SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" source "${SOURCE_DIR}/commons.sh" -# hard-link source cache into spack folder to avoid duplication. -mkdir -p "${YASHCHIKI_SPACK_PATH}/var/spack/cache/" -find "${SOURCE_CACHE_DIR}" -mindepth 1 -maxdepth 1 -print0 \ - | xargs -r -n 1 "-I{}" -0 cp -vrl '{}' "${YASHCHIKI_SPACK_PATH}/var/spack/cache/" - # temporary spack config scope directory for fetching tmp_config_scope=("$(mktemp -d)") @@ -22,6 +17,11 @@ export MY_SPACK_BIN="${MY_SPACK_FOLDER}/bin/spack" # therefore we also need to redefine this command variable export MY_SPACK_CMD="${MY_SPACK_BIN} --config-scope ${YASHCHIKI_SPACK_CONFIG} --config-scope ${tmp_config_scope}" +cat >"${tmp_config_scope}/config.yaml" <<EOF +config: + source_cache: ${YASHCHIKI_CACHES_ROOT}/download_cache +EOF + # fetch "everything" (except for pip shitness) echo "FETCHING..." @@ -185,15 +185,6 @@ for package in "${packages_to_fetch[@]}"; do fetch_specfiles+=( "${specfile}" ) done if ! ${MY_SPACK_CMD} fetch -D "${fetch_specfiles[@]/^/-f }"; then - fetch_failed=1 -else - fetch_failed=0 -fi - -# update cache in any case to store successfully loaded files -rsync -av "${MY_SPACK_FOLDER}/var/spack/cache/" "${SOURCE_CACHE_DIR}/" - -if (( fetch_failed != 0 )); then # propagate error exit 1 fi diff --git a/lib/yashchiki/install_singularity_as_root.sh b/lib/yashchiki/install_singularity.sh similarity index 100% rename from lib/yashchiki/install_singularity_as_root.sh rename to lib/yashchiki/install_singularity.sh diff --git a/lib/yashchiki/prepare_spack.sh b/lib/yashchiki/prepare_spack.sh new file mode 100755 index 0000000000000000000000000000000000000000..d07e6499692757c386949e497fd75851e3f65958 --- /dev/null +++ b/lib/yashchiki/prepare_spack.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# prepare spack as root during container setup + +set -euo pipefail +shopt -s inherit_errexit 2>/dev/null || true + +SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" +source "${SOURCE_DIR}/commons.sh" + +# spack stuff +mkdir /opt/spack_views +mkdir -p "${SPEC_FOLDER_IN_CONTAINER}" +chmod go=rwx /opt +chmod +x /opt/spack_install_scripts/*.sh +# have a convenience folder to easily execute other shells for user +# sessions independent of any app +mkdir /opt/shell diff --git a/lib/yashchiki/prepare_spack_as_root.sh b/lib/yashchiki/prepare_spack_as_root.sh deleted file mode 100755 index bcb0beb1e701f7cd3adb8b21a29d27d08024a973..0000000000000000000000000000000000000000 --- a/lib/yashchiki/prepare_spack_as_root.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# prepare spack as root during container setup - -set -euo pipefail -shopt -s inherit_errexit 2>/dev/null || true - -SOURCE_DIR="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" -source "${SOURCE_DIR}/commons.sh" - -# spack stuff -# home has to exist, so we simply point ot /opt/spack -spack_create_user_cmd -chown spack:$spack_gid /opt -mkdir /opt/spack_views -chown spack:$spack_gid /opt/spack_views -mkdir -p "${SPEC_FOLDER_IN_CONTAINER}" -chown spack:$spack_gid "${SPEC_FOLDER_IN_CONTAINER}" -chown spack:$spack_gid "${BUILD_CACHE_INSIDE}" -chmod go=rwx /opt -# in the final image /opt/spack* should be owned by the spack user. -# Therefore: chown everything to the spack user except for var/cache (contains -# hardlinks to host-user-owned files) -find "/opt/spack" \ - \( -type d -wholename "/opt/spack/var/spack/cache" -prune \ - \) -o -exec chown spack:$spack_gid '{}' \; -chmod +x /opt/spack_install_scripts/*.sh -# have a convenience folder to easily execute other shells for user -# sessions independent of any app -mkdir /opt/shell -chown spack:$spack_gid /opt/shell diff --git a/lib/yashchiki/restore_host_user_ownership.sh b/lib/yashchiki/restore_host_user_ownership.sh deleted file mode 100755 index d3230ddb4fa3ce761343dbbe8ce785713521da78..0000000000000000000000000000000000000000 --- a/lib/yashchiki/restore_host_user_ownership.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -euo pipefail -shopt -s inherit_errexit 2>/dev/null || true - -if [ -d "${YASHCHIKI_SPACK_PATH}" ]; then - sudo chown -R $(id -un):$(id -gn) "${YASHCHIKI_SPACK_PATH}" -fi - -if [ -d "${JOB_TMP_SPACK}" ]; then - sudo chown -R $(id -un):$(id -gn) "${JOB_TMP_SPACK}" -fi diff --git a/lib/yashchiki/restore_spack_user_settings_as_root.sh b/lib/yashchiki/restore_spack_user_settings_as_root.sh deleted file mode 100755 index 56c1e17978a32890700ea2babfd1c01a5772a447..0000000000000000000000000000000000000000 --- a/lib/yashchiki/restore_spack_user_settings_as_root.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# -# Restore settings that are used during build but should be reset for the end -# user -# - -set -euo pipefail -shopt -s inherit_errexit 2>/dev/null || true - -sourcedir="$(dirname "$(readlink -m "${BASH_SOURCE[0]}")")" -source "${sourcedir}/commons.sh" - -# shrink image: remove download cache (owned by host-user) -rm -rf "${MY_SPACK_FOLDER}"/var/spack/cache/* -chown spack:$spack_gid "${MY_SPACK_FOLDER}"/var/spack/cache diff --git a/lib/yashchiki/update_build_cache.sh b/lib/yashchiki/update_build_cache.sh index b5ebbd8c830ef01d41dc5a44bf2e3785077d2ef7..4a578035500b776eec022a9a0a6e9d99171dd8c2 100755 --- a/lib/yashchiki/update_build_cache.sh +++ b/lib/yashchiki/update_build_cache.sh @@ -29,7 +29,7 @@ source "${SOURCE_DIR}/commons.sh" # update script inside the container set +e # Arugments needed once we switch to singularity3: --writable-tmpfs -sudo -E singularity exec\ +/skretch/opt/apptainer/1.2.5/bin/apptainer exec\ -B "${BUILD_CACHE_OUTSIDE}:${BUILD_CACHE_INSIDE}:rw"\ "${IMAGE_NAME}" \ - sudo -Eu spack /opt/spack_install_scripts/update_build_cache_in_container.sh -j ${YASHCHIKI_JOBS} -q || exit 0 + /opt/spack_install_scripts/update_build_cache_in_container.sh -j ${YASHCHIKI_JOBS} -q || exit 0 diff --git a/share/yashchiki/styles/asic/create_recipe.sh b/share/yashchiki/styles/asic/create_recipe.sh index 588ea5e1c26a9c32efa56ca2d501935c3cdb7f8f..4257fc78dd3a37f070beb38fb8a91942e98d8339 100755 --- a/share/yashchiki/styles/asic/create_recipe.sh +++ b/share/yashchiki/styles/asic/create_recipe.sh @@ -11,38 +11,37 @@ Bootstrap: docker From: ${DOCKER_BASE_IMAGE} %setup - # bind-mount spack-folder as moving involves copying the complete download cache - mkdir \${SINGULARITY_ROOTFS}/opt/spack - mount --no-mtab --bind "${YASHCHIKI_SPACK_PATH}" "\${SINGULARITY_ROOTFS}/opt/spack" - # bind-mount ccache - mkdir \${SINGULARITY_ROOTFS}/opt/ccache - mount --no-mtab --bind "${YASHCHIKI_CACHES_ROOT}/spack_ccache" "\${SINGULARITY_ROOTFS}/opt/ccache" - # bind-mount build_cache - mkdir -p "\${SINGULARITY_ROOTFS}${BUILD_CACHE_INSIDE}" - # create buildcache directory if it does not exist + # location to bind-mount spack-folder + mkdir \${APPTAINER_ROOTFS}/opt/spack + # location to bind-mount spack-source-cache-folder + mkdir -p \${APPTAINER_ROOTFS}/opt/spack/var/spack/cache/ + # copy spack repo + rsync -av ${YASHCHIKI_SPACK_PATH}/ \${APPTAINER_ROOTFS}/opt/spack + # location to bind-mount ccache + mkdir \${APPTAINER_ROOTFS}/opt/ccache + # location to bind-mount build_cache + mkdir -p "\${APPTAINER_ROOTFS}${BUILD_CACHE_INSIDE}" + # # create buildcache directory if it does not exist [ ! -d "${BUILD_CACHE_OUTSIDE}" ] && mkdir -p "${BUILD_CACHE_OUTSIDE}" - # mount the full build cache folder into container because some files might be symlinked to other buildcaches - mount --no-mtab --bind "${BASE_BUILD_CACHE_OUTSIDE}" "\${SINGULARITY_ROOTFS}${BASE_BUILD_CACHE_INSIDE}" - # bind-mount preserved packages in case the build fails - mkdir -p "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" - mount --no-mtab --bind "${PRESERVED_PACKAGES_OUTSIDE}" "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" - # bind-mount tmp-folder - mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack" - mount --no-mtab --bind "${JOB_TMP_SPACK}" "\${SINGULARITY_ROOTFS}/tmp/spack" - # bind-mount spack config tmp-folder - mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack_config" - mount --no-mtab --bind "${YASHCHIKI_SPACK_CONFIG}" "\${SINGULARITY_ROOTFS}/tmp/spack_config" + # location to mount the full build cache folder into container because some files might be symlinked to other buildcaches + # mount --no-mtab --bind "${BASE_BUILD_CACHE_OUTSIDE}" "\${APPTAINER_ROOTFS}${BASE_BUILD_CACHE_INSIDE}" + # location to bind-mount preserved packages in case the build fails + mkdir -p "\${APPTAINER_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" + # location to bind-mount tmp-folder + mkdir -p "\${APPTAINER_ROOTFS}/tmp/spack" + # location to bind-mount spack config tmp-folder + mkdir -p "\${APPTAINER_ROOTFS}/tmp/spack_config" # copy install scripts - mkdir "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av --chmod 0755 "${ROOT_DIR}"/share/yashchiki/styles/${CONTAINER_STYLE}/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av --chmod 0755 "${ROOT_DIR}"/lib/yashchiki/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av "${ROOT_DIR}"/lib/yashchiki/*.awk "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av "${ROOT_DIR}"/share/yashchiki/patches "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - mkdir -p "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}" - rsync -av "${META_DIR_OUTSIDE}/" "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}" + mkdir "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av --chmod 0755 "${ROOT_DIR}"/share/yashchiki/styles/${CONTAINER_STYLE}/*.sh "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av --chmod 0755 "${ROOT_DIR}"/lib/yashchiki/*.sh "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av "${ROOT_DIR}"/lib/yashchiki/*.awk "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av "${ROOT_DIR}"/share/yashchiki/patches "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + mkdir -p "\${APPTAINER_ROOTFS}/${META_DIR_INSIDE}" + rsync -av "${META_DIR_OUTSIDE}/" "\${APPTAINER_ROOTFS}/${META_DIR_INSIDE}" # init scripts for user convenience - mkdir -p "\${SINGULARITY_ROOTFS}/opt/init" - rsync -av "${ROOT_DIR}"/share/yashchiki/misc-files/init/*.sh "\${SINGULARITY_ROOTFS}/opt/init" + mkdir -p "\${APPTAINER_ROOTFS}/opt/init" + rsync -av "${ROOT_DIR}"/share/yashchiki/misc-files/init/*.sh "\${APPTAINER_ROOTFS}/opt/init" %files # NOTE: Due to a bug in singularity 2.6 all paths in this section _cannot_ @@ -254,14 +253,14 @@ From: ${DOCKER_BASE_IMAGE} export YASHCHIKI_SPACK_VERBOSE="${YASHCHIKI_SPACK_VERBOSE}" export YASHCHIKI_DEBUG=${YASHCHIKI_DEBUG} export CONTAINER_STYLE="${CONTAINER_STYLE}" - "${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post_as_root.sh" + "${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post.sh" wait ( - "${SPACK_INSTALL_SCRIPTS}/install_singularity_as_root.sh" && \ - "${SPACK_INSTALL_SCRIPTS}/install_gocryptfs_as_root.sh" + "${SPACK_INSTALL_SCRIPTS}/install_singularity.sh" && \ + "${SPACK_INSTALL_SCRIPTS}/install_gocryptfs.sh" ) || \ ( - sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && + "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && exit 1 # propagate the error ) diff --git a/share/yashchiki/styles/asic/install_gocryptfs_as_root.sh b/share/yashchiki/styles/asic/install_gocryptfs.sh similarity index 100% rename from share/yashchiki/styles/asic/install_gocryptfs_as_root.sh rename to share/yashchiki/styles/asic/install_gocryptfs.sh diff --git a/share/yashchiki/styles/asic/spack_collection.sh b/share/yashchiki/styles/asic/spack_collection.sh index de3317968c52cfbbc79ad9cd54e05fc7c1699dde..41cace19cdcc472d42c222be11255552408c5a90 100644 --- a/share/yashchiki/styles/asic/spack_collection.sh +++ b/share/yashchiki/styles/asic/spack_collection.sh @@ -14,9 +14,3 @@ spack_views_no_default_gcc=(\ spack_views_gccxml=( ) - -spack_gid="nobody" - -spack_create_user_cmd() { - adduser spack --uid 888 --gid nobody --no-create-home --no-user-group --home /opt/spack --system --shell /bin/bash -} diff --git a/share/yashchiki/styles/visionary/create_recipe.sh b/share/yashchiki/styles/visionary/create_recipe.sh index a7447ec079628eba55653ea4322612b6474f3bef..cf1cb80e661a41832e703ded6b5ea449b97ddefa 100755 --- a/share/yashchiki/styles/visionary/create_recipe.sh +++ b/share/yashchiki/styles/visionary/create_recipe.sh @@ -16,38 +16,37 @@ Bootstrap: docker From: ${DOCKER_BASE_IMAGE} %setup - # bind-mount spack-folder as moving involves copying the complete download cache - mkdir \${SINGULARITY_ROOTFS}/opt/spack - mount --no-mtab --bind "${YASHCHIKI_SPACK_PATH}" "\${SINGULARITY_ROOTFS}/opt/spack" - # bind-mount ccache - mkdir \${SINGULARITY_ROOTFS}/opt/ccache - mount --no-mtab --bind "${YASHCHIKI_CACHES_ROOT}/spack_ccache" "\${SINGULARITY_ROOTFS}/opt/ccache" - # bind-mount build_cache - mkdir -p "\${SINGULARITY_ROOTFS}${BUILD_CACHE_INSIDE}" - # create buildcache directory if it does not exist + # location to bind-mount spack-folder + mkdir \${APPTAINER_ROOTFS}/opt/spack + # location to bind-mount spack-source-cache-folder + mkdir -p \${APPTAINER_ROOTFS}/opt/spack/var/spack/cache/ + # copy spack repo + rsync -av ${YASHCHIKI_SPACK_PATH}/ \${APPTAINER_ROOTFS}/opt/spack + # location to bind-mount ccache + mkdir \${APPTAINER_ROOTFS}/opt/ccache + # location to bind-mount build_cache + mkdir -p "\${APPTAINER_ROOTFS}${BUILD_CACHE_INSIDE}" + # # create buildcache directory if it does not exist [ ! -d "${BUILD_CACHE_OUTSIDE}" ] && mkdir -p "${BUILD_CACHE_OUTSIDE}" - # mount the full build cache folder into container because some files might be symlinked to other buildcaches - mount --no-mtab --bind "${BASE_BUILD_CACHE_OUTSIDE}" "\${SINGULARITY_ROOTFS}${BASE_BUILD_CACHE_INSIDE}" - # bind-mount preserved packages in case the build fails - mkdir -p "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" - mount --no-mtab --bind "${PRESERVED_PACKAGES_OUTSIDE}" "\${SINGULARITY_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" - # bind-mount tmp-folder - mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack" - mount --no-mtab --bind "${JOB_TMP_SPACK}" "\${SINGULARITY_ROOTFS}/tmp/spack" - # bind-mount spack config tmp-folder - mkdir -p "\${SINGULARITY_ROOTFS}/tmp/spack_config" - mount --no-mtab --bind "${YASHCHIKI_SPACK_CONFIG}" "\${SINGULARITY_ROOTFS}/tmp/spack_config" + # location to mount the full build cache folder into container because some files might be symlinked to other buildcaches + # mount --no-mtab --bind "${BASE_BUILD_CACHE_OUTSIDE}" "\${APPTAINER_ROOTFS}${BASE_BUILD_CACHE_INSIDE}" + # location to bind-mount preserved packages in case the build fails + mkdir -p "\${APPTAINER_ROOTFS}${PRESERVED_PACKAGES_INSIDE}" + # location to bind-mount tmp-folder + mkdir -p "\${APPTAINER_ROOTFS}/tmp/spack" + # location to bind-mount spack config tmp-folder + mkdir -p "\${APPTAINER_ROOTFS}/tmp/spack_config" # copy install scripts - mkdir "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av --chmod 0755 "${ROOT_DIR}"/share/yashchiki/styles/${CONTAINER_STYLE}/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av --chmod 0755 "${ROOT_DIR}"/lib/yashchiki/*.sh "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av "${ROOT_DIR}"/lib/yashchiki/*.awk "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - rsync -av "${ROOT_DIR}"/share/yashchiki/patches "\${SINGULARITY_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" - mkdir -p "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}" - rsync -av "${META_DIR_OUTSIDE}/" "\${SINGULARITY_ROOTFS}/${META_DIR_INSIDE}" + mkdir "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av --chmod 0755 "${ROOT_DIR}"/share/yashchiki/styles/${CONTAINER_STYLE}/*.sh "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av --chmod 0755 "${ROOT_DIR}"/lib/yashchiki/*.sh "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av "${ROOT_DIR}"/lib/yashchiki/*.awk "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + rsync -av "${ROOT_DIR}"/share/yashchiki/patches "\${APPTAINER_ROOTFS}/${SPACK_INSTALL_SCRIPTS}" + mkdir -p "\${APPTAINER_ROOTFS}/${META_DIR_INSIDE}" + rsync -av "${META_DIR_OUTSIDE}/" "\${APPTAINER_ROOTFS}/${META_DIR_INSIDE}" # init scripts for user convenience - mkdir -p "\${SINGULARITY_ROOTFS}/opt/init" - rsync -av "${ROOT_DIR}"/share/yashchiki/misc-files/init/*.sh "\${SINGULARITY_ROOTFS}/opt/init" + mkdir -p "\${APPTAINER_ROOTFS}/opt/init" + rsync -av "${ROOT_DIR}"/share/yashchiki/misc-files/init/*.sh "\${APPTAINER_ROOTFS}/opt/init" %files # NOTE: Due to a bug in singularity 2.6 all paths in this section _cannot_ @@ -96,14 +95,14 @@ From: ${DOCKER_BASE_IMAGE} PID_MAIN="\$\$" ( "${SPACK_INSTALL_SCRIPTS}/install_system_dependencies.sh" \ || kill \${PID_MAIN} ) & - "${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post_as_root.sh" + "${SPACK_INSTALL_SCRIPTS}/complete_spack_install_routine_called_in_post.sh" # system dependencies might not have installed by now # currently, singularity needs some dependendencies from apt as well, so # wait till we are finished with system dependencies wait - "${SPACK_INSTALL_SCRIPTS}/install_singularity_as_root.sh" || \ + "${SPACK_INSTALL_SCRIPTS}/install_singularity.sh" || \ ( - sudo -Eu spack "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && + "${SPACK_INSTALL_SCRIPTS}/preserve_built_spack_packages.sh" && exit 1 # propagate the error ) # apply some system-level patching (TODO: remove this as soon as gccxml dependency is gone) diff --git a/share/yashchiki/styles/visionary/spack_collection.sh b/share/yashchiki/styles/visionary/spack_collection.sh index bd7b9054a0d24989aa4a35d0a4c975af2e6baad1..032ecc16c8a99390629c714e55960218b917ef9b 100644 --- a/share/yashchiki/styles/visionary/spack_collection.sh +++ b/share/yashchiki/styles/visionary/spack_collection.sh @@ -33,13 +33,6 @@ spack_views_gccxml=( ) - -spack_gid="nogroup" - -spack_create_user_cmd() { - adduser spack --uid 888 --no-create-home --home /opt/spack --disabled-password --system --shell /bin/bash -} - # all views get the default gcc except those in spack_views_no_default_gcc # (defined above) spack_add_to_view_with_dependencies["${YASHCHIKI_SPACK_GCC}"]="no" diff --git a/share/yashchiki/utils/public.sh b/share/yashchiki/utils/public.sh index 4e707642d7ad683ff4df78df045b0018e0b5ec8d..98b8f179737ad0c141a79a670650a34ee88281ff 100755 --- a/share/yashchiki/utils/public.sh +++ b/share/yashchiki/utils/public.sh @@ -69,7 +69,7 @@ check_container_inner() { fi # check that there are no blacklisted packages in the container - if singularity shell "${container}" -l \ + if /skretch/opt/apptainer/1.2.5/bin/apptainer shell "${container}" -l \ -c "spack find | grep -q \"$(get_grep_pattern_blacklisted)\"" \ &>/dev/null; then # do NOT use container if blacklisted package present