Fix: remove rpath of libs and executable to force ld_library_path use
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 11 Dec 2017 19:44:14 +0000 (14:44 -0500)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 14 Dec 2017 20:24:28 +0000 (15:24 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
lttng_ivc/utils/project.py
requirements.txt
tox.ini

index 819503ae1d9e5abcebe6f4d7f8d12b775a42e475..7e3ba98ae07c58d1f2f4c370e8ec9bb9316e628e 100644 (file)
@@ -25,6 +25,7 @@ import subprocess
 import logging
 import lttng_ivc.settings as Settings
 import pprint
+import magic
 
 from lttng_ivc.utils.utils import sha256_checksum
 from lttng_ivc.utils.utils import find_dir, find_file
@@ -166,7 +167,6 @@ class Project(object):
 
         if self.isConfigured ^ self.isBuilt ^ self.isInstalled:
             raise Exception("Project steps where manually triggered. Can't autobuild")
-
         _logger.debug("{} Autobuild configure".format(self.label))
         try:
             self.configure()
@@ -188,6 +188,13 @@ class Project(object):
             _logger.error("{} Install failed. See {} for more details.".format(self.label, self.log_path))
             raise e
 
+        _logger.debug("{} Autobuild rpath strip".format(self.label))
+        try:
+            self.rpath_strip()
+        except subprocess.CalledProcessError as e:
+            _logger.error("{} Rpath stripping failed. See {} for more details.".format(self.label, self.log_path))
+            raise e
+
     def checkout(self):
         if self._immutable:
             raise Exception("Object is immutable. Illegal checkout")
@@ -304,6 +311,30 @@ class Project(object):
         self.isInstalled = True
         return p
 
+    def rpath_strip(self):
+        to_strip = [os.path.join(self.installation_path, "bin"),
+                    os.path.join(self.installation_path, "lib")]
+
+        out = os.path.join(self.log_path, "rpath-strip.out")
+        err = os.path.join(self.log_path, "rpath-strip.err")
+
+        for path in to_strip:
+            for base, dirs, files in os.walk(path):
+                for tmp in files:
+                    abs_path = os.path.abspath(os.path.join(base, tmp))
+                    magic_str = magic.from_file(abs_path)
+                    # Skip all non-elf file
+                    if "ELF" not in magic_str.split():
+                        with open(err, 'a') as stderr:
+                            stderr.write("{} skip, is not an ELF, file type: {}\n".format(abs_path, magic_str))
+                        continue
+                    cmd = ["chrpath", "-d", abs_path]
+                    with open(out, 'a') as stdout, open(err, 'a') as stderr:
+                        stdout.write("Running {}\n".format(cmd))
+                        stderr.write("Running {}\n".format(cmd))
+                        p = subprocess.run(cmd, stdout=stdout, stderr=stderr)
+                        p.check_returncode()
+
     def cleanup(self):
         if os.path.exists(self.source_path):
             shutil.rmtree(self.source_path)
@@ -345,6 +376,9 @@ class Lttng_modules(Project):
         except subprocess.CalledProcessError as e:
             self.skip = True
 
+    def rpath_strip(self):
+        pass
+
 
 class Lttng_ust(Project):
     def __init__(self, label, git_path, sha1, tmpdir):
index e29f79e93dd3ce42c946ead4f276278134906f5e..2df43c923595ca6fd9339f1e2f821a7d5cba1a47 100644 (file)
@@ -4,3 +4,4 @@ pickleshare==0.7.4
 psutil==5.3.1
 pytest==3.2.2
 PyYAML==3.12
+python-magic
diff --git a/tox.ini b/tox.ini
index df218605ff7e823c16f024f697e6d9e131ab9579..86581ca58c09b4ad1bd8091e7e57135266d37bd8 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -17,3 +17,4 @@ deps =
     GitPython
     lxml
     PyYAML
+    python-magic
This page took 0.034699 seconds and 5 git commands to generate.