From d335c40e9971a1871348414ed13a4c0284b07b8b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 8 Oct 2011 16:27:35 +0200 Subject: [PATCH] Run /sbin/ldconfig after every installation of shared objects. --- python/pakfire/actions.py | 66 ++++++++++++++++++++++++++++++------- python/pakfire/constants.py | 2 ++ 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/python/pakfire/actions.py b/python/pakfire/actions.py index 0d714f51b..3ee64c9be 100644 --- a/python/pakfire/actions.py +++ b/python/pakfire/actions.py @@ -77,6 +77,38 @@ class Action(object): """ return self.pakfire.repos.local + def do(self, cmd, **kwargs): + # If we are running in /, we do not need to chroot there. + chroot_path = None + if not self.pakfire.path == "/": + chroot_path = self.pakfire.path + + # Find suitable cwd. + cwd = "/" + for i in ("tmp", "root"): + _cwd = os.path.join(chroot_path, i) + if os.path.exists(_cwd): + cwd = _cwd + break + + args = { + "cwd" : cwd, + "logger" : logging.getLogger(), + "personality" : self.pakfire.distro.personality, + "shell" : False, + "timeout" : SCRIPTLET_TIMEOUT, + } + + # Overwrite by args that were passed. + args.update(kwargs) + + # You can never overwrite chrootPath. + args.update({ + "chrootPath" : chroot_path, + }) + + return chroot.do(cmd, **args) + class ActionScript(Action): type = "script" @@ -148,18 +180,8 @@ class ActionScript(Action): # Generate the script command. command = [script_file_chroot] + self.args - # If we are running in /, we do not need to chroot there. - chroot_path = None - if not self.pakfire.path == "/": - chroot_path = self.pakfire.path - try: - ret = chroot.do(command, cwd="/tmp", - chrootPath=chroot_path, - personality=self.pakfire.distro.personality, - shell=False, - timeout=SCRIPTLET_TIMEOUT, - logger=logging.getLogger()) + self.do(command) except Error, e: raise ActionError, _("The scriptlet returned an error:\n%s" % e) @@ -231,6 +253,28 @@ class ActionInstall(Action): self.pkg.extract(_("Installing"), prefix=self.pakfire.path) + # Check if shared objects were extracted. If this is the case, we need + # to run ldconfig. + ldconfig_needed = False + for file in self.pkg.filelist: + if ".so." in file.name: + ldconfig_needed = True + break + + if "etc/ld.so.conf" in file.name: + ldconfig_needed = True + break + + if ldconfig_needed: + # Check if ldconfig is present. + ldconfig = os.path.join(self.pakfire.path, LDCONFIG[1:]) + + if os.path.exists(ldconfig) and os.access(ldconfig, os.X_OK): + self.do(LDCONFIG) + + else: + logging.debug("ldconfig is not present or not executable.") + class ActionUpdate(Action): type = "upgrade" diff --git a/python/pakfire/constants.py b/python/pakfire/constants.py index 69d1960c8..9b4c40e36 100644 --- a/python/pakfire/constants.py +++ b/python/pakfire/constants.py @@ -185,3 +185,5 @@ SCRIPTS = ( "posttransun", "posttransup", ) + +LDCONFIG = "/sbin/ldconfig" -- 2.39.5