fix BSD ldconfig handling (#9631)

For libraries installed to libdir, it's not expected to have rpath
hooked up. But for non-default libdirs, the path might not get searched
by default. `ldconfig -m <libdir>` is convenient here, as it will
programmatically add a new directory to search for shared libraries, so
the resulting installed programs work out of the box.

Include the dragonfly BSD platform name, which doesn't match the 'bsd'
catch-all pattern.
pull/9604/head
Eli Schwartz 3 years ago committed by GitHub
parent 1e19757899
commit 99d809b59d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      mesonbuild/backend/backends.py
  2. 18
      mesonbuild/minstall.py

@ -107,7 +107,7 @@ class CleanTrees:
self.trees = trees
class InstallData:
def __init__(self, source_dir: str, build_dir: str, prefix: str,
def __init__(self, source_dir: str, build_dir: str, prefix: str, libdir: str,
strip_bin: T.List[str], install_umask: T.Union[str, int],
mesonintrospect: T.List[str], version: str):
# TODO: in python 3.8 or with typing_Extensions install_umask could be:
@ -115,6 +115,7 @@ class InstallData:
self.source_dir = source_dir
self.build_dir = build_dir
self.prefix = prefix
self.libdir = libdir
self.strip_bin = strip_bin
self.install_umask = install_umask
self.targets: T.List[TargetInstallData] = []
@ -1485,6 +1486,7 @@ class Backend:
d = InstallData(self.environment.get_source_dir(),
self.environment.get_build_dir(),
self.environment.get_prefix(),
self.environment.get_libdir(),
strip_bin,
umask,
self.environment.get_build_command() + ['introspect'],

@ -244,7 +244,7 @@ def restore_selinux_contexts() -> None:
'Standard output:', out,
'Standard error:', err, sep='\n')
def apply_ldconfig(dm: DirMaker) -> None:
def apply_ldconfig(dm: DirMaker, libdir: str) -> None:
'''
Apply ldconfig to update the ld.so.cache.
'''
@ -252,7 +252,14 @@ def apply_ldconfig(dm: DirMaker) -> None:
# If we don't have ldconfig, failure is ignored quietly.
return
if 'bsd' in platform.system().lower():
platlower = platform.system().lower()
if platlower == 'dragonfly' or 'bsd' in platlower:
if libdir in dm.all_dirs:
proc, out, err = Popen_safe(['ldconfig', '-m', libdir])
if proc.returncode != 0:
print('Failed to apply ldconfig ...',
'Standard output:', out,
'Standard error:', err, sep='\n')
return
# Try to update ld cache, it could fail if we don't have permission.
@ -372,9 +379,9 @@ class Installer:
if not self.dry_run and not destdir:
restore_selinux_contexts()
def apply_ldconfig(self, dm: DirMaker, destdir: str) -> None:
def apply_ldconfig(self, dm: DirMaker, destdir: str, libdir: str) -> None:
if not self.dry_run and not destdir:
apply_ldconfig(dm)
apply_ldconfig(dm, libdir)
def Popen_safe(self, *args: T.Any, **kwargs: T.Any) -> T.Tuple[int, str, str]:
if not self.dry_run:
@ -536,6 +543,7 @@ class Installer:
os.environ['DESTDIR'] = destdir
destdir = destdir or ''
fullprefix = destdir_join(destdir, d.prefix)
libdir = os.path.join(d.prefix, d.libdir)
if d.install_umask != 'preserve':
assert isinstance(d.install_umask, int)
@ -551,7 +559,7 @@ class Installer:
self.install_emptydir(d, dm, destdir, fullprefix)
self.install_data(d, dm, destdir, fullprefix)
self.restore_selinux_contexts(destdir)
self.apply_ldconfig(dm, destdir)
self.apply_ldconfig(dm, destdir, libdir)
self.run_install_script(d, destdir, fullprefix)
if not self.did_install_something:
self.log('Nothing to install.')

Loading…
Cancel
Save