diff options
author | Guillaume Dollé | 2019-10-03 11:10:10 +0200 |
---|---|---|
committer | Guillaume Dollé | 2019-10-13 13:57:10 +0200 |
commit | 9beca457e0241719924063b76b1cfd14557bfa05 (patch) | |
tree | a316c0cbe9fc3aa063376d91d1b7685b438c63e9 | |
parent | 34f0ee864983c5cbd06d574d05742d7c7a274f42 (diff) | |
download | aur-9beca457e0241719924063b76b1cfd14557bfa05.tar.gz |
Add polkit usage
Spack should be run as user (spack:spack).
Changelog:
- Add polkit config
- Add spack user/group
- Add script to run spack via pkexec (move origin bin directory to libexec)
- Fix directory permission
-rw-r--r-- | .SRCINFO | 19 | ||||
-rw-r--r-- | PKGBUILD | 67 | ||||
-rw-r--r-- | spack.binsh | 2 | ||||
-rw-r--r-- | spack.csh | 3 | ||||
-rw-r--r-- | spack.pkaction | 18 | ||||
-rw-r--r-- | spack.pkrules | 7 | ||||
-rw-r--r-- | spack.sh | 3 | ||||
-rw-r--r-- | spack.sysusers | 1 | ||||
-rw-r--r-- | spack.tmpfiles | 6 |
9 files changed, 111 insertions, 15 deletions
@@ -1,14 +1,31 @@ pkgbase = spack pkgdesc = A flexible package manager for supercomputer that supports multiple versions, configurations, platforms, and compilers. pkgver = 0.12.1 - pkgrel = 1 + pkgrel = 2 url = https://spack.io/ arch = i686 arch = x86_64 license = MIT depends = python + depends = polkit + optdepends = env-modules-tcl + optdepends = lmod source = https://github.com/spack/spack/archive/v0.12.1.tar.gz + source = spack.sysusers + source = spack.tmpfiles + source = spack.pkaction + source = spack.pkrules + source = spack.sh + source = spack.csh + source = spack.binsh sha256sums = 511d131b0d0abfe23b9feb84f9464fe654a6e0e4f3064ec026bba58116a074fc + sha256sums = e6d46e8f5140b4e86596d38f23af379d9adce8e9afc66f800571d7a4d9211e19 + sha256sums = 0eafdac44fc1379a98ee43e0def665cecded2b6182b0a2ae1754247155244fa8 + sha256sums = c9d79463721f5006ae6129e175ca8038bb13b9beb9b584a890662110fcf0579a + sha256sums = 7f593b7f9289972ae83ad11e0dd3281faf1c56bffa0428dd69641b36b8b94356 + sha256sums = 163202be92788f98283d1b0b7c365d736a1675b16ef91f27d2a58617f17030f7 + sha256sums = 7fb67101a9095a05006862e478cedf1a5771725ae2c8420c248e1ad5d3b504e2 + sha256sums = a82a14f51519f8f3ea594845e5f9bf61988f3ba79d55099409acd7730debb6a0 pkgname = spack @@ -1,29 +1,68 @@ # Maintainer: Guillaume Dolle <dev at gdolle.com> pkgname=spack pkgver=0.12.1 -pkgrel=1 +pkgrel=2 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') -source=(https://github.com/spack/spack/archive/v${pkgver}.tar.gz) -sha256sums=('511d131b0d0abfe23b9feb84f9464fe654a6e0e4f3064ec026bba58116a074fc') -# See also spack.sh +depends=('python' 'polkit') +optdepends=('env-modules-tcl' 'lmod') +source=(https://github.com/spack/spack/archive/v${pkgver}.tar.gz + spack.sysusers + spack.tmpfiles + spack.pkaction + spack.pkrules + spack.sh + spack.csh + spack.binsh) +sha256sums=('511d131b0d0abfe23b9feb84f9464fe654a6e0e4f3064ec026bba58116a074fc' + 'e6d46e8f5140b4e86596d38f23af379d9adce8e9afc66f800571d7a4d9211e19' + '0eafdac44fc1379a98ee43e0def665cecded2b6182b0a2ae1754247155244fa8' + 'c9d79463721f5006ae6129e175ca8038bb13b9beb9b584a890662110fcf0579a' + '7f593b7f9289972ae83ad11e0dd3281faf1c56bffa0428dd69641b36b8b94356' + '163202be92788f98283d1b0b7c365d736a1675b16ef91f27d2a58617f17030f7' + '7fb67101a9095a05006862e478cedf1a5771725ae2c8420c248e1ad5d3b504e2' + 'a82a14f51519f8f3ea594845e5f9bf61988f3ba79d55099409acd7730debb6a0') _spackroot=/opt/spack +_spackcfg=etc/spack/defaults/config.yaml + +prepare() { + cd ${srcdir}/${pkgname}-${pkgver} + sed -i "s/install_tree:.*/install_tree: \/var\/lib\/spack\/packages/g" ${_spackcfg} + sed -i "s/source_cache:.*/source_cache: \/var\/lib\/spack\/cache\/source/g" ${_spackcfg} + sed -i "s/misc_cache:.*/misc_cache: \/var\/lib\/spack\/cache\/misc/g" ${_spackcfg} + sed -i "s/tcl:.*/tcl: \/var\/lib\/spack\/modules\/tcl/g" ${_spackcfg} + 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} +} package() { cd ${srcdir}/${pkgname}-${pkgver} - mkdir -p ${pkgdir}/${_spackroot} - cp -ax share ${pkgdir}/${_spackroot} - cp -ax lib ${pkgdir}/${_spackroot} - cp -ax bin ${pkgdir}/${_spackroot} - cp -ax etc ${pkgdir}/${_spackroot} - cp -ax var ${pkgdir}/${_spackroot} + mkdir -p ${pkgdir}/${_spackroot}/ + mkdir -p ${pkgdir}/${_spackroot}/libexec/ + mkdir -p ${pkgdir}/${_spackroot}/bin/ + cp -dr --no-preserve=ownership share ${pkgdir}/${_spackroot} + cp -dr --no-preserve=ownership lib ${pkgdir}/${_spackroot} + cp -dr --no-preserve=ownership bin/* ${pkgdir}/${_spackroot}/libexec + cp -dr --no-preserve=ownership etc ${pkgdir}/${_spackroot} + cp -dr --no-preserve=ownership var ${pkgdir}/${_spackroot} find ./* -maxdepth 0 -type f \( ! -name ".*" \) -exec install -Dm 644 "{}" "${pkgdir}/${_spackroot}/{}" \; - mkdir -p ${pkgdir}/etc/profile.d - ln -sf ${_spackroot}/share/spack/setup-env.sh ${pkgdir}/etc/profile.d/${pkgname}.sh - ln -sf ${_spackroot}/share/spack/setup-env.csh ${pkgdir}/etc/profile.d/${pkgname}.csh + 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 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 + # Fix mode to match polkit. + install -d -o root -g 102 -m 750 ${pkgdir}/usr/share/polkit-1/rules.d + + # Script using polkit. + install -Dm 755 ${pkgname}.binsh ${pkgdir}/${_spackroot}/bin/${pkgname} } diff --git a/spack.binsh b/spack.binsh new file mode 100644 index 000000000000..fd420f4c0371 --- /dev/null +++ b/spack.binsh @@ -0,0 +1,2 @@ +#!/bin/bash +pkexec --user spack ${SPACK_ROOT}/libexec/spack $@ diff --git a/spack.csh b/spack.csh new file mode 100644 index 000000000000..90e1ca2a8287 --- /dev/null +++ b/spack.csh @@ -0,0 +1,3 @@ +setenv SPACK_ROOT /opt/spack +setenv PATH /opt/spack/bin:${PATH} +setenv MODULEPATH /var/lib/spack/modules/tcl/:${MODULEPATH} diff --git a/spack.pkaction b/spack.pkaction new file mode 100644 index 000000000000..e6ef88d6b7ea --- /dev/null +++ b/spack.pkaction @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE policyconfig PUBLIC + "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" + "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd"> +<policyconfig> + <action id="org.archlinux.pkexec.spack"> + <message>Authentication is required to run spack</message> + <icon_name>spack</icon_name> + <defaults> + <allow_any>auth_admin</allow_any> + <allow_inactive>auth_admin</allow_inactive> + <allow_active>auth_admin</allow_active> + </defaults> + <annotate key="org.freedesktop.policykit.exec.path">/opt/spack/libexec/spack</annotate> + <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate> + </action> +</policyconfig> + diff --git a/spack.pkrules b/spack.pkrules new file mode 100644 index 000000000000..2682ec3de7d7 --- /dev/null +++ b/spack.pkrules @@ -0,0 +1,7 @@ +/* Allow users in spack group to use spack feature requiring root without authentication */ +polkit.addRule(function(action, subject) { + if (( action.id == "org.archlinux.pkexec.spack") && + subject.isInGroup("spack")) { + return polkit.Result.YES; + } +}); diff --git a/spack.sh b/spack.sh new file mode 100644 index 000000000000..8c63271ede31 --- /dev/null +++ b/spack.sh @@ -0,0 +1,3 @@ +export SPACK_ROOT=/opt/spack +export PATH=/opt/spack/bin:${PATH} +export MODULEPATH=/var/lib/spack/modules/tcl/:${MODULEPATH} diff --git a/spack.sysusers b/spack.sysusers new file mode 100644 index 000000000000..be5ec2cb0c29 --- /dev/null +++ b/spack.sysusers @@ -0,0 +1 @@ +u spack - "spack packager" /var/lib/spack diff --git a/spack.tmpfiles b/spack.tmpfiles new file mode 100644 index 000000000000..74b934ba2908 --- /dev/null +++ b/spack.tmpfiles @@ -0,0 +1,6 @@ +d /var/lib/spack 0755 spack spack +d /var/lib/spack/packages 0755 spack spack +d /var/lib/spack/cache 0755 spack spack +d /opt/spack/var/spack/junit-report 0755 spack spack +d /opt/spack/var/spack/stage 0755 spack spack +d /opt/spack/var/spack/repos 0755 spack spack |