From c070e3f702c7b9cb153e24ac90bbd2e16bb0e34843d3a29810e8692722593ac8 Mon Sep 17 00:00:00 2001
From: Christian Goll <cgoll@suse.com>
Date: Thu, 1 Apr 2021 12:11:29 +0000
Subject: [PATCH] Accepting request 882557 from home:mslacken:sp

again

OBS-URL: https://build.opensuse.org/request/show/882557
OBS-URL: https://build.opensuse.org/package/show/network:cluster/spack?expand=0&rev=17
---
 run-find-external.sh | 10 ++++++----
 spack.spec           |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/run-find-external.sh b/run-find-external.sh
index 128d892..8f40e7e 100644
--- a/run-find-external.sh
+++ b/run-find-external.sh
@@ -11,7 +11,7 @@ echo "Create /etc/spack/no_rpm_trigger to stop spack to search for new packages
 # 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
+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}
@@ -24,9 +24,11 @@ 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
+  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' 
diff --git a/spack.spec b/spack.spec
index 8089c2e..709180a 100644
--- a/spack.spec
+++ b/spack.spec
@@ -69,6 +69,7 @@ Requires:       gcc-fortran
 Requires:       gpg2
 Requires:       libbz2-devel
 Requires:       lua-lmod
+Requires:       patch
 Requires:       polkit
 Requires:       spack-recipes
 Requires:       sudo