commit:     3da0ff3d2dd47469becd80e744c0c3ced448a516
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 15 08:16:45 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 26 07:58:30 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3da0ff3d

lib: env_update: check ldconfig exit code

Bug: https://bugs.gentoo.org/910376
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                           |  2 ++
 lib/portage/util/env_update.py | 13 ++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index fcbbdb2a5..4c54ba382 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Bug fixes:
 * install-qa-check.d/05prefix: Fix prefixifying shebang for >= EAPI 7 ebuilds
   (bug #909147).
 
+* env-update: Check exit code from ldconfig (bug #910376).
+
 * emerge: Fix 'no ebuilds available' message always mentioning binpkgs
   (bug #909853).
 

diff --git a/lib/portage/util/env_update.py b/lib/portage/util/env_update.py
index d76042a6b..5c2b2fdd5 100644
--- a/lib/portage/util/env_update.py
+++ b/lib/portage/util/env_update.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2020 Gentoo Authors
+# Copyright 2010-2023 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ["env_update"]
@@ -6,6 +6,7 @@ __all__ = ["env_update"]
 import errno
 import glob
 import stat
+import sys
 import time
 
 import portage
@@ -363,12 +364,12 @@ def _env_update(makelinks, target_root, prev_mtimes, 
contents, env, writemsg_lev
             writemsg_level(
                 _(">>> Regenerating %setc/ld.so.cache...\n") % (target_root,)
             )
-            os.system(f"cd / ; {ldconfig} -X -r '{target_root}'")
+            ret = os.system(f"cd / ; {ldconfig} -X -r '{target_root}'")
         elif ostype in ("FreeBSD", "DragonFly"):
             writemsg_level(
                 _(">>> Regenerating %svar/run/ld-elf.so.hints...\n") % 
target_root
             )
-            os.system(
+            ret = os.system(
                 (
                     "cd / ; %s -elf -i "
                     + "-f '%svar/run/ld-elf.so.hints' '%setc/ld.so.conf'"
@@ -376,6 +377,12 @@ def _env_update(makelinks, target_root, prev_mtimes, 
contents, env, writemsg_lev
                 % (ldconfig, target_root, target_root)
             )
 
+        ret = os.waitstatus_to_exitcode(ret)
+        if ret > 0:
+            writemsg(f"!!! ldconfig failed with exit status {ret}\n", 
noiselevel=-1)
+        if ret < 0:
+            writemsg(f"!!! ldconfig was killed with signal {-ret}\n", 
noiselevel=-1)
+
     del specials["LDPATH"]
 
     notice = "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"

Reply via email to