rb_sys 0.9.47 → 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 +224 -0
- data/lib/rb_sys/toolchain_info.rb +4 -0
- data/lib/rb_sys/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +5 -3
- 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
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "rb_sys/version"
|
5
|
+
require "rb_sys/toolchain_info"
|
6
|
+
require "fileutils"
|
7
|
+
|
8
|
+
options = {
|
9
|
+
version: RbSys::VERSION
|
10
|
+
}
|
11
|
+
|
12
|
+
def log(level, message, emoji: true, io: $stderr)
|
13
|
+
emoji_opt, shellcode = case level
|
14
|
+
when :error
|
15
|
+
["❌", "\e[1;31m"]
|
16
|
+
when :warn
|
17
|
+
["⚠️", "\e[1;33m"]
|
18
|
+
when :info
|
19
|
+
["ℹ️", "\e[1;37m"]
|
20
|
+
when :notice
|
21
|
+
["🐳", "\e[1;34m"]
|
22
|
+
when :trace
|
23
|
+
return unless ENV["LOG_LEVEL"] == "trace"
|
24
|
+
|
25
|
+
["🔍", "\e[1;2m"]
|
26
|
+
else raise "Unknown log level: #{level.inspect}"
|
27
|
+
end
|
28
|
+
|
29
|
+
emoji_opt = if emoji.is_a?(String)
|
30
|
+
emoji + " "
|
31
|
+
elsif emoji
|
32
|
+
emoji_opt + " "
|
33
|
+
end
|
34
|
+
|
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"
|
39
|
+
end
|
40
|
+
|
41
|
+
OptionParser.new do |opts|
|
42
|
+
opts.banner = "Usage: rb-sys-dock --platform PLATFORM [COMMAND]"
|
43
|
+
|
44
|
+
opts.on("-v", "--version", "Prints version") do
|
45
|
+
require "rb_sys/version"
|
46
|
+
puts RbSys::VERSION
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on("-p", "--platform PLATFORM", "Platform to build for (i.e. x86_64-linux)") do |p|
|
51
|
+
toolchain_info = begin
|
52
|
+
RbSys::ToolchainInfo.new(p)
|
53
|
+
rescue
|
54
|
+
supported_list = RbSys::ToolchainInfo.all
|
55
|
+
supported_list.select!(&:supported?)
|
56
|
+
list = supported_list.map { |p| "- #{p} (#{p.rust_target})" }.join("\n")
|
57
|
+
log(:error, "Platform #{p} is not supported, please use one of:\n\n#{list}")
|
58
|
+
exit(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
options[:platform] = p
|
62
|
+
options[:toolchain_info] = toolchain_info
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("--latest", "Use the latest version of the Docker image") do
|
66
|
+
log(:notice, "Using latest version of the Docker image", emoji: "🆕")
|
67
|
+
options[:version] = "latest"
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("--list-platforms", "--list", "List all supported platforms") do
|
71
|
+
log(:notice, "Supported platforms listed below:")
|
72
|
+
|
73
|
+
RbSys::ToolchainInfo.supported.each do |p|
|
74
|
+
log(:info, "- #{p} (#{p.rust_target})", emoji: false, io: $stdout)
|
75
|
+
end
|
76
|
+
|
77
|
+
exit(0)
|
78
|
+
end
|
79
|
+
|
80
|
+
opts.on("-h", "--help", "Prints this help") do
|
81
|
+
puts opts
|
82
|
+
exit
|
83
|
+
end
|
84
|
+
|
85
|
+
opts.on("-V", "--verbose", "Prints verbose output") do
|
86
|
+
ENV["LOG_LEVEL"] = "trace"
|
87
|
+
ENV["VERBOSE"] = "1"
|
88
|
+
options[:verbose] = true
|
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
|
98
|
+
|
99
|
+
def cache_dir
|
100
|
+
return @cache_dir if defined?(@cache_dir)
|
101
|
+
|
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")
|
114
|
+
end
|
115
|
+
|
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)
|
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")
|
197
|
+
end
|
198
|
+
|
199
|
+
def download_image(_options)
|
200
|
+
image = ENV.fetch("RCD_IMAGE")
|
201
|
+
|
202
|
+
if `#{docker_command} images -q #{image}`.strip.empty?
|
203
|
+
# Nicely formatted message that we are downloading the image which might take awhile
|
204
|
+
log(:notice, "Downloading container #{image.inspect}, this might take awhile...")
|
205
|
+
system("#{docker_command} pull #{image} --quiet > /dev/null")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def log_some_useful_info(_options)
|
210
|
+
if ARGV.empty?
|
211
|
+
log(:notice, "Entering shell in Docker container #{ENV["RCD_IMAGE"].inspect}")
|
212
|
+
else
|
213
|
+
log(:notice, "Running command #{ARGV.inspect} in Docker container #{ENV["RCD_IMAGE"].inspect}")
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def set_env(options)
|
218
|
+
ENV["RCD_IMAGE"] = "rbsys/#{options[:toolchain_info]}:#{options[:version]}"
|
219
|
+
end
|
220
|
+
|
221
|
+
set_env(options)
|
222
|
+
download_image(options)
|
223
|
+
log_some_useful_info(options)
|
224
|
+
rcd(ARGV, options)
|
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.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
@@ -30,18 +30,20 @@ cert_chain:
|
|
30
30
|
Rl+ASkq2/1i07TkBpCf+2hq66+h/hx+/Y/KrUzXfe0jtvil0WESkJT2kqRqHWNhD
|
31
31
|
9GKBxaQlXokNDtWCm1/gl6cD8WRZ0N5S4ZGJT1FLLsA=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2022-12-
|
33
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description:
|
36
36
|
email:
|
37
37
|
- i.kerseymer@gmail.com
|
38
|
-
executables:
|
38
|
+
executables:
|
39
|
+
- rb-sys-dock
|
39
40
|
extensions: []
|
40
41
|
extra_rdoc_files: []
|
41
42
|
files:
|
42
43
|
- LICENSE-APACHE
|
43
44
|
- LICENSE-MIT
|
44
45
|
- certs/ianks.pem
|
46
|
+
- exe/rb-sys-dock
|
45
47
|
- lib/rb_sys.rb
|
46
48
|
- lib/rb_sys/cargo_builder.rb
|
47
49
|
- lib/rb_sys/cargo_builder/link_flag_converter.rb
|
metadata.gz.sig
CHANGED
Binary file
|