aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2021-09-30 09:21:07 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2021-10-10 14:42:13 +0300
commit6b7d43ebe0d77ac85fa2c01e0e358efc64418126 (patch)
tree82f60e2cc25be076d0777c57e417cf4a03c1923c
parentda81586a5b026fcce1b11a3505b380dfd61e6a2c (diff)
downloadmeson-6b7d43ebe0d77ac85fa2c01e0e358efc64418126.zip
meson-6b7d43ebe0d77ac85fa2c01e0e358efc64418126.tar.gz
meson-6b7d43ebe0d77ac85fa2c01e0e358efc64418126.tar.bz2
minstall: Ignore ldconfig errors when we did not install libraries
Fixes: #9241
-rw-r--r--mesonbuild/minstall.py31
1 files changed, 22 insertions, 9 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 7864742..e3934a7 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -89,10 +89,12 @@ class DirMaker:
def __init__(self, lf: T.TextIO, makedirs: T.Callable[..., None]):
self.lf = lf
self.dirs: T.List[str] = []
+ self.all_dirs: T.Set[str] = set()
self.makedirs_impl = makedirs
def makedirs(self, path: str, exist_ok: bool = False) -> None:
dirname = os.path.normpath(path)
+ self.all_dirs.add(dirname)
dirs = []
while dirname != os.path.dirname(dirname):
if dirname in self.dirs:
@@ -241,7 +243,7 @@ def restore_selinux_contexts() -> None:
'Standard output:', out,
'Standard error:', err, sep='\n')
-def apply_ldconfig() -> None:
+def apply_ldconfig(dm: DirMaker) -> None:
'''
Apply ldconfig to update the ld.so.cache.
'''
@@ -249,11 +251,22 @@ def apply_ldconfig() -> None:
# If we don't have ldconfig, failure is ignored quietly.
return
- proc, out, err = Popen_safe(['ldconfig'])
- if proc.returncode != 0:
- print('Failed to apply ldconfig ...',
- 'Standard output:', out,
- 'Standard error:', err, sep='\n')
+ # Try to update ld cache, it could fail if we don't have permission.
+ proc, out, err = Popen_safe(['ldconfig', '-v'])
+ if proc.returncode == 0:
+ return
+
+ # ldconfig failed, print the error only if we actually installed files in
+ # any of the directories it lookup for libraries. Otherwise quietly ignore
+ # the error.
+ for l in out.splitlines():
+ # Lines that start with a \t are libraries, not directories.
+ if not l or l[0].isspace():
+ continue
+ # Example: `/usr/lib/i386-linux-gnu/i686: (hwcap: 0x0002000000000000)`
+ if l[:l.find(':')] in dm.all_dirs:
+ print(f'Failed to apply ldconfig:\n{err}')
+ break
def get_destdir_path(destdir: str, fullprefix: str, path: str) -> str:
if os.path.isabs(path):
@@ -355,9 +368,9 @@ class Installer:
if not self.dry_run and not destdir:
restore_selinux_contexts()
- def apply_ldconfig(self, destdir: str) -> None:
+ def apply_ldconfig(self, dm: DirMaker, destdir: str) -> None:
if not self.dry_run and not destdir:
- apply_ldconfig()
+ apply_ldconfig(dm)
def Popen_safe(self, *args: T.Any, **kwargs: T.Any) -> T.Tuple[int, str, str]:
if not self.dry_run:
@@ -534,7 +547,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(destdir)
+ self.apply_ldconfig(dm, destdir)
self.run_install_script(d, destdir, fullprefix)
if not self.did_install_something:
self.log('Nothing to install.')