tebako 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/CMakeLists.txt +694 -0
  3. data/Gemfile +35 -0
  4. data/README.adoc +389 -0
  5. data/Rakefile +33 -0
  6. data/bin/console +15 -0
  7. data/bin/setup +8 -0
  8. data/cmake/copy_dir.cmake +29 -0
  9. data/cmake/def_tty_colours.cmake +19 -0
  10. data/common.env +6 -0
  11. data/exe/tebako +31 -0
  12. data/include/tebako/tebako-fs.h +40 -0
  13. data/include/tebako/tebako-main.h +40 -0
  14. data/lib/cli.rb +28 -0
  15. data/lib/tebako/cli.rb +137 -0
  16. data/lib/tebako/cli_helpers.rb +147 -0
  17. data/lib/tebako/error.rb +39 -0
  18. data/lib/tebako/packager/pass1.rb +155 -0
  19. data/lib/tebako/packager/pass2.rb +374 -0
  20. data/lib/tebako/packager.rb +210 -0
  21. data/lib/tebako/version.rb +30 -0
  22. data/resources/tebako-fs.cpp.in +37 -0
  23. data/resources/tebako-version.h.in +37 -0
  24. data/src/tebako-main.cpp +188 -0
  25. data/tebako.gemspec +63 -0
  26. data/tests/scripts/cross-tests.sh +34 -0
  27. data/tests/scripts/functional-tests.sh +335 -0
  28. data/tests/test-00/test.rb +4 -0
  29. data/tests/test-01/tebako-test-run.rb +5 -0
  30. data/tests/test-09/tebako-test-0.0.1.gem +0 -0
  31. data/tests/test-11/bin/tebako-test-run.rb +10 -0
  32. data/tests/test-11/lib/tebako-test.rb +20 -0
  33. data/tests/test-11/tebako-test.gemspec +15 -0
  34. data/tests/test-12/tebako-test-a.gemspec +15 -0
  35. data/tests/test-12/tebako-test-b.gemspec +15 -0
  36. data/tests/test-13/bin/tebako-test-run.rb +10 -0
  37. data/tests/test-13/lib/tebako-test.rb +20 -0
  38. data/tests/test-13/tebako-test.gemspec +15 -0
  39. data/tests/test-15/Gemfile +8 -0
  40. data/tests/test-15/Rakefile +4 -0
  41. data/tests/test-15/bin/tebako-test-run.rb +10 -0
  42. data/tests/test-15/lib/tebako/bundle/test/version.rb +9 -0
  43. data/tests/test-15/lib/tebako/bundle/test.rb +29 -0
  44. data/tests/test-15/tebako-bundle-test.gemspec +30 -0
  45. data/tests/test-16/Gemfile +8 -0
  46. data/tests/test-16/Rakefile +4 -0
  47. data/tests/test-16/bin/tebako-test-run.rb +10 -0
  48. data/tests/test-16/lib/tebako/bundle/test/version.rb +9 -0
  49. data/tests/test-16/lib/tebako/bundle/test.rb +29 -0
  50. data/tests/test-16/tebako-bundle-test.gemspec +24 -0
  51. data/tests/test-18/Gemfile +5 -0
  52. data/tests/test-18/tebako-test-run.rb +12 -0
  53. data/tests/test-19/Gemfile +6 -0
  54. data/tests/test-19/tebako-test-run.rb +11 -0
  55. data/tests-2/fixtures/gems-bundler/Gemfile +4 -0
  56. data/tests-2/fixtures/gems-bundler/gems-bundler.rb +34 -0
  57. data/tests-2/fixtures/gems-byebug/Gemfile +5 -0
  58. data/tests-2/fixtures/gems-byebug/gems-byebug.rb +31 -0
  59. data/tests-2/fixtures/gems-expressir/Gemfile +7 -0
  60. data/tests-2/fixtures/gems-expressir/gems-expressir.rb +33 -0
  61. data/tests-2/fixtures/gems-libmspack/Gemfile +5 -0
  62. data/tests-2/fixtures/gems-libmspack/gems-libmspack.rb +91 -0
  63. data/tests-2/fixtures/gems-sassc/Gemfile +6 -0
  64. data/tests-2/fixtures/gems-sassc/base_style/all.scss +1 -0
  65. data/tests-2/fixtures/gems-sassc/base_style/reset.scss +100 -0
  66. data/tests-2/fixtures/gems-sassc/gems-sassc.rb +129 -0
  67. data/tests-2/fixtures/gems-seven-zip/Gemfile +7 -0
  68. data/tests-2/fixtures/gems-seven-zip/gems-seven-zip.rb +53 -0
  69. data/tests-2/fixtures/launcher-coreincl/launcher-coreincl.rb +29 -0
  70. data/tests-2/fixtures/launcher-package/launcher-package.rb +29 -0
  71. data/tests-2/fixtures/launcher-pwd/launcher-pwd.rb +28 -0
  72. data/tests-2/fixtures/launcher-stdinredir/input.txt +1 -0
  73. data/tests-2/fixtures/launcher-stdinredir/launcher-stdinredir.rb +31 -0
  74. data/tests-2/fixtures/launcher-stdoutredir/launcher-stdoutredir.rb +28 -0
  75. data/tests-2/fixtures/patches-dir/level-1/level-2/file-1.txt +1 -0
  76. data/tests-2/fixtures/patches-dir/level-1/level-2/file-2.txt +1 -0
  77. data/tests-2/fixtures/patches-dir/level-1/level-2/file-3.txt +1 -0
  78. data/tests-2/fixtures/patches-dir/patches-dir.rb +154 -0
  79. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-1.txt +1 -0
  80. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-2.txt +2 -0
  81. data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-3.txt +1 -0
  82. data/tests-2/fixtures/patches-io-and-file/level-1/link-3 +1 -0
  83. data/tests-2/fixtures/patches-io-and-file/patches-io-and-file.rb +87 -0
  84. data/tests-2/fixtures/patches-main/patches-main.rb +6 -0
  85. data/tests-2/tebako-test.rb +312 -0
  86. metadata +170 -0
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2023 [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
+ source "https://rubygems.org"
29
+
30
+ # Specify your gem's dependencies in tebako.gemspec
31
+ gemspec
32
+ gem "hoe"
33
+ gem "minitest"
34
+ gem "rubocop", "~> 1.52"
35
+ gem "rubocop-rubycw"
data/README.adoc ADDED
@@ -0,0 +1,389 @@
1
+ = Tebako: an image packager
2
+
3
+ image:https://github.com/tamatebako/tebako/actions/workflows/ubuntu.yml/badge.svg["Ubuntu amd64", link="https://github.com/tamatebako/tebako/actions/workflows/ubuntu.yml"]
4
+ image:https://github.com/tamatebako/tebako/actions/workflows/alpine.yml/badge.svg["Alpine", link="https://github.com/tamatebako/tebako/actions/workflows/alpine.yml"]
5
+ image:https://github.com/tamatebako/tebako/actions/workflows/macos.yml/badge.svg["MacOS amd64", link="https://github.com/tamatebako/tebako/actions/workflows/macos.yml"]
6
+ image:https://github.com/tamatebako/tebako/actions/workflows/lint.yml/badge.svg["lint", link="https://github.com/tamatebako/tebako/actions/workflows/lint.yml"]
7
+
8
+ image:https://api.cirrus-ci.com/github/tamatebako/tebako.svg?branch=main&task=ubuntu-aarch64["Ubuntu aarch64", link="https://cirrus-ci.com/github/tamatebako/tebako"]
9
+ image:https://api.cirrus-ci.com/github/tamatebako/tebako.svg?branch=main&task=macos-arm64["MacOS arm64", link="https://cirrus-ci.com/github/tamatebako/tebako"]
10
+
11
+ == Purpose
12
+
13
+ Tebako is an executable packager. It packages a set of files into a DwarFS file
14
+ system for read-only purposes.
15
+
16
+ After packaging the file system into an image, Tebako produces a single
17
+ executable binary that allows the user to execute a selected file from the
18
+ packaged software from a point in the file system.
19
+
20
+ The packaged binary should support:
21
+
22
+ * Packaging a default DwarFS image inside the binary
23
+ * Support signing of the binary on macOS (via notarization)
24
+
25
+ In the future:
26
+
27
+ * Downloading new DwarFS images to be stored in the local home directory
28
+ * Allowing loading multiple DwarFS images in a stacked way
29
+ * Supporting a COW mechanism that the newly written files are stored
30
+ in a separate image that can be loaded on top of the read-only file systems.
31
+
32
+ == Supported platforms
33
+
34
+ The Tebako packager is tested on the following platforms:
35
+
36
+ * Linux: Ubuntu 20.04; Alpine 3.16
37
+ * macOS: macOS 11.0 (Monterey)
38
+ * Windows: TBD
39
+
40
+ == Supported Ruby versions
41
+
42
+ The Tebako packager supports the following versions of Ruby for packaging:
43
+ * 2.7.7
44
+ * 3.0.6
45
+ * 3.1.4
46
+
47
+ Support of specific version including minor release requires some effort, sometimes extensive
48
+ but our goal is to be able to package all maintained Ruby releases.
49
+
50
+ == Prerequisites
51
+
52
+ === Ubuntu
53
+
54
+ ==== GNU C/C++ 9+ or Clang C/C++ 11+
55
+
56
+ ==== CMake version 3.20+
57
+
58
+ Tebako relies on CMake 3.20+, which may not be available as a default package.
59
+
60
+ If it is not available as default package it can be set up as follows:
61
+
62
+ [source,sh]
63
+ ----
64
+ apt-get remove --purge --auto-remove cmake
65
+ apt-get update
66
+ apt-get install -y software-properties-common lsb-release curl
67
+ apt-get clean all
68
+ curl https://apt.kitware.com/kitware-archive.sh | bash
69
+ apt-get install cmake
70
+ ----
71
+
72
+ ==== Other development tools and libraries
73
+
74
+ [source,sh]
75
+ ----
76
+ apt-get install -y curl git ruby ruby-dev pkg-config bison flex make autoconf
77
+ apt-get install -y binutils-dev libarchive-dev libevent-dev libjemalloc-dev acl-dev \
78
+ libdouble-conversion-dev libiberty-dev liblz4-dev liblzma-dev libssl-dev \
79
+ libboost-context-dev libboost-filesystem-dev libboost-program-options-dev \
80
+ libboost-regex-dev libboost-system-dev libboost-thread-dev \
81
+ libunwind-dev libdwarf-dev libelf-dev libfuse-dev libgoogle-glog-dev \
82
+ libffi-dev libgdbm-dev libyaml-dev libncurses-dev libreadline-dev \
83
+ libfmt-dev
84
+ ----
85
+
86
+
87
+ == Installation
88
+
89
+ === General
90
+
91
+ Just clone this repository, install Ruby bundle and run `tebako setup` as follows.
92
+
93
+ [source,sh]
94
+ ----
95
+ git clone https://github.com/tamatebako/tebako
96
+ bundle install
97
+ tebako/exe/tebako setup
98
+ ----
99
+
100
+ === Quick setup on Ubuntu 20.04 on Docker
101
+
102
+ Launch a container on the target platform:
103
+
104
+ [source,sh]
105
+ ----
106
+ # For x86_64
107
+ docker run -it --platform linux/x86_64 ubuntu bash
108
+
109
+ # For Apple M1
110
+ docker run -it --platform linux/aarch64 ubuntu bash
111
+ ----
112
+
113
+ In the container:
114
+
115
+ [source,sh]
116
+ ----
117
+ export DEBIAN_FRONTEND=noninteractive
118
+ export TZ=Etc/UTC
119
+
120
+ apt-get update
121
+ apt-get install -y software-properties-common
122
+ add-apt-repository -y ppa:ubuntu-toolchain-r/test
123
+ apt-get install -y gcc-9 g++-9
124
+
125
+ update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
126
+ update-alternatives --set gcc /usr/bin/gcc-9
127
+
128
+ apt-get install -y curl git ruby ruby-dev pkg-config bison flex make autoconf
129
+ curl https://apt.kitware.com/kitware-archive.sh | bash
130
+ apt-get install -y cmake
131
+
132
+ apt-get install -y binutils-dev libarchive-dev libevent-dev libjemalloc-dev acl-dev \
133
+ libdouble-conversion-dev libiberty-dev liblz4-dev liblzma-dev libssl-dev \
134
+ libboost-context-dev libboost-filesystem-dev libboost-program-options-dev \
135
+ libboost-regex-dev libboost-system-dev libboost-thread-dev \
136
+ libunwind-dev libdwarf-dev libelf-dev libfuse-dev libgoogle-glog-dev \
137
+ libffi-dev libgdbm-dev libyaml-dev libncurses-dev libreadline-dev \
138
+ libsqlite3-dev
139
+
140
+ apt-get install -y libfmt-dev
141
+
142
+ git clone https://github.com/tamatebako/tebako
143
+ bundle install
144
+ tebako/exe/tebako setup
145
+ ----
146
+
147
+ == Usage
148
+
149
+ === Commands
150
+
151
+ ==== Installation
152
+
153
+ [source,sh]
154
+ ----
155
+ gem install tebako
156
+ ----
157
+
158
+ ==== Press
159
+
160
+ This command "presses" a Ruby project using the Tebako setup from the Tebako root
161
+ folder (`<tebako-root-folder>`).
162
+ Please note that upon the first invocation of press command tebako collects required packages,
163
+ builds the and creates packaging environment. This is a lengthly task that can take significant
164
+ time, up to 1 hour.
165
+ Upon the next invocation tebako will use previously created packaging environment. The press process
166
+ itself takes minutes.
167
+ You can manage setup of packaging environment manually; please refer to description of setup and clean
168
+ cmmands below.
169
+
170
+ [source,sh]
171
+ ----
172
+ <install-folder>/exe/tebako press \
173
+ [-p |--prefix=<tebako-root-folder>] \
174
+ [-R | --Ruby=<2.7.7|3.0.6|3.1.4>] \
175
+ -r|--root=<project-root-folder> \
176
+ -e|--entry-point=<entry-point> \
177
+ [-o |--output=<packaged file name>] \
178
+ [-l|--log-level=<error|warn|debug|trace>]
179
+ ----
180
+
181
+ Where:
182
+
183
+ * `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
184
+ folder)
185
+
186
+ * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.0.6)
187
+
188
+ * `<project-root>`, a folder at the host source file system where project files
189
+ are located
190
+
191
+ * `<entry-point>`, an executable file (binary executable or script) that shall
192
+ be started when packaged file is called
193
+
194
+ * `output`, the output file name (optional, defaults to `<current folder>/<entry
195
+ point base name`)
196
+
197
+ * `log-level`, the logging level for tebako built-in memory filesystem driver (optional, defaults to `error`)
198
+
199
+ [example]
200
+ ====
201
+ [source,sh]
202
+ ----
203
+ exe/tebako press \
204
+ --root='~/projects/myproject' \
205
+ --entry=start.rb \
206
+ --output=/temp/myproject.tebako
207
+ ----
208
+ ====
209
+
210
+ ==== Setup
211
+
212
+ Collects required packages, builds the and creates packaging environment. This is a lengthly
213
+ task that can take significant time, up to 1 hour.
214
+ Tebako supports several configurations at a single system given that their root
215
+ directories differ and nultiple Ruby versions within single configuration
216
+
217
+ This command is optional, tebako creates packaging environment automatically upon the first
218
+ invocation of press command.
219
+
220
+ [source,sh]
221
+ ----
222
+ <install-folder>/exe/tebako setup \
223
+ [-p |--prefix=<tebako-root-folder>] \
224
+ [-R | --Ruby=<2.7.7|3.0.6|3.1.4>]
225
+ ----
226
+
227
+ Where:
228
+
229
+ * `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
230
+ folder)
231
+
232
+ * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.0.6)
233
+
234
+
235
+
236
+ ==== Clean
237
+
238
+ This command deletes tebako artifacts created by setup and press commands.
239
+ Normally you do not need to do it since tebako packager optimizes artifacts lifecycle on its own.
240
+
241
+ [source,sh]
242
+ ----
243
+ exe/tebako press \
244
+ [-p |--prefix=<tebako-root-folder>]
245
+ ----
246
+
247
+ Where:
248
+
249
+ * `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
250
+ folder)
251
+
252
+ [example]
253
+ ====
254
+ [source,sh]
255
+ ----
256
+ exe/tebako clean --root='~/projects/myproject'
257
+ ----
258
+ ====
259
+
260
+ === Exit codes
261
+
262
+ [cols,"a,a"]
263
+ |===
264
+ | Code | Condition
265
+
266
+ | 0 | No error
267
+ | 1 | Invalid command line
268
+ | 101 | `tebako setup` failed at configuration step
269
+ | 102 | `tebako setup` failed at build step
270
+ | 103 | `tebako press` failed at configuration step
271
+ | 104 | `tebako press` failed at build step
272
+ | 253 | Unsupported Ruby version
273
+ | 254 | Unsupported operating systems
274
+ | 255 | Internal error
275
+
276
+ |===
277
+
278
+ == Image extraction
279
+
280
+ Tebako provides an option to an extract filesystem from a package to local
281
+ folder for verification or execution.
282
+
283
+ [source,sh]
284
+ ----
285
+ <tebako-packaged-executable> --tebako-extract [<root folder for extracted filesystem>]
286
+ ----
287
+
288
+ Where,
289
+
290
+ * `<root folder for extracted filesystem>` is optional and defaults to
291
+ `source_filesystem`
292
+
293
+ [example]
294
+ ====
295
+ Extracting Tebako content from the `metanorma` package:
296
+
297
+ [source,sh]
298
+ ----
299
+ metanorma --tebako-extract temp-image
300
+ ----
301
+ ====
302
+
303
+ The `--tebako-extract` option actually runs the following Ruby script:
304
+
305
+ [source,ruby]
306
+ ----
307
+ require 'fileutils'
308
+ FileUtils.copy_entry '<in-memory filesystem root>', ARGV[2] || 'source_filesystem'
309
+ ----
310
+
311
+ == Ruby packaging specification
312
+
313
+ This is high-level description of the Tebako Ruby packaging mechanism.
314
+ This specification was inspired by the `ruby-packer` approach.
315
+
316
+ NOTE: For various reasons, Tebako Ruby is a fully separate implementation,
317
+ no line of code was copied from `ruby-packer`.
318
+
319
+ Depending on the configuration files that are present in the root project folder,
320
+ the Tebako Ruby packager support five different scenarios:
321
+
322
+ [cols="a,a,a,a"]
323
+ |===
324
+ | Scenario | `*.gemspec` | `Gemfile` | `*.gem`
325
+
326
+ | 1 | No | No | No
327
+ | 2 | No | No | One
328
+ | 3 | One | No | Any
329
+ | 4 | One | One | Any
330
+ | 5 | No | One | Any
331
+ | Error | No | No |Two or more
332
+ | Error |Two or more| Any | Any
333
+
334
+ |===
335
+
336
+ These scenarios differ in what files are packaged and where the entry point is
337
+ located, as follows:
338
+
339
+ [cols="a,a,a,a"]
340
+ |===
341
+ | Scenario | Description | Packaging | Entry point
342
+
343
+ | 1
344
+ | Simple ruby script
345
+ | Copy `<project-root>` with all sub-folders to packaged filesystem
346
+ | `<mount_point>/local/<entry_point base name>`
347
+
348
+ | 2
349
+ | Packaged gem
350
+ | Install the gem with `gem install` to packaged filesystem
351
+ | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
352
+
353
+ | 3
354
+ | Gem source, no `bundler`
355
+ |
356
+ . Build the gem using `gem build` command at the host
357
+ . Install it with `gem install` to packaged filesystem
358
+
359
+ | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
360
+
361
+ | 4
362
+ | Gem source, `bundler`
363
+ |
364
+ . Collect dependencies at the host with `bundle install`
365
+ . Build the gem using `gem build` command
366
+ . Install it with `gem install` to packaged file system
367
+
368
+ | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
369
+
370
+ | 5
371
+ | Rails project
372
+ | Deploy project to packaged filesystem using `bundle install`
373
+ | `<mount_point>/local/<entry_point base name>`
374
+
375
+ |===
376
+
377
+
378
+ == Trivia: origin of name
379
+
380
+ "tamatebako" (玉手箱) is the treasure box given to Urashima Taro in the Ryugu,
381
+ for which he was asked not to open if he wished to return. He opened the box
382
+ upon the shock from his return that three hundred years has passed. Apparently
383
+ what was stored in the box was his age.
384
+
385
+ This packager was made to store Ruby and its gems, and therefore named after
386
+ the said treasure box (storing gems inside a treasure box).
387
+
388
+ Since "tamatebako" is rather long for the non-Japanese speaker, we use "tebako"
389
+ (手箱, also "tehako") instead, the generic term for a personal box.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2023 [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 "bundler/gem_tasks"
29
+ require "rubocop/rake_task"
30
+
31
+ RuboCop::RakeTask.new
32
+
33
+ task default: %i[rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "tebako"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
2
+ # All rights reserved.
3
+ # This file is a part of tebako
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ # 1. Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
18
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24
+ # POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ # https://cmake.org/Bug/view.php?id=13204
27
+ # note the trailing slash after ${SOURCE_DIR}
28
+
29
+ file (COPY "${SOURCE_DIR}/" DESTINATION "${TARGET_DIR}")
@@ -0,0 +1,19 @@
1
+ if(NOT WIN32)
2
+ string(ASCII 27 Escape)
3
+ set(ColourReset "${Escape}[m")
4
+ set(ColourBold "${Escape}[1m")
5
+ set(ColourRed "${Escape}[31m")
6
+ set(ColourGreen "${Escape}[32m")
7
+ set(ColourYellow "${Escape}[33m")
8
+ set(ColourBlue "${Escape}[34m")
9
+ set(ColourMagenta "${Escape}[35m")
10
+ set(ColourCyan "${Escape}[36m")
11
+ set(ColourWhite "${Escape}[37m")
12
+ set(ColourBoldRed "${Escape}[1;31m")
13
+ set(ColourBoldGreen "${Escape}[1;32m")
14
+ set(ColourBoldYellow "${Escape}[1;33m")
15
+ set(ColourBoldBlue "${Escape}[1;34m")
16
+ set(ColourBoldMagenta "${Escape}[1;35m")
17
+ set(ColourBoldCyan "${Escape}[1;36m")
18
+ set(ColourBoldWhite "${Escape}[1;37m")
19
+ endif()
data/common.env ADDED
@@ -0,0 +1,6 @@
1
+ BUILD_TYPE=Release
2
+ DEPS=deps
3
+ INCBIN_TAG=348e36b
4
+ DWARFS_WR_TAG=v0.3.4
5
+ BUNDLER_VER=2.3.22
6
+ RUBY_VER=3.0.6
data/exe/tebako ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
5
+ # All rights reserved.
6
+ # This file is a part of tebako
7
+ #
8
+ # Redistribution and use in source and binary forms, with or without
9
+ # modification, are permitted provided that the following conditions
10
+ # are met:
11
+ # 1. Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ # 2. Redistributions in binary form must reproduce the above copyright
14
+ # notice, this list of conditions and the following disclaimer in the
15
+ # documentation and/or other materials provided with the distribution.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
21
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
+ # POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ require_relative "../lib/cli"
30
+
31
+ Tebako::TebakoCli.start
@@ -0,0 +1,40 @@
1
+ /**
2
+ *
3
+ * Copyright (c) 2021, [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
+ */
29
+
30
+ #pragma once
31
+
32
+ #include <incbin/incbin.h>
33
+
34
+ INCBIN_EXTERN(fs);
35
+
36
+ namespace tebako {
37
+ extern const char* fs_log_level;
38
+ extern const char* fs_mount_point;
39
+ extern const char* fs_entry_point;
40
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ *
3
+ * Copyright (c) 2021, [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
+ */
29
+
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+ int tebako_main(int* argc, char*** argv);
34
+ const char* tebako_mount_point(void);
35
+ #ifdef RB_W32
36
+ int tebako_file_load_ok(const char *path);
37
+ #endif
38
+ #ifdef __cplusplus
39
+ }
40
+ #endif
data/lib/cli.rb ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2023 [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 "tebako/cli"