tebako 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.adoc CHANGED
@@ -1,62 +1,416 @@
1
- = Tebako: an image packager
1
+ = Tebako: An advanced image packager for interpretive languages
2
2
 
3
+ Platform tests on GitHub:
3
4
  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
5
  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/macos.yml/badge.svg["macOS amd64", link="https://github.com/tamatebako/tebako/actions/workflows/macos.yml"]
6
7
  image:https://github.com/tamatebako/tebako/actions/workflows/windows-msys.yml/badge.svg["Windows msys", link="https://github.com/tamatebako/tebako/actions/workflows/windows-msys.yml"]
7
8
 
9
+ Platform tests on Cirrus:
8
10
  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
11
 
12
+ Quality:
10
13
  image:https://github.com/tamatebako/tebako/actions/workflows/lint.yml/badge.svg["lint", link="https://github.com/tamatebako/tebako/actions/workflows/lint.yml"]
11
14
 
12
15
  == Purpose
13
16
 
14
- Tebako is an executable packager. It packages a set of files into a DwarFS file
15
- system for read-only purposes.
17
+ Tebako is an advanced executable packager designed for applications written in
18
+ interpretive languages.
16
19
 
17
- After packaging the file system into an image, Tebako produces a single
18
- executable binary that allows the user to execute a selected file from the
19
- packaged software from a point in the file system.
20
+ It simplifies distribution and deployment by packaging your entire project with
21
+ a bundled runtime into a single, performant, executable binary.
20
22
 
21
- The packaged binary should support:
23
+ == Architecture
22
24
 
23
- * Packaging a default DwarFS image inside the binary
24
- * Support signing of the binary on macOS (via notarization)
25
+ A Tebako-packaged binary is effectively a self-executing container-in-a-file.
25
26
 
26
- In the future:
27
+ The packaged binary contains the following components:
28
+
29
+ * An on-file filesystem (OFFS) containing all the project files and
30
+ dependencies in DwarFS format.
31
+
32
+ * A runtime environment that includes the necessary libraries and interpreters,
33
+ with patched filesystem calls that redirect access of project files to the
34
+ on-file filesystem.
35
+
36
+ * An executable loader that loads the on-file filesystem in memory and executes
37
+ the project.
38
+
39
+
40
+ == Supported runtimes, platforms and architectures
41
+
42
+ Tebako artifacts can be built and executed on the following platforms and
43
+ architectures.
44
+
45
+ .Supported platforms and architectures
46
+ [cols="3", options="header"]
47
+ |===
48
+ | Platform and version | Architectures | Build system
49
+
50
+ 3+| **Linux**
51
+ | Ubuntu 20.04 | amd64, aarch64 | gcc/g+\+: 10; clang/clang++: 12
52
+ | Alpine 3.17 | amd64 | gcc/g+\+: default; clang/clang++: default
53
+
54
+ 3+| **macOS**
55
+ | macOS 12 (Monterey) | amd64 | xcode: [13.1, 14.3.1]
56
+ | macOS 13 (Ventura) | amd64, aarch64 | xcode: [13.1, 14.3.1]
57
+ | macOS 14 (Sonoma) | amd64, aarch64 | xcode: [13.1, 14.3.1, 15.4]
58
+
59
+ 3+| **Windows**
60
+ | Windows 10 | amd64 | MinGW ucrt64
61
+ | Windows 11 | amd64 | MinGW ucrt64
62
+ | Windows Server 2019 | amd64 | MinGW ucrt64
63
+ | Windows Server 2022 | amd64 | MinGW ucrt64
64
+
65
+ |===
66
+
67
+ [NOTE]
68
+ ====
69
+ Windows build caveats:
70
+
71
+ * Tebako may face errors related to CMake path length limitations (https://gitlab.kitware.com/cmake/cmake/-/issues/25936).
72
+ This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
73
+ There is no workaround for this issue as it looks like is a limitation of the manifest used to build CMake executable.
74
+
75
+ * MSys strip utility creates broken executable when tebako image is processed. Linking with '-s' flag produces unusable
76
+ executables as well.
77
+ Until this issue (https://github.com/tamatebako/tebako/issues/172) is resolved we plan to produce an Windows executable
78
+ with debug information unstripped. You can opt to run 'strip -S' manually, it most cases it works.
79
+ ====
80
+
81
+
82
+ .Supported Ruby versions
83
+ [cols="2", options="header"]
84
+ |===
85
+ | Ruby version | Supported platforms
86
+
87
+ | 2.7.8 | Linux, macOS
88
+ | 3.0.7 | Linux, macOS
89
+ | 3.1.{4,5,6} | Linux, macOS, Windows
90
+ | 3.2.{3,4} | Linux, macOS, Windows
91
+ | 3.3.{3,4} | Linux, macOS, Windows
92
+
93
+ |===
94
+
95
+ NOTE: Our goal is to support all maintained Ruby releases, including minor versions.
96
+
97
+ == Future plans
27
98
 
28
99
  * Downloading new DwarFS images to be stored in the local home directory
29
100
  * Allowing loading multiple DwarFS images in a stacked way
30
101
  * Supporting a COW mechanism that the newly written files are stored
31
102
  in a separate image that can be loaded on top of the read-only file systems.
32
103
 
33
- == Supported platforms
34
104
 
35
- The Tebako packager is tested on the following platforms:
105
+ == FAQ
106
+
107
+ === Why use Tebako?
108
+
109
+ Tebako is particularly useful for developers who need to:
110
+
111
+ * Distribute applications without requiring users to have specific runtimes installed.
112
+ * Simplify the deployment process by packaging all dependencies into one binary.
113
+ * Ensure consistency across different environments by using a single executable.
114
+ * Flexibility to support different runtime versions on the user's machine.
115
+
116
+
117
+ === How do I know I need Tebako?
118
+
119
+ You might need Tebako if you:
120
+
121
+ * Want to package your application into a single, self-contained binary.
122
+ * Want to avoid the complexities of managing runtime environments on target machines.
123
+ * Distribute software to environments where installing runtimes and their dependencies is challenging.
124
+ * Require a streamlined way to deliver applications to end-users.
125
+ * Need to ensure that your application runs consistently across different environments and architectures.
126
+
127
+
128
+ === What is DwarFS?
129
+
130
+ https://github.com/mhx/dwarfs[DwarFS] is a fast, high compression read-only
131
+ user-land file system designed for efficient storage and access of large
132
+ collections of files.
133
+
134
+ It is used by Tebako to package applications into a compact and efficient format.
135
+
136
+ Tebako uses https://github.com/tamatebako/libdwarfs[libdwarfs], the library
137
+ form of https://github.com/mhx/dwarfs[DwarFS], developed for the Tebako project.
138
+
139
+ === When is Tebako better than comparable solutions?
140
+
141
+ Tebako offers several advantages over comparable solutions for supported
142
+ interpretive languages.
143
+
144
+ They are listed in order of the degree of virtualization below.
145
+
146
+ Tebako stands out by providing a lightweight runtime bundling approach that
147
+ simplifies distribution and deployment while offering flexibility and
148
+ efficiency.
149
+
150
+ It eliminates the need for users to have specific runtimes installed and ensures
151
+ consistency across different environments.
152
+
153
+ With Tebako, you can package your entire project with a bundled runtime into a
154
+ single, performant, executable binary.
155
+
156
+ [cols="a,3a,3a"]
157
+ |===
158
+ | Solution | Pros | Cons
159
+
160
+ | Virtual machines (VMs)
161
+ |
162
+ - Provides full isolation and compatibility across environments
163
+ |
164
+ - Requires a separate VM installation for each application
165
+ - Heavy resource consumption for virtualization
166
+
167
+ | Docker
168
+ |
169
+ - Provides portable containers
170
+ - Isolates entire applications and their dependencies
171
+ - Supports easy deployment and scalability
172
+ |
173
+ - Requires Docker installation and management
174
+ - Requires administrative rights on machine
175
+ - Containerization overhead
176
+
177
+ | *Tebako*
178
+ |
179
+ - Packages all files and dependencies into a single binary
180
+ - Supports multiple operating systems and architectures
181
+ - Provides efficient packaging and execution with DwarFS
182
+ - Offers security features like signing on macOS
183
+ - Simplifies distribution and deployment
184
+ - Native running speed
185
+ |
186
+ - Initial packaging time longer than Ruby gems
187
+ - Minor runtime overhead
188
+
189
+ | Ruby Gems
190
+ |
191
+ - Easy installation of Ruby libraries
192
+ - Provides user-side version control and dependency management
193
+ |
194
+ - Requires Ruby installation and gem management
195
+ - Runtime execution dependent on the user's installed Ruby version and gems
196
+
197
+ |===
198
+
199
+
200
+ == Usage
201
+
202
+ === Command-line interface
203
+
204
+ Tebako works by packaging your project into a single executable binary that
205
+ includes all the necessary dependencies.
206
+
207
+ The way to work with Tebako is through its command-line interface (CLI).
208
+ It provides the following commands:
209
+
210
+ `setup`::
211
+ Prepares the Tebako packaging environment.
212
+
213
+ `press`::
214
+ Packages a project into a single executable binary.
215
+
216
+ `clean`::
217
+ Removes Tebako artifacts.
218
+
219
+ `clean_ruby`::
220
+ Removes Tebako Ruby artifacts.
36
221
 
37
- * Linux: Ubuntu 20.04; Alpine 3.17
38
- * MacOS: macOS 12 (Monterey), 13 (Ventura), 14 (Sonoma)
39
- * Windows: 2019, 2022 (using MinGW ucrt64 toolchain)
222
+ `hash`::
223
+ Calculates the Tebako script hash for use as a cache key in CI/CD environments.
40
224
 
41
- Please note that Windows support is in pre-release and is a subject of further testing and optimization
225
+ `extract`::
226
+ Extracts the filesystem from a Tebako package.
42
227
 
43
- == Supported Ruby versions
228
+ `version`::
229
+ Displays the Tebako version.
44
230
 
45
- The Tebako packager supports the following versions of Ruby for packaging:
231
+ `help`::
232
+ Displays the help message.
46
233
 
47
- * 2.7.8 (Linux, MacOS)
48
- * 3.0.7 (Linux, MacOS)
49
- * 3.1.4, 3.1.5, 3.1.6 (Linux, MacOS, Windows)
50
- * 3.2.3, 3.2.4 (Linux, MacOS, Windows)
51
234
 
52
- Support of specific version including minor release requires some effort, sometimes extensive
53
- but our goal is to be able to package all maintained Ruby releases.
54
235
 
55
- == Prerequisites
56
236
 
57
- === Ubuntu 20.04
237
+ == Usage
238
+
239
+ === General
240
+
241
+ Tebako can be used in two ways:
242
+
243
+ * Through the Tebako container
244
+ * Local installation
245
+
246
+ Please refer to the <<installation>> section on how to install Tebako.
247
+
248
+
249
+ [[installation]]
250
+ == Installation
251
+
252
+ === General
253
+
254
+ Installation of Tebako is only needed in order to package an application.
255
+
256
+ There is no need to install anything for users who run the packaged application.
257
+
258
+
259
+ === Using Docker
260
+
261
+ ==== General
262
+
263
+ If you have Docker installed and available, the easiest way to run Tebako is
264
+ through the official Docker containers.
265
+
266
+ Docker containers with preinstalled Tebako packaging environments for Ubuntu and
267
+ Alpine Linux are available at
268
+ https://github.com/tamatebako/tebako-ci-containers[tebako-ci-containers].
58
269
 
59
- ==== GNU C/C++ 10+ or Clang C/C++ 12+
270
+
271
+ ==== Pull the container
272
+
273
+ Pull the Tebako container image.
274
+
275
+ [source,sh]
276
+ ----
277
+ docker pull ghcr.io/tamatebako/tebako-<container_tag>:latest
278
+ ----
279
+
280
+ `<container_tag>`:: is the desired image tag (e.g., `ubuntu-20.04` or `alpine-3.17`).
281
+
282
+
283
+ ==== Running Tebako commands in the container
284
+
285
+ Simply prefix the Tebako command with `docker run` and the container image.
286
+
287
+ [source,sh]
288
+ ----
289
+ docker run -v <application_folder>:/mnt/w \
290
+ -t ghcr.io/tamatebako/tebako-<container_tag>:latest \
291
+ tebako {command} {parameters}
292
+ ----
293
+
294
+
295
+
296
+
297
+ ==== Packaging from outside the container
298
+
299
+ To package your application from outside the container, just run a single Docker
300
+ command.
301
+
302
+ This command mounts the application folder into the container and runs the
303
+ `tebako press` command, specifying the application root, entry point, output
304
+ location, and Ruby version.
305
+
306
+ [source,sh]
307
+ ----
308
+ docker run -v <application_folder>:/mnt/w \
309
+ -t ghcr.io/tamatebako/tebako-<container_tag>:latest \
310
+ tebako press <tebako-press-parameters>
311
+ ----
312
+
313
+ `<application_folder>`:: is the path to your application folder.
314
+
315
+ `<container_tag>`:: is the desired image tag (e.g., `ubuntu-20.04` or `alpine-3.17`).
316
+
317
+
318
+ [example]
319
+ ====
320
+ Assume that you have a Ruby application in the `fontist` folder of the current
321
+ directory.
322
+
323
+ You can package it to `./fontist-package` using the following command:
324
+
325
+ [source,sh]
326
+ ----
327
+ docker run -v $PWD:/mnt/w \
328
+ -t ghcr.io/tamatebako/tebako-ubuntu-20.04:latest \
329
+ tebako press --root=/mnt/w/fontist --entry-point=fontist --output=/mnt/w/fontist-package --Ruby=3.2.4
330
+ ----
331
+ ====
332
+
333
+ ==== Packaging from inside the container
334
+
335
+ It is also possible to package an application from inside the Tebako container.
336
+
337
+ Start and enter the container interactively.
338
+
339
+ [source,sh]
340
+ ----
341
+ docker run -it --rm -v <application_folder>:/mnt/w \
342
+ ghcr.io/tamatebako/tebako-<container_tag>:latest bash
343
+ ----
344
+
345
+ `<application_folder>`:: is the path to your application folder.
346
+
347
+ `<container_tag>`:: is the desired image tag (e.g., `ubuntu-20.04` or `alpine-3.17`).
348
+
349
+
350
+ Once inside, run the `tebako press` command:
351
+
352
+ [source,sh]
353
+ ----
354
+ tebako press <tebako press parameters>
355
+ ----
356
+
357
+ [example]
358
+ ====
359
+ Assume that you have a Ruby application in the `fontist` folder of the current
360
+ directory.
361
+
362
+ You can package it to `./fontist-package` using the following command:
363
+
364
+ [source,sh]
365
+ ----
366
+ $ docker run -it --rm -v $PWD:/mnt/w ghcr.io/tamatebako/tebako-<container_tag>:latest bash
367
+
368
+ # Inside the container:
369
+ $ tebako press --root=/mnt/w/fontist --entry-point=fontist --output=/mnt/w/fontist-package --Ruby=3.2.4
370
+ ----
371
+ ====
372
+
373
+
374
+ === Local installation
375
+
376
+ ==== General
377
+
378
+ There are cases where Docker may not be suitable for your needs, such as:
379
+
380
+ . Admin privileges: Running Docker requires administrative privileges, which
381
+ means Docker may not be available to users on their machines.
382
+
383
+ . Performance penalty: Docker introduces a performance penalty due to the
384
+ overhead of running containers. This can be a concern when packaging complex
385
+ applications that require heavy memory usage.
386
+
387
+ In such cases, you can choose to install Tebako locally.
388
+
389
+ Tebako is distributed as a Ruby gem. A Ruby environment is necessary.
390
+
391
+
392
+ [source,sh]
393
+ ----
394
+ $ gem install tebako
395
+ ----
396
+
397
+
398
+ ==== Prerequisites
399
+
400
+ These prerequisites are needed only for users who want to install Tebako on
401
+ their machine and build all Tebako components locally.
402
+
403
+ If you use Docker, there is no need to set up these prerequisites.
404
+
405
+ ===== Ubuntu 20.04
406
+
407
+ ====== General
408
+
409
+ There are several prerequisites that need to be installed on Ubuntu 20.04 for
410
+ Tebako to work correctly.
411
+
412
+
413
+ ====== GNU C/C++ 10+ or Clang C/C++ 12+
60
414
 
61
415
  [source,sh]
62
416
  ----
@@ -74,12 +428,14 @@ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 150
74
428
  update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 150
75
429
  ----
76
430
 
77
- ==== CMake version 3.20+
431
+ ====== CMake version 3.20+
78
432
 
79
- Tebako relies on CMake 3.20+, which may not be available as a default package.
433
+ Tebako requires CMake at a version of at least 3.20+.
80
434
 
81
- If it is not available as default package it can be set up as follows:
435
+ If such CMake version is not available as a default package, set it up as
436
+ follows.
82
437
 
438
+ .Installing CMake 3.20+
83
439
  [source,sh]
84
440
  ----
85
441
  apt-get remove --purge --auto-remove cmake
@@ -90,7 +446,7 @@ curl https://apt.kitware.com/kitware-archive.sh | bash
90
446
  apt-get install cmake
91
447
  ----
92
448
 
93
- ==== Other development tools and libraries
449
+ ====== Other development tools and libraries
94
450
 
95
451
  [source,sh]
96
452
  ----
@@ -105,7 +461,16 @@ apt-get -y install sudo git curl build-essential pkg-config bison flex autoconf
105
461
  libutfcpp-dev
106
462
  ----
107
463
 
108
- === Alpine 3.17
464
+ ===== Alpine 3.17
465
+
466
+ ====== General
467
+
468
+ There are several prerequisites that need to be installed on Alpine 3.17 for
469
+ Tebako to work correctly.
470
+
471
+ ====== APK packages
472
+
473
+ Run the following command to install all prerequisites.
109
474
 
110
475
  [source,sh]
111
476
  ----
@@ -119,122 +484,178 @@ apk --no-cache --upgrade add build-base cmake git bash autoconf boost-static \
119
484
  brotli-static jemalloc-dev fmt-dev xz-static
120
485
  ----
121
486
 
122
- === macOS 12 (Monterey) through macOS 14 (Sonoma)
487
+ ===== macOS
488
+
489
+ ====== General
490
+
491
+ There are several prerequisites that need to be installed on macOS for Tebako to work correctly.
492
+
493
+ The following instructions work for:
494
+
495
+ * macOS 12 (Monterey) through macOS 14 (Sonoma)
496
+
497
+
498
+ ====== Homebrew packages
499
+
500
+ We use Homebrew to install the necessary packages on macOS.
123
501
 
124
502
  [source,sh]
125
503
  ----
126
504
  brew update
127
- brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib ncurses \
128
- double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz libyaml openssl@3
505
+ brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib \
506
+ ncurses double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz \
507
+ libyaml openssl@3
129
508
  ----
130
509
 
131
- ==== Bison 3+
510
+ ====== Bison 3+
132
511
 
133
- Tebako relies on bison 3 but the default macOS version installed is 2.3 and the Homebrew formula is keg-only.
134
- To ensure the correct version of bison is picked, run this command before the build process:
512
+ Tebako requires Bison 3+.
513
+
514
+ On macOS 14, the default Bison version is 2.3, and the Homebrew formula is keg-only,
515
+ which means that the full path to the Bison binary must be used to utilize the
516
+ correct version.
517
+
518
+ Run the following command prior to using Tebako, or add it into your shell
519
+ profile.
135
520
 
136
521
  [source,sh]
137
522
  ----
138
- export PATH="$(brew --prefix bison)/bin:$PATH"
523
+ export PATH="$(brew --prefix bison)/bin:$PATH"
139
524
  ----
140
525
 
141
- === Windows (workstation 10, 11; Server 2019, 2022)
526
+ ===== Windows
142
527
 
143
- The simplest approach is to use Ruby development environment provided by RubyInstaller, for example Ruby+Devkit 3.1.4-1.
144
- Once it is installed use the following commands:
528
+ ====== General
145
529
 
146
- [source,sh]
147
- ----
148
- ridk enable ucrt64
149
- pacman -S git tar bison flex toolchain make cmake
150
- boost diffutils libevent double-conversion
151
- fmt glog dlfcn gtest autotools ncurses libyaml
152
- ----
530
+ There are several prerequisites that need to be installed on macOS for Tebako to work correctly.
153
531
 
154
- Please note that on Windows tebako may face issues related by CMake path length limitations.
155
- (https://gitlab.kitware.com/cmake/cmake/-/issues/25936)
156
- This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
157
- There is no workaround for this issue as it lloks like is a limitation of the manifest used to build CMake executable.
532
+ The following instructions work for:
158
533
 
159
- == Installation
534
+ * Windows 10, 11
535
+ * Windows Server 2019, 2022
160
536
 
161
- === General
537
+ ====== Ruby
162
538
 
163
- Tebako is distributed as a Ruby gem.
164
- Additionally, Docker containers for Ubuntu and Alpine Linux with a preinstalled Tebako packaging environment
165
- are available at https://github.com/orgs/tamatebako/packages.
539
+ To run Tebako you need to have Ruby installed.
540
+ It is simplest to use the Ruby development environment provided by
541
+ https://rubyinstaller.org[RubyInstaller].
166
542
 
167
- == Usage
543
+ For example, Ruby+Devkit 3.1.4-1.
168
544
 
169
- === Commands
545
+ ====== MinGW ucrt64
546
+
547
+ Enable MinGW ucrt64 and install the necessary packages.
170
548
 
171
- ==== Installation
549
+ The `ridk` command originates from the RubyInstaller installation.
172
550
 
173
551
  [source,sh]
174
552
  ----
175
- gem install tebako
553
+ $ ridk enable ucrt64
554
+ $ pacman -S git tar bison flex toolchain make cmake
555
+ boost diffutils libevent double-conversion
556
+ fmt glog dlfcn gtest autotools ncurses libyaml
176
557
  ----
177
558
 
178
- === Tebako Root Folder (aka Prefix) Selection
179
559
 
180
- The prefix in Tebako determines the base directory for the Tebako setup. It is an essential part of configuring how Tebako operates within your system.
181
- The selection of the prefix follows a specific order of precedence to ensure flexibility and ease of use:
182
560
 
183
- . *User-Specified Prefix*: The most direct way to set the root folder is by specifying it through an option. This can be done via command-line argument.
561
+ == Usage
562
+
563
+ === Tebako root folder (aka prefix) selection
184
564
 
185
- . *Current Working Directory (PWD)*: If the prefix option is explicitly set to "PWD", Tebako uses the current working directory as Tebako root folder.
565
+ The Tebako prefix determines the base directory for the Tebako setup.
186
566
 
187
- . *Environment Variable (TEBAKO_PREFIX)*: In the absence of a user-specified option, Tebako looks for an environment variable named `TEBAKO_PREFIX`. If found, its value is used as the root folder.
567
+ It is an essential part of configuring how Tebako operates within your system.
188
568
 
189
- . *Default Value*: If no prefix is specified and the `TEBAKO_DIR` environment variable is not set, Tebako defaults to using a directory named `.tebako` in the user's home directory.
569
+ The selection of the Tebako prefix follows a specific order of precedence to
570
+ ensure flexibility and ease of use:
190
571
 
572
+ . *User-specified prefix*:
573
+ The most direct way to set the root folder is by specifying it through a
574
+ command-line argument.
191
575
 
192
- Path Expansion: Regardless of the method used to set the prefix, Tebako expands the provided path to an absolute path. This expansion includes resolving relative paths based on the current working
193
- directory and expanding user directory shortcuts like `~`.
576
+ . *Current Working Directory (PWD)*:
577
+ If the prefix option is explicitly set to `PWD`, Tebako uses the current working
578
+ directory as Tebako root folder.
579
+
580
+ . *Environment variable (`TEBAKO_PREFIX`)*:
581
+ In the absence of a user-specified option, Tebako looks for an environment
582
+ variable named `TEBAKO_PREFIX`. If found, its value is used as the root folder.
583
+
584
+ . *Default value*:
585
+ If no prefix is specified and the `TEBAKO_DIR` environment variable is not set,
586
+ Tebako defaults to using a directory named `.tebako` in the user's home
587
+ directory.
588
+
589
+
590
+ Path Expansion: Regardless of the method used to set the Tebako prefix, Tebako
591
+ expands the provided path to an absolute path. This expansion includes resolving
592
+ relative paths based on the current working directory and expanding user
593
+ directory shortcuts like `~`.
594
+
595
+
596
+ === Commands
597
+
598
+ Tebako provides several commands to manage the packaging and deployment process.
194
599
 
195
600
  ==== Press
196
601
 
197
- This command "presses" a Ruby project using the Tebako setup from the Tebako root
198
- folder (`<tebako-root-folder>`).
199
- Please note that upon the first invocation of press command tebako collects required packages,
200
- builds the and creates packaging environment. This is a lengthly task that can take significant
201
- time, up to 1 hour.
202
- Upon the next invocation tebako will use previously created packaging environment. The press process
203
- itself takes minutes.
204
- You can manage setup of packaging environment manually; please refer to description of setup and clean
205
- cmmands below.
602
+ This command "presses" a Ruby project using the Tebako components built in the Tebako
603
+ root folder (`<tebako-root-folder>`).
604
+
206
605
 
207
- [source]
606
+ [NOTE]
607
+ ====
608
+ The first invocation of the `press` command can take up to an hour as it sets up
609
+ the packaging environment and collects the required dependencies. Subsequent
610
+ invocations are much faster.
611
+ ====
612
+
613
+ Upon the next invocation tebako will use previously created packaging
614
+ environment. The press process itself takes minutes.
615
+
616
+ You can manage setup of packaging environment manually; please refer to
617
+ description of setup and clean commands below.
618
+
619
+ [source,sh]
208
620
  ----
209
- tebako press \
621
+ tebako press \
622
+ -e|--entry-point=<entry-point> \
623
+ -r|--root=<project-root-folder> \
210
624
  [-p|--prefix=<tebako-root-folder>] \
211
- [-R|--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>] \
212
- -r|--root=<project-root-folder> \
213
- -e|--entry-point=<entry-point> \
214
- [-o|--output=<packaged file name>] \
625
+ [-R|--Ruby=<ruby-version>] \
626
+ [-o|--output=<packaged-file-name>] \
215
627
  [-l|--log-level=<error|warn|debug|trace>] \
216
628
  [-D|--devmode]
217
629
  ----
218
630
 
219
631
  Where:
220
632
 
221
- * `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
633
+ `<tebako-root-folder>`::
634
+ the Tebako root folder (see details in the Tebako Root Folder Selection section)
222
635
 
223
- * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
636
+ `Ruby`::
637
+ This parameter defines Ruby version that will be packaged (optional, defaults to
638
+ `3.1.6`)
224
639
 
225
- * `<project-root>`, a folder at the host source file system where project files
226
- are located
640
+ `<project-root>`::
641
+ a folder at the host source file system where project files are located
227
642
 
228
- * `<entry-point>`, an executable file (binary executable or script) that shall
229
- be started when packaged file is called
643
+ `<entry-point>`::
644
+ an executable file (binary executable or script) that shall be started when
645
+ packaged file is called
230
646
 
231
- * `output`, the output file name (optional, defaults to `<current folder>/<entry
232
- point base name`)
647
+ `output`::
648
+ the output file name (optional, defaults to `<current folder>/<entry point base name>`)
233
649
 
234
- * `log-level`, the logging level for tebako built-in memory filesystem driver (optional, defaults to `error`)
650
+ `log-level`::
651
+ logging level for the Tebako built-in memory filesystem driver
652
+ (optional, defaults to `error`)
235
653
 
236
- * `devmode` flag activates development mode, in which Tebako's cache and packaging consistency checks are relaxed.
237
- Please note that this mode is not intended for production use and should only be used during development.
654
+ `devmode`:: flag that activates development mode, in which Tebako's cache and
655
+ packaging consistency checks are relaxed.
656
+ +
657
+ NOTE: Development mode is *not intended for production use* and should only be
658
+ used during development.
238
659
 
239
660
  [example]
240
661
  ====
@@ -249,47 +670,54 @@ tebako press \
249
670
 
250
671
  ==== Setup
251
672
 
252
- Collects required packages, builds the and creates packaging environment. This is a lengthly
253
- task that can take significant time, up to 1 hour.
673
+ This command sets up the Tebako packaging environment.
674
+
675
+ Collects required packages, builds the and creates packaging environment. This
676
+ is a lengthy task that can take significant time, up to 1 hour.
677
+
254
678
  Tebako supports several configurations at a single system given that their root
255
- directories differ and nultiple Ruby versions within single configuration
679
+ directories differ and multiple Ruby versions within single configuration
680
+
681
+ This command is optional, tebako creates packaging environment automatically
682
+ upon the first invocation of press command.
256
683
 
257
- This command is optional, tebako creates packaging environment automatically upon the first
258
- invocation of press command.
259
- However, if you plan to use tebako in CI/CD environment with caching it is highly recommended to build cache
260
- based on ```tebako setup``` output. Building cache based on ```tebako press``` may create inconsistent environment upon restore.
684
+ However, if you plan to use tebako in CI/CD environment with caching it is
685
+ highly recommended to build cache based on `tebako setup` output. Building cache
686
+ based on `tebako press` may create inconsistent environment upon restore.
261
687
 
262
- [source]
688
+ [source,sh]
263
689
  ----
264
- tebako setup \
265
- [-p |--prefix=<tebako-root-folder>] \
266
- [-R |--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>] \
267
- [-D | --devmode]
690
+ $ tebako setup \
691
+ [-p|--prefix=<tebako-root-folder>] \
692
+ [-R|--Ruby=<ruby-version>] \
693
+ [-D|--devmode]
268
694
  ----
269
695
 
270
696
  Where:
271
697
 
272
- * `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
698
+ `<tebako-root-folder>`:: the Tebako root folder (see details in the Tebako Root Folder Selection section)
273
699
 
274
- * `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
700
+ `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
275
701
 
276
- * `devmode` flag activates development mode, in which Tebako's cache and packaging consistency checks are relaxed.
702
+ `devmode` flag activates development mode, in which Tebako's cache and packaging consistency checks are relaxed.
277
703
  Please note that this mode is not intended for production use and should only be used during development.
278
704
 
279
705
  ==== Clean
280
706
 
281
- This command deletes tebako artifacts created by setup and press commands.
707
+ This command cleans up all Tebako artifacts in the specified prefix directory.
708
+
709
+ NOTE: These artifacts are created by the `setup` and `press` commands.
282
710
  Normally you do not need to do it since tebako packager optimizes artifacts lifecycle on its own.
283
711
 
284
- [source]
712
+ [source,sh]
285
713
  ----
286
- tebako clean \
714
+ $ tebako clean \
287
715
  [-p|--prefix=<tebako-root-folder>]
288
716
  ----
289
717
 
290
718
  Where:
291
719
 
292
- * `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
720
+ `<tebako-root-folder>`:: the Tebako root folder (see details in the Tebako Root Folder Selection section)
293
721
 
294
722
  [example]
295
723
  ====
@@ -299,23 +727,32 @@ tebako clean --prefix='~/.tebako'
299
727
  ----
300
728
  ====
301
729
 
302
- ==== Clean ruby
303
730
 
304
- This command deletes tebako Ruby artifacts created by setup and press commands. Dwarfs libraries are not cleaned.
305
- Normally you do not need to do it since tebako packager optimizes artifacts lifecycle on its own.
731
+ ==== Clean Ruby
306
732
 
307
- [source]
733
+ This command cleans up only the Ruby artifacts from the specified prefix
734
+ directory.
735
+
736
+ NOTE: These artifacts are created by the `setup` and `press` commands.
737
+ Normally you do not need to do it, since Tebako packager optimizes artifacts
738
+ lifecycle on its own.
739
+
740
+ NOTE: Compiled DwarFS libraries are not cleaned.
741
+
742
+ [source,sh]
308
743
  ----
309
- tebako clean_ruby
310
- [-p|--prefix=<tebako-root-folder>]
311
- [-R|--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>]
744
+ $ tebako clean_ruby
745
+ [-p|--prefix=<tebako-root-folder>] \
746
+ [-R|--Ruby=<ruby-version>]
312
747
  ----
313
748
 
314
749
  Where:
315
750
 
316
- * `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
317
- folder)
318
- * `Ruby` parameter defines Ruby version that will cleaned (optional, cleans all versions by default)
751
+ `<tebako-root-folder>`::
752
+ the Tebako setup folder (optional, defaults to current folder)
753
+
754
+ `Ruby`::
755
+ defines Ruby version that will cleaned (optional, cleans all versions by default)
319
756
 
320
757
  [example]
321
758
  ====
@@ -326,45 +763,30 @@ tebako clean_ruby --prefix='~/.tebako'
326
763
  ====
327
764
 
328
765
  ==== Build script hash
329
- Hash command will calculate tebako script hash that may be used as a cache key in CI/CD environment like GitHub Actions
330
766
 
331
- [source]
767
+ This command outputs a hash value for the Tebako build script, which can be used
768
+ as a cache key in CI/CD pipelines.
769
+
770
+ [source,sh]
332
771
  ----
333
- tebako hash
772
+ $ tebako hash
334
773
  ----
335
774
 
336
- === Exit codes
337
775
 
338
- [cols,"a,a"]
339
- |===
340
- | Code | Condition
776
+ === Image extraction
341
777
 
342
- | 0 | No error
343
- | 1 | Invalid command line
344
- | 101 | `tebako setup` failed at configuration step
345
- | 102 | `tebako setup` failed at build step
346
- | 103 | `tebako press` failed at configuration step
347
- | 104 | `tebako press` failed at build step
348
- | 253 | Unsupported Ruby version
349
- | 254 | Unsupported operating systems
350
- | 255 | Internal error
351
-
352
- |===
353
-
354
- == Image extraction
355
-
356
- Tebako provides an option to an extract filesystem from a package to local
357
- folder for verification or execution.
778
+ Tebako provides an option to an extract its DwarFS filesystem from a package to
779
+ a local folder for verification or execution.
358
780
 
359
781
  [source,sh]
360
782
  ----
361
- <tebako-packaged-executable> --tebako-extract [<root folder for extracted filesystem>]
783
+ $ <tebako-packaged-executable> --tebako-extract [<root folder for extracted filesystem>]
362
784
  ----
363
785
 
364
786
  Where,
365
787
 
366
- * `<root folder for extracted filesystem>` is optional and defaults to
367
- `source_filesystem`
788
+ `<root folder for extracted filesystem>`::
789
+ The root folder for the extracted filesystem (optional, defaults to `source_filesystem`)
368
790
 
369
791
  [example]
370
792
  ====
@@ -384,47 +806,67 @@ require 'fileutils'
384
806
  FileUtils.copy_entry '<in-memory filesystem root>', ARGV[2] || 'source_filesystem'
385
807
  ----
386
808
 
387
- == Ruby packaging specification
809
+ === Exit codes
388
810
 
389
- This is high-level description of the Tebako Ruby packaging mechanism.
390
- This specification was inspired by the `ruby-packer` approach.
811
+ The Tebako CLI exits with different exit codes to indicate the status of the
812
+ operation. The following table lists the possible exit codes and their meanings.
391
813
 
392
- NOTE: For various reasons, Tebako Ruby is a fully separate implementation,
393
- no line of code was copied from `ruby-packer`.
814
+ .Tebako CLI exit codes
815
+ [cols="a,a"]
816
+ |===
817
+ | Code | Condition
394
818
 
395
- Depending on the configuration files that are present in the root project folder,
396
- the Tebako Ruby packager support five different scenarios:
819
+ | 0 | No error
820
+ | 1 | Invalid command line
821
+ | 101 | `tebako setup` failed at configuration step
822
+ | 102 | `tebako setup` failed at build step
823
+ | 103 | `tebako press` failed at configuration step
824
+ | 104 | `tebako press` failed at build step
825
+ | 253 | Unsupported Ruby version
826
+ | 254 | Unsupported operating systems
827
+ | 255 | Internal error
397
828
 
398
- [cols="a,a,a,a"]
399
829
  |===
400
- | Scenario | `*.gemspec` | `Gemfile` | `*.gem`
401
830
 
402
- | 1 | No | No | No
403
- | 2 | No | No | One
404
- | 3 | One | No | Any
405
- | 4 | One | One | Any
406
- | 5 | No | One | Any
407
- | Error | No | No |Two or more
408
- | Error |Two or more| Any | Any
409
831
 
410
- |===
832
+ == Packaging scenarios with Ruby
833
+
834
+ Tebako for Ruby supports the following packaging scenarios.
835
+
836
+ This is high-level description of the Tebako Ruby packaging mechanism.
837
+
838
+ NOTE: These scenarios were inspired by the `ruby-packer` approach.
839
+
840
+ NOTE: Tebako Ruby is created independently from `ruby-packer`, no line of code
841
+ was copied from `ruby-packer`.
411
842
 
412
- These scenarios differ in what files are packaged and where the entry point is
413
- located, as follows:
843
+ Depending on the configuration files that are present in the root project folder, the Tebako Ruby packager supports different packaging scenarios.
414
844
 
415
- [cols="a,a,a,a"]
845
+ These scenarios differ in what files are packaged and where the entry point is located.
846
+
847
+ Here is a summary of the scenarios:
848
+
849
+ [cols="a,2a,4a,3a,a,a,a"]
416
850
  |===
417
- | Scenario | Description | Packaging | Entry point
851
+ | Scenario | Description | Packaging | Entry point | `*.gemspec` | `Gemfile` | `*.gem`
418
852
 
419
853
  | 1
420
854
  | Simple ruby script
421
855
  | Copy `<project-root>` with all sub-folders to packaged filesystem
422
856
  | `<mount_point>/local/<entry_point base name>`
857
+ | No
858
+ | No
859
+ | No
860
+
423
861
 
424
862
  | 2
425
863
  | Packaged gem
426
864
  | Install the gem with `gem install` to packaged filesystem
427
865
  | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
866
+ | No
867
+ | No
868
+ | One
869
+
428
870
 
429
871
  | 3
430
872
  | Gem source, no `bundler`
@@ -433,6 +875,10 @@ located, as follows:
433
875
  . Install it with `gem install` to packaged filesystem
434
876
 
435
877
  | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
878
+ | One
879
+ | No
880
+ | Any
881
+
436
882
 
437
883
  | 4
438
884
  | Gem source, `bundler`
@@ -442,15 +888,43 @@ located, as follows:
442
888
  . Install it with `gem install` to packaged file system
443
889
 
444
890
  | `<mount_point>/bin/<entry_point base name>` (i.e., binstub is expected)
891
+ | One
892
+ | One
893
+ | Any
894
+
445
895
 
446
896
  | 5
447
897
  | Rails project
448
898
  | Deploy project to packaged filesystem using `bundle install`
449
899
  | `<mount_point>/local/<entry_point base name>`
900
+ | No
901
+ | One
902
+ | Any
903
+
904
+
905
+ | Error
906
+ | Error: Two or more `*.gem` files present
907
+ | -
908
+ | -
909
+ | No
910
+ | No
911
+ | Two or more
912
+
913
+
914
+ | Error
915
+ | Error: Two or more `*.gemspec` files present
916
+ | -
917
+ | -
918
+ | Two or more
919
+ | Any
920
+ | Any
450
921
 
451
922
  |===
452
923
 
453
924
 
925
+ These scenarios determine how the project is packaged and where the entry point is located within the packaged filesystem.
926
+
927
+
454
928
  == Trivia: origin of name
455
929
 
456
930
  "tamatebako" (玉手箱) is the treasure box given to Urashima Taro in the Ryugu,
@@ -463,3 +937,14 @@ the said treasure box (storing gems inside a treasure box).
463
937
 
464
938
  Since "tamatebako" is rather long for the non-Japanese speaker, we use "tebako"
465
939
  (手箱, also "tehako") instead, the generic term for a personal box.
940
+
941
+ == Contributing
942
+
943
+ We welcome contributions! Please see our contributing guidelines for more
944
+ information.
945
+
946
+ == License
947
+
948
+ Copyright Ribose. All rights reserved.
949
+
950
+ Tebako is released under the BSD 2-Clause License. See the LICENSE file for details.