MANPATH needs a trailing ':' to utilize system defaults (#21682)
otherwise spack breaks using system man pages by default. Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
This commit is contained in:
parent
bd0ffa8a3c
commit
96535cc4f9
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -16,6 +17,24 @@
|
|||||||
location = SpackCommand('location')
|
location = SpackCommand('location')
|
||||||
|
|
||||||
|
|
||||||
|
def test_manpath_trailing_colon(install_mockery, mock_fetch, mock_archive,
|
||||||
|
mock_packages, working_env):
|
||||||
|
"""Test that the commands generated by load add the MANPATH prefix
|
||||||
|
inspections. Also test that Spack correctly preserves the default/existing
|
||||||
|
manpath search path via a trailing colon"""
|
||||||
|
install('mpileaks')
|
||||||
|
|
||||||
|
sh_out = load('--sh', '--only', 'package', 'mpileaks')
|
||||||
|
lines = sh_out.split('\n')
|
||||||
|
assert any(re.match(r'export MANPATH=.*:;', ln) for ln in lines)
|
||||||
|
|
||||||
|
os.environ['MANPATH'] = '/tmp/man:'
|
||||||
|
|
||||||
|
sh_out = load('--sh', '--only', 'package', 'mpileaks')
|
||||||
|
lines = sh_out.split('\n')
|
||||||
|
assert any(re.match(r'export MANPATH=.*:/tmp/man:;', ln) for ln in lines)
|
||||||
|
|
||||||
|
|
||||||
def test_load(install_mockery, mock_fetch, mock_archive, mock_packages):
|
def test_load(install_mockery, mock_fetch, mock_archive, mock_packages):
|
||||||
"""Test that the commands generated by load add the specified prefix
|
"""Test that the commands generated by load add the specified prefix
|
||||||
inspections. Also test that Spack records loaded specs by hash in the
|
inspections. Also test that Spack records loaded specs by hash in the
|
||||||
|
@ -611,7 +611,6 @@ def apply_modifications(self, env=None):
|
|||||||
def shell_modifications(self, shell='sh', explicit=False, env=None):
|
def shell_modifications(self, shell='sh', explicit=False, env=None):
|
||||||
"""Return shell code to apply the modifications and clears the list."""
|
"""Return shell code to apply the modifications and clears the list."""
|
||||||
modifications = self.group_by_name()
|
modifications = self.group_by_name()
|
||||||
new_env = os.environ.copy()
|
|
||||||
|
|
||||||
if env is None:
|
if env is None:
|
||||||
env = os.environ
|
env = os.environ
|
||||||
@ -622,6 +621,9 @@ def shell_modifications(self, shell='sh', explicit=False, env=None):
|
|||||||
for x in actions:
|
for x in actions:
|
||||||
x.execute(new_env)
|
x.execute(new_env)
|
||||||
|
|
||||||
|
if 'MANPATH' in new_env and not new_env.get('MANPATH').endswith(':'):
|
||||||
|
new_env['MANPATH'] += ':'
|
||||||
|
|
||||||
cmds = ''
|
cmds = ''
|
||||||
|
|
||||||
for name in sorted(set(modifications)):
|
for name in sorted(set(modifications)):
|
||||||
|
@ -28,6 +28,7 @@ class Mpileaks(Package):
|
|||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
touch(prefix.mpileaks)
|
touch(prefix.mpileaks)
|
||||||
|
mkdirp(prefix.man)
|
||||||
|
|
||||||
def setup_environment(self, senv, renv):
|
def setup_environment(self, senv, renv):
|
||||||
renv.set('FOOBAR', self.name)
|
renv.set('FOOBAR', self.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user