summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Derumigny2021-03-03 13:26:16 +0100
committerNicolas Derumigny2021-03-03 15:04:58 +0100
commit7b8b3a07aa22ec15b061f78b35719fc61e2e6a57 (patch)
treeae303975d5d86a260491e528f3d615c4b7f9a60d
parent415e8c13400648b429b2eeda960d23a27d991fde (diff)
downloadaur-7b8b3a07aa22ec15b061f78b35719fc61e2e6a57.tar.gz
pkexec: passing (nearly) all env variables to spack
This resolves `spack unload` which was not working properly due to `$SPACK_LOADED_HASHES` incorrectly set.
-rw-r--r--PKGBUILD33
-rw-r--r--spack.bin.py14
-rw-r--r--spack.bin.sh2
-rw-r--r--spack.csh3
-rw-r--r--spack.env.sh.patch92
-rw-r--r--spack.pkaction3
-rw-r--r--spack.sh3
7 files changed, 127 insertions, 23 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 5d39ffea598e..1e6eaebc5cea 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,30 +1,35 @@
# Maintainer: Guillaume Dolle <dev at gdolle.com>
pkgname=spack
pkgver=0.16.1
-pkgrel=2
+pkgrel=3
pkgdesc="A flexible package manager for supercomputer that supports multiple versions, configurations, platforms, and compilers."
arch=('i686' 'x86_64')
url="https://spack.io/"
license=('MIT')
depends=('python' 'polkit')
optdepends=( 'env-modules-tcl' 'lmod' )
-source=(spack-${pkgver}.tar.gz::https://github.com/spack/spack/archive/v${pkgver}.tar.gz
+source=(
+ spack-${pkgver}.tar.gz::https://github.com/spack/spack/archive/v${pkgver}.tar.gz
spack.sysusers
spack.tmpfiles
spack.pkaction
spack.pkrules
spack.sh
spack.csh
- spack.bin.sh
+ spack.bin.py
+ spack.env.sh.patch
)
-sha256sums=('SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP'
- 'SKIP')
+sha256sums=(
+ '8d893036b24d9ee0feee41ac33dd66e4fc68d392918f346f8a7a36a69c567567'
+ 'e6d46e8f5140b4e86596d38f23af379d9adce8e9afc66f800571d7a4d9211e19'
+ 'db0cc4a4ab32e6ee2e5c32898c69a0f0ce05b4e3c605beb024b5463c46e3710f'
+ '1f2c4c6b8841d927fa4056206b8e5603719c0d829586ff0937efaa935d054376'
+ '7f593b7f9289972ae83ad11e0dd3281faf1c56bffa0428dd69641b36b8b94356'
+ '0bddb0a0f1d470509f44c3031041ab0de5472de84f58c90d4b6c91e6782cb6a2'
+ '7b427625d7890dbc0ae493da095a4d7de47742fd3b02e3f42d7ee52e3599a4ac'
+ '70ac76748d40d93fb5e5597fbaae933756c4eeb0b8969255e16435d0fad60006'
+ '6b850208af0788222de1a14989cb52289e2c7ecd7455e121ceb990e4079c6ed5'
+)
_spackroot=/opt/spack
_spackcfg=etc/spack/defaults/config.yaml
_spacksetenv_sh=share/spack/setup-env.sh
@@ -38,7 +43,6 @@ prepare() {
sed -i "s/lmod:.*/lmod: \/var\/lib\/spack\/modules\/lmod/g" ${_spackcfg}
sed -i "s/dotkit:.*/dotkit: \/var\/lib\/spack\/modules\/dotkit/g" ${_spackcfg}
sed -i "s/\$spack\/var\/spack\/stage/\/var\/lib\/spack\/stage/g" ${_spackcfg}
- sed -i "s%command spack%command pkexec --user spack ${_spackroot}/bin/spack%g" ${_spacksetenv_sh}
}
package() {
@@ -52,13 +56,16 @@ package() {
cp -dr --no-preserve=ownership var ${pkgdir}/${_spackroot}
find ./* -maxdepth 0 -type f \( ! -name ".*" \) -exec install -Dm 644 "{}" "${pkgdir}/${_spackroot}/{}" \;
+ cd ${pkgdir}/${_spackroot}
+ patch -p0 < ${srcdir}/spack.env.sh.patch
+
cd ${srcdir}
install -Dm 644 ${pkgname}.sh ${pkgdir}/etc/profile.d/${pkgname}.sh
install -Dm 644 ${pkgname}.csh ${pkgdir}/etc/profile.d/${pkgname}.csh
install -Dm 644 ${pkgname}.sysusers ${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf
install -Dm 644 ${pkgname}.tmpfiles ${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf
- install -Dm 755 ${pkgname}.bin.sh ${pkgdir}/usr/bin/${pkgname}
+ install -Dm 755 ${pkgname}.bin.py ${pkgdir}/usr/bin/${pkgname}
install -Dm 644 ${pkgname}.pkrules ${pkgdir}/usr/share/polkit-1/rules.d/${pkgname}.rules
install -Dm 644 ${pkgname}.pkaction ${pkgdir}/usr/share/polkit-1/actions/org.archlinux.pkexec.spack.policy
diff --git a/spack.bin.py b/spack.bin.py
new file mode 100644
index 000000000000..cc8777253dc1
--- /dev/null
+++ b/spack.bin.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+import os
+import sys
+
+env = os.environ.copy()
+# removing user-specific environement variables
+for var in ["USER", "HOME", "LOGNAME"]:
+ if var in env:
+ env.pop(var)
+arg_list = ["/usr/bin/pkexec", "--user", "spack", "/usr/bin/env"]
+arg_list += [var + "=" + value for var, value in env.items()]
+arg_list.append("/opt/spack/bin/spack")
+arg_list += sys.argv[1:]
+os.execv("/usr/bin/pkexec", arg_list)
diff --git a/spack.bin.sh b/spack.bin.sh
deleted file mode 100644
index 761ec1c9a996..000000000000
--- a/spack.bin.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-pkexec --user spack ${SPACK_ROOT}/bin/spack $@
diff --git a/spack.csh b/spack.csh
index fc09687b115f..03bf2f6dff1a 100644
--- a/spack.csh
+++ b/spack.csh
@@ -1,5 +1,2 @@
setenv SPACK_ROOT /opt/spack
-#setenv PATH /opt/spack/bin:${PATH}
setenv MODULEPATH /var/lib/spack/modules/tcl/:${MODULEPATH}
-
-#alias spack "pkexec --user spack ${SPACK_ROOT}/bin/spack $@"
diff --git a/spack.env.sh.patch b/spack.env.sh.patch
new file mode 100644
index 000000000000..26f9e4f3bc48
--- /dev/null
+++ b/spack.env.sh.patch
@@ -0,0 +1,92 @@
+--- share/spack/setup-env.sh 2021-02-19 20:06:33.000000000 +0100
++++ share/spack/setup-env.sh 2021-03-03 12:23:39.557249552 +0100
+@@ -45,6 +45,9 @@
+ fi
+ export _sp_initializing=true
+
++_pkexec_env() {
++ /usr/bin/spack $@
++}
+
+ _spack_shell_wrapper() {
+ # Store LD_LIBRARY_PATH variables from spack shell function
+@@ -75,7 +78,7 @@
+ [ "${_sp_flags#*h}" != "${_sp_flags}" ] || \
+ [ "${_sp_flags#*V}" != "${_sp_flags}" ];
+ then
+- command spack $_sp_flags "$@"
++ _pkexec_env $_sp_flags "$@"
+ return
+ fi
+
+@@ -96,7 +99,7 @@
+ shift
+ fi
+ if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then
+- command spack cd -h
++ _pkexec_env cd -h
+ else
+ LOC="$(spack location $_sp_arg "$@")"
+ if [ -d "$LOC" ] ; then
+@@ -115,7 +118,7 @@
+ fi
+
+ if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then
+- command spack env -h
++ _pkexec_env env -h
+ else
+ case $_sp_arg in
+ activate)
+@@ -133,10 +136,10 @@
+ [ "${_a#* --help}" != "$_a" ];
+ then
+ # No args or args contain --sh, --csh, or -h/--help: just execute.
+- command spack env activate "$@"
++ _pkexec_env env activate "$@"
+ else
+ # Actual call to activate: source the output.
+- eval $(command spack $_sp_flags env activate --sh "$@")
++ eval $(_pkexec_env $_sp_flags env activate --sh "$@")
+ fi
+ ;;
+ deactivate)
+@@ -151,17 +154,17 @@
+ [ "${_a#* --csh}" != "$_a" ];
+ then
+ # Args contain --sh or --csh: just execute.
+- command spack env deactivate "$@"
++ _pkexec_env env deactivate "$@"
+ elif [ -n "$*" ]; then
+ # Any other arguments are an error or -h/--help: just run help.
+- command spack env deactivate -h
++ _pkexec_env env deactivate -h
+ else
+ # No args: source the output of the command.
+- eval $(command spack $_sp_flags env deactivate --sh)
++ eval $(_pkexec_env $_sp_flags env deactivate --sh)
+ fi
+ ;;
+ *)
+- command spack env $_sp_arg "$@"
++ _pkexec_env env $_sp_arg "$@"
+ ;;
+ esac
+ fi
+@@ -181,14 +184,14 @@
+ [ "${_a#* --help}" != "$_a" ];
+ then
+ # Args contain --sh, --csh, or -h/--help: just execute.
+- command spack $_sp_flags $_sp_subcommand "$@"
++ _pkexec_env $_sp_flags $_sp_subcommand "$@"
+ else
+- eval $(command spack $_sp_flags $_sp_subcommand --sh "$@" || \
++ eval $(_pkexec_env $_sp_flags $_sp_subcommand --sh "$@" || \
+ echo "return 1") # return 1 if spack command fails
+ fi
+ ;;
+ *)
+- command spack $_sp_flags $_sp_subcommand "$@"
++ _pkexec_env $_sp_flags $_sp_subcommand "$@"
+ ;;
+ esac
+ }
diff --git a/spack.pkaction b/spack.pkaction
index 2e6360fdc3e8..93c2ea4738d9 100644
--- a/spack.pkaction
+++ b/spack.pkaction
@@ -11,8 +11,7 @@
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
- <annotate key="org.freedesktop.policykit.exec.path">/opt/spack/bin/spack</annotate>
- <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
+ <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/env</annotate>
</action>
</policyconfig>
diff --git a/spack.sh b/spack.sh
index 772c98fb17dd..5c41b6bc2291 100644
--- a/spack.sh
+++ b/spack.sh
@@ -1,5 +1,2 @@
export SPACK_ROOT=/opt/spack
-#export PATH=/opt/spack/bin:${PATH}
export MODULEPATH=/var/lib/spack/modules/tcl/:${MODULEPATH}
-
-#alias spack="pkexec --user spack ${SPACK_ROOT}/bin/spack $@"