tebako 0.10.0 → 0.12.0

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.
@@ -37,15 +37,17 @@ module Tebako
37
37
  "3.1.6" => "0d0dafb859e76763432571a3109d1537d976266be3083445651dc68deed25c22",
38
38
  "3.2.4" => "c72b3c5c30482dca18b0f868c9075f3f47d8168eaf626d4e682ce5b59c858692",
39
39
  "3.2.5" => "ef0610b498f60fb5cfd77b51adb3c10f4ca8ed9a17cb87c61e5bea314ac34a16",
40
+ "3.2.6" => "d9cb65ecdf3f18669639f2638b63379ed6fbb17d93ae4e726d4eb2bf68a48370",
40
41
  "3.3.3" => "83c05b2177ee9c335b631b29b8c077b4770166d02fa527f3a9f6a40d13f3cce2",
41
42
  "3.3.4" => "fe6a30f97d54e029768f2ddf4923699c416cdbc3a6e96db3e2d5716c7db96a34",
42
- "3.3.5" => "3781a3504222c2f26cb4b9eb9c1a12dbf4944d366ce24a9ff8cf99ecbce75196"
43
+ "3.3.5" => "3781a3504222c2f26cb4b9eb9c1a12dbf4944d366ce24a9ff8cf99ecbce75196",
44
+ "3.3.6" => "8dc48fffaf270f86f1019053f28e51e4da4cce32a36760a0603a9aee67d7fd8d",
45
+ "3.4.1" => "3d385e5d22d368b064c817a13ed8e3cc3f71a7705d7ed1bae78013c33aa7c87f"
43
46
  }.freeze
44
47
 
45
48
  MIN_RUBY_VERSION_WINDOWS = "3.1.6"
46
- DEFAULT_RUBY_VERSION = "3.2.5"
49
+ DEFAULT_RUBY_VERSION = "3.2.6"
47
50
 
48
- # rub_ver version = options["Ruby"].nil? ? DEFAULT_RUBY_VERSION : options["Ruby"]
49
51
  def initialize(ruby_version)
50
52
  @ruby_version = ruby_version.nil? ? DEFAULT_RUBY_VERSION : ruby_version
51
53
 
@@ -76,6 +78,10 @@ module Tebako
76
78
  @ruby33 ||= ruby3x? && @ruby_version[2].to_i >= 3
77
79
  end
78
80
 
81
+ def ruby34?
82
+ @ruby34 ||= ruby3x? && @ruby_version[2].to_i >= 4
83
+ end
84
+
79
85
  def api_version
80
86
  @api_version ||= "#{@ruby_version.split(".")[0..1].join(".")}.0"
81
87
  end
@@ -35,7 +35,7 @@ module Tebako
35
35
  class ScenarioManager
36
36
  def initialize(fs_root, fs_entrance)
37
37
  initialize_root(fs_root)
38
- initialize_entry_point(fs_entrance)
38
+ initialize_entry_point(fs_entrance || "stub.rb")
39
39
  end
40
40
 
41
41
  attr_reader :fs_entry_point, :fs_mount_point, :fs_entrance
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.10.0"
29
+ VERSION = "0.12.0"
30
30
  end
data/src/tebako-main.cpp CHANGED
@@ -53,9 +53,20 @@
53
53
  #include <tebako/tebako-version.h>
54
54
  #include <tebako/tebako-main.h>
55
55
  #include <tebako/tebako-fs.h>
56
- #include <tebako/tebako-cmdline-helpers.h>
56
+ #include <tebako/tebako-cmdline.h>
57
57
 
58
58
  static int running_miniruby = 0;
59
+ static tebako::cmdline_args* args = nullptr;
60
+ static std::vector<char> package;
61
+
62
+ static void tebako_clean(void)
63
+ {
64
+ unmount_root_memfs();
65
+ if (args) {
66
+ delete args;
67
+ args = nullptr;
68
+ }
69
+ }
59
70
 
60
71
  extern "C" int tebako_main(int* argc, char*** argv)
61
72
  {
@@ -70,26 +81,41 @@ extern "C" int tebako_main(int* argc, char*** argv)
70
81
  running_miniruby = -1;
71
82
  }
