Avoid double 'lib' for packages whose name already starts with lib (#7651)
This commit is contained in:
parent
5106efe495
commit
cdefbd7475
4 changed files with 51 additions and 12 deletions
|
@ -201,9 +201,9 @@ def change_sed_delimiter(old_delim, new_delim, *filenames):
|
|||
|
||||
def set_install_permissions(path):
|
||||
"""Set appropriate permissions on the installed file."""
|
||||
# If this points to a file maintained in a Spack prefix, it is assumed that
|
||||
# this function will be invoked on the target. If the file is outside a
|
||||
# Spack-maintained prefix, the permissions should not be modified.
|
||||
# If this points to a file maintained in a Spack prefix, it is assumed that
|
||||
# this function will be invoked on the target. If the file is outside a
|
||||
# Spack-maintained prefix, the permissions should not be modified.
|
||||
if os.path.islink(path):
|
||||
return
|
||||
if os.path.isdir(path):
|
||||
|
|
|
@ -1201,22 +1201,32 @@ def do_fake_install(self):
|
|||
"""Make a fake install directory containing fake executables,
|
||||
headers, and libraries."""
|
||||
|
||||
name = self.name
|
||||
library_name = 'lib' + self.name
|
||||
command = self.name
|
||||
header = self.name
|
||||
library = self.name
|
||||
|
||||
# Avoid double 'lib' for packages whose names already start with lib
|
||||
if not self.name.startswith('lib'):
|
||||
library = 'lib' + library
|
||||
|
||||
dso_suffix = '.dylib' if sys.platform == 'darwin' else '.so'
|
||||
chmod = which('chmod')
|
||||
|
||||
# Install fake command
|
||||
mkdirp(self.prefix.bin)
|
||||
touch(join_path(self.prefix.bin, name))
|
||||
chmod('+x', join_path(self.prefix.bin, name))
|
||||
touch(join_path(self.prefix.bin, command))
|
||||
chmod('+x', join_path(self.prefix.bin, command))
|
||||
|
||||
# Install fake header file
|
||||
mkdirp(self.prefix.include)
|
||||
touch(join_path(self.prefix.include, name + '.h'))
|
||||
touch(join_path(self.prefix.include, header + '.h'))
|
||||
|
||||
# Install fake shared and static libraries
|
||||
mkdirp(self.prefix.lib)
|
||||
touch(join_path(self.prefix.lib, library_name + dso_suffix))
|
||||
touch(join_path(self.prefix.lib, library_name + '.a'))
|
||||
for suffix in [dso_suffix, '.a']:
|
||||
touch(join_path(self.prefix.lib, library + suffix))
|
||||
|
||||
# Install fake man page
|
||||
mkdirp(self.prefix.man.man1)
|
||||
|
||||
packages_dir = spack.store.layout.build_packages_path(self.spec)
|
||||
|
|
|
@ -702,7 +702,8 @@ def _libs_default_handler(descriptor, spec, cls):
|
|||
"""Default handler when looking for the 'libs' attribute.
|
||||
|
||||
Tries to search for ``lib{spec.name}`` recursively starting from
|
||||
``spec.prefix``.
|
||||
``spec.prefix``. If ``spec.name`` starts with ``lib``, searches for
|
||||
``{spec.name}`` instead.
|
||||
|
||||
Parameters:
|
||||
descriptor (ForwardQueryToPackage): descriptor that triggered the call
|
||||
|
@ -727,7 +728,11 @@ def _libs_default_handler(descriptor, spec, cls):
|
|||
# depending on which one exists (there is a possibility, of course, to
|
||||
# get something like 'libabcXabc.so, but for now we consider this
|
||||
# unlikely).
|
||||
name = 'lib' + spec.name.replace('-', '?')
|
||||
name = spec.name.replace('-', '?')
|
||||
|
||||
# Avoid double 'lib' for packages whose names already start with lib
|
||||
if not name.startswith('lib'):
|
||||
name = 'lib' + name
|
||||
|
||||
# To speedup the search for external packages configured e.g. in /usr,
|
||||
# perform first non-recursive search in prefix.lib then in prefix.lib64 and
|
||||
|
|
|
@ -154,6 +154,8 @@ def _mock_remove(spec):
|
|||
|
||||
|
||||
def test_default_queries(database):
|
||||
# Testing a package whose name *doesn't* start with 'lib'
|
||||
# to ensure the library has 'lib' prepended to the name
|
||||
install_db = database.mock.db
|
||||
rec = install_db.get_record('zmpi')
|
||||
|
||||
|
@ -161,15 +163,37 @@ def test_default_queries(database):
|
|||
|
||||
libraries = spec['zmpi'].libs
|
||||
assert len(libraries) == 1
|
||||
assert libraries.names[0] == 'zmpi'
|
||||
|
||||
headers = spec['zmpi'].headers
|
||||
assert len(headers) == 1
|
||||
assert headers.names[0] == 'zmpi'
|
||||
|
||||
command = spec['zmpi'].command
|
||||
assert isinstance(command, Executable)
|
||||
assert command.name == 'zmpi'
|
||||
assert os.path.exists(command.path)
|
||||
|
||||
# Testing a package whose name *does* start with 'lib'
|
||||
# to ensure the library doesn't have a double 'lib' prefix
|
||||
install_db = database.mock.db
|
||||
rec = install_db.get_record('libelf')
|
||||
|
||||
spec = rec.spec
|
||||
|
||||
libraries = spec['libelf'].libs
|
||||
assert len(libraries) == 1
|
||||
assert libraries.names[0] == 'elf'
|
||||
|
||||
headers = spec['libelf'].headers
|
||||
assert len(headers) == 1
|
||||
assert headers.names[0] == 'libelf'
|
||||
|
||||
command = spec['libelf'].command
|
||||
assert isinstance(command, Executable)
|
||||
assert command.name == 'libelf'
|
||||
assert os.path.exists(command.path)
|
||||
|
||||
|
||||
def test_005_db_exists(database):
|
||||
"""Make sure db cache file exists after creating."""
|
||||
|
|
Loading…
Reference in a new issue