Class: Yast::UIPluginInfo
- Inherits:
-
SharedLibInfo
- Object
- SharedLibInfo
- Yast::UIPluginInfo
- Includes:
- Logger
- Defined in:
- library/system/src/lib/yast2/ui_plugin_info.rb
Overview
Class to get information about UI plug-ins used by a process (by default the current process) from its /proc/self/maps file.
You can also get information for a different process by specifying its /proc/$pid/maps file.
For testing, a fixed file can be used.
The information stored in this class is only a snapshot in the life time of the process. As new shared libs are loaded (e.g. plug-ins are loaded with dlopen()), this information may become outdated. In that case, simply let the old instance go out of scope and create a new one.
More information: https://github.com/yast/yast-yast2/pull/1194
Instance Attribute Summary
Attributes inherited from SharedLibInfo
Instance Method Summary collapse
-
#initialize(maps_file = "/proc/self/maps") ⇒ UIPluginInfo
constructor
Constructor.
-
#main_ui_plugin ⇒ String?
Return the short name of the main UI plug-in, i.e.
-
#main_ui_plugin_complete ⇒ String?
Return the complete name (with path and SO number) of the main UI plug-in.
-
#short_name(ui_plugin) ⇒ String
Return the short name of a UI plug-in, i.e.
-
#ui_extension_pkg(ext) ⇒ String
Return the package name (with standard SUSE libyui package naming conventions) for a UI extension for the current UI main plug-in.
-
#ui_extension_plugin(ext) ⇒ String
Return the name of a UI extension plug-in with SO number for the current UI main plug-in.
-
#ui_extension_plugin_complete(ext) ⇒ String
Return the complete name (with path) of a UI extension plug-in with SO number for the current UI main plug-in.
-
#ui_plugins ⇒ Array<String>
Find the UI plug-ins among the shared libs.
-
#ui_so_major ⇒ String?
Find the SO major number of the UI main plug-in.
-
#ui_so_number ⇒ String?
Find the SO number of the UI main plug-in.
Methods inherited from SharedLibInfo
build_lib_name, #clear, lib_basename, #parse_maps_line, #read, #shared_lib?, so_major, so_number, split_lib_name
Constructor Details
#initialize(maps_file = "/proc/self/maps") ⇒ UIPluginInfo
Constructor.
39 40 41 42 43 44 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 39 def initialize(maps_file = "/proc/self/maps") super # Lazy init for those member variables @ui_plugins = nil @main_ui_plugin_complete = nil end |
Instance Method Details
#main_ui_plugin ⇒ String?
Return the short name of the main UI plug-in, i.e. without path, "libyui-" prefix and SO number Several UI plug-ins might be loaded; the main plug-in is generally the one with the shortest lib base name ("qt", "qt-pkg", "qt-graph"; "ncurses", "ncurses-pkg").
93 94 95 96 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 93 def main_ui_plugin name = SharedLibInfo.lib_basename(main_ui_plugin_complete) name&.gsub!(/^libyui-/, "") end |
#main_ui_plugin_complete ⇒ String?
Return the complete name (with path and SO number) of the main UI plug-in. Several UI plug-ins might be loaded; the main plug-in is generally the one with the shortest lib base name ("qt", "qt-pkg", "qt-graph"; "ncurses", "ncurses-pkg").
76 77 78 79 80 81 82 83 84 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 76 def main_ui_plugin_complete return nil if ui_plugins.empty? relevant_plugins = ui_plugins.grep_v(/rest-api/) @main_ui_plugin_complete ||= relevant_plugins.min do |a, b| SharedLibInfo.lib_basename(a).size <=> SharedLibInfo.lib_basename(b).size end @main_ui_plugin_complete end |
#short_name(ui_plugin) ⇒ String
Return the short name of a UI plug-in, i.e. only the lib base name with any leading "libyui-" removed, i.e. something like "qt", "ncurses".
64 65 66 67 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 64 def short_name(ui_plugin) name = SharedLibInfo.lib_basename(ui_plugin) name&.gsub(/^libyui-/, "") end |
#ui_extension_pkg(ext) ⇒ String
Return the package name (with standard SUSE libyui package naming conventions) for a UI extension for the current UI main plug-in.
Example: "pkg" for "libyui-qt.so.15.0.0" -> "libyui-qt-pkg15" "pkg" for "libyui-ncurses.so.15.0.0" -> "libyui-ncurses-pkg15"
157 158 159 160 161 162 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 157 def ui_extension_pkg(ext) ui = main_ui_plugin return nil if ui.nil? "libyui-#{ui}-#{ext}#{ui_so_major}" end |
#ui_extension_plugin(ext) ⇒ String
Return the name of a UI extension plug-in with SO number for the current UI main plug-in.
Example: "pkg" for "libyui-qt.so.15.0.0" -> "libyui-qt-pkg.so.15.0.0" "pkg" for "libyui-ncurses.so.15.0.0" -> "libyui-ncurses-pkg.so.15.0.0"
124 125 126 127 128 129 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 124 def ui_extension_plugin(ext) (ui_name, so_number) = SharedLibInfo.split_lib_name(main_ui_plugin_complete) return nil if ui_name.nil? SharedLibInfo.build_lib_name("#{ui_name}-#{ext}", so_number) end |
#ui_extension_plugin_complete(ext) ⇒ String
Return the complete name (with path) of a UI extension plug-in with SO number for the current UI main plug-in.
Example: "pkg" for "/usr/lib64/yui/libyui-qt.so.15.0.0" -> "/usr/lib64/yui/libyui-qt-pkg.so.15.0.0" "pkg" for "/usr/lib64/yui/libyui-ncurses.so.15.0.0" -> "/usr/lib64/yui/libyui-ncurses-pkg.so.15.0.0"
141 142 143 144 145 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 141 def ui_extension_plugin_complete(ext) return nil if main_ui_plugin_complete.nil? File.join(File.dirname(main_ui_plugin_complete), ui_extension_plugin(ext)) end |
#ui_plugins ⇒ Array<String>
Find the UI plug-ins among the shared libs.
50 51 52 53 54 55 56 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 50 def ui_plugins if @ui_plugins.nil? @ui_plugins = shared_libs.grep(/yui\/libyui-/) log.info("UI plug-ins: #{@ui_plugins}") end @ui_plugins end |
#ui_so_major ⇒ String?
Find the SO major number of the UI main plug-in.
110 111 112 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 110 def ui_so_major SharedLibInfo.so_major(main_ui_plugin_complete) end |
#ui_so_number ⇒ String?
Find the SO number of the UI main plug-in.
102 103 104 |
# File 'library/system/src/lib/yast2/ui_plugin_info.rb', line 102 def ui_so_number SharedLibInfo.so_number(main_ui_plugin_complete) end |