rb_sys 0.9.48 → 0.9.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/exe/rb-sys-dock +119 -20
- data/lib/rb_sys/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d65319f94ce1b79cc27ed5b42a61246d7183cb7f9616fafc6f60ce023fe3b687
|
4
|
+
data.tar.gz: 0e3fe62efd6b9f0f8246f182b91d6918b0161b89691f1df8ded5628fa26ad105
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 307b71b55f1602546201f8380b101824f2b241eb219041f36938c6316d315b0094d1fc5e1fd41412c37be90afdcc42dffa308042e6038f05f187109d80128b0e
|
7
|
+
data.tar.gz: 0c7162a722fdfbdfd483f342f7d737284539b5d5b3c8b303a0f55d107c2b32fd5346617a224ed15475326ae2fb474603dfcfbbf6f6840d993b8a093b40a13838
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/exe/rb-sys-dock
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "optparse"
|
4
4
|
require "rb_sys/version"
|
5
5
|
require "rb_sys/toolchain_info"
|
6
|
+
require "fileutils"
|
6
7
|
|
7
8
|
options = {
|
8
9
|
version: RbSys::VERSION
|
@@ -18,6 +19,10 @@ def log(level, message, emoji: true, io: $stderr)
|
|
18
19
|
["ℹ️", "\e[1;37m"]
|
19
20
|
when :notice
|
20
21
|
["🐳", "\e[1;34m"]
|
22
|
+
when :trace
|
23
|
+
return unless ENV["LOG_LEVEL"] == "trace"
|
24
|
+
|
25
|
+
["🔍", "\e[1;2m"]
|
21
26
|
else raise "Unknown log level: #{level.inspect}"
|
22
27
|
end
|
23
28
|
|
@@ -27,7 +32,10 @@ def log(level, message, emoji: true, io: $stderr)
|
|
27
32
|
emoji_opt + " "
|
28
33
|
end
|
29
34
|
|
30
|
-
|
35
|
+
# Escape the message for bash shell codes (e.g. \e[1;31m)
|
36
|
+
escaped = message.gsub("\\", "\\\\\\").gsub("\e", "\\e")
|
37
|
+
|
38
|
+
io.puts "#{shellcode}#{emoji_opt}#{escaped}\e[0m"
|
31
39
|
end
|
32
40
|
|
33
41
|
OptionParser.new do |opts|
|
@@ -73,37 +81,128 @@ OptionParser.new do |opts|
|
|
73
81
|
puts opts
|
74
82
|
exit
|
75
83
|
end
|
76
|
-
end.parse!
|
77
84
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
abort "rake-compiler-dock is not installed. Please run `gem install rake-compiler-dock` to use this command."
|
85
|
+
opts.on("-V", "--verbose", "Prints verbose output") do
|
86
|
+
ENV["LOG_LEVEL"] = "trace"
|
87
|
+
ENV["VERBOSE"] = "1"
|
88
|
+
options[:verbose] = true
|
83
89
|
end
|
90
|
+
end.parse!
|
91
|
+
|
92
|
+
def determine_cache_dir
|
93
|
+
return ENV["RB_SYS_DOCK_CACHE_DIR"] if ENV["RB_SYS_DOCK_CACHE_DIR"]
|
94
|
+
return File.join(ENV["XDG_CACHE_HOME"], "rb-sys-dock") if ENV["XDG_CACHE_HOME"]
|
95
|
+
|
96
|
+
File.join(ENV["HOME"], ".cache", "rb-sys-dock")
|
97
|
+
end
|
84
98
|
|
85
|
-
|
99
|
+
def cache_dir
|
100
|
+
return @cache_dir if defined?(@cache_dir)
|
86
101
|
|
87
|
-
|
88
|
-
|
89
|
-
|
102
|
+
@cache_dir = determine_cache_dir
|
103
|
+
FileUtils.mkdir_p(@cache_dir)
|
104
|
+
@cache_dir
|
105
|
+
end
|
106
|
+
|
107
|
+
def mount_cargo_registry
|
108
|
+
local_registry_dir = if ENV["CARGO_HOME"]
|
109
|
+
ENV["CARGO_HOME"]
|
110
|
+
elsif File.exist?(cargo_home = File.join(ENV["HOME"], ".cargo"))
|
111
|
+
cargo_home
|
112
|
+
else
|
113
|
+
File.join(cache_dir, "cargo")
|
90
114
|
end
|
91
115
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
116
|
+
dirs = []
|
117
|
+
dirs << File.join(local_registry_dir, "registry", "index")
|
118
|
+
dirs << File.join(local_registry_dir, "registry", "cache")
|
119
|
+
dirs << File.join(local_registry_dir, "registry", "git", "db")
|
120
|
+
|
121
|
+
dirs.each do |dir|
|
122
|
+
log(:trace, "Mounting cargo registry dir: #{dir}")
|
123
|
+
FileUtils.mkdir_p(dir)
|
98
124
|
end
|
125
|
+
dirs.map { |dir| "-v #{dir}:#{dir}" }.join(" ")
|
126
|
+
end
|
127
|
+
|
128
|
+
def mount_bundle_cache(options, extra_env)
|
129
|
+
dir = File.join(cache_dir, options.fetch(:platform), "bundle")
|
130
|
+
FileUtils.mkdir_p(dir)
|
131
|
+
log(:trace, "Mounting bundle cache: #{dir}")
|
132
|
+
extra_env << "BUNDLE_PATH=\"/tmp/bundle\""
|
133
|
+
"-v #{dir}:/tmp/bundle"
|
134
|
+
end
|
135
|
+
|
136
|
+
def mount_target_dir(options, _extra_env)
|
137
|
+
tmp_target_dir = File.join(Dir.pwd, "tmp", "rb-sys-dock", options[:platform], "target")
|
138
|
+
FileUtils.mkdir_p(tmp_target_dir)
|
139
|
+
"-v #{tmp_target_dir}:#{File.join(Dir.pwd, "target")}"
|
140
|
+
end
|
141
|
+
|
142
|
+
def mount_command_history(options)
|
143
|
+
return unless $stdin.tty?
|
144
|
+
|
145
|
+
history_dir = File.join(cache_dir, options.fetch(:platform), "commandhistory")
|
146
|
+
"-v #{history_dir}:/tmp/commandhistory"
|
147
|
+
end
|
148
|
+
|
149
|
+
def rcd(input_args, options)
|
150
|
+
wrapper_command = []
|
151
|
+
wrapper_command << "sigfw" unless $stdin.tty?
|
152
|
+
wrapper_command << "runas"
|
153
|
+
|
154
|
+
extra_env = []
|
155
|
+
|
156
|
+
docker_options = []
|
157
|
+
docker_options << "--tty" if $stdin.tty?
|
158
|
+
run_command = input_args.empty? ? "bash" : input_args.join(" ")
|
159
|
+
|
160
|
+
cmd = <<~SH
|
161
|
+
#{docker_command} run \
|
162
|
+
-v #{Dir.pwd}:#{Dir.pwd} \
|
163
|
+
#{mount_target_dir(options, extra_env)} \
|
164
|
+
#{mount_cargo_registry} \
|
165
|
+
#{mount_bundle_cache(options, extra_env)} \
|
166
|
+
#{mount_command_history(options)} \
|
167
|
+
-e UID=#{ENV.fetch("RB_SYS_DOCK_UID", "1000")} \
|
168
|
+
-e GID=#{ENV.fetch("RB_SYS_DOCK_GID", "1000")} \
|
169
|
+
-e USER=rb-sys-dock \
|
170
|
+
-e GROUP=_staff \
|
171
|
+
-e GEM_PRIVATE_KEY_PASSPHRASE \
|
172
|
+
-e ftp_proxy \
|
173
|
+
-e http_proxy \
|
174
|
+
-e https_proxy \
|
175
|
+
-e RCD_HOST_RUBY_PLATFORM=#{RbConfig::CONFIG["arch"]} \
|
176
|
+
-e RCD_HOST_RUBY_VERSION=#{RUBY_VERSION} \
|
177
|
+
-e RCD_IMAGE \
|
178
|
+
-e TERM \
|
179
|
+
-w #{Dir.pwd} \
|
180
|
+
--rm \
|
181
|
+
--interactive \
|
182
|
+
#{docker_options.join(" ")} \
|
183
|
+
#{ENV.fetch("RCD_IMAGE")} \
|
184
|
+
#{wrapper_command.join(" ")} \
|
185
|
+
#{run_command}
|
186
|
+
SH
|
187
|
+
|
188
|
+
log(:trace, "Running command: \n$ #{cmd}")
|
189
|
+
|
190
|
+
exec(cmd)
|
191
|
+
end
|
192
|
+
|
193
|
+
def docker_command
|
194
|
+
return @docker_command if defined?(@docker_command)
|
195
|
+
|
196
|
+
@docker_command = ENV.fetch("DOCKER", "docker")
|
99
197
|
end
|
100
198
|
|
101
199
|
def download_image(_options)
|
102
200
|
image = ENV.fetch("RCD_IMAGE")
|
103
|
-
|
201
|
+
|
202
|
+
if `#{docker_command} images -q #{image}`.strip.empty?
|
104
203
|
# Nicely formatted message that we are downloading the image which might take awhile
|
105
204
|
log(:notice, "Downloading container #{image.inspect}, this might take awhile...")
|
106
|
-
system("
|
205
|
+
system("#{docker_command} pull #{image} --quiet > /dev/null")
|
107
206
|
end
|
108
207
|
end
|
109
208
|
|
@@ -122,4 +221,4 @@ end
|
|
122
221
|
set_env(options)
|
123
222
|
download_image(options)
|
124
223
|
log_some_useful_info(options)
|
125
|
-
rcd(ARGV)
|
224
|
+
rcd(ARGV, options)
|
data/lib/rb_sys/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|