Skip to content

Commit 2c3a68b

Browse files
Stéphane Cerveauxclaesse
authored andcommitted
install: apply ldconfig at the end of the install
On linux system ldconfig needs to be called to update the ld.so.cache to be able to load libraries from /usr/local/lib/x86_64-linux-gnu on debian based distributions for example.
1 parent 7e8d520 commit 2c3a68b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

mesonbuild/minstall.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,25 @@ def restore_selinux_contexts() -> None:
240240
# If the list of files is empty, do not try to call restorecon.
241241
return
242242

243-
proc, out, err = Popen_safe(['restorecon', '-F', '-f-', '-0'], (b'\0'.join(os.fsencode(f) for f in selinux_updates) + b'\0').decode())
243+
proc, out, err = Popen_safe(['restorecon', '-F', '-f-', '-0'], ('\0'.join(f for f in selinux_updates) + '\0'))
244244
if proc.returncode != 0 :
245245
print('Failed to restore SELinux context of installed files...',
246246
'Standard output:', out,
247247
'Standard error:', err, sep='\n')
248248

249+
def apply_ldconfig() -> None:
250+
'''
251+
Apply ldconfig to update the ld.so.cache.
252+
'''
253+
if not shutil.which('ldconfig'):
254+
# If we don't have ldconfig, failure is ignored quietly.
255+
return
256+
257+
proc, out, err = Popen_safe(['ldconfig'])
258+
if proc.returncode != 0:
259+
print('Failed to apply ldconfig ...',
260+
'Standard output:', out,
261+
'Standard error:', err, sep='\n')
249262

250263
def get_destdir_path(destdir: str, fullprefix: str, path: str) -> str:
251264
if os.path.isabs(path):
@@ -346,6 +359,10 @@ def restore_selinux_contexts(self) -> None:
346359
if not self.dry_run:
347360
restore_selinux_contexts()
348361

362+
def apply_ldconfig(self, destdir: str) -> None:
363+
if not self.dry_run and not destdir:
364+
apply_ldconfig()
365+
349366
def Popen_safe(self, *args: T.Any, **kwargs: T.Any) -> T.Tuple[int, str, str]:
350367
if not self.dry_run:
351368
p, o, e = Popen_safe(*args, **kwargs)
@@ -520,6 +537,7 @@ def do_install(self, datafilename: str) -> None:
520537
self.install_man(d, dm, destdir, fullprefix)
521538
self.install_data(d, dm, destdir, fullprefix)
522539
self.restore_selinux_contexts()
540+
self.apply_ldconfig(destdir)
523541
self.run_install_script(d, destdir, fullprefix)
524542
if not self.did_install_something:
525543
self.log('Nothing to install.')

0 commit comments

Comments
 (0)