Class: Bwrap::Args::Bind::Library Private
- Inherits:
-
Object
- Object
- Bwrap::Args::Bind::Library
- Includes:
- Execution::Path, Output
- Defined in:
- lib/bwrap/args/bind/library.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
TODO: documentation
TODO: It may be that this should be renamed to “Binary” or ”Executable”, as this handles all binaries, not just libraries.
Defined Under Namespace
Classes: RubyBinds
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
private
Instance of Config.
-
#environment ⇒ Object
writeonly
private
Instance of Environment.
-
#executable ⇒ Object
writeonly
private
Instance of Resolvers::Executable.
Instance Method Summary collapse
-
#binds_for_features ⇒ Object
private
Some features, like Config::Features::Nscd, requires some binds in order to operate properly.
- #extra_executables_mounts ⇒ Object private
- #handle_given_command ⇒ Object private
-
#initialize(args) ⇒ Library
constructor
private
TODO: Remove? attr_writer :executable_path.
-
#resolve_executable_libraries(executable_name, executable_path) ⇒ Object
private
Does some inspection to find out libraries given executable needs in order to work.
Methods included from Output
debug?, debug_output, error_output, handle_output_options, info_output, quiet?, trace?, trace_output, verb_output, verbose?, warn_output
Constructor Details
#initialize(args) ⇒ Library
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: Remove? attr_writer :executable_path
40 41 42 |
# File 'lib/bwrap/args/bind/library.rb', line 40 def initialize args @args = args end |
Instance Attribute Details
#config=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instance of Config.
26 27 28 |
# File 'lib/bwrap/args/bind/library.rb', line 26 def config=(value) @config = value end |
#environment=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instance of Environment.
29 30 31 |
# File 'lib/bwrap/args/bind/library.rb', line 29 def environment=(value) @environment = value end |
#executable=(value) ⇒ Object (writeonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instance of Resolvers::Executable.
32 33 34 |
# File 'lib/bwrap/args/bind/library.rb', line 32 def executable=(value) @executable = value end |
Instance Method Details
#binds_for_features ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Some features, like Config::Features::Nscd, requires some binds in order to operate properly.
104 105 106 107 108 109 110 111 |
# File 'lib/bwrap/args/bind/library.rb', line 104 def binds_for_features # NOTE: Still nothing here, as I think this is better for library binds than anything else. # The nscd bind is better in another, more generic, place. # # Keeping this method because I think this really makes sense for structure, in future. ruby_binds_for_features end |
#extra_executables_mounts ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 |
# File 'lib/bwrap/args/bind/library.rb', line 44 def extra_executables_mounts return unless @config&.extra_executables @config.extra_executables.each do |extra_executable| executable = Bwrap::Resolvers::Executable.new extra_executable generate_binds_for_command :extra_executable_mounts, executable, inside_root: false end end |
#handle_given_command ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/bwrap/args/bind/library.rb', line 54 def handle_given_command generate_binds_for_command :given_command, @executable end |
#resolve_executable_libraries(executable_name, executable_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ensure scanelf is available (and throw proper error if it is not, telling to not use full_system_mounts option.)
Does some inspection to find out libraries given executable needs in order to work.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/bwrap/args/bind/library.rb', line 67 def resolve_executable_libraries executable_name, executable_path debug "Resolving executable libraries of #{executable_path}" mime = Bwrap::Resolvers::Mime.new executable_name, executable_path mime.resolve_mime_type return if shell_executable_binds mime # TODO: Ideally mime stuff should be handled as config, # but then shebang parsing logic would be necessary to move to config classes. # # That may make sense, but for now this is here. # # This basically allows features to use mime data to get for example path to necessary interpreter. # # This way there is possibility that wrong mime information would be used, # as this thing is more generalized. @config.features.mime = mime if @config&.features # Then find out required libraries library_mounts = [] library_object = ::Bwrap::Resolvers::Library.new libraries = library_object.libraries_needed_by mime.executable_path # TODO: following is bad? #library_object.needed_libraries(mime.executable_path).each do |library| libraries.each do |library| library_mounts << "--ro-bind" << library << library end @args.add_uniq :extra_executable_libraries, library_mounts end |