bwrap 1.0.0.pre.alpha5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +26 -0
- data/lib/bwrap/args/args.rb +5 -1
- data/lib/bwrap/args/bind/library.rb +188 -0
- data/lib/bwrap/args/bind/mime.rb +58 -0
- data/lib/bwrap/args/bind.rb +27 -89
- data/lib/bwrap/args/construct.rb +3 -2
- data/lib/bwrap/args/environment.rb +59 -1
- data/lib/bwrap/args/features.rb +65 -3
- data/lib/bwrap/args/library.rb +17 -10
- data/lib/bwrap/args/machine_id.rb +6 -3
- data/lib/bwrap/args/mount.rb +1 -0
- data/lib/bwrap/bwrap.rb +151 -0
- data/lib/bwrap/bwrap_module.rb +26 -0
- data/lib/bwrap/config/features.rb +116 -0
- data/lib/bwrap/config.rb +96 -92
- data/lib/bwrap/execution/exceptions.rb +24 -0
- data/lib/bwrap/execution/execute.rb +4 -1
- data/lib/bwrap/execution/execution.rb +147 -3
- data/lib/bwrap/execution/labels.rb +8 -1
- data/lib/bwrap/execution/path.rb +30 -10
- data/lib/bwrap/execution.rb +6 -160
- data/lib/bwrap/output/colors.rb +0 -2
- data/lib/bwrap/output/log.rb +17 -5
- data/lib/bwrap/output/output_impl.rb +182 -0
- data/lib/bwrap/output.rb +8 -152
- data/lib/bwrap/version.rb +1 -2
- data/lib/bwrap.rb +1 -79
- data.tar.gz.sig +0 -0
- metadata +11 -19
- metadata.gz.sig +0 -0
- data/lib/bwrap/output/output.rb +0 -8
data/lib/bwrap/output.rb
CHANGED
@@ -1,157 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require "English"
|
3
|
+
require_relative "bwrap_module"
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Extends the module with outputting methods.
|
5
|
+
# Declare Output module here so Bwrap::Output module is
|
6
|
+
# already declared for Output module classes, to avoid
|
7
|
+
# a circular dependency.
|
8
|
+
#
|
9
|
+
# See output/output.rb for documentation.
|
12
10
|
module Bwrap::Output
|
13
|
-
include Bwrap::Output::Colors
|
14
|
-
|
15
|
-
# @see #verbose?
|
16
|
-
def self.verbose?
|
17
|
-
Bwrap::Output::Levels.verbose?
|
18
|
-
end
|
19
|
-
|
20
|
-
# @see #debug?
|
21
|
-
def self.debug?
|
22
|
-
Bwrap::Output::Levels.debug?
|
23
|
-
end
|
24
|
-
|
25
|
-
# @see #trace?
|
26
|
-
def self.trace?
|
27
|
-
Bwrap::Output::Levels.trace?
|
28
|
-
end
|
29
|
-
|
30
|
-
# Takes hash of options received from Optimist and checks output related flags.
|
31
|
-
def self.handle_output_options options
|
32
|
-
Bwrap::Output::Levels.handle_output_options options
|
33
|
-
end
|
34
|
-
|
35
|
-
# Handler used by #trace to output given string.
|
36
|
-
def self.trace_output str, raw: false, log_callback: 1
|
37
|
-
return unless trace?
|
38
|
-
|
39
|
-
if raw
|
40
|
-
print str
|
41
|
-
else
|
42
|
-
out = Bwrap::Output::Levels.trace_print_formatted str, log_callback: (log_callback + 1)
|
43
|
-
end
|
44
|
-
Bwrap::Output::Log.puts_to_log out || str
|
45
|
-
end
|
46
|
-
|
47
|
-
# Handler used by #debug to output given string.
|
48
|
-
def self.debug_output str, raw: false, log_callback: 1
|
49
|
-
return unless debug?
|
50
|
-
|
51
|
-
if raw
|
52
|
-
print str
|
53
|
-
else
|
54
|
-
out = Bwrap::Output::Levels.debug_print_formatted str, log_callback: (log_callback + 1)
|
55
|
-
end
|
56
|
-
Bwrap::Output::Log.puts_to_log out || str
|
57
|
-
end
|
58
|
-
|
59
|
-
# Handler used by #verb to output given string.
|
60
|
-
def self.verb_output str, raw: false, log_callback: 1
|
61
|
-
return unless verbose?
|
62
|
-
|
63
|
-
if raw
|
64
|
-
print str
|
65
|
-
else
|
66
|
-
out = Bwrap::Output::Levels.verbose_print_formatted str, log_callback: (log_callback + 1)
|
67
|
-
end
|
68
|
-
Bwrap::Output::Log.puts_to_log out || str
|
69
|
-
end
|
70
|
-
|
71
|
-
# Handler used by #warn to output given string.
|
72
|
-
def self.warn_output str, raw: false, log_callback: 1
|
73
|
-
if raw
|
74
|
-
print str
|
75
|
-
else
|
76
|
-
out = Bwrap::Output::Levels.warning_print_formatted str, log_callback: (log_callback + 1)
|
77
|
-
end
|
78
|
-
Bwrap::Output::Log.puts_to_log out || str
|
79
|
-
end
|
80
|
-
|
81
|
-
# Aborts current process.
|
82
|
-
#
|
83
|
-
# Use this instead of Ruby’s #exit in order to filter out dummy #exit calls from the code.
|
84
|
-
def self.error_output str = nil, label: :unspecified, log_callback: 1, raise_exception: false
|
85
|
-
unless str.nil?
|
86
|
-
out = Bwrap::Output::Levels.error_print_formatted str, log_callback: (log_callback + 1)
|
87
|
-
Bwrap::Output::Log.puts_to_log out
|
88
|
-
end
|
89
|
-
|
90
|
-
exit_code = Bwrap::Execution::Labels.resolve_exit_code(label)
|
91
|
-
raise str if raise_exception
|
92
|
-
|
93
|
-
exit exit_code
|
94
|
-
end
|
95
|
-
|
96
|
-
# @return true if --verbose, --debug or --trace has been passed, false if not.
|
97
|
-
private def verbose?
|
98
|
-
Bwrap::Output::Levels.verbose?
|
99
|
-
end
|
100
|
-
|
101
|
-
# @return true if --debug or --trace has been passed, false if not.
|
102
|
-
private def debug?
|
103
|
-
Bwrap::Output::Levels.debug?
|
104
|
-
end
|
105
|
-
|
106
|
-
# @return true if --trace has been passed, false if not.
|
107
|
-
private def trace?
|
108
|
-
Bwrap::Output::Levels.trace?
|
109
|
-
end
|
110
|
-
|
111
|
-
# Outputs given string if trace flag has been set.
|
112
|
-
#
|
113
|
-
# Output flags can be set with {.handle_output_options}.
|
114
|
-
#
|
115
|
-
# @param str String to be outputted
|
116
|
-
# @param raw [Boolean] If true, disables output formatting
|
117
|
-
private def trace str, raw: false
|
118
|
-
Bwrap::Output.trace_output(str, raw: raw, log_callback: 2)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Outputs given string if debug flag has been set.
|
122
|
-
#
|
123
|
-
# Output flags can be set with {.handle_output_options}.
|
124
|
-
#
|
125
|
-
# @param str String to be outputted
|
126
|
-
# @param raw [Boolean] If true, disables output formatting
|
127
|
-
private def debug str, raw: false
|
128
|
-
Bwrap::Output.debug_output(str, raw: raw, log_callback: 2)
|
129
|
-
end
|
130
|
-
|
131
|
-
# Outputs given string if verbose flag has been set.
|
132
|
-
#
|
133
|
-
# Output flags can be set with {.handle_output_options}.
|
134
|
-
#
|
135
|
-
# @param str String to be outputted
|
136
|
-
# @param raw [Boolean] If true, disables output formatting
|
137
|
-
private def verb str, raw: false
|
138
|
-
Bwrap::Output.verb_output(str, raw: raw, log_callback: 2)
|
139
|
-
end
|
140
|
-
|
141
|
-
# Outputs given string to `$stderr`.
|
142
|
-
#
|
143
|
-
# @param str String to be outputted
|
144
|
-
# @param raw [Boolean] If true, disables output formatting
|
145
|
-
private def warn str, raw: false
|
146
|
-
Bwrap::Output.warn_output(str, raw: raw, log_callback: 2)
|
147
|
-
end
|
148
|
-
|
149
|
-
# Outputs given string to `$stderr` and halts execution.
|
150
|
-
#
|
151
|
-
# @param str String to be outputted
|
152
|
-
# @param label [Symbol] Exit label accepted by {Bwrap::Execution.resolve_exit_code}
|
153
|
-
# @param raise [Boolean] if true, an exception is raised instead of just existing with exit code.
|
154
|
-
private def error str = nil, label: :unspecified, raise_exception: false
|
155
|
-
Bwrap::Output.error_output(str, label: label, log_callback: 2, raise_exception: raise_exception)
|
156
|
-
end
|
157
11
|
end
|
12
|
+
|
13
|
+
require_relative "output/output_impl"
|
data/lib/bwrap/version.rb
CHANGED
data/lib/bwrap.rb
CHANGED
@@ -1,81 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
|
5
|
-
#require "deep-cover" if ENV["DEEP_COVER"]
|
6
|
-
|
7
|
-
require "bwrap/version"
|
8
|
-
require "bwrap/args/construct"
|
9
|
-
require "bwrap/config"
|
10
|
-
require "bwrap/execution"
|
11
|
-
|
12
|
-
# Executes bwrap command using given configuration.
|
13
|
-
class Bwrap::Bwrap
|
14
|
-
include Bwrap::Execution
|
15
|
-
|
16
|
-
def initialize config
|
17
|
-
@config = config
|
18
|
-
end
|
19
|
-
|
20
|
-
# Parses command line arguments given to caller script.
|
21
|
-
def parse_command_line_arguments
|
22
|
-
options = parse_options
|
23
|
-
|
24
|
-
Bwrap::Output.handle_output_options options
|
25
|
-
end
|
26
|
-
|
27
|
-
# Runs given command inside bwrap.
|
28
|
-
#
|
29
|
-
# @param command [String, Array] Command, with necessary arguments, to be executed inside bwrap
|
30
|
-
def run command
|
31
|
-
construct = Bwrap::Args::Construct.new
|
32
|
-
construct.command = command
|
33
|
-
construct.config = @config
|
34
|
-
bwrap_args = construct.construct_bwrap_args
|
35
|
-
|
36
|
-
exec_command = [ "bwrap" ]
|
37
|
-
exec_command += bwrap_args
|
38
|
-
exec_command.append command
|
39
|
-
exec_command += @cli_args if @cli_args
|
40
|
-
|
41
|
-
execute exec_command
|
42
|
-
|
43
|
-
construct.cleanup
|
44
|
-
end
|
45
|
-
|
46
|
-
# Parses global bwrap flags using Optimist.
|
47
|
-
#
|
48
|
-
# Sets instance variable `@cli_args`.
|
49
|
-
#
|
50
|
-
# @return [Hash] options parsed by {Optimist.options}
|
51
|
-
private def parse_options
|
52
|
-
options = Optimist.options do
|
53
|
-
version ::Bwrap::VERSION
|
54
|
-
|
55
|
-
banner "Usage:"
|
56
|
-
banner " #{$PROGRAM_NAME} [global options]\n \n"
|
57
|
-
banner "Global options:"
|
58
|
-
opt :verbose,
|
59
|
-
"Show verbose output",
|
60
|
-
short: "v"
|
61
|
-
opt :debug,
|
62
|
-
"Show debug output (useful when debugging a problem)",
|
63
|
-
short: "d"
|
64
|
-
opt :trace,
|
65
|
-
"Show trace output (noisiest, probably not useful for most of time)",
|
66
|
-
short: :none
|
67
|
-
opt :version,
|
68
|
-
"Print version and exit",
|
69
|
-
short: "V"
|
70
|
-
opt :help,
|
71
|
-
"Show help message",
|
72
|
-
short: "h"
|
73
|
-
|
74
|
-
educate_on_error
|
75
|
-
end
|
76
|
-
|
77
|
-
@cli_args = ARGV.dup
|
78
|
-
|
79
|
-
options
|
80
|
-
end
|
81
|
-
end
|
3
|
+
require "bwrap/bwrap"
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bwrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samu Voutilainen
|
@@ -34,22 +34,8 @@ cert_chain:
|
|
34
34
|
X4ioQwEn1/9tHs19VO1CLF58451HgEo1BXd7eWLmV1V5cqw0YWok1ly4L/Su/Phf
|
35
35
|
MRxVMHiVAqY=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date:
|
37
|
+
date: 2022-04-16 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: optimist
|
41
|
-
requirement: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - "~>"
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '3.0'
|
46
|
-
type: :runtime
|
47
|
-
prerelease: false
|
48
|
-
version_requirements: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '3.0'
|
53
39
|
- !ruby/object:Gem::Dependency
|
54
40
|
name: bundler
|
55
41
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +120,20 @@ files:
|
|
134
120
|
- lib/bwrap.rb
|
135
121
|
- lib/bwrap/args/args.rb
|
136
122
|
- lib/bwrap/args/bind.rb
|
123
|
+
- lib/bwrap/args/bind/library.rb
|
124
|
+
- lib/bwrap/args/bind/mime.rb
|
137
125
|
- lib/bwrap/args/construct.rb
|
138
126
|
- lib/bwrap/args/environment.rb
|
139
127
|
- lib/bwrap/args/features.rb
|
140
128
|
- lib/bwrap/args/library.rb
|
141
129
|
- lib/bwrap/args/machine_id.rb
|
142
130
|
- lib/bwrap/args/mount.rb
|
131
|
+
- lib/bwrap/bwrap.rb
|
132
|
+
- lib/bwrap/bwrap_module.rb
|
143
133
|
- lib/bwrap/config.rb
|
134
|
+
- lib/bwrap/config/features.rb
|
144
135
|
- lib/bwrap/execution.rb
|
136
|
+
- lib/bwrap/execution/exceptions.rb
|
145
137
|
- lib/bwrap/execution/execute.rb
|
146
138
|
- lib/bwrap/execution/execution.rb
|
147
139
|
- lib/bwrap/execution/labels.rb
|
@@ -150,7 +142,7 @@ files:
|
|
150
142
|
- lib/bwrap/output/colors.rb
|
151
143
|
- lib/bwrap/output/levels.rb
|
152
144
|
- lib/bwrap/output/log.rb
|
153
|
-
- lib/bwrap/output/
|
145
|
+
- lib/bwrap/output/output_impl.rb
|
154
146
|
- lib/bwrap/version.rb
|
155
147
|
homepage: https://git.sr.ht/~smar/ruby-bwrap
|
156
148
|
licenses:
|
@@ -171,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
163
|
version: 2.5.0
|
172
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
165
|
requirements:
|
174
|
-
- - "
|
166
|
+
- - ">="
|
175
167
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
168
|
+
version: '0'
|
177
169
|
requirements: []
|
178
170
|
rubyforge_project:
|
179
171
|
rubygems_version: 2.7.6.3
|
metadata.gz.sig
CHANGED
Binary file
|