tebako 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +5 -15
- data/README.adoc +237 -75
- data/common.env +1 -1
- data/lib/tebako/cli.rb +34 -11
- data/lib/tebako/cli_helpers.rb +25 -9
- data/lib/tebako/codegen.rb +95 -10
- data/lib/tebako/deploy_helper.rb +1 -1
- data/lib/tebako/options_manager.rb +89 -12
- data/lib/tebako/package_descriptor.rb +143 -0
- data/lib/tebako/packager.rb +12 -18
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/scenario_manager.rb +1 -1
- data/lib/tebako/version.rb +1 -1
- data/src/tebako-main.cpp +46 -30
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04ff17b2a527c5b6cf6f1630f097d828a10fa3f0fa32eaa86e3c2a063a579e19
|
4
|
+
data.tar.gz: 740f889112a57820ce703917e4654403e13dd7960ccab22d02ceb6b9050f51d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e48b494352c230d533f914ef9553c8a48f8f0de56f291e1738a391d2991469c873be5397ebb58b480f91be0bd2c9510316d4e93922994dd625ffe6045b3f1a8
|
7
|
+
data.tar.gz: 7c4418d8bba50f67956db52b149001f407d8e1e4f64d44a41bdb63dfdec57d2a9fcebbdf681ed49d97fc3fc841c9515399b67002873aa1821f746e244d8033b0
|
data/CMakeLists.txt
CHANGED
@@ -181,7 +181,7 @@ string(CONCAT RUBY_API_VER ${RUBY_VER_BASE} ".0")
|
|
181
181
|
# list(GET LIBDWARFS_WR_VER_COMPONENTS 2 LIBDWARFS_WR_VER_PATCH)
|
182
182
|
# set (LIBDWARFS_WR_VER_M ${LIBDWARFS_WR_VER_MAJOR}.${LIBDWARFS_WR_VER_MINOR}.${LIBDWARFS_WR_VER_PATCH})
|
183
183
|
#else(DWARFS_PRELOAD)
|
184
|
-
def_ext_prj_g(DWARFS_WR "v0.
|
184
|
+
def_ext_prj_g(DWARFS_WR "v0.9.2")
|
185
185
|
#endif(DWARFS_PRELOAD)
|
186
186
|
|
187
187
|
def_ext_prj_g(PATCHELF "65e14792061c298f1d2bc44becd48a10cbf0bc81")
|
@@ -406,24 +406,14 @@ else (${SETUP_MODE})
|
|
406
406
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
407
407
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
408
408
|
|
409
|
+
# ...................................................................
|
410
|
+
# Packaged filesystem
|
411
|
+
|
409
412
|
add_custom_target(packaged_filesystem
|
410
413
|
COMMAND ruby ${DEPS_BIN_DIR}/deploy.rb
|
411
414
|
DEPENDS ${RUBY_PRJ}
|
412
415
|
BYPRODUCTS ${DATA_BIN_FILE}
|
413
|
-
|
414
|
-
|
415
|
-
# ...................................................................
|
416
|
-
# Packaged filesystem
|
417
|
-
|
418
|
-
#add_custom_target(packaged_filesystem
|
419
|
-
# No progress below is critical since in reporting mode mkdwarfs tries to work directly with terminal
|
420
|
-
# and it creates issues for stderr redirects (&2 > 1) used by Ninja and our test srcipts
|
421
|
-
# It may be fixable bit is very difficult to reproduce in test environment
|
422
|
-
# COMMAND ${DEPS_BIN_DIR}/mkdwarfs -o ${DATA_BIN_FILE} -i ${DATA_SRC_DIR} --no-progress
|
423
|
-
# #COMMAND ${CMAKE_COMMAND} -E touch ${DEPS_SRC_DIR}/tebako/tebako-fs.cpp
|
424
|
-
# DEPENDS setup source_filesystem
|
425
|
-
# VERBATIM
|
426
|
-
#)
|
416
|
+
)
|
427
417
|
|
428
418
|
set(CMAKE_CXX_FLAGS "${RUBY_C_FLAGS}")
|
429
419
|
|
data/README.adoc
CHANGED
@@ -26,20 +26,23 @@ a bundled runtime into a single, performant, executable binary.
|
|
26
26
|
|
27
27
|
== Architecture
|
28
28
|
|
29
|
-
A Tebako
|
29
|
+
A Tebako package is effectively a self-executing container-in-a-file.
|
30
30
|
|
31
|
-
The
|
31
|
+
The package contains the following components:
|
32
32
|
|
33
33
|
* An on-file filesystem (OFFS) containing all the project files and
|
34
|
-
dependencies in DwarFS format
|
34
|
+
dependencies in DwarFS format ("application")
|
35
35
|
|
36
|
-
* A runtime environment that includes the necessary libraries and interpreters,
|
36
|
+
* A runtime environment that includes the the necessary libraries and interpreters,
|
37
37
|
with patched filesystem calls that redirect access of project files to the
|
38
|
-
on-file filesystem
|
38
|
+
on-file filesystem ("runtime")
|
39
39
|
|
40
|
-
|
41
|
-
the
|
40
|
+
Tebako is capable to create a single file that contains both runtime and
|
41
|
+
application or place runtime and application to separate files. In the latter
|
42
|
+
case the runtime can be used with different applications or versions of the same
|
43
|
+
application.
|
42
44
|
|
45
|
+
Please refer to `mode` option below that controls Tebako output.
|
43
46
|
|
44
47
|
== Supported runtimes, platforms and architectures
|
45
48
|
|
@@ -72,19 +75,24 @@ architectures.
|
|
72
75
|
====
|
73
76
|
Windows build caveats:
|
74
77
|
|
75
|
-
* Tebako may face errors related to CMake path length limitations
|
76
|
-
|
77
|
-
|
78
|
+
* Tebako may face errors related to CMake path length limitations
|
79
|
+
(https://gitlab.kitware.com/cmake/cmake/-/issues/25936).
|
80
|
+
This error may affect not Tebako itself but the gems that need to be package and
|
81
|
+
use CMake to build native extensions.
|
82
|
+
There is no workaround for this issue as it looks like is a limitation of the
|
83
|
+
manifest used to build CMake executable.
|
78
84
|
|
79
|
-
* MSys strip utility creates broken executable when
|
80
|
-
executables as well.
|
81
|
-
Until this issue (https://github.com/tamatebako/tebako/issues/172) is resolved
|
82
|
-
|
85
|
+
* MSys strip utility creates broken executable when Tebako image is processed.
|
86
|
+
Linking with `-s` flag produces unusable executables as well.
|
87
|
+
Until this issue (https://github.com/tamatebako/tebako/issues/172) is resolved
|
88
|
+
we plan to produce a Windows executable with debug information unstripped. You
|
89
|
+
can opt to run `strip -S` manually, it most cases it works.
|
83
90
|
|
84
91
|
MacOS build caveats:
|
85
92
|
|
86
|
-
* We saw clang compiler
|
87
|
-
This issue is not reproducible with XCode 15.0.1 or
|
93
|
+
* We saw `clang` compiler segmentation fault when during packaging of very large
|
94
|
+
projects with XCode 14.3.1. This issue is not reproducible with XCode 15.0.1 or
|
95
|
+
higher.
|
88
96
|
====
|
89
97
|
|
90
98
|
|
@@ -302,9 +310,6 @@ Removes Tebako Ruby artifacts.
|
|
302
310
|
`hash`::
|
303
311
|
Calculates the Tebako script hash for use as a cache key in CI/CD environments.
|
304
312
|
|
305
|
-
`extract`::
|
306
|
-
Extracts the filesystem from a Tebako package.
|
307
|
-
|
308
313
|
`version`::
|
309
314
|
Displays the Tebako version.
|
310
315
|
|
@@ -595,24 +600,46 @@ brew bundle
|
|
595
600
|
|
596
601
|
Tebako requires Bison 3+.
|
597
602
|
|
598
|
-
On macOS 14, the default Bison version is 2.3, and the Homebrew formula is
|
599
|
-
which means that the full path to the Bison binary must be used to
|
600
|
-
correct version.
|
603
|
+
On macOS 14, the default Bison version is 2.3, and the Homebrew formula is
|
604
|
+
keg-only, which means that the full path to the Bison binary must be used to
|
605
|
+
utilize the correct version.
|
601
606
|
|
602
607
|
Run the following command prior to using Tebako, or add it into your shell
|
603
608
|
profile.
|
604
609
|
|
605
|
-
|
610
|
+
[source,sh]
|
611
|
+
----
|
612
|
+
export PATH="$(brew --prefix bison)/bin:$PATH"
|
613
|
+
----
|
614
|
+
|
615
|
+
====== jemalloc library build
|
616
|
+
|
617
|
+
On macOS, the `libdwarfs` build script creates an additional `jemalloc`
|
618
|
+
installation. This is done to satisfy the magic applied by folly during linking
|
619
|
+
but uses a static library.
|
620
|
+
|
621
|
+
If the `jemalloc` library is built within an emulated environment (QEMU,
|
622
|
+
Rosetta, etc.), there are known issues
|
623
|
+
(link:https://github.com/jemalloc/jemalloc/issues/1997[jemalloc issue #1997])
|
624
|
+
where `jemalloc` incorrectly detects the number of significant virtual address
|
625
|
+
bits and therefore defines them wrongly (`lg-vaddr` parameter).
|
606
626
|
|
607
|
-
|
608
|
-
|
627
|
+
Technically, these issues can be fixed by explicitly setting the
|
628
|
+
`--with-lg-vaddr` parameter for the `jemalloc` build. However, we decided not to
|
629
|
+
automate this since we do not feel that we can provide reasonable test coverage.
|
609
630
|
|
610
|
-
|
631
|
+
Instead, our build script accepts the `LG_VADDR` environment variable and passes
|
632
|
+
it to the jemalloc build as `--with-lg-vaddr=${LG_VADDR}`.
|
611
633
|
|
612
|
-
The `LG_VADDR` parameter specifies the number of significant virtual address
|
634
|
+
The `LG_VADDR` parameter specifies the number of significant virtual address
|
635
|
+
bits, which can vary based on the CPU architecture and emulation status.
|
613
636
|
|
614
|
-
|
637
|
+
This is a simple example script to set `LG_VADDR`.
|
615
638
|
|
639
|
+
NOTE: This is provided for illustration only.
|
640
|
+
|
641
|
+
[example]
|
642
|
+
====
|
616
643
|
[source,sh]
|
617
644
|
----
|
618
645
|
#!/bin/bash
|
@@ -634,13 +661,9 @@ fi
|
|
634
661
|
|
635
662
|
echo "Setting lg-vaddr to $LG_VADDR"
|
636
663
|
----
|
664
|
+
====
|
637
665
|
|
638
666
|
|
639
|
-
[source,sh]
|
640
|
-
----
|
641
|
-
export PATH="$(brew --prefix bison)/bin:$PATH"
|
642
|
-
----
|
643
|
-
|
644
667
|
===== Windows
|
645
668
|
|
646
669
|
====== General
|
@@ -676,6 +699,7 @@ $ pacman -S git tar bison flex toolchain make cmake
|
|
676
699
|
|
677
700
|
== Packaging
|
678
701
|
|
702
|
+
[[root-folder-selection]]
|
679
703
|
=== Tebako root folder (aka prefix) selection
|
680
704
|
|
681
705
|
The Tebako prefix determines the base directory for the Tebako setup.
|
@@ -726,7 +750,7 @@ the packaging environment and collects the required dependencies. Subsequent
|
|
726
750
|
invocations are much faster.
|
727
751
|
====
|
728
752
|
|
729
|
-
Upon the next invocation
|
753
|
+
Upon the next invocation, Tebako will use previously created packaging
|
730
754
|
environment. The press process itself takes minutes.
|
731
755
|
|
732
756
|
You can manage setup of packaging environment manually; please refer to
|
@@ -744,53 +768,100 @@ tebako press \
|
|
744
768
|
[-c|--cwd=<package current working directory>]
|
745
769
|
[-D|--devmode] \
|
746
770
|
[-P|--patchelf] \
|
771
|
+
[-m|--mode=<bundle|both|application|runtime>] \
|
772
|
+
[-u|--ref=<runtime-reference>] \
|
747
773
|
[-t|--tebafile=<path-to-tebafile>]
|
748
774
|
----
|
749
775
|
|
750
776
|
Where:
|
751
777
|
|
752
778
|
`<tebako-root-folder>`::
|
753
|
-
the Tebako root folder (see details
|
779
|
+
the Tebako root folder (see details: <<root-folder-selection>>)
|
754
780
|
|
755
781
|
`Ruby`::
|
756
782
|
this parameter defines Ruby version that will be packaged (optional, defaults to
|
757
783
|
`3.1.6`)
|
758
784
|
|
759
785
|
`project-root`::
|
760
|
-
a folder at the host source file system where project files are located
|
786
|
+
a folder at the host source file system where project files are located.
|
787
|
+
This parameter is not required if the operation mode is `runtime`.
|
761
788
|
|
762
789
|
`entry-point`::
|
763
790
|
an executable file (binary executable or script) that shall be started when
|
764
|
-
packaged file is called
|
791
|
+
packaged file is called. This parameter is not required if the operation mode is `runtime`.
|
765
792
|
|
766
793
|
`output`::
|
767
|
-
|
794
|
+
(optional)
|
795
|
+
the output file name.
|
796
|
+
+
|
797
|
+
Defaults to `<current folder>/<entry point base name>`.
|
798
|
+
+
|
799
|
+
On Windows output file will have `exe` extension.
|
800
|
+
If the application is to be a separate file (`both` or `application` mode), it
|
801
|
+
will have the same name with the `.tebako` extension.
|
768
802
|
|
769
803
|
`log-level`::
|
770
804
|
logging level for the Tebako built-in memory filesystem driver
|
771
805
|
(optional, defaults to `error`)
|
772
806
|
|
773
807
|
`cwd`::
|
808
|
+
(optional)
|
774
809
|
a folder within Tebako memfs where the packaged application will start. This folder should be specified relative to the memfs root.
|
775
|
-
|
776
|
-
|
777
|
-
|
810
|
+
+
|
811
|
+
If not provided, the application will start within the current folder of the
|
812
|
+
host (i.e., at `$PWD`).
|
813
|
+
+
|
814
|
+
This argument is required because it is not possible to change the directory to
|
815
|
+
a memfs folder until the package is started, as opposed to any host folder that
|
816
|
+
can be set as the current directory before Tebako package invocation. Tebako
|
817
|
+
saves the original working directory in a global Ruby variable
|
818
|
+
`$tebako_original_pwd`.
|
778
819
|
|
779
820
|
`devmode`:: flag that activates development mode, in which Tebako's cache and
|
780
821
|
packaging consistency checks are relaxed.
|
781
822
|
|
782
823
|
`patchelf`::
|
783
|
-
|
784
|
-
|
785
|
-
|
824
|
+
Allows forward-compatibility of Tebako packages with Linux GNU distributions.
|
825
|
+
+
|
826
|
+
Specifically, this is a flag that removes a reference to the `GLIBC_PRIVATE`
|
827
|
+
version of `libpthread` from a Tebako package. This allows Linux GNU packages
|
828
|
+
to run against versions of `libpthread` that differ from the version used for
|
829
|
+
packaging.
|
830
|
+
+
|
831
|
+
NOTE: This option only works on GNU Linux only.
|
832
|
+
+
|
833
|
+
[example]
|
834
|
+
For example, a package created at Ubuntu 20 system can be used on Ubuntu 22.
|
835
|
+
+
|
836
|
+
NOTE: The feature is exeprimental, we may consider another approach in the future.
|
837
|
+
|
838
|
+
`mode`::
|
839
|
+
output mode for tebako package (optional, defaults to `bundle`).
|
840
|
+
|
841
|
+
`bundle`::: place runtime and application to a single file
|
842
|
+
`both`::: create both run-rime and application
|
843
|
+
`application`::: create appplication only
|
844
|
+
`runtime`::: create runtime only
|
845
|
+
|
846
|
+
`ref`::
|
847
|
+
(optional)
|
848
|
+
Defaults to `tebako-runtime`.
|
849
|
+
When a Tebako application package is created on Windows, it is linked against a
|
850
|
+
Tebako runtime file name. The `ref` parameter allows to specify the name of the
|
851
|
+
runtime file.
|
852
|
+
+
|
853
|
+
NOTE: The `ref` option specificies the name of the runtime -- the runtime file
|
854
|
+
can be recreated or changed but not renamed.
|
786
855
|
|
787
856
|
`tebafile`::
|
788
857
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
789
|
-
Please refer to the separate section below for tebafile
|
858
|
+
Please refer to the separate section below for description of the tebafile.
|
790
859
|
+
|
791
|
-
|
792
|
-
|
793
|
-
|
860
|
+
NOTE: Development mode is *not intended for production use* and should only be
|
861
|
+
used during development.
|
862
|
+
+
|
863
|
+
NOTE: `entry-point` and `project-root-folder` are required parameters and may be
|
864
|
+
provided either via command-line or in the tebafile.
|
794
865
|
|
795
866
|
[example]
|
796
867
|
====
|
@@ -831,9 +902,9 @@ $ tebako setup \
|
|
831
902
|
|
832
903
|
Where:
|
833
904
|
|
834
|
-
`<tebako-root-folder>`:: the Tebako root folder (see details
|
905
|
+
`<tebako-root-folder>`:: the Tebako root folder (see details: <<root-folder-selection>>)
|
835
906
|
|
836
|
-
`Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
|
907
|
+
`Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to `3.1.6`)
|
837
908
|
|
838
909
|
`tebafile`::
|
839
910
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
@@ -858,7 +929,7 @@ $ tebako clean \
|
|
858
929
|
|
859
930
|
Where:
|
860
931
|
|
861
|
-
`<tebako-root-folder>`:: the Tebako root folder (see details
|
932
|
+
`<tebako-root-folder>`:: the Tebako root folder (see details: <<root-folder-selection>>)
|
862
933
|
|
863
934
|
`tebafile`::
|
864
935
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
@@ -925,8 +996,14 @@ $ tebako hash
|
|
925
996
|
|
926
997
|
=== Tebako configuration file
|
927
998
|
|
928
|
-
It is possible to provide all or some options for the `tebako
|
929
|
-
|
999
|
+
It is possible to provide all or some options for the `tebako
|
1000
|
+
{setup | press | clean | clean_ruby}` commands via a Tebako configuration file
|
1001
|
+
('tebafile').
|
1002
|
+
|
1003
|
+
Tebafile is a YAML file with a single key `options`. The options are the same as
|
1004
|
+
long names for the command line.
|
1005
|
+
|
1006
|
+
For example, for the prefix option:
|
930
1007
|
|
931
1008
|
[source]
|
932
1009
|
----
|
@@ -934,15 +1011,37 @@ Tebafile is a YAML file with a single section 'options'. The options are the sam
|
|
934
1011
|
----
|
935
1012
|
the key in the YAML file would be 'prefix'.
|
936
1013
|
|
937
|
-
|
1014
|
+
.Example tebafile that sets values for prefix and Ruby options
|
1015
|
+
[example]
|
1016
|
+
====
|
1017
|
+
This is an example tebafile that sets values for prefix and Ruby options:
|
1018
|
+
|
938
1019
|
[source,yaml]
|
939
1020
|
----
|
940
1021
|
options:
|
941
1022
|
prefix: /tmp/tebako
|
942
1023
|
Ruby: 3.2.4
|
943
1024
|
----
|
1025
|
+
====
|
1026
|
+
|
1027
|
+
=== Options prefernce order
|
1028
|
+
|
1029
|
+
Tebako supports several methods to set options. The table below show preference order and limitations for specific options.
|
1030
|
+
samller order means higher proirity.
|
1031
|
+
|
1032
|
+
[cols="4", options="header"]
|
1033
|
+
|===
|
1034
|
+
| Order | Mode | Option source | Applicability
|
1035
|
+
|
1036
|
+
| 1 | All | Command-line | All options
|
1037
|
+
| 2 | All |Tebako configuration file | All option except ``--tebafile`` (you can not specify new tebafile in a tebafile)
|
1038
|
+
.2+| 3 .2+| All .2+| Environment variable | TEBAKO_PREFIX to set ``--prefix`` option
|
1039
|
+
| LG_VADDR to set ``--with-lg-vaddr`` jemalloc parameter
|
1040
|
+
.2+| 4 | ``runtime`` | Tebako defaults | All options except ``--entry-point`` and ``--root`` that are mandatory
|
1041
|
+
| ``bundle``, ``both``, ``application`` | Tebako defaults | All options
|
1042
|
+
|
1043
|
+
|===
|
944
1044
|
|
945
|
-
Please note that the options provided on the command line have preference over tebafile settings.
|
946
1045
|
|
947
1046
|
=== Exit codes
|
948
1047
|
|
@@ -1063,7 +1162,9 @@ These scenarios determine how the project is packaged and where the entry point
|
|
1063
1162
|
|
1064
1163
|
== Run-time options
|
1065
1164
|
|
1066
|
-
|
1165
|
+
=== General
|
1166
|
+
|
1167
|
+
Generally Tebako package passes command line options to the packaged application.
|
1067
1168
|
|
1068
1169
|
[example]
|
1069
1170
|
====
|
@@ -1091,9 +1192,53 @@ myproject --option --parameter value
|
|
1091
1192
|
----
|
1092
1193
|
====
|
1093
1194
|
|
1094
|
-
However there are several command-line parameters that are intercepted processed
|
1195
|
+
However there are several command-line parameters that are intercepted processed
|
1196
|
+
by Tebako bootstrap code as described below.
|
1197
|
+
|
1198
|
+
=== Running tebako image by tebako runtime (`--tebako-run` option)
|
1199
|
+
|
1200
|
+
Tebako provides an option to an extract its DwarFS filesystem from a package to
|
1201
|
+
a local folder for verification or execution.
|
1202
|
+
|
1203
|
+
[source,sh]
|
1204
|
+
----
|
1205
|
+
$ <tebako-runtime> --tebako-run [<tebako application>]
|
1206
|
+
----
|
1207
|
+
|
1208
|
+
Where,
|
1209
|
+
|
1210
|
+
`<tebako runtime>`::
|
1211
|
+
The tebako runtime in ```runtime``` or ```both``` mode
|
1212
|
+
|
1213
|
+
`<tebako application>`::
|
1214
|
+
The tebako application package created in ```application``` or ```both``` mode
|
1215
|
+
|
1216
|
+
[example]
|
1217
|
+
====
|
1218
|
+
Creating separate runtime and application and running it:
|
1219
|
+
|
1220
|
+
[source,sh]
|
1221
|
+
----
|
1222
|
+
tebako press -m runtime -o tebako-runtime
|
1223
|
+
tebako press -m application -o tebako-application -e hello.rb -r test
|
1224
|
+
tabako-runtime --tebako-run tebako-application Maxim
|
1225
|
+
----
|
1226
|
+
where hello.rb is the Ruby application
|
1227
|
+
[source,Ruby]
|
1228
|
+
----
|
1229
|
+
# frozen_string_literal: true
|
1230
|
+
|
1231
|
+
puts "Hello, #{ARGV[0]}!"
|
1232
|
+
----
|
1233
|
+
And expected output from ```tabako-runtime --tebako-run tebako-application Maxim``` is
|
1234
|
+
[source,sh]
|
1235
|
+
----
|
1236
|
+
Hello, Maxim!
|
1237
|
+
----
|
1238
|
+
|
1239
|
+
====
|
1095
1240
|
|
1096
|
-
=== Image extraction (
|
1241
|
+
=== Image extraction (`--tebako-extract` option)
|
1097
1242
|
|
1098
1243
|
Tebako provides an option to an extract its DwarFS filesystem from a package to
|
1099
1244
|
a local folder for verification or execution.
|
@@ -1126,27 +1271,42 @@ require 'fileutils'
|
|
1126
1271
|
FileUtils.copy_entry '<in-memory filesystem root>', ARGV[2] || 'source_filesystem'
|
1127
1272
|
----
|
1128
1273
|
|
1129
|
-
=== Mounting
|
1274
|
+
=== Mounting host folder to Tebako memfs (`--tebako-mount` option)
|
1275
|
+
|
1276
|
+
Some programs unconditionally use folders located under the application root,
|
1277
|
+
and when processed by Tebako or similar tools, these folders are included in the
|
1278
|
+
packaging.
|
1279
|
+
|
1280
|
+
[example]
|
1281
|
+
====
|
1282
|
+
Rails, for example, does not provide a configuration option to change where
|
1283
|
+
it expects the `tmp` folder to be.
|
1284
|
+
|
1285
|
+
The location is hardcoded in multiple places within the Rails codebase, residing
|
1286
|
+
under the application root, and as a result, it gets included in the read-only
|
1287
|
+
Tebako memfs.
|
1130
1288
|
|
1131
|
-
|
1132
|
-
|
1289
|
+
Although patches have been proposed (e.g.,
|
1290
|
+
https://github.com/rails/rails/issues/39583), there is currently no way to
|
1291
|
+
change the paths for temporary files, caches, and sockets.
|
1292
|
+
====
|
1133
1293
|
|
1134
|
-
|
1135
|
-
|
1136
|
-
and as a result, it gets included in the read-only Tebako memfs. Although patches have been proposed
|
1137
|
-
(e.g., https://github.com/rails/rails/issues/39583), there is currently no way to change the paths for
|
1138
|
-
temporary files, caches, and sockets.
|
1294
|
+
To address this inevitable limitation for Ruby applications,
|
1295
|
+
Tebako provides an option to mount a host folder to the memfs tree.
|
1139
1296
|
|
1140
|
-
|
1141
|
-
|
1297
|
+
When using Tebako, consider the packaging scenario mentioned above, as it
|
1298
|
+
defines the layout of the application tree.
|
1142
1299
|
|
1143
|
-
|
1144
|
-
|
1300
|
+
The `--tebako-extract` option may be useful for understanding the placement of
|
1301
|
+
files and folders.
|
1145
1302
|
|
1146
1303
|
[example]
|
1147
1304
|
====
|
1148
|
-
The following command starts a `rails.tebako` package with `$PWD/tmp` mounted as
|
1305
|
+
The following command starts a `rails.tebako` package with `$PWD/tmp` mounted as
|
1306
|
+
`local/tmp` in the memfs.
|
1307
|
+
|
1149
1308
|
Any remaining command-line parameters are passed to the application.
|
1309
|
+
|
1150
1310
|
[source,sh]
|
1151
1311
|
----
|
1152
1312
|
rails.tebako --tebako-mount local/tmp:$PWD/tmp server
|
@@ -1154,15 +1314,17 @@ rails.tebako --tebako-mount local/tmp:$PWD/tmp server
|
|
1154
1314
|
====
|
1155
1315
|
|
1156
1316
|
The `--tebako-mount` option has the following syntax:
|
1317
|
+
|
1157
1318
|
[source,sh]
|
1158
1319
|
----
|
1159
1320
|
--tebako-mount <memfs path>:<host path>
|
1160
1321
|
----
|
1161
1322
|
|
1162
|
-
The `--tebako-mount` option can be repeated multiple times to mount more than
|
1163
|
-
is relative to the memfs root, and it is
|
1164
|
-
|
1165
|
-
|
1323
|
+
The `--tebako-mount` option can be repeated multiple times to mount more than
|
1324
|
+
one object. The `memfs path` is relative to the memfs root, and it is
|
1325
|
+
recommended to use absolute paths for host objects. Both directories and files
|
1326
|
+
can be mounted in this way. Tebako allows overlaying existing memfs objects, so
|
1327
|
+
there are no significant limitations.
|
1166
1328
|
|
1167
1329
|
== Trivia: origin of name
|
1168
1330
|
|
data/common.env
CHANGED
data/lib/tebako/cli.rb
CHANGED
@@ -43,7 +43,7 @@ require_relative "version"
|
|
43
43
|
module Tebako
|
44
44
|
DEFAULT_TEBAFILE = ".tebako.yml"
|
45
45
|
# Tebako packager front-end
|
46
|
-
class Cli < Thor
|
46
|
+
class Cli < Thor # rubocop:disable Metrics/ClassLength
|
47
47
|
package_name "Tebako"
|
48
48
|
class_option :prefix, type: :string, aliases: "-p", required: false,
|
49
49
|
desc: "A path to tebako packaging environment, '~/.tebako' ('$HOME/.tebako') by default"
|
@@ -82,28 +82,35 @@ module Tebako
|
|
82
82
|
#{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
|
83
83
|
DESC
|
84
84
|
|
85
|
+
REF_DESCRIPTION = <<~DESC
|
86
|
+
"Referenced tebako run-time package; 'tebako-runtime' by default".
|
87
|
+
This option specifies the tebako runtime to be used by the application on Windows and if mode is 'application' only .
|
88
|
+
DESC
|
89
|
+
|
85
90
|
RGP_DESCRIPTION = <<~DESC
|
86
|
-
|
87
|
-
#{" " * 65}#
|
88
|
-
#{" " * 65}# Gnu toolchain only (not for LLVM/clang). The feature is exeprimental, we may consider other approach in the future.
|
91
|
+
Current working directory for packaged application. This directory shall be specified relative to root.
|
92
|
+
#{" " * 65}# If this parameter is not set, the application will start in the current directory of the host file system.
|
89
93
|
DESC
|
90
94
|
|
91
95
|
desc "press", "Press tebako image"
|
92
|
-
method_option :cwd, type: :string, aliases: "-c", required: false,
|
93
|
-
desc: CWD_DESCRIPTION
|
94
|
-
method_option :"entry-point", type: :string, aliases: ["-e", "--entry"], required: true,
|
95
|
-
desc: "Ruby application entry point"
|
96
|
+
method_option :cwd, type: :string, aliases: "-c", required: false, desc: CWD_DESCRIPTION
|
96
97
|
method_option :"log-level", type: :string, aliases: "-l", required: false, enum: %w[error warn debug trace],
|
97
98
|
desc: "Tebako memfs logging level, 'error' by default"
|
98
99
|
method_option :output, type: :string, aliases: "-o", required: false,
|
99
100
|
desc: "Tebako package file name, entry point base file name in the current folder by default"
|
100
|
-
method_option :
|
101
|
+
method_option :"entry-point", type: :string, aliases: ["-e", "--entry"], required: false,
|
102
|
+
desc: "Ruby application entry point"
|
103
|
+
method_option :root, type: :string, aliases: "-r", required: false, desc: "Root folder of the Ruby application"
|
101
104
|
method_option :Ruby, type: :string, aliases: "-R", required: false,
|
102
105
|
enum: Tebako::RubyVersion::RUBY_VERSIONS.keys,
|
103
106
|
desc: "Tebako package Ruby version, #{Tebako::RubyVersion::DEFAULT_RUBY_VERSION} by default"
|
104
|
-
method_option :patchelf, aliases: "-P", type: :boolean,
|
105
|
-
|
107
|
+
method_option :patchelf, aliases: "-P", type: :boolean, desc: RGP_DESCRIPTION
|
108
|
+
method_option :mode, type: :string, aliases: "-m", required: false, enum: %w[bundle both runtime application],
|
109
|
+
desc: "Tebako press mode, 'bundle' by default"
|
110
|
+
method_option :ref, type: :string, aliases: "-u", required: false, desc: REF_DESCRIPTION
|
111
|
+
|
106
112
|
def press
|
113
|
+
validate_press_options
|
107
114
|
(om, cm) = bootstrap
|
108
115
|
|
109
116
|
do_press(om)
|
@@ -159,6 +166,22 @@ module Tebako
|
|
159
166
|
end
|
160
167
|
end
|
161
168
|
|
169
|
+
no_commands do
|
170
|
+
def source
|
171
|
+
c_path = Pathname.new(__FILE__).realpath
|
172
|
+
@source ||= File.expand_path("../../..", c_path)
|
173
|
+
end
|
174
|
+
|
175
|
+
def validate_press_options
|
176
|
+
return unless options["mode"] != "runtime"
|
177
|
+
|
178
|
+
opts = ""
|
179
|
+
opts += " '--root'" if options["root"].nil?
|
180
|
+
opts += " '--entry-point'" if options["entry-point"].nil?
|
181
|
+
raise Thor::Error, "No value provided for required options #{opts}" unless opts.empty?
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
162
185
|
no_commands do
|
163
186
|
include Tebako::CliHelpers
|
164
187
|
end
|