Accepting request 1070262 from home:eeich:branches:network:cluster

- 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.

- using `--all` flag for `spack external find` in the %triggrin

OBS-URL: https://build.opensuse.org/request/show/1070262
OBS-URL: https://build.opensuse.org/package/show/network:cluster/spack?expand=0&rev=63
This commit is contained in:
Christian Goll 2023-03-09 07:41:20 +00:00 committed by Git OBS Bridge
parent f11bbce2bf
commit 128c6ea878
3 changed files with 99 additions and 33 deletions

View File

@ -1,5 +1,49 @@
#!/bin/bash #!/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 exit 0
fi fi
if [ "x$(id -u)" != "x0" ] ; then 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" 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 # 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 # 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 # test if we can run as nobody
getent passwd nobody &> /dev/null getent passwd nobody &> /dev/null
if [ "x$?" == "x0" ] ; then if [ "x$?" == "x0" ] ; then
# drop all root rights, when calling external find scope=user
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'
fi fi
case $what in
packages) find_packages $scope ;;
compilers) find_compilers $scope ;;
'') find_packages $scope
find_compilers $scope ;;
*) exit 1 ;;
esac

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Mar 8 19:54:55 UTC 2023 - Egbert Eich <eich@suse.com>
- 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 <cgoll@suse.com> Wed Mar 1 13:13:34 UTC 2023 - Christian Goll <cgoll@suse.com>
@ -7,7 +15,7 @@ Wed Mar 1 13:13:34 UTC 2023 - Christian Goll <cgoll@suse.com>
* Improve error message for requirements * Improve error message for requirements
* Fix libtool filter for Fujitsu compilers * Fix libtool filter for Fujitsu compilers
* FileCache: delete the new cache file on exception * 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 section, as MPI packages were not recognized any more, fixing
(bsc#1208751) (bsc#1208751)

View File

@ -27,12 +27,19 @@ ExclusiveArch: do_not_build
%define spack_dir %_prefix/lib/spack/ %define spack_dir %_prefix/lib/spack/
%define spack_group spack %define spack_group spack
# These packages are found and can be used by spack, /etc/spack/packages-yaml # 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. # needs to be updated when one of these packages is updated or uninstalled.
# Distinguish between packages we recommend and packages which # 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 # 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 # non oss packages
%define spack_trigger_external cuda-nvcc %define spack_trigger_external cuda-nvcc
Name: spack Name: spack
@ -79,7 +86,7 @@ Requires: python3-clingo
Requires: sudo Requires: sudo
Requires: tar Requires: tar
Requires: xz Requires: xz
Recommends: %spack_trigger_recommended Recommends: %spack_trigger_recommended_packages %spack_trigger_recommended_compilers
%else %else
BuildRequires: git BuildRequires: git
BuildRequires: makeinfo BuildRequires: makeinfo
@ -460,11 +467,17 @@ mkdir -p /opt/spack
chgrp spack /opt/spack chgrp spack /opt/spack
chmod 0775 /opt/spack chmod 0775 /opt/spack
%triggerin -- %{?spack_trigger_recommended} %{?spack_trigger_packages} %{?spack_trigger_external} %triggerin -- %{?spack_trigger_recommended_packages} %{?spack_trigger_packages} %{?spack_trigger_external}
/usr/lib/spack/run-find-external.sh /usr/lib/spack/run-find-external.sh packages
%triggerpostun -- %{?spack_trigger_recommended} %{?spack_trigger_packages} %{?spack_trigger_external} %triggerin -- %{?spack_trigger_recommended_compilers} %{?spack_trigger_compilers}
/usr/lib/spack/run-find-external.sh /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} %if %{without doc}
%files %files