72
83
  else {
84
+ std::string mount_point = tebako::fs_mount_point;
85
+ std::string entry_point = tebako::fs_entry_point;
86
+ std::optional<std::string> cwd;
87
+ if (tebako::package_cwd != nullptr) {
88
+ cwd = tebako::package_cwd;
89
+ }
90
+ const void* data = &gfsData[0];
91
+ size_t size = gfsSize;
92
+
73
93
  try {
74
- fsret = mount_root_memfs(&gfsData[0], gfsSize, tebako::fs_log_level, nullptr, nullptr, nullptr, nullptr, nullptr);
94
+ args = new tebako::cmdline_args(*argc, (const char**)*argv);
95
+ args->parse_arguments();
96
+ if (args->with_application()) {
97
+ args->process_package();
98
+ auto descriptor = args->get_descriptor();
99
+ package = std::move(args->get_package());
100
+ if (descriptor.has_value()) {
101
+ mount_point = descriptor->get_mount_point().c_str();
102
+ entry_point = descriptor->get_entry_point().c_str();
103
+ cwd = descriptor->get_cwd();
104
+ data = package.data();
105
+ size = package.size();
106
+ }
107
+ }
75
108
 
109
+ fsret = mount_root_memfs(data, size, tebako::fs_log_level, nullptr, nullptr, nullptr, nullptr, "auto");
76
110
  if (fsret == 0) {
77
- if ((*argc > 1) && strcmp((*argv)[1], "--tebako-extract") == 0) {
78
- ret = tebako::build_arguments_for_extract(argc, argv, tebako::fs_mount_point);
79
- }
80
- else {
81
- auto [mountpoints, parsed_argv] = tebako::parse_arguments(*argc, *argv);
82
- // for (auto& mp : mountpoints) {
83
- // printf("Mountpoint: %s\n", mp.c_str());
84
- // }
85
- tebako::process_mountpoints(mountpoints);
86
- std::tie(*argc, *argv) = tebako::build_arguments(parsed_argv, tebako::fs_mount_point, tebako::fs_entry_point);
87
- ret = 0;
88
- }
111
+ args->process_mountpoints();
112
+ args->build_arguments(mount_point.c_str(), entry_point.c_str());
113
+ *argc = args->get_argc();
114
+ *argv = args->get_argv();
115
+ ret = 0;
116
+ atexit(tebako_clean);
89
117
  }
90
- atexit(unmount_root_memfs);
91
118
  }
92
-
93
119
  catch (std::exception e) {
94
120
  printf("Failed to process command line: %s\n", e.what());
95
121
  }
@@ -99,9 +125,9 @@ extern "C" int tebako_main(int* argc, char*** argv)
99
125
  ret = -1;
100
126
  }
101
127
 
