diff --git a/run-find-external.sh.in b/run-find-external.sh.in index e32cddb..b767ce7 100644 --- a/run-find-external.sh.in +++ b/run-find-external.sh.in @@ -1,5 +1,49 @@ #!/bin/bash -if [ -e @@_sysconfdir@@/spack/no_rpm_trigger ] ; then + +scope=system +what=$1 + +addpath() { + path=$1 + shift + while [ -n "$1" ]; do + eval "${path}"=${1}:${!path} + shift + done +} + +find_packages() { + if [ $scope = user ]; then + test -e /etc/spack/packages.yaml && mv /etc/spack/packages.yaml /etc/spack/packages.yaml.old + # drop all root rights, when calling external find + sudo -u nobody PATH=${mypath}:${PATH} spack external find --scope user --all #--exclude 'installdbgsymbols' + if [ -e /var/lib/nobody/.spack/packages.yaml ] ; then + mv -v /var/lib/nobody/.spack/packages.yaml /etc/spack/packages.yaml + chown root:root /etc/spack/packages.yaml + fi + rm -r /var/lib/nobody/.spack + else + # May run in a container... + PATH=${mypath}:${PATH} spack external find --scope system --all #--exclude 'installdbgsymbols' + fi +} + +find_compilers() { + if [ $scope = user ]; then + test -e /etc/spack/compilers.yaml && mv /etc/spack/compilers.yaml /etc/spack/compilers.yaml.old + # drop all root rights, when calling external find + sudo -u nobody PATH=${cpath}:${PATH} spack compiler find --scope user + if [ -e /var/lib/nobody/.spack/compilers.yaml ] ; then + mv -v /var/lib/nobody/.spack/compilers.yaml /etc/spack/compilers.yaml + chown root:root /etc/spack/compilers.yaml + fi + else + # May run in a container... + PATH=${cpath}:${PATH} spack compiler find --scope system + fi +} + +if [ -e /etc/spack/no_rpm_trigger ] ; then exit 0 fi if [ "x$(id -u)" != "x0" ] ; then @@ -9,34 +53,35 @@ fi echo "Create /etc/spack/no_rpm_trigger to stop spack to search for new packages after a rpm install" # save old packages.yml, it has to be removed as when not -# the new and old packages.yaml files would have to be +# the new and old packages.yaml files would have to be # combined -test -e /etc/spack/packages.yaml && mv /etc/spack/packages.yaml /etc/spack/packages.yaml.old -# prepare the path -mypath=/usr/lib64/mpi/gcc/openmpi4/bin -mypath=/usr/lib64/mpi/gcc/openmpi3/bin:${mypath} -mypath=/usr/lib64/mpi/gcc/openmpi2/bin:${mypath} -mypath=/usr/lib64/mpi/gcc/openmpi1/bin:${mypath} -mypath=/usr/lib64/mpi/gcc/mvapich2/bin:${mypath} -mypath=/usr/lib64/mpi/gcc/mpich/bin:${mypath} -mypath=/usr/lib/hpc/gnu?/mpi/openmpi/4.*/bin:${mypath} -mypath=/usr/lib/hpc/gnu?/mpi/openmpi/3.*/bin:${mypath} -mypath=/usr/lib/hpc/gnu?/mpi/openmpi/2.*/bin:${mypath} -mypath=/usr/lib/hpc/gnu?/mpi/mpich/3.*/bin:${mypath} -mypath=/usr/lib/hpc/gnu?/mpi/mvapich2/2.*/bin:${mypath} +# prepare the path +shopt -s nullglob +addpath mypath /usr/lib64/mpi/gcc/openmpi4/bin +addpath mypath /usr/lib64/mpi/gcc/openmpi3/bin +addpath mypath /usr/lib64/mpi/gcc/openmpi2/bin +addpath mypath /usr/lib64/mpi/gcc/openmpi1/bin +addpath mypath /usr/lib64/mpi/gcc/mvapich2/bin +addpath mypath /usr/lib64/mpi/gcc/mpich/bin +addpath mypath /usr/lib/hpc/gnu*/mpi/openmpi/4.*/bin +addpath mypath /usr/lib/hpc/gnu*/mpi/openmpi/3.*/bin +addpath mypath /usr/lib/hpc/gnu*/mpi/openmpi/2.*/bin +addpath mypath /usr/lib/hpc/gnu*/mpi/mpich/3.*/bin +addpath mypath /usr/lib/hpc/gnu*/mpi/mvapich2/2.*/bin +addpath cpath /usr/lib/hpc/compiler/gnu/*/bin + # test if we can run as nobody getent passwd nobody &> /dev/null if [ "x$?" == "x0" ] ; then -# drop all root rights, when calling external find - sudo -u nobody PATH=${mypath}:${PATH} spack external find --all --scope user #--exclude 'installdbgsymbols' - if [ -e /var/lib/nobody/.spack/packages.yaml ] ; then - mv -v /var/lib/nobody/.spack/packages.yaml /etc/spack/packages.yaml - chown root:root /etc/spack/packages.yaml - rm -r /var/lib/nobody/.spack - fi -else - # May run in a container... - PATH=${mypath}:${PATH} spack external find --scope system #--exclude 'installdbgsymbols' + scope=user fi + +case $what in + packages) find_packages $scope ;; + compilers) find_compilers $scope ;; + '') find_packages $scope + find_compilers $scope ;; + *) exit 1 ;; +esac diff --git a/spack.changes b/spack.changes index 1c11d78..3032e6f 100644 --- a/spack.changes +++ b/spack.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Mar 8 19:54:55 UTC 2023 - Egbert Eich + +- Improve run-find-external.sh: + * Extend to run 'spack compiler find'. + * Separate triggers for packages and compilers. + * Better handle when search patterns match multiple directories. + ------------------------------------------------------------------- Wed Mar 1 13:13:34 UTC 2023 - Christian Goll @@ -7,7 +15,7 @@ Wed Mar 1 13:13:34 UTC 2023 - Christian Goll * Improve error message for requirements * Fix libtool filter for Fujitsu compilers * FileCache: delete the new cache file on exception -- using `--all` flag for `spack external find` in the %triggrin +- using `--all` flag for `spack external find` in the %triggrin section, as MPI packages were not recognized any more, fixing (bsc#1208751) diff --git a/spack.spec b/spack.spec index 8497e0a..ffc7a2e 100644 --- a/spack.spec +++ b/spack.spec @@ -27,12 +27,19 @@ ExclusiveArch: do_not_build %define spack_dir %_prefix/lib/spack/ %define spack_group spack + # These packages are found and can be used by spack, /etc/spack/packages-yaml # needs to be updated when one of these packages is updated or uninstalled. # Distinguish between packages we recommend and packages which -%define spack_trigger_recommended autoconf bash bison bzip2 libzip-devel cmake-full ccache cpio diffutils findutils flex gcc gcc-c++ gcc-fortran git-lfs make m4 ncurses-devel libtool openssl-devel perl-base pkgconf pkg-config python3-base tar info xz xz-devel +%define spack_trigger_recommended_packages autoconf bash bison bzip2 libzip-devel cmake-full ccache cpio diffutils findutils flex git-lfs make m4 ncurses-devel libtool openssl-devel perl-base pkgconf pkg-config python3-base tar info xz xz-devel + +%define spack_trigger_recommended_compilers gcc gcc-c++ gcc-fortran + # packages recognized by spack, but not recommended -%define spack_trigger_packages ghostscript go fish fzf hugo java-11-openjdk-devel java-14-openjdk-devel java-15-openjdk-devel java-16-openjdk-devel java-1_8_0-openjdk-devel ruby openmpi1-devel openmpi2-devel openmpi3-devel openmpi4-devel openmpi1-gnu-hpc-devel openmpi2-gnu-hpc-devel openmpi3-gnu-hpc-devel openmpi4-gnu-hpc-devel mvapich2-devel mpich-devel gcc7 gcc8 gcc9 gcc10 gcc11 gcc7-c++ gcc8-c++ gcc9-c++ gcc10-c++ gcc11-c++ gcc7-fortran gcc8-fortran gcc9-fortran gcc10-fortran gcc11-fortran +%define spack_trigger_packages ghostscript go fish fzf hugo java-11-openjdk-devel java-14-openjdk-devel java-15-openjdk-devel java-16-openjdk-devel java-1_8_0-openjdk-devel ruby openmpi1-devel openmpi2-devel openmpi3-devel openmpi4-devel openmpi1-gnu-hpc-devel openmpi2-gnu-hpc-devel openmpi3-gnu-hpc-devel openmpi4-gnu-hpc-devel mvapich2-devel mpich-devel + +%define spack_trigger_compilers gcc7 gcc8 gcc9 gcc10 gcc11 gcc12 gcc7-c++ gcc8-c++ gcc9-c++ gcc10-c++ gcc11-c++ gcc12-c++ gcc7-fortran gcc8-fortran gcc9-fortran gcc10-fortran gcc11-fortran gcc12-fortran + # non oss packages %define spack_trigger_external cuda-nvcc Name: spack @@ -79,7 +86,7 @@ Requires: python3-clingo Requires: sudo Requires: tar Requires: xz -Recommends: %spack_trigger_recommended +Recommends: %spack_trigger_recommended_packages %spack_trigger_recommended_compilers %else BuildRequires: git BuildRequires: makeinfo @@ -460,11 +467,17 @@ mkdir -p /opt/spack chgrp spack /opt/spack chmod 0775 /opt/spack -%triggerin -- %{?spack_trigger_recommended} %{?spack_trigger_packages} %{?spack_trigger_external} -/usr/lib/spack/run-find-external.sh +%triggerin -- %{?spack_trigger_recommended_packages} %{?spack_trigger_packages} %{?spack_trigger_external} +/usr/lib/spack/run-find-external.sh packages -%triggerpostun -- %{?spack_trigger_recommended} %{?spack_trigger_packages} %{?spack_trigger_external} -/usr/lib/spack/run-find-external.sh +%triggerin -- %{?spack_trigger_recommended_compilers} %{?spack_trigger_compilers} +/usr/lib/spack/run-find-external.sh compilers + +%triggerpostun -- %{?spack_trigger_recommended_packages} %{?spack_trigger_packages} %{?spack_trigger_external} +/usr/lib/spack/run-find-external.sh packages + +%triggerpostun -- %{?spack_trigger_recommended_compilers} %{?spack_trigger_compilers} +/usr/lib/spack/run-find-external.sh compilers %if %{without doc} %files