rb_sys 0.9.59 → 0.9.60
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 +92 -21
- data/lib/rb_sys/cargo_builder.rb +1 -2
- data/lib/rb_sys/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 84546ca4af298b39d45c6c8b931d59671a1e04900a8e2b86a852c9921475442d
|
4
|
+
data.tar.gz: 6ea6cde3068e5fa49eed2c9fbedc676eb48bb6932922d986f6d691f5a25eb7a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f6f0bbe1a74b1bd994217d7d25c89abce2df9b10b44dad0b656d906b02edc3aec1b142c927a57e773ea9e6764cb90f59657700a232775515717c450f42bf7d
|
7
|
+
data.tar.gz: c17a3fda12f884ab3577c1b9ee16f1aada070fc2935421b36fa7888cbd521a6c0c5d20848642829fe337e1da88f298941d3ab0409587d778668e175115ec6019
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/exe/rb-sys-dock
CHANGED
@@ -4,6 +4,7 @@ require "optparse"
|
|
4
4
|
require "rb_sys/version"
|
5
5
|
require "rb_sys/toolchain_info"
|
6
6
|
require "fileutils"
|
7
|
+
require "tmpdir"
|
7
8
|
|
8
9
|
options = {
|
9
10
|
version: RbSys::VERSION
|
@@ -101,6 +102,7 @@ OptionParser.new do |opts|
|
|
101
102
|
opts.on("--latest", "Use the latest version of the Docker image") do
|
102
103
|
log(:notice, "Using latest version of the Docker image", emoji: "🆕")
|
103
104
|
options[:version] = "latest"
|
105
|
+
options[:no_cache] = true
|
104
106
|
end
|
105
107
|
|
106
108
|
opts.on("--list-platforms", "--list", "List all supported platforms") do
|
@@ -123,6 +125,10 @@ OptionParser.new do |opts|
|
|
123
125
|
ENV["VERBOSE"] = "1"
|
124
126
|
options[:verbose] = true
|
125
127
|
end
|
128
|
+
|
129
|
+
opts.on("--build", "Build the Docker image") do
|
130
|
+
options[:build] = true
|
131
|
+
end
|
126
132
|
end.parse!
|
127
133
|
|
128
134
|
def determine_cache_dir
|
@@ -160,48 +166,113 @@ def mount_cargo_registry
|
|
160
166
|
"--mount type=bind,source=#{File.join(local_registry_dir, dir)},target=#{File.join("/usr/local/cargo", dir)},readonly=false"
|
161
167
|
end
|
162
168
|
|
163
|
-
def
|
164
|
-
|
169
|
+
def volume(src, dest, mode: "rw")
|
170
|
+
"--volume #{src}:#{dest}:rw"
|
171
|
+
end
|
172
|
+
|
173
|
+
def mount_bundle_cache(options)
|
174
|
+
unless File.exist?(File.join(Dir.pwd, "Gemfile"))
|
175
|
+
log(:trace, "Ignoring bundler config")
|
176
|
+
return
|
177
|
+
end
|
178
|
+
|
179
|
+
dir = File.join(cache_dir, options.fetch(:toolchain_info).platform, "bundle")
|
180
|
+
bundle_path = File.join(docker_tmp, "bundle")
|
165
181
|
FileUtils.mkdir_p(dir)
|
166
182
|
log(:trace, "Mounting bundle cache: #{dir}")
|
167
|
-
|
183
|
+
bundle_config = gen_bundle_config_file(bundle_path)
|
184
|
+
bundle_dir = File.dirname(bundle_config)
|
185
|
+
|
186
|
+
"#{volume(dir, bundle_path)} -v #{bundle_dir}:#{File.join(Dir.pwd, ".bundle")}"
|
168
187
|
end
|
169
188
|
|
170
|
-
def
|
171
|
-
tmp_target_dir
|
172
|
-
|
173
|
-
|
189
|
+
def tmp_target_dir(options)
|
190
|
+
return @tmp_target_dir if defined?(@tmp_target_dir)
|
191
|
+
|
192
|
+
dir = File.join(Dir.pwd, "tmp", "rb-sys-dock", options.fetch(:toolchain_info).platform, "target")
|
193
|
+
FileUtils.mkdir_p(dir)
|
194
|
+
@tmp_target_dir = dir
|
195
|
+
end
|
196
|
+
|
197
|
+
def mount_target_dir(options)
|
198
|
+
"-v #{tmp_target_dir(options)}:#{File.join(Dir.pwd, "target")}"
|
174
199
|
end
|
175
200
|
|
176
201
|
def mount_command_history(options)
|
177
202
|
return unless $stdin.tty?
|
178
203
|
|
179
204
|
history_dir = File.join(cache_dir, options.fetch(:platform), "commandhistory")
|
205
|
+
FileUtils.mkdir_p(history_dir)
|
180
206
|
"-v #{history_dir}:#{File.join(docker_tmp, "commandhistory")}"
|
181
207
|
end
|
182
208
|
|
209
|
+
def default_command_to_run(input_args, options)
|
210
|
+
input_cmd = input_args.empty? ? "true" : input_args.join(" ")
|
211
|
+
|
212
|
+
if options[:build]
|
213
|
+
with_bundle = "test -f Gemfile && bundle install && #{input_cmd} && bundle exec rake native:$RUBY_TARGET gem"
|
214
|
+
without_bundle = "#{input_cmd} && rake native:$RUBY_TARGET gem"
|
215
|
+
|
216
|
+
log(:notice, "Running default build command:")
|
217
|
+
log(:notice, " $ rake native:#{options[:toolchain_info].platform} gem")
|
218
|
+
cargo_env = "export RB_SYS_CARGO_TARGET_DIR=#{tmp_target_dir(options)}"
|
219
|
+
"bash -c '#{cargo_env}; (#{with_bundle}) || (#{without_bundle})'"
|
220
|
+
else
|
221
|
+
input_args.empty? ? "bash" : "bash -c '#{input_args.join(" ")}'"
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def uid_gid
|
226
|
+
if /darwin/.match?(RbConfig::CONFIG["host_os"])
|
227
|
+
["1000", "1000"]
|
228
|
+
else
|
229
|
+
[Process.uid, Process.gid]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def user_mapping
|
234
|
+
uid, gid = uid_gid
|
235
|
+
"-e UID=#{uid} -e GID=#{gid} -e GROUP=_staff -e USER=rb-sys-dock"
|
236
|
+
end
|
237
|
+
|
238
|
+
def interactive?(input_args)
|
239
|
+
$stdin.tty?
|
240
|
+
end
|
241
|
+
|
242
|
+
def gen_bundle_config_file(path)
|
243
|
+
dir = Dir.mktmpdir("rb-sys-dock")
|
244
|
+
file = File.join(dir, "config")
|
245
|
+
File.write(file, <<~YAML)
|
246
|
+
---
|
247
|
+
BUNDLE_JOBS: "4"
|
248
|
+
BUNDLE_RETRY: "4"
|
249
|
+
BUNDLE_PATH: #{path.inspect}
|
250
|
+
YAML
|
251
|
+
|
252
|
+
file
|
253
|
+
end
|
254
|
+
|
255
|
+
def mount_tmp_dir(options)
|
256
|
+
"--mount type=bind,source=#{Dir.mktmpdir},destination=#{Dir.pwd}/tmp/#{options.fetch(:toolchain_info).platform},readonly=false"
|
257
|
+
end
|
258
|
+
|
183
259
|
def rcd(input_args, options)
|
184
260
|
wrapper_command = []
|
185
|
-
wrapper_command << "sigfw" unless
|
261
|
+
wrapper_command << "sigfw" unless interactive?(input_args)
|
186
262
|
wrapper_command << "runas"
|
187
263
|
|
188
|
-
extra_env = []
|
189
|
-
|
190
264
|
docker_options = []
|
191
|
-
docker_options << "--tty" if
|
192
|
-
cmd = input_args.empty? ? "bash" : "bash -c '#{input_args.join(" ")}'"
|
265
|
+
docker_options << "--tty" if interactive?(input_args)
|
193
266
|
|
194
267
|
cmd = <<~SH
|
195
268
|
#{default_docker_command} run \
|
196
269
|
-v #{Dir.pwd}:#{Dir.pwd} \
|
197
|
-
#{
|
270
|
+
#{mount_tmp_dir(options)} \
|
271
|
+
#{mount_target_dir(options)} \
|
198
272
|
#{mount_cargo_registry} \
|
199
|
-
#{mount_bundle_cache(options
|
273
|
+
#{mount_bundle_cache(options)} \
|
200
274
|
#{mount_command_history(options)} \
|
201
|
-
|
202
|
-
-e GID=#{ENV.fetch("RB_SYS_DOCK_GID", "1000")} \
|
203
|
-
-e USER=rb-sys-dock \
|
204
|
-
-e GROUP=_staff \
|
275
|
+
#{user_mapping} \
|
205
276
|
-e GEM_PRIVATE_KEY_PASSPHRASE \
|
206
277
|
-e ftp_proxy \
|
207
278
|
-e http_proxy \
|
@@ -216,7 +287,7 @@ def rcd(input_args, options)
|
|
216
287
|
#{docker_options.join(" ")} \
|
217
288
|
#{ENV.fetch("RCD_IMAGE")} \
|
218
289
|
#{wrapper_command.join(" ")} \
|
219
|
-
#{
|
290
|
+
#{default_command_to_run(input_args, options)}
|
220
291
|
SH
|
221
292
|
|
222
293
|
log(:trace, "Running command: $ #{cmd}")
|
@@ -224,10 +295,10 @@ def rcd(input_args, options)
|
|
224
295
|
exec(cmd)
|
225
296
|
end
|
226
297
|
|
227
|
-
def download_image(
|
298
|
+
def download_image(options)
|
228
299
|
image = ENV.fetch("RCD_IMAGE")
|
229
300
|
|
230
|
-
if docker("images -q #{image}").strip.empty?
|
301
|
+
if docker("images -q #{image}").strip.empty? || options[:no_cache]
|
231
302
|
# Nicely formatted message that we are downloading the image which might take awhile
|
232
303
|
log(:notice, "Downloading container #{image.inspect}, this might take awhile...")
|
233
304
|
docker("pull #{image} --quiet > /dev/null")
|
data/lib/rb_sys/cargo_builder.rb
CHANGED
@@ -59,10 +59,9 @@ module RbSys
|
|
59
59
|
|
60
60
|
def cargo_command(dest_path, args = [])
|
61
61
|
manifest = File.join(ext_dir, "Cargo.toml")
|
62
|
-
cargo = ENV.fetch("CARGO", "cargo")
|
63
62
|
|
64
63
|
cmd = []
|
65
|
-
cmd += [cargo, "rustc"]
|
64
|
+
cmd += ["cargo", "rustc"]
|
66
65
|
cmd += ["--target", target] if target
|
67
66
|
cmd += ["--target-dir", dest_path]
|
68
67
|
cmd += ["--features", features.join(",")] unless features.empty?
|
data/lib/rb_sys/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb_sys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.60
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
Rl+ASkq2/1i07TkBpCf+2hq66+h/hx+/Y/KrUzXfe0jtvil0WESkJT2kqRqHWNhD
|
31
31
|
9GKBxaQlXokNDtWCm1/gl6cD8WRZ0N5S4ZGJT1FLLsA=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2023-02-
|
33
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description:
|
36
36
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|