tebako 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.10.0"
29
+ VERSION = "0.11.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.11.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: 2024-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -171,6 +171,7 @@ files:
171
171
  - lib/tebako/deploy_helper.rb
172
172
  - lib/tebako/error.rb
173
173
  - lib/tebako/options_manager.rb
174
+ - lib/tebako/package_descriptor.rb
174
175
  - lib/tebako/packager.rb
175
176
  - lib/tebako/packager/pass1.rb
176
177
  - lib/tebako/packager/pass1a.rb
@@ -180,6 +181,7 @@ files:
180
181
  - lib/tebako/packager/patch_libraries.rb
181
182
  - lib/tebako/packager/patch_literals.rb
182
183
  - lib/tebako/packager/patch_main.rb
184
+ - lib/tebako/packager_lite.rb
183
185
  - lib/tebako/ruby_builder.rb
184
186
  - lib/tebako/ruby_version.rb
185
187
  - lib/tebako/scenario_manager.rb