tebako 0.12.8 → 0.12.10
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/CMakeLists.txt +5 -5
- data/README.adoc +27 -13
- data/common.env +1 -1
- data/exe/tebako-packager +10 -11
- data/lib/tebako/build_helpers.rb +1 -14
- data/lib/tebako/cli.rb +28 -7
- data/lib/tebako/cli_helpers.rb +2 -2
- data/lib/tebako/codegen.rb +21 -20
- data/lib/tebako/deploy_helper.rb +18 -30
- data/lib/tebako/error.rb +3 -0
- data/lib/tebako/options_manager.rb +5 -27
- data/lib/tebako/packager/pass1_patch.rb +13 -62
- data/lib/tebako/packager/pass2_patch.rb +154 -0
- data/lib/tebako/packager/patch_buildsystem.rb +10 -6
- data/lib/tebako/packager/patch_helpers.rb +0 -12
- data/lib/tebako/packager/rubygems_patch.rb +83 -0
- data/lib/tebako/packager.rb +20 -18
- data/lib/tebako/ruby_builder.rb +1 -1
- data/lib/tebako/ruby_version.rb +11 -6
- data/lib/tebako/scenario_manager.rb +159 -40
- data/lib/tebako/version.rb +1 -1
- data/tebako.gemspec +2 -0
- metadata +32 -3
- data/lib/tebako/packager/pass2.rb +0 -149
@@ -29,6 +29,7 @@ require_relative "patch_helpers"
|
|
29
29
|
require_relative "patch_buildsystem"
|
30
30
|
|
31
31
|
require_relative "patch"
|
32
|
+
require_relative "rubygems_patch"
|
32
33
|
# Tebako - an executable packager
|
33
34
|
module Tebako
|
34
35
|
# Packager module
|
@@ -46,24 +47,13 @@ module Tebako
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
# Ruby patching definitions (pass1 - common)
|
49
|
-
class Pass1Patch <
|
50
|
+
class Pass1Patch < RubygemsPatch
|
50
51
|
# [TODO] looks like it does not exist in 3.1.4
|
51
52
|
# May be obsolete
|
52
53
|
TOOL_RBINSTALL_RB_PATCH = {
|
53
54
|
" next if files.empty?" => "# tebako patched next if files.empty?"
|
54
55
|
}.freeze
|
55
56
|
|
56
|
-
RUBYGEM_OPENSSL_RB_SUBST = <<~SUBST
|
57
|
-
# Start of tebako patch
|
58
|
-
require "openssl"
|
59
|
-
# End of tebako patch
|
60
|
-
autoload :OpenSSL, "openssl"
|
61
|
-
SUBST
|
62
|
-
|
63
|
-
RUBYGEM_OPENSSL_RB_PATCH = {
|
64
|
-
'autoload :OpenSSL, "openssl"' => RUBYGEM_OPENSSL_RB_SUBST
|
65
|
-
}.freeze
|
66
|
-
|
67
57
|
EXT_SETUP_PATCH = {
|
68
58
|
"#option nodynamic" => "option nodynamic"
|
69
59
|
}.freeze
|
@@ -131,9 +121,8 @@ module Tebako
|
|
131
121
|
"Logging::message \"=== Checking done. ===\\n\"" => OPENSSL_EXTCONF_RB_SUBST
|
132
122
|
}.freeze
|
133
123
|
|
134
|
-
def initialize(
|
135
|
-
super()
|
136
|
-
@mountpoint = mountpoint
|
124
|
+
def initialize(mount_point, ruby_ver)
|
125
|
+
super(mount_point)
|
137
126
|
@ruby_ver = ruby_ver
|
138
127
|
end
|
139
128
|
|
@@ -152,7 +141,7 @@ module Tebako
|
|
152
141
|
|
153
142
|
# ....................................................
|
154
143
|
# Allow only packaged gems (from within memfs)
|
155
|
-
"lib/rubygems/path_support.rb" => rubygems_path_support_patch,
|
144
|
+
"lib/rubygems/path_support.rb" => rubygems_path_support_patch(@mount_point),
|
156
145
|
|
157
146
|
# ....................................................
|
158
147
|
# Disable dynamic extensions
|
@@ -170,46 +159,10 @@ module Tebako
|
|
170
159
|
# ....................................................
|
171
160
|
# autoload :OpenSSL, "openssl"
|
172
161
|
# fails to deal with a default gem from statically linked extension
|
173
|
-
pm.store("lib/rubygems/openssl.rb",
|
162
|
+
pm.store("lib/rubygems/openssl.rb", RUBYGEMS_OPENSSL_RB_PATCH) if @ruby_ver.ruby3x?
|
174
163
|
|
175
164
|
pm.freeze
|
176
165
|
end
|
177
|
-
|
178
|
-
private
|
179
|
-
|
180
|
-
def rubygems_path_support_patch_one
|
181
|
-
<<~SUBST
|
182
|
-
@home = env["GEM_HOME"] || Gem.default_dir
|
183
|
-
# -- Start of tebako patch --
|
184
|
-
unless env["TEBAKO_PASS_THROUGH"]
|
185
|
-
@home = Gem.default_dir unless @home.index("#{@mount_point}") == 0
|
186
|
-
end
|
187
|
-
# -- End of tebako patch --
|
188
|
-
|
189
|
-
SUBST
|
190
|
-
end
|
191
|
-
|
192
|
-
def rubygems_path_support_patch_two
|
193
|
-
<<~SUBST
|
194
|
-
|
195
|
-
@path = split_gem_path env["GEM_PATH"], @home
|
196
|
-
# -- Start of tebako patch --
|
197
|
-
unless env["TEBAKO_PASS_THROUGH"]
|
198
|
-
@path.keep_if do |xpath|
|
199
|
-
xpath.index("#{@mount_point}") == 0
|
200
|
-
end
|
201
|
-
end
|
202
|
-
# -- End of tebako patch --
|
203
|
-
|
204
|
-
SUBST
|
205
|
-
end
|
206
|
-
|
207
|
-
def rubygems_path_support_patch
|
208
|
-
{
|
209
|
-
' @home = env["GEM_HOME"] || Gem.default_dir' => rubygems_path_support_patch_one,
|
210
|
-
' @path = split_gem_path env["GEM_PATH"], @home' => rubygems_path_support_patch_two
|
211
|
-
}
|
212
|
-
end
|
213
166
|
end
|
214
167
|
|
215
168
|
# Ruby patching definitions (pass1 - darwin)
|
@@ -233,7 +186,7 @@ module Tebako
|
|
233
186
|
|
234
187
|
WIN32_WINMAIN_C_PATCH = {
|
235
188
|
"WinMain(HINSTANCE current, HINSTANCE prev, LPSTR cmdline, int showcmd)" =>
|
236
|
-
"wWinMain(HINSTANCE current, HINSTANCE prev, LPWSTR cmdline, int showcmd)"
|
189
|
+
"wWinMain(HINSTANCE current, HINSTANCE prev, LPWSTR cmdline, int showcmd) /* tebako patched */"
|
237
190
|
}.freeze
|
238
191
|
|
239
192
|
def patch_map
|
@@ -249,23 +202,21 @@ module Tebako
|
|
249
202
|
def gnumakefile_in_patch_p1 # rubocop:disable Metrics/MethodLength
|
250
203
|
objext = @ruby_ver.ruby32? ? "$(OBJEXT)" : "@OBJEXT@"
|
251
204
|
{
|
252
|
-
"
|
253
|
-
"# tebako patched DLLWRAP += -mno-cygwin",
|
205
|
+
"$(Q) $(DLLWRAP) \\" => GNUMAKEFILE_IN_DLLTOOL_SUBST,
|
254
206
|
|
255
207
|
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext}" =>
|
256
208
|
"$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext} $(WINMAINOBJ) # tebako patched",
|
257
209
|
|
258
210
|
"$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@" =>
|
211
|
+
|
259
212
|
"$(WINMAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ # tebako patched",
|
260
213
|
|
261
|
-
"--output-exp=$(RUBY_EXP) \\" =>
|
262
|
-
"--output-exp=$(RUBY_EXP) --output-lib=$(LIBRUBY) --output-def=tebako.def \\",
|
214
|
+
"--output-exp=$(RUBY_EXP) \\" => "# tebako patched --output-exp=$(RUBY_EXP) \\",
|
263
215
|
|
264
216
|
"--export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)" =>
|
265
|
-
"--export-all $(LIBRUBY_A) $(LIBS) -o
|
217
|
+
"# tebako patched --export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)",
|
266
218
|
|
267
|
-
"@rm -f $(PROGRAM)" =>
|
268
|
-
"@rm -f program-stub.exe # tebako patched",
|
219
|
+
"@rm -f $(PROGRAM)" => "# tebako patched @rm -f $(PROGRAM)",
|
269
220
|
|
270
221
|
" $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)" =>
|
271
222
|
"# tebako patched $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)",
|
@@ -288,7 +239,7 @@ module Tebako
|
|
288
239
|
def msys_patches
|
289
240
|
pm = msys_base_patches
|
290
241
|
|
291
|
-
if @ruby_ver.
|
242
|
+
if @ruby_ver.ruby337?
|
292
243
|
# ....................................................
|
293
244
|
# RUBY_EXTERN shall be extern for static build but is set to __declspec(dllimport) for encodin libarary
|
294
245
|
pm.store("include/ruby/onigmo.h", INCLUDE_RUBY_ONIGMO_H_PATCH)
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2021-2024 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions
|
9
|
+
# are met:
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
require_relative "patch_literals"
|
29
|
+
require_relative "patch_main"
|
30
|
+
require_relative "patch_libraries"
|
31
|
+
require_relative "patch_helpers"
|
32
|
+
require_relative "patch_buildsystem"
|
33
|
+
|
34
|
+
# Tebako - an executable packager
|
35
|
+
module Tebako
|
36
|
+
module Packager
|
37
|
+
# Ruby patching definitions (pass2)
|
38
|
+
class Pass2Patch < Patch
|
39
|
+
def initialize(ostype, deps_lib_dir, ruby_ver)
|
40
|
+
super()
|
41
|
+
@ostype = ostype
|
42
|
+
@scmb = ScenarioManagerBase.new(@ostype)
|
43
|
+
@deps_lib_dir = deps_lib_dir
|
44
|
+
@ruby_ver = ruby_ver
|
45
|
+
end
|
46
|
+
|
47
|
+
def patch_map
|
48
|
+
patch_map = patch_map_base
|
49
|
+
patch_map.store("thread_pthread.c", LINUX_MUSL_THREAD_PTHREAD_PATCH) if @scmb.musl?
|
50
|
+
if @scmb.msys?
|
51
|
+
patch_map.merge!(msys_patches)
|
52
|
+
elsif @ruby_ver.ruby3x?
|
53
|
+
patch_map.store("common.mk", COMMON_MK_PATCH)
|
54
|
+
end
|
55
|
+
extend_patch_map_r33(patch_map)
|
56
|
+
patch_map.store("prism_compile.c", PRISM_PATCHES) if @ruby_ver.ruby34?
|
57
|
+
patch_map
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
include Tebako::Packager::PatchBuildsystem
|
63
|
+
include Tebako::Packager::PatchLiterals
|
64
|
+
def extend_patch_map_r33(patch_map)
|
65
|
+
if @ruby_ver.ruby33? || @scmb.msys?
|
66
|
+
patch_map.store("config.status",
|
67
|
+
get_config_status_patch(@ostype, @deps_lib_dir, @ruby_ver))
|
68
|
+
end
|
69
|
+
patch_map
|
70
|
+
end
|
71
|
+
|
72
|
+
def dir_c_patch
|
73
|
+
pattern = ScenarioManagerBase.new.msys? ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST"
|
74
|
+
patch = PatchHelpers.patch_c_file_pre(pattern)
|
75
|
+
patch.merge!(DIR_C_BASE_PATCH)
|
76
|
+
patch
|
77
|
+
end
|
78
|
+
|
79
|
+
def dln_c_patch
|
80
|
+
pattern = "#ifndef dln_loaderror"
|
81
|
+
# Not using substitutions of dlxxx functions on Windows
|
82
|
+
patch = {
|
83
|
+
pattern => "#{@scmb.msys? ? C_FILE_SUBST_LESS : C_FILE_SUBST}\n#{pattern}\n"
|
84
|
+
}
|
85
|
+
|
86
|
+
if @scmb.msys?
|
87
|
+
patch.merge!(@ruby_ver.ruby32? ? DLN_C_MSYS_PATCH : DLN_C_MSYS_PATCH_PRE32)
|
88
|
+
end
|
89
|
+
|
90
|
+
patch
|
91
|
+
end
|
92
|
+
|
93
|
+
def io_c_msys_patch
|
94
|
+
patch = @ruby_ver.ruby32? ? IO_C_MSYS_PATCH : IO_C_MSYS_PATCH_PRE_32
|
95
|
+
patch.merge(IO_C_MSYS_BASE_PATCH)
|
96
|
+
end
|
97
|
+
|
98
|
+
def io_c_patch
|
99
|
+
patch = PatchHelpers.patch_c_file_pre("/* define system APIs */")
|
100
|
+
patch.merge!(io_c_msys_patch) if @scmb.msys?
|
101
|
+
patch
|
102
|
+
end
|
103
|
+
|
104
|
+
def util_c_patch
|
105
|
+
if @ruby_ver.ruby31?
|
106
|
+
PatchHelpers.patch_c_file_post("#endif /* !HAVE_GNU_QSORT_R */")
|
107
|
+
else
|
108
|
+
PatchHelpers.patch_c_file_pre("#ifndef S_ISDIR")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def tool_mkconfig_rb_patch
|
113
|
+
subst = @scmb.msys? ? TOOL_MKCONFIG_RB_SUBST_MSYS : TOOL_MKCONFIG_RB_SUBST
|
114
|
+
{
|
115
|
+
" if fast[name]" => subst
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
def msys_patches
|
120
|
+
{
|
121
|
+
"cygwin/GNUmakefile.in" => get_gnumakefile_in_patch_p2(@ruby_ver),
|
122
|
+
"ruby.c" => RUBY_C_MSYS_PATCHES,
|
123
|
+
"win32/file.c" => WIN32_FILE_C_MSYS_PATCHES,
|
124
|
+
"win32/win32.c" => WIN32_WIN32_C_MSYS_PATCHES
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
def patch_map_base
|
129
|
+
{
|
130
|
+
"template/Makefile.in" => template_makefile_in_patch,
|
131
|
+
"tool/mkconfig.rb" => tool_mkconfig_rb_patch,
|
132
|
+
"dir.c" => dir_c_patch, "dln.c" => dln_c_patch,
|
133
|
+
"io.c" => io_c_patch, "main.c" => PatchMain.get_main_c_patch(@ruby_ver),
|
134
|
+
"file.c" => PatchHelpers.patch_c_file_pre("/* define system APIs */"),
|
135
|
+
"util.c" => util_c_patch
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
def mlibs_subst
|
140
|
+
yjit_libs = @ruby_ver.ruby32only? ? "$(YJIT_LIBS) " : ""
|
141
|
+
{
|
142
|
+
"MAINLIBS = #{yjit_libs}@MAINLIBS@" =>
|
143
|
+
"# -- Start of tebako patch -- \n" \
|
144
|
+
"MAINLIBS = #{yjit_libs}#{PatchLibraries.mlibs(@ostype, @deps_lib_dir, @ruby_ver, true)}\n" \
|
145
|
+
"# -- End of tebako patch -- \n"
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def template_makefile_in_patch
|
150
|
+
template_makefile_in_patch_two(@ruby_ver).merge(mlibs_subst)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -77,8 +77,8 @@ module Tebako
|
|
77
77
|
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
78
78
|
"# -- End of tebako patch --"
|
79
79
|
|
80
|
-
def template_makefile_in_subst(
|
81
|
-
if
|
80
|
+
def template_makefile_in_subst(ruby_ver)
|
81
|
+
if ScenarioManagerBase.new.msys?
|
82
82
|
TEMPLATE_MAKEFILE_IN_BASE_PATCH_MSYS
|
83
83
|
elsif !ruby_ver.ruby31?
|
84
84
|
TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1
|
@@ -87,16 +87,20 @@ module Tebako
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def template_makefile_in_patch_two(
|
90
|
+
def template_makefile_in_patch_two(ruby_ver)
|
91
91
|
if !ruby_ver.ruby31?
|
92
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => template_makefile_in_subst(
|
92
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => template_makefile_in_subst(ruby_ver) }
|
93
93
|
elsif !ruby_ver.ruby33?
|
94
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_3 => template_makefile_in_subst(
|
94
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_3 => template_makefile_in_subst(ruby_ver) }
|
95
95
|
else
|
96
|
-
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => template_makefile_in_subst(
|
96
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => template_makefile_in_subst(ruby_ver) }
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
GNUMAKEFILE_IN_DLLTOOL_SUBST = <<~SUBST
|
101
|
+
$(Q) dlltool --output-lib=$(LIBRUBY) --output-def=tebako.def --export-all $(LIBRUBY_A) --output-exp=$(RUBY_EXP) # tebako patched
|
102
|
+
SUBST
|
103
|
+
|
100
104
|
# This MSYS specific thing ensure compilation of winmain.c
|
101
105
|
# Did try to understand why it did not work out of the box
|
102
106
|
GNUMAKEFILE_IN_WINMAIN_SUBST = <<~SUBST
|
@@ -62,18 +62,6 @@ module Tebako
|
|
62
62
|
out
|
63
63
|
end
|
64
64
|
|
65
|
-
def exe_suffix(ostype)
|
66
|
-
msys?(ostype) ? ".exe" : ""
|
67
|
-
end
|
68
|
-
|
69
|
-
def msys?(ostype)
|
70
|
-
ostype =~ /msys|cygwin|mingw/
|
71
|
-
end
|
72
|
-
|
73
|
-
def macos?(ostype)
|
74
|
-
ostype =~ /darwin/
|
75
|
-
end
|
76
|
-
|
77
65
|
def patch_c_file_pre(pattern)
|
78
66
|
{
|
79
67
|
pattern => "#{PatchLiterals::C_FILE_SUBST}\n#{pattern}"
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024-2025 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions
|
9
|
+
# are met:
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
require_relative "patch"
|
29
|
+
# Tebako - an executable packager
|
30
|
+
module Tebako
|
31
|
+
module Packager
|
32
|
+
# Shared accross Pass1Patch and RybugemsUpdatePatch
|
33
|
+
class RubygemsPatch < Patch
|
34
|
+
RUBYGEMS_OPENSSL_RB_SUBST = <<~SUBST
|
35
|
+
# Start of tebako patch
|
36
|
+
require "openssl"
|
37
|
+
# End of tebako patch
|
38
|
+
autoload :OpenSSL, "openssl"
|
39
|
+
SUBST
|
40
|
+
|
41
|
+
RUBYGEMS_OPENSSL_RB_PATCH = {
|
42
|
+
'autoload :OpenSSL, "openssl"' => RUBYGEMS_OPENSSL_RB_SUBST
|
43
|
+
}.freeze
|
44
|
+
|
45
|
+
def initialize(mount_point)
|
46
|
+
super()
|
47
|
+
@mount_point = mount_point
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def rubygems_path_support_patch(mount_point)
|
53
|
+
patch = <<~SUBST
|
54
|
+
# -- Start of tebako patch --
|
55
|
+
@home = Gem.default_dir unless @home.index("#{mount_point}") == 0 unless env["TEBAKO_PASS_THROUGH"]
|
56
|
+
# -- End of tebako patch --
|
57
|
+
@path = split_gem_path env["GEM_PATH"], @home
|
58
|
+
# -- Start of tebako patch --
|
59
|
+
@path.keep_if do |xpath|
|
60
|
+
xpath.index("#{mount_point}") == 0
|
61
|
+
end unless env["TEBAKO_PASS_THROUGH"]
|
62
|
+
# -- End of tebako patch --
|
63
|
+
SUBST
|
64
|
+
|
65
|
+
{
|
66
|
+
' @path = split_gem_path env["GEM_PATH"], @home' => patch
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Rubygems patch after update
|
72
|
+
class RubygemsUpdatePatch < RubygemsPatch
|
73
|
+
def patch_map
|
74
|
+
pm = {
|
75
|
+
"rubygems/openssl.rb" => RUBYGEMS_OPENSSL_RB_PATCH,
|
76
|
+
"rubygems/path_support.rb" => rubygems_path_support_patch(@mount_point)
|
77
|
+
}
|
78
|
+
pm.merge!(super)
|
79
|
+
pm.freeze
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/tebako/packager.rb
CHANGED
@@ -35,7 +35,7 @@ require_relative "ruby_builder"
|
|
35
35
|
require_relative "stripper"
|
36
36
|
require_relative "packager/pass1_patch"
|
37
37
|
require_relative "packager/pass1a_patch"
|
38
|
-
require_relative "packager/
|
38
|
+
require_relative "packager/pass2_patch"
|
39
39
|
require_relative "packager/patch_helpers"
|
40
40
|
|
41
41
|
# Tebako - an executable packager
|
@@ -89,15 +89,20 @@ module Tebako
|
|
89
89
|
Tebako::Stripper.strip(deploy_helper, target_dir)
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
92
|
+
def do_patch(patch_map, root)
|
93
|
+
patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
|
94
|
+
end
|
95
|
+
|
96
|
+
def finalize(src_dir, app_name, ruby_ver, patchelf)
|
93
97
|
puts "-- Running finalize script"
|
94
98
|
|
95
99
|
RubyBuilder.new(ruby_ver, src_dir).target_build
|
96
|
-
exe_suffix =
|
100
|
+
exe_suffix = ScenarioManagerBase.new.exe_suffix
|
97
101
|
src_name = File.join(src_dir, "ruby#{exe_suffix}")
|
98
102
|
patchelf(src_name, patchelf)
|
99
103
|
package_name = "#{app_name}#{exe_suffix}"
|
100
|
-
strip_or_copy(os_type, src_name, package_name)
|
104
|
+
# strip_or_copy(os_type, src_name, package_name)
|
105
|
+
Tebako::Stripper.strip_file(src_name, package_name)
|
101
106
|
puts "Created tebako package at \"#{package_name}\""
|
102
107
|
end
|
103
108
|
|
@@ -145,7 +150,8 @@ module Tebako
|
|
145
150
|
def pass2(ostype, ruby_source_dir, deps_lib_dir, ruby_ver)
|
146
151
|
puts "-- Running pass2 script"
|
147
152
|
|
148
|
-
|
153
|
+
patch = Pass2Patch.new(ostype, deps_lib_dir, ruby_ver).patch_map
|
154
|
+
do_patch(patch, ruby_source_dir)
|
149
155
|
end
|
150
156
|
|
151
157
|
# Stash
|
@@ -183,10 +189,6 @@ module Tebako
|
|
183
189
|
File.join(src_dir, "lib", "libx64-ucrt-ruby#{ruby_ver.lib_version}.a")
|
184
190
|
end
|
185
191
|
|
186
|
-
def do_patch(patch_map, root)
|
187
|
-
patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
|
188
|
-
end
|
189
|
-
|
190
192
|
def patchelf(src_name, patchelf)
|
191
193
|
return if patchelf.nil?
|
192
194
|
|
@@ -194,15 +196,15 @@ module Tebako
|
|
194
196
|
BuildHelpers.run_with_capture(params)
|
195
197
|
end
|
196
198
|
|
197
|
-
def strip_or_copy(
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
end
|
199
|
+
# def strip_or_copy(_os_type, src_name, package_name)
|
200
|
+
# [TODO] On MSys strip sometimes creates a broken executable
|
201
|
+
# https://github.com/tamatebako/tebako/issues/172
|
202
|
+
# if Packager::PatchHelpers.msys?(os_type)
|
203
|
+
# FileUtils.cp(src_name, package_name)
|
204
|
+
# else
|
205
|
+
# Tebako::Stripper.strip_file(src_name, package_name)
|
206
|
+
# end
|
207
|
+
# end
|
206
208
|
end
|
207
209
|
end
|
208
210
|
end
|
data/lib/tebako/ruby_builder.rb
CHANGED
data/lib/tebako/ruby_version.rb
CHANGED
@@ -43,6 +43,7 @@ module Tebako
|
|
43
43
|
"3.3.4" => "fe6a30f97d54e029768f2ddf4923699c416cdbc3a6e96db3e2d5716c7db96a34",
|
44
44
|
"3.3.5" => "3781a3504222c2f26cb4b9eb9c1a12dbf4944d366ce24a9ff8cf99ecbce75196",
|
45
45
|
"3.3.6" => "8dc48fffaf270f86f1019053f28e51e4da4cce32a36760a0603a9aee67d7fd8d",
|
46
|
+
"3.3.7" => "9c37c3b12288c7aec20ca121ce76845be5bb5d77662a24919651aaf1d12c8628",
|
46
47
|
"3.4.1" => "3d385e5d22d368b064c817a13ed8e3cc3f71a7705d7ed1bae78013c33aa7c87f"
|
47
48
|
}.freeze
|
48
49
|
|
@@ -89,6 +90,10 @@ module Tebako
|
|
89
90
|
@ruby33 ||= ruby3x? && @ruby_version[2].to_i >= 3
|
90
91
|
end
|
91
92
|
|
93
|
+
def ruby337?
|
94
|
+
@ruby337 ||= ruby34? || (ruby33? && @ruby_version[2] == "3" && @ruby_version[4].to_i >= 7)
|
95
|
+
end
|
96
|
+
|
92
97
|
def ruby34?
|
93
98
|
@ruby34 ||= ruby3x? && @ruby_version[2].to_i >= 4
|
94
99
|
end
|
@@ -115,8 +120,7 @@ module Tebako
|
|
115
120
|
end
|
116
121
|
|
117
122
|
def version_check_msys
|
118
|
-
if Gem::Version.new(@ruby_version) < Gem::Version.new(MIN_RUBY_VERSION_WINDOWS) &&
|
119
|
-
RUBY_PLATFORM =~ /msys|mingw|cygwin/
|
123
|
+
if Gem::Version.new(@ruby_version) < Gem::Version.new(MIN_RUBY_VERSION_WINDOWS) && ScenarioManagerBase.new.msys?
|
120
124
|
raise Tebako::Error.new("Ruby version #{@ruby_version} is not supported on Windows", 111)
|
121
125
|
end
|
122
126
|
end
|
@@ -127,14 +131,14 @@ module Tebako
|
|
127
131
|
def initialize(ruby_version, gemfile_path)
|
128
132
|
# Assuming that it does not attempt to load any gems or resolve dependencies
|
129
133
|
# this can be done with any bundler version
|
130
|
-
|
131
|
-
ruby_v = gemfile.ruby_version&.versions
|
134
|
+
ruby_v = Bundler::Definition.build(gemfile_path, nil, nil).ruby_version&.versions
|
132
135
|
if ruby_v.nil?
|
133
136
|
super(ruby_version)
|
134
137
|
else
|
135
138
|
process_gemfile_ruby_version(ruby_version, ruby_v)
|
136
|
-
run_checks
|
137
139
|
end
|
140
|
+
rescue Tebako::Error
|
141
|
+
raise
|
138
142
|
rescue StandardError => e
|
139
143
|
Tebako.packaging_error(115, e.message)
|
140
144
|
end
|
@@ -148,12 +152,13 @@ module Tebako
|
|
148
152
|
else
|
149
153
|
process_gemfile_ruby_version_d(ruby_version, requirement)
|
150
154
|
end
|
155
|
+
run_checks
|
151
156
|
end
|
152
157
|
|
153
158
|
def process_gemfile_ruby_version_d(ruby_version, requirement)
|
154
159
|
current_version = Gem::Version.new(ruby_version)
|
155
160
|
unless requirement.satisfied_by?(current_version)
|
156
|
-
raise Tebako::Error.new("Ruby version #{ruby_version} does not satisfy requirement #{
|
161
|
+
raise Tebako::Error.new("Ruby version #{ruby_version} does not satisfy requirement '#{requirement}'", 116)
|
157
162
|
end
|
158
163
|
|
159
164
|
@ruby_version = ruby_version
|