File: 0003-Add-default-plugin-path.patch

package info (click to toggle)
ros-pluginlib 5.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 372 kB
  • sloc: cpp: 1,135; xml: 57; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,844 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Sun, 12 Jun 2022 18:28:23 +0200
Subject: Add default plugin path

ld.so/libdl will expand ${LIB} at runtime to the token that was
configured into our glibc, which in Debian's case is
"lib/x86_64-linux-gnu" or similar.

https://lists.debian.org/debian-python/2022/06/msg00052.html
---
 include/pluginlib/class_loader_imp.hpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/pluginlib/class_loader_imp.hpp b/include/pluginlib/class_loader_imp.hpp
index 12557a2..d53b8b3 100644
--- a/include/pluginlib/class_loader_imp.hpp
+++ b/include/pluginlib/class_loader_imp.hpp
@@ -511,6 +511,30 @@ std::string ClassLoader<T>::getClassLibraryPath(const std::string & lookup_name)
       return *path_it;
     }
   }
+
+  // ${LIB} is resolved by dlopen
+  std::string default_path("/usr/${LIB}/ros/" + library_name + ".so");
+  try {
+    lowlevel_class_loader_.loadLibrary(default_path);
+    lowlevel_class_loader_.unloadLibrary(default_path);
+    return default_path;
+  } catch (const class_loader::LibraryLoadException & ex) {
+    RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
+      "plugin not found in default path: %s",
+      default_path.c_str());
+  }
+
+  std::string alt_path("/usr/${LIB}/" + library_name + ".so");
+  try {
+    lowlevel_class_loader_.loadLibrary(alt_path);
+    lowlevel_class_loader_.unloadLibrary(alt_path);
+    return alt_path;
+  } catch (const class_loader::LibraryLoadException & ex) {
+    RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
+      "plugin not found in default path: %s",
+      alt_path.c_str());
+  }
+
   std::ostringstream error_msg;
   error_msg << "Could not find library corresponding to plugin " << lookup_name <<
     ". Make sure that the library '" << library_name << "' actually exists.";