spack/run-find-external.sh
Christian Goll 971afa3fa1 Accepting request 882183 from home:mslacken:sp
- added run-find-external.sh which calls the command in post
  `sack external find` as nobody and not as root

- added libbz2-devel as dependency as spack requires this, as soon
  as the bzip2 binary is found

>>>>>>> ./spack.changes.r6ab42661d49aaf33d7c9b12997157f78

OBS-URL: https://build.opensuse.org/request/show/882183
OBS-URL: https://build.opensuse.org/package/show/network:cluster/spack?expand=0&rev=15
2021-03-30 14:36:39 +00:00

34 lines
1.3 KiB
Bash

#!/bin/bash
if [ -e %{_sysconfdir}/spack/no_rpm_trigger ] ; then
exit 0
fi
if [ "x$(id -u)" != "x0" ] ; then
echo "Must run as root, in order to copy back the configuration files and use sudo"
exit 0
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
# combined
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}
# 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 --scope user --exclude 'installdbgsymbols'
mv /var/lib/nobody/.spack/packages.yaml /etc/spack/packages.yaml
chown root:root /etc/spack/packages.yaml
rmdir /var/lib/nobody/.spack
else
# May run in a container...
PATH=${mypath}:${PATH} spack external find --scope system --exclude 'installdbgsymbols'
fi