Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Spack example: use external packages.yaml, add patch #1883

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions examples/spack/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,29 @@ FROM almalinux:8
# Spack’s m4, and that package is in PowerTools, which we enable using sed(1)
# to avoid installing the config-manager DNF plugin.
#
# autoconf, git, openssl, pkg-config, python3, fuse3-libs, fuse3-devel, are
# packages that are typically installed on systems. Thus we install them outside
# of Spack and rely them as externals to speed up the build process.
#
# [1]: https://spack.readthedocs.io/en/latest/getting_started.html
# [2]: https://spack.readthedocs.io/en/latest/workflows.html#using-spack-to-create-docker-images
RUN sed -Ei 's/enabled=0/enabled=1/' \
/etc/yum.repos.d/almalinux-powertools.repo
RUN dnf install -y --setopt=install_weak_deps=false \
autoconf \
automake \
bzip2 \
gcc \
gcc-c++ \
git \
gnupg2-smime \
file \
fuse3-devel \
fuse3-libs \
make \
patch \
python3 \
pkg-config \
python38 \
texinfo \
unzip \
which \
Expand All @@ -50,28 +59,38 @@ ARG SPACK_REPO=https://github.com/spack/spack
RUN git clone $SPACK_REPO && cd spack && git checkout releases/latest # slow
RUN cd spack && git status && git rev-parse --short HEAD

# Set up environment to use Spack. (We can’t use setup-env.sh because the
# Dockerfile shell is sh, not Bash.)
ENV PATH /spack/bin:$PATH
RUN spack compiler find --scope system
# Copy our Spack package file; by relying on external packages already installed
# by the container we expedite the spack install process. We do this using
# Spacks config hierarchy, e.g., /etc/spack; however, this file could also be
# placed in the user $HOME/.spack directory.
COPY packages.yaml /etc/spack/

# Test: Some basic commands.
RUN which spack
RUN spack --version
RUN spack compiler find
RUN spack compiler list
RUN spack compiler list --scope=system
RUN spack compiler list --scope=user
RUN spack compilers
RUN spack spec charliecloud
# Apply a patch that resolves issues with Charliecloud 0.35 finding the
# Squashfuse ll.h header. Remove after https://github.com/spack/spack/pull/43374
# is merged and included in the latest spack release.
COPY libfuse.patch /
RUN patch -p 0 < libfuse.patch

# Test: Install Charliecloud.
# Test some basic commands and install Charliecloud.
# Kludge: here we specify an older python sphinx rtd_theme version because
# newer default version, 0.5.0, introduces a dependency on node-js which doesn’t
# appear to build on gcc 4.8 or gcc 8.3
# (see: https://github.com/spack/spack/issues/19310).
RUN spack spec charliecloud+docs^[email protected]
RUN spack install charliecloud+docs^[email protected]
RUN source /spack/share/spack/setup-env.sh \
&& spack --version \
&& spack env create ch \
&& spack env activate ch \
&& spack compiler find \
&& spack compiler list --scope=system \
&& spack compiler list --scope=user \
&& spack compilers \
&& spack add charliecloud +docs +squashfuse ^[email protected] \
&& spack concretize --fresh --force \
&& spack env depfile -o Makefile \
&& make -j $(nproc) SPACK_COLOR=always \
&& spack load charliecloud \
&& ch-run --version \
&& ldd $(which ch-run)

# Clean up.
RUN spack clean --all
RUN /spack/bin/spack clean --all
9 changes: 9 additions & 0 deletions examples/spack/libfuse.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
index 0e8f983545..b85ef9958a 100644
--- spack/var/spack/repos/builtin/packages/charliecloud/package.py
+++ spack/var/spack/repos/builtin/packages/charliecloud/package.py
@@ -152,5 +152,7 @@ def configure_args(self):
if "+squashfuse" in self.spec:
squashfuse_prefix = "{0}".format(self.spec["squashfuse"].prefix)
args.append("--with-libsquashfuse={0}".format(squashfuse_prefix))
+ fuse_include = self.spec["fuse"].prefix.include.fuse3
+ args.append("CFLAGS=-I{0}".format(fuse_include))
47 changes: 47 additions & 0 deletions examples/spack/packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
packages:
# The following packages are built externally to speed up the spack build
# process; they can be built from spack without issue, e.g., you can remove
# them from here without issue.
autoconf:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
automake:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
git:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
perl:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
pkgconf:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
python:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
openssl:
buildable: false
externals:
- spec: [email protected]
prefix: /usr

# Unlike the above, the following packages require a sysadmin. Removing these
# will likely cause issues.
libfuse:
buildable: false
externals:
- spec: [email protected]
prefix: /usr
2 changes: 2 additions & 0 deletions misc/loc
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ find ./.github ./examples ./test -type f -a \( \
-o -path ./test/fixtures/README \
-o -path ./.github/PERUSEME \
-o -path ./examples/chtest/printns \
-o -path ./examples/spack/packages.yaml \
-o -path ./examples/spack/libfuse.patch \
-o -path ./test/approved-trailing-whitespace \
-o -path ./test/common.bash \
-o -path ./test/doctest-auto \
Expand Down
Loading