102
- if (tebako::package_cwd != nullptr) {
103
- if (tebako_chdir(tebako::package_cwd) != 0) {
104
- printf("Failed to chdir to '%s' : %s\n", tebako::package_cwd, strerror(errno));
128
+ if (cwd.has_value()) {
129
+ if (tebako_chdir(cwd->c_str()) != 0) {
130
+ printf("Failed to chdir to '%s' : %s\n", cwd->c_str(), strerror(errno));
105
131
  ret = -1;
106
132
  }
107
133
  }
@@ -110,17 +136,7 @@ extern "C" int tebako_main(int* argc, char*** argv)
110
136
  if (ret != 0) {
111
137
  try {
112
138
  printf("Tebako initialization failed\n");
113
- if (new_argv) {
114
- delete new_argv;
115
- new_argv = nullptr;
116
- }
117
- if (argv_memory) {
118
- delete argv_memory;
119
- argv_memory = nullptr;
120
- }
121
- if (fsret == 0) {
122
- unmount_root_memfs();
123
- }
139
+ tebako_clean();
124
140
  }
125
141
  catch (...) {
126
142
  // Nested error, no recovery :(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tebako
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-13 00:00:00.000000000 Z
11
+ date: 2025-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -162,6 +162,7 @@ files:
162
162
  - exe/tebako-packager
163
163
  - include/tebako/tebako-fs.h
164
164
  - include/tebako/tebako-main.h
165
+ - include/tebako/tebako-prism.h
165
166
  - lib/tebako.rb
166
167
  - lib/tebako/build_helpers.rb
167
168
  - lib/tebako/cache_manager.rb
@@ -171,15 +172,18 @@ files:
171
172
  - lib/tebako/deploy_helper.rb
172
173
  - lib/tebako/error.rb
173
174
  - lib/tebako/options_manager.rb
175
+ - lib/tebako/package_descriptor.rb
174
176
  - lib/tebako/packager.rb
175
- - lib/tebako/packager/pass1.rb
176
- - lib/tebako/packager/pass1a.rb
177
+ - lib/tebako/packager/pass1_patch.rb
178
+ - lib/tebako/packager/pass1a_patch.rb
177
179
  - lib/tebako/packager/pass2.rb
180
+ - lib/tebako/packager/patch.rb
178
181
  - lib/tebako/packager/patch_buildsystem.rb
179
182
  - lib/tebako/packager/patch_helpers.rb
180
183
  - lib/tebako/packager/patch_libraries.rb
181
184
  - lib/tebako/packager/patch_literals.rb
182
185
  - lib/tebako/packager/patch_main.rb
186
+ - lib/tebako/packager_lite.rb
183
187
  - lib/tebako/ruby_builder.rb
184
188
  - lib/tebako/ruby_version.rb
185
189
  - lib/tebako/scenario_manager.rb
@@ -1,242 +0,0 @@
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_helpers"
30
- require_relative "patch_buildsystem"
31
-
32
- # Tebako - an executable packager
33
- module Tebako
34
- module Packager
35
- # Ruby patching definitions (pass1)
36
- module Pass1
37
- # [TODO] looks like it does not exist in 3.1.4
38
- # May be obsolete
39
- TOOL_RBINSTALL_RB_PATCH = {
40
- " next if files.empty?" => "# tebako patched next if files.empty?"
41
- }.freeze
42
-
43
- RUBYGEM_OPENSSL_RB_SUBST = <<~SUBST
44
- # Start of tebako patch
45
- require "openssl"
46
- # End of tebako patch
47
- autoload :OpenSSL, "openssl"
48
- SUBST
49
-
50
- RUBYGEM_OPENSSL_RB_PATCH = {
51
- 'autoload :OpenSSL, "openssl"' => RUBYGEM_OPENSSL_RB_SUBST
52
- }.freeze
53
-
54
- EXT_SETUP_PATCH = {
55
- "#option nodynamic" => "option nodynamic"
56
- }.freeze
57
-
58
- EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH = {
59
- "#include \"ruby/ruby.h\"" => <<~SUBST
60
- #include "ruby/ruby.h"
61
-
62
- /* -- Start of tebako patch -- */
63
- #ifndef HAVE_RB_SYM2STR
64
- #define HAVE_RB_SYM2STR 1
65
- #endif
66
-
67
- #ifndef HAVE_RB_ARRAY_CONST_PTR
68
- #define HAVE_RB_ARRAY_CONST_PTR 1
69
- #endif
70
-
71
- #ifndef HAVE_RB_RATIONAL_NUM
72
- #define HAVE_RB_RATIONAL_NUM 1
73
- #endif
74
-
75
- #ifndef HAVE_RB_RATIONAL_DEN
76
- #define HAVE_RB_RATIONAL_DEN 1
77
- #endif
78
-
79
- #ifndef HAVE_RB_COMPLEX_REAL
80
- #define HAVE_RB_COMPLEX_REAL
81
- #endif
82
-
83
- #ifndef HAVE_RB_COMPLEX_IMAG
84
- #define HAVE_RB_COMPLEX_IMAG
85
- #endif
86
- /* -- End of tebako patch -- */
87
-
88
- SUBST
89
- }.freeze
90
-
91
- # The logic for statically linked extensions is broken entirely in the latest Ruby versions.
92
- # The code below looks reasonble - we do not set -bundle_loader when building with -with-static-ext option
93
- # However Gems bundled with Ruby just ignore with-static-ext option and build extensions as shared libraries
94
- # So the -bundler_loader option is required for them to link.
95
- # It is strange that it is disabled in any case because this option does not create any issues for static
96
- # libraries.
97
- # ---------------------------------------------------
98
- # elif test "x$EXTSTATIC" = x
99
- # then :
100
- #
101
- # # When building exts as bundles, a mach-o bundle needs to know its loader
102
- # # program to bind symbols from the ruby executable
103
- # EXTDLDFLAGS="-bundle_loader '\$(BUILTRUBY)'"
104
-
105
- DARWIN_CONFIGURE_PATCH = {
106
- "elif test \"x$EXTSTATIC\" = x" => "elif true"
107
- }.freeze
108
-
109
- OPENSSL_EXTCONF_RB_SUBST = <<~SUBST
110
- # Start of tebako patch
111
- $defs.push("-DRUBY_EXPORT=1")
112
- # End of tebako patch
113
-
114
- Logging::message "=== Checking done. ===\\n"
115
- SUBST
116
-
117
- OPENSSL_EXTCONF_RB_PATCH = {
118
- "Logging::message \"=== Checking done. ===\\n\"" => OPENSSL_EXTCONF_RB_SUBST
119
- }.freeze
120
-
121
- class << self
122
- def get_base_patch_map(mount_point)
123
- {
124
- # ....................................................
125
- # It won't install gems with no files defined in spec
126
- # However if
127
- # -- we are installing a default gem from extension
128
- # -- extension is build statically
129
- # there may be no files install in addition to spec
130
- # Example: io/wait extension (and others)
131
- # [TODO] Check if it is still required
132
- # No match and patching on Ruby 3.1.4 but works wo issues
133
- "tool/rbinstall.rb" => TOOL_RBINSTALL_RB_PATCH,
134
-
135
- # ....................................................
136
- # This is something that I cannnot explain
137
- # (this patch does not seem related to static compilation)
138
- "ext/bigdecimal/bigdecimal.h" => EXT_BIGDECIMAL_BIGDECIMAL_H_PATCH,
139
-
140
- # ....................................................
141
- # Allow only packaged gems (from within memfs)
142
- "lib/rubygems/path_support.rb" => rubygems_path_support_patch(mount_point),
143
-
144
- # ....................................................
145
- # Disable dynamic extensions
146
- "ext/Setup" => EXT_SETUP_PATCH
147
- }
148
- end
149
-
150
- def get_patch_map(ostype, mount_point, ruby_ver)
151
- patch_map = get_base_patch_map(mount_point)
152
-
153
- # ....................................................
154
- patch_map.store("configure", DARWIN_CONFIGURE_PATCH) if ostype =~ /darwin/
155
-
156
- # ....................................................
157
- # autoload :OpenSSL, "openssl"
158
- # fails to deal with a default gem from statically linked extension
159
- patch_map.store("lib/rubygems/openssl.rb", RUBYGEM_OPENSSL_RB_PATCH) if ruby_ver.ruby3x?
160
-
161
- if ostype =~ /msys/
162
- # ....................................................
163
- # Generate export definitions; use WinMain to build rubyw.exe
164
- patch_map.store("cygwin/GNUmakefile.in", get_gnumakefile_in_patch_p1(ruby_ver))
165
- # ....................................................
166
- # RUBY_EXPORT=1 (shall be set for static builds but is missing in openssl extension)
167
- patch_map.store("ext/openssl/extconf.rb", OPENSSL_EXTCONF_RB_PATCH)
168
- end
169
-
170
- patch_map
171
- end
172
-
173
- private
174
-
175
- include Tebako::Packager::PatchLiterals
176
- include Tebako::Packager::PatchBuildsystem
177
-
178
- def get_gnumakefile_in_patch_p1(ruby_ver) # rubocop:disable Metrics/MethodLength
179
- objext = ruby_ver.ruby32? ? "$(OBJEXT)" : "@OBJEXT@"
180
- {
181
- " DLLWRAP += -mno-cygwin" =>
182
- "# tebako patched DLLWRAP += -mno-cygwin",
183
-
184
- "$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext}" =>
185
- "$(WPROGRAM): $(RUBYW_INSTALL_NAME).res.#{objext} $(WINMAINOBJ) # tebako patched",
186
-
187
- "$(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@" =>
188
- "$(WINMAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) -o $@ # tebako patched",
189
-
190
- "--output-exp=$(RUBY_EXP) \\" =>
191
- "--output-exp=$(RUBY_EXP) --output-lib=$(LIBRUBY) --output-def=tebako.def \\",
192
-
193
- "--export-all $(LIBRUBY_A) $(LIBS) -o $(PROGRAM)" =>
194
- "--export-all $(LIBRUBY_A) $(LIBS) -o program-stub.exe # tebako patched",
195
-
196
- "@rm -f $(PROGRAM)" =>
197
- "@rm -f program-stub.exe # tebako patched",
198
-
199
- " $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)" =>
200
- "# tebako patched $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) dmyext.o $(SOLIBS) -o $(PROGRAM)",
201
-
202
- "RUBYDEF = $(DLL_BASE_NAME).def" => GNUMAKEFILE_IN_WINMAIN_SUBST
203
- }
204
- end
205
-
206
- def rubygems_path_support_patch_one(mount_point)
207
- <<~SUBST
208
- @home = env["GEM_HOME"] || Gem.default_dir
209
- # -- Start of tebako patch --
210
- unless env["TEBAKO_PASS_THROUGH"]
211
- @home = Gem.default_dir unless @home.index("#{mount_point}") == 0
212
- end
213
- # -- End of tebako patch --
214
-
215
- SUBST
216
- end
217
-
218
- def rubygems_path_support_patch_two(mount_point)
219
- <<~SUBST
220
-
221
- @path = split_gem_path env["GEM_PATH"], @home
222
- # -- Start of tebako patch --
223
- unless env["TEBAKO_PASS_THROUGH"]
224
- @path.keep_if do |xpath|
225
- xpath.index("#{mount_point}") == 0
226
- end
227
- end
228
- # -- End of tebako patch --
229
-
230
- SUBST
231
- end
232
-
233
- def rubygems_path_support_patch(mount_point)
234
- {
235
- ' @home = env["GEM_HOME"] || Gem.default_dir' => rubygems_path_support_patch_one(mount_point),
236
- ' @path = split_gem_path env["GEM_PATH"], @home' => rubygems_path_support_patch_two(mount_point)
237
- }
238
- end
239
- end
240
- end
241
- end
242
- end