tebako-runtime 0.8.0 → 0.8.1
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
- data/lib/tebako-runtime/adapters/jing.rb +19 -0
- data/lib/tebako-runtime/adapters/mn2pdf.rb +47 -0
- data/lib/tebako-runtime/memfs.rb +23 -0
- data/lib/tebako-runtime/pre/excavate.rb +4 -1
- data/lib/tebako-runtime/pre/seven-zip.rb +14 -9
- data/lib/tebako-runtime/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ba52d9e206dd564fbe88cf079186d2dbfe06fad5b842cf4163230f9871c3b07
|
|
4
|
+
data.tar.gz: 7850d54601ade1c550764b32707b37ba79aeb607b40ebb9ac47e9bb5c37a76a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9df00fb7bd933634a0348458be54624f701b3106b12c0a358c8e4603c53a309508a28cad0bfdd00cc4e761f2a346676f24d3f1ab55bd4a0d1196c7cdb2b34842
|
|
7
|
+
data.tar.gz: 2e1c99b83a6c9b763378afc693c994d3b8b527f4a78c70de656a2709c279d5b71e4c00f81e7188edd1e15c3d2190c8690381b40b7b4281cfdc1492f1be228a9f
|
|
@@ -41,9 +41,28 @@ class Jing
|
|
|
41
41
|
# path. Force the extracted path per-instance (a nil option hash
|
|
42
42
|
# leaves @options empty, and the builder's stale default would win).
|
|
43
43
|
@options[:jar] = DEFAULT_JAR
|
|
44
|
+
# The mounted openjdk toolkit payload's java wins over PATH (the
|
|
45
|
+
# memfs-binary exec path; the bare "java" keeps the PATH answer).
|
|
46
|
+
@options[:java] = TebakoRuntime.mounted_exe("openjdk", "java")
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
def validate(xml)
|
|
47
50
|
original_validate(TebakoRuntime.extract_memfs(xml))
|
|
48
51
|
end
|
|
52
|
+
|
|
53
|
+
# The spawn shape, array form (the stock execute() backticks a shell
|
|
54
|
+
# string, which the tebako spawn hook deliberately skips; the mounted
|
|
55
|
+
# java only execs through the hook from an absolute-path array spawn).
|
|
56
|
+
def execute(options) # rubocop:disable Metrics/AbcSize
|
|
57
|
+
cmd = [options[:java]]
|
|
58
|
+
cmd += options[:java_opts].split if options[:java_opts]
|
|
59
|
+
cmd += ["-jar", options[:jar].to_s]
|
|
60
|
+
cmd << "-c" if options[:compact]
|
|
61
|
+
cmd += ["-e", options[:encoding]] if options[:encoding]
|
|
62
|
+
cmd << "-i" if options[:id_check]
|
|
63
|
+
cmd += [options[:schema].to_s, options[:xmlfile].to_s]
|
|
64
|
+
IO.popen(cmd, err: %i[child out], &:read)
|
|
65
|
+
rescue SystemCallError => e
|
|
66
|
+
raise ExecutionError, "jing execution failed: #{e}"
|
|
67
|
+
end
|
|
49
68
|
end
|
|
@@ -55,3 +55,50 @@ module Mn2pdf
|
|
|
55
55
|
options)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
|
+
|
|
59
|
+
# The java resolution + the spawn shape (the memfs-binary exec path):
|
|
60
|
+
# when the openjdk toolkit payload is mounted, its /opt/openjdk/bin/java
|
|
61
|
+
# wins over PATH; the spawn is the ARRAY form — the shell form
|
|
62
|
+
# (`Open3.capture3(string)`) goes through /bin/sh, which the tebako
|
|
63
|
+
# spawn hook deliberately skips.
|
|
64
|
+
module Jvm
|
|
65
|
+
singleton_class.send(:alias_method, :run_orig, :run)
|
|
66
|
+
singleton_class.send(:remove_method, :run)
|
|
67
|
+
|
|
68
|
+
def self.run(args = [])
|
|
69
|
+
java = TebakoRuntime.mounted_exe("openjdk", "java")
|
|
70
|
+
return run_orig(args) if java == "java"
|
|
71
|
+
|
|
72
|
+
# The stock form joins everything into a SHELL string: values ride
|
|
73
|
+
# shell-quoted (whole-value and inner forms), and legacy callers pass
|
|
74
|
+
# whole fragments in one element (`--param baseassetpath="/dir"`).
|
|
75
|
+
# The array spawn needs shell-word rules applied — split on unquoted
|
|
76
|
+
# spaces, shed the quotes — exactly what the shell did with the
|
|
77
|
+
# stock string.
|
|
78
|
+
clean = args.flat_map { |a| TebakoRuntime.shell_split(a.to_s) }
|
|
79
|
+
cmd = [java, *options, "-jar", MN2PDF_JAR_PATH.to_s, *clean]
|
|
80
|
+
puts cmd.join(" ")
|
|
81
|
+
Open3.capture3(*cmd).then { |stdout, stderr, status| [stdout, stderr, status] }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# options_to_cmd's joined form (`--param "k=v"` in ONE shell word) is
|
|
86
|
+
# shell-string machinery; the array spawn takes flag and value as
|
|
87
|
+
# separate elements with the shell quotes removed. Stock behavior
|
|
88
|
+
# stands for the PATH java.
|
|
89
|
+
module Mn2pdf
|
|
90
|
+
singleton_class.send(:alias_method, :options_to_cmd_orig, :options_to_cmd)
|
|
91
|
+
singleton_class.send(:remove_method, :options_to_cmd)
|
|
92
|
+
|
|
93
|
+
def self.options_to_cmd(options, cmd)
|
|
94
|
+
return options_to_cmd_orig(options, cmd) if TebakoRuntime.mounted_exe("openjdk", "java") == "java"
|
|
95
|
+
|
|
96
|
+
options.each do |k, v|
|
|
97
|
+
if k.to_s.end_with?("=")
|
|
98
|
+
cmd << "#{k}#{v.to_s.delete('"')}"
|
|
99
|
+
else
|
|
100
|
+
cmd << k.to_s << v.to_s.delete('"')
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
data/lib/tebako-runtime/memfs.rb
CHANGED
|
@@ -97,6 +97,29 @@ module TebakoRuntime
|
|
|
97
97
|
|
|
98
98
|
is_quoted ? memfs_extracted_file.to_path.quote : memfs_extracted_file.to_path
|
|
99
99
|
end
|
|
100
|
+
|
|
101
|
+
# The mounted-toolkit resolution (spec 03 §2.2): an executable the
|
|
102
|
+
# named toolkit payload provides at its declared mount. Returns the
|
|
103
|
+
# in-image absolute path when the mounts hold it (the spawn hook
|
|
104
|
+
# execs those through dlmap2file + the preload), the bare name
|
|
105
|
+
# otherwise (the consumer's PATH answer stands).
|
|
106
|
+
#
|
|
107
|
+
# TebakoRuntime.mounted_exe("openjdk", "java")
|
|
108
|
+
# # => "/opt/openjdk/bin/java" when the openjdk payload is mounted,
|
|
109
|
+
# else "java"
|
|
110
|
+
def self.mounted_exe(toolkit, name)
|
|
111
|
+
mounted = "/opt/#{toolkit}/bin/#{name}"
|
|
112
|
+
embedded_path?(mounted) ? mounted : name
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Shell-word split for the array spawn (the memfs-binary exec path):
|
|
116
|
+
# legacy adapters compose arguments as a SHELL fragment in ONE element
|
|
117
|
+
# (`--param baseassetpath="/dir"`), and shell-quoted whole values ride
|
|
118
|
+
# as single elements. Split on unquoted spaces, then shed the quotes —
|
|
119
|
+
# exactly the shell's own word rules (a quoted space never splits).
|
|
120
|
+
def self.shell_split(word)
|
|
121
|
+
word.scan(/"([^"]*)"|(\S+)/).map { |quoted, bare| quoted || bare }
|
|
122
|
+
end
|
|
100
123
|
end
|
|
101
124
|
|
|
102
125
|
at_exit do
|
|
@@ -28,4 +28,7 @@
|
|
|
28
28
|
# For some reason on Windows an attempt to require "seven_zip_ruby" from excavate fails
|
|
29
29
|
# I cannot debug it effectively because of https://github.com/tamatebako/tebako/issues/119
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
# Only legacy excavate loads seven_zip_ruby; omnizip-era excavate has no
|
|
32
|
+
# seven-zip gem at all — wiring it then would crash the require chain
|
|
33
|
+
# with Gem::MissingSpecError (metanorma dogfood, 2026-08-11).
|
|
34
|
+
require "seven_zip_ruby" if Gem::Specification.find_all_by_name("seven-zip").any?
|
|
@@ -28,15 +28,20 @@
|
|
|
28
28
|
require_relative "../memfs"
|
|
29
29
|
require_relative "../../tebako-runtime"
|
|
30
30
|
|
|
31
|
-
# Fix path for 7zip load
|
|
31
|
+
# Fix path for 7zip load.
|
|
32
|
+
# Legacy-excavate only: omnizip-era excavate ships no seven-zip gem —
|
|
33
|
+
# when it is absent there is nothing to excavate, so the hook is a
|
|
34
|
+
# no-op (never a Gem::MissingSpecError — metanorma dogfood, 2026-08-11).
|
|
32
35
|
module TebakoRuntime
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if Gem::Specification.find_all_by_name("seven-zip").any?
|
|
37
|
+
sevenz_lib = RUBY_PLATFORM.downcase.match(/mswin|mingw/) ? "7z*.dll" : "7z.so"
|
|
38
|
+
sevenz_path = File.join(full_gem_path("seven-zip"), "lib", "seven_zip_ruby", sevenz_lib)
|
|
39
|
+
sevenz_paths = Dir.glob(sevenz_path)
|
|
40
|
+
sevenz_new_folder = COMPILER_MEMFS_LIB_CACHE / "seven_zip_ruby"
|
|
41
|
+
FileUtils.mkdir_p(sevenz_new_folder)
|
|
42
|
+
sevenz_paths.each do |file|
|
|
43
|
+
FileUtils.cp(file, sevenz_new_folder)
|
|
44
|
+
end
|
|
45
|
+
$LOAD_PATH.unshift(COMPILER_MEMFS_LIB_CACHE.to_s)
|
|
40
46
|
end
|
|
41
|
-
$LOAD_PATH.unshift(COMPILER_MEMFS_LIB_CACHE.to_s)
|
|
42
47
|
end
|