tebako 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CMakeLists.txt +5 -15
- data/README.adoc +241 -78
- data/common.env +2 -2
- data/include/tebako/tebako-prism.h +51 -0
- 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/pass1_patch.rb +301 -0
- data/lib/tebako/packager/pass1a_patch.rb +55 -0
- data/lib/tebako/packager/pass2.rb +4 -3
- data/lib/tebako/packager/{pass1a.rb → patch.rb} +5 -13
- data/lib/tebako/packager/patch_literals.rb +39 -15
- data/lib/tebako/packager.rb +18 -23
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/ruby_version.rb +9 -3
- data/lib/tebako/scenario_manager.rb +1 -1
- data/lib/tebako/version.rb +1 -1
- data/src/tebako-main.cpp +46 -30
- metadata +8 -4
- data/lib/tebako/packager/pass1.rb +0 -242
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78803d4ebbfe58cdf860a80c9ec60fe44a80e2d12bd695678a37c914f069948b
|
4
|
+
data.tar.gz: f13f3e254a4058044a7c84c03f07ebc3c5a07c3fc00eda1e4ced0e336326fa55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76bd6166857ebf239218e3871136142a6c158a5d568f019eb374ea694b9af07d342378ee23e3e760063049b3e84048a42a92ed5b0dc420957898aef7679dd64
|
7
|
+
data.tar.gz: 15c95e6dcb0f746f4708548b5ceda202552fd2c9ed6461d4f814707ddb9c80d6d58fddf00791437a26142eb9db703f4d3017bb47f74f55afeb1a78fc6e78c585
|
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
|
|
@@ -96,8 +104,9 @@ This issue is not reproducible with XCode 15.0.1 or higher.
|
|
96
104
|
| 2.7.8 | Linux, macOS
|
97
105
|
| 3.0.7 | Linux, macOS
|
98
106
|
| 3.1.6 | Linux, macOS, Windows
|
99
|
-
| 3.2.{4,5} | Linux, macOS, Windows
|
100
|
-
| 3.3.{3,4,5} | Linux, macOS, Windows
|
107
|
+
| 3.2.{4,5,6} | Linux, macOS, Windows
|
108
|
+
| 3.3.{3,4,5,6} | Linux, macOS, Windows
|
109
|
+
| 3.4.1 | Linux, macOS, Windows
|
101
110
|
|
102
111
|
|===
|
103
112
|
|
@@ -302,9 +311,6 @@ Removes Tebako Ruby artifacts.
|
|
302
311
|
`hash`::
|
303
312
|
Calculates the Tebako script hash for use as a cache key in CI/CD environments.
|
304
313
|
|
305
|
-
`extract`::
|
306
|
-
Extracts the filesystem from a Tebako package.
|
307
|
-
|
308
314
|
`version`::
|
309
315
|
Displays the Tebako version.
|
310
316
|
|
@@ -595,24 +601,46 @@ brew bundle
|
|
595
601
|
|
596
602
|
Tebako requires Bison 3+.
|
597
603
|
|
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.
|
604
|
+
On macOS 14, the default Bison version is 2.3, and the Homebrew formula is
|
605
|
+
keg-only, which means that the full path to the Bison binary must be used to
|
606
|
+
utilize the correct version.
|
601
607
|
|
602
608
|
Run the following command prior to using Tebako, or add it into your shell
|
603
609
|
profile.
|
604
610
|
|
605
|
-
|
611
|
+
[source,sh]
|
612
|
+
----
|
613
|
+
export PATH="$(brew --prefix bison)/bin:$PATH"
|
614
|
+
----
|
615
|
+
|
616
|
+
====== jemalloc library build
|
617
|
+
|
618
|
+
On macOS, the `libdwarfs` build script creates an additional `jemalloc`
|
619
|
+
installation. This is done to satisfy the magic applied by folly during linking
|
620
|
+
but uses a static library.
|
621
|
+
|
622
|
+
If the `jemalloc` library is built within an emulated environment (QEMU,
|
623
|
+
Rosetta, etc.), there are known issues
|
624
|
+
(link:https://github.com/jemalloc/jemalloc/issues/1997[jemalloc issue #1997])
|
625
|
+
where `jemalloc` incorrectly detects the number of significant virtual address
|
626
|
+
bits and therefore defines them wrongly (`lg-vaddr` parameter).
|
606
627
|
|
607
|
-
|
608
|
-
|
628
|
+
Technically, these issues can be fixed by explicitly setting the
|
629
|
+
`--with-lg-vaddr` parameter for the `jemalloc` build. However, we decided not to
|
630
|
+
automate this since we do not feel that we can provide reasonable test coverage.
|
609
631
|
|
610
|
-
|
632
|
+
Instead, our build script accepts the `LG_VADDR` environment variable and passes
|
633
|
+
it to the jemalloc build as `--with-lg-vaddr=${LG_VADDR}`.
|
611
634
|
|
612
|
-
The `LG_VADDR` parameter specifies the number of significant virtual address
|
635
|
+
The `LG_VADDR` parameter specifies the number of significant virtual address
|
636
|
+
bits, which can vary based on the CPU architecture and emulation status.
|
613
637
|
|
614
|
-
|
638
|
+
This is a simple example script to set `LG_VADDR`.
|
615
639
|
|
640
|
+
NOTE: This is provided for illustration only.
|
641
|
+
|
642
|
+
[example]
|
643
|
+
====
|
616
644
|
[source,sh]
|
617
645
|
----
|
618
646
|
#!/bin/bash
|
@@ -634,13 +662,9 @@ fi
|
|
634
662
|
|
635
663
|
echo "Setting lg-vaddr to $LG_VADDR"
|
636
664
|
----
|
665
|
+
====
|
637
666
|
|
638
667
|
|
639
|
-
[source,sh]
|
640
|
-
----
|
641
|
-
export PATH="$(brew --prefix bison)/bin:$PATH"
|
642
|
-
----
|
643
|
-
|
644
668
|
===== Windows
|
645
669
|
|
646
670
|
====== General
|
@@ -676,6 +700,7 @@ $ pacman -S git tar bison flex toolchain make cmake
|
|
676
700
|
|
677
701
|
== Packaging
|
678
702
|
|
703
|
+
[[root-folder-selection]]
|
679
704
|
=== Tebako root folder (aka prefix) selection
|
680
705
|
|
681
706
|
The Tebako prefix determines the base directory for the Tebako setup.
|
@@ -726,7 +751,7 @@ the packaging environment and collects the required dependencies. Subsequent
|
|
726
751
|
invocations are much faster.
|
727
752
|
====
|
728
753
|
|
729
|
-
Upon the next invocation
|
754
|
+
Upon the next invocation, Tebako will use previously created packaging
|
730
755
|
environment. The press process itself takes minutes.
|
731
756
|
|
732
757
|
You can manage setup of packaging environment manually; please refer to
|
@@ -744,53 +769,100 @@ tebako press \
|
|
744
769
|
[-c|--cwd=<package current working directory>]
|
745
770
|
[-D|--devmode] \
|
746
771
|
[-P|--patchelf] \
|
772
|
+
[-m|--mode=<bundle|both|application|runtime>] \
|
773
|
+
[-u|--ref=<runtime-reference>] \
|
747
774
|
[-t|--tebafile=<path-to-tebafile>]
|
748
775
|
----
|
749
776
|
|
750
777
|
Where:
|
751
778
|
|
752
779
|
`<tebako-root-folder>`::
|
753
|
-
the Tebako root folder (see details
|
780
|
+
the Tebako root folder (see details: <<root-folder-selection>>)
|
754
781
|
|
755
782
|
`Ruby`::
|
756
783
|
this parameter defines Ruby version that will be packaged (optional, defaults to
|
757
|
-
`3.
|
784
|
+
`3.2.6`)
|
758
785
|
|
759
786
|
`project-root`::
|
760
|
-
a folder at the host source file system where project files are located
|
787
|
+
a folder at the host source file system where project files are located.
|
788
|
+
This parameter is not required if the operation mode is `runtime`.
|
761
789
|
|
762
790
|
`entry-point`::
|
763
791
|
an executable file (binary executable or script) that shall be started when
|
764
|
-
packaged file is called
|
792
|
+
packaged file is called. This parameter is not required if the operation mode is `runtime`.
|
765
793
|
|
766
794
|
`output`::
|
767
|
-
|
795
|
+
(optional)
|
796
|
+
the output file name.
|
797
|
+
+
|
798
|
+
Defaults to `<current folder>/<entry point base name>`.
|
799
|
+
+
|
800
|
+
On Windows output file will have `exe` extension.
|
801
|
+
If the application is to be a separate file (`both` or `application` mode), it
|
802
|
+
will have the same name with the `.tebako` extension.
|
768
803
|
|
769
804
|
`log-level`::
|
770
805
|
logging level for the Tebako built-in memory filesystem driver
|
771
806
|
(optional, defaults to `error`)
|
772
807
|
|
773
808
|
`cwd`::
|
809
|
+
(optional)
|
774
810
|
a folder within Tebako memfs where the packaged application will start. This folder should be specified relative to the memfs root.
|
775
|
-
|
776
|
-
|
777
|
-
|
811
|
+
+
|
812
|
+
If not provided, the application will start within the current folder of the
|
813
|
+
host (i.e., at `$PWD`).
|
814
|
+
+
|
815
|
+
This argument is required because it is not possible to change the directory to
|
816
|
+
a memfs folder until the package is started, as opposed to any host folder that
|
817
|
+
can be set as the current directory before Tebako package invocation. Tebako
|
818
|
+
saves the original working directory in a global Ruby variable
|
819
|
+
`$tebako_original_pwd`.
|
778
820
|
|
779
821
|
`devmode`:: flag that activates development mode, in which Tebako's cache and
|
780
822
|
packaging consistency checks are relaxed.
|
781
823
|
|
782
824
|
`patchelf`::
|
783
|
-
|
784
|
-
|
785
|
-
|
825
|
+
Allows forward-compatibility of Tebako packages with Linux GNU distributions.
|
826
|
+
+
|
827
|
+
Specifically, this is a flag that removes a reference to the `GLIBC_PRIVATE`
|
828
|
+
version of `libpthread` from a Tebako package. This allows Linux GNU packages
|
829
|
+
to run against versions of `libpthread` that differ from the version used for
|
830
|
+
packaging.
|
831
|
+
+
|
832
|
+
NOTE: This option only works on GNU Linux only.
|
833
|
+
+
|
834
|
+
[example]
|
835
|
+
For example, a package created at Ubuntu 20 system can be used on Ubuntu 22.
|
836
|
+
+
|
837
|
+
NOTE: The feature is exeprimental, we may consider another approach in the future.
|
838
|
+
|
839
|
+
`mode`::
|
840
|
+
output mode for tebako package (optional, defaults to `bundle`).
|
841
|
+
|
842
|
+
`bundle`::: place runtime and application to a single file
|
843
|
+
`both`::: create both run-rime and application
|
844
|
+
`application`::: create appplication only
|
845
|
+
`runtime`::: create runtime only
|
846
|
+
|
847
|
+
`ref`::
|
848
|
+
(optional)
|
849
|
+
Defaults to `tebako-runtime`.
|
850
|
+
When a Tebako application package is created on Windows, it is linked against a
|
851
|
+
Tebako runtime file name. The `ref` parameter allows to specify the name of the
|
852
|
+
runtime file.
|
853
|
+
+
|
854
|
+
NOTE: The `ref` option specificies the name of the runtime -- the runtime file
|
855
|
+
can be recreated or changed but not renamed.
|
786
856
|
|
787
857
|
`tebafile`::
|
788
858
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
789
|
-
Please refer to the separate section below for tebafile
|
859
|
+
Please refer to the separate section below for description of the tebafile.
|
790
860
|
+
|
791
|
-
|
792
|
-
|
793
|
-
|
861
|
+
NOTE: Development mode is *not intended for production use* and should only be
|
862
|
+
used during development.
|
863
|
+
+
|
864
|
+
NOTE: `entry-point` and `project-root-folder` are required parameters and may be
|
865
|
+
provided either via command-line or in the tebafile.
|
794
866
|
|
795
867
|
[example]
|
796
868
|
====
|
@@ -831,9 +903,9 @@ $ tebako setup \
|
|
831
903
|
|
832
904
|
Where:
|
833
905
|
|
834
|
-
`<tebako-root-folder>`:: the Tebako root folder (see details
|
906
|
+
`<tebako-root-folder>`:: the Tebako root folder (see details: <<root-folder-selection>>)
|
835
907
|
|
836
|
-
`Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to 3.
|
908
|
+
`Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to `3.2.6`)
|
837
909
|
|
838
910
|
`tebafile`::
|
839
911
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
@@ -858,7 +930,7 @@ $ tebako clean \
|
|
858
930
|
|
859
931
|
Where:
|
860
932
|
|
861
|
-
`<tebako-root-folder>`:: the Tebako root folder (see details
|
933
|
+
`<tebako-root-folder>`:: the Tebako root folder (see details: <<root-folder-selection>>)
|
862
934
|
|
863
935
|
`tebafile`::
|
864
936
|
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
@@ -925,8 +997,14 @@ $ tebako hash
|
|
925
997
|
|
926
998
|
=== Tebako configuration file
|
927
999
|
|
928
|
-
It is possible to provide all or some options for the `tebako
|
929
|
-
|
1000
|
+
It is possible to provide all or some options for the `tebako
|
1001
|
+
{setup | press | clean | clean_ruby}` commands via a Tebako configuration file
|
1002
|
+
('tebafile').
|
1003
|
+
|
1004
|
+
Tebafile is a YAML file with a single key `options`. The options are the same as
|
1005
|
+
long names for the command line.
|
1006
|
+
|
1007
|
+
For example, for the prefix option:
|
930
1008
|
|
931
1009
|
[source]
|
932
1010
|
----
|
@@ -934,15 +1012,37 @@ Tebafile is a YAML file with a single section 'options'. The options are the sam
|
|
934
1012
|
----
|
935
1013
|
the key in the YAML file would be 'prefix'.
|
936
1014
|
|
937
|
-
|
1015
|
+
.Example tebafile that sets values for prefix and Ruby options
|
1016
|
+
[example]
|
1017
|
+
====
|
1018
|
+
This is an example tebafile that sets values for prefix and Ruby options:
|
1019
|
+
|
938
1020
|
[source,yaml]
|
939
1021
|
----
|
940
1022
|
options:
|
941
1023
|
prefix: /tmp/tebako
|
942
1024
|
Ruby: 3.2.4
|
943
1025
|
----
|
1026
|
+
====
|
1027
|
+
|
1028
|
+
=== Options prefernce order
|
1029
|
+
|
1030
|
+
Tebako supports several methods to set options. The table below show preference order and limitations for specific options.
|
1031
|
+
samller order means higher proirity.
|
1032
|
+
|
1033
|
+
[cols="4", options="header"]
|
1034
|
+
|===
|
1035
|
+
| Order | Mode | Option source | Applicability
|
1036
|
+
|
1037
|
+
| 1 | All | Command-line | All options
|
1038
|
+
| 2 | All |Tebako configuration file | All option except ``--tebafile`` (you can not specify new tebafile in a tebafile)
|
1039
|
+
.2+| 3 .2+| All .2+| Environment variable | TEBAKO_PREFIX to set ``--prefix`` option
|
1040
|
+
| LG_VADDR to set ``--with-lg-vaddr`` jemalloc parameter
|
1041
|
+
.2+| 4 | ``runtime`` | Tebako defaults | All options except ``--entry-point`` and ``--root`` that are mandatory
|
1042
|
+
| ``bundle``, ``both``, ``application`` | Tebako defaults | All options
|
1043
|
+
|
1044
|
+
|===
|
944
1045
|
|
945
|
-
Please note that the options provided on the command line have preference over tebafile settings.
|
946
1046
|
|
947
1047
|
=== Exit codes
|
948
1048
|
|
@@ -1063,7 +1163,9 @@ These scenarios determine how the project is packaged and where the entry point
|
|
1063
1163
|
|
1064
1164
|
== Run-time options
|
1065
1165
|
|
1066
|
-
|
1166
|
+
=== General
|
1167
|
+
|
1168
|
+
Generally Tebako package passes command line options to the packaged application.
|
1067
1169
|
|
1068
1170
|
[example]
|
1069
1171
|
====
|
@@ -1091,9 +1193,53 @@ myproject --option --parameter value
|
|
1091
1193
|
----
|
1092
1194
|
====
|
1093
1195
|
|
1094
|
-
However there are several command-line parameters that are intercepted processed
|
1196
|
+
However there are several command-line parameters that are intercepted processed
|
1197
|
+
by Tebako bootstrap code as described below.
|
1198
|
+
|
1199
|
+
=== Running tebako image by tebako runtime (`--tebako-run` option)
|
1200
|
+
|
1201
|
+
Tebako provides an option to an extract its DwarFS filesystem from a package to
|
1202
|
+
a local folder for verification or execution.
|
1203
|
+
|
1204
|
+
[source,sh]
|
1205
|
+
----
|
1206
|
+
$ <tebako-runtime> --tebako-run [<tebako application>]
|
1207
|
+
----
|
1208
|
+
|
1209
|
+
Where,
|
1210
|
+
|
1211
|
+
`<tebako runtime>`::
|
1212
|
+
The tebako runtime in ```runtime``` or ```both``` mode
|
1213
|
+
|
1214
|
+
`<tebako application>`::
|
1215
|
+
The tebako application package created in ```application``` or ```both``` mode
|
1216
|
+
|
1217
|
+
[example]
|
1218
|
+
====
|
1219
|
+
Creating separate runtime and application and running it:
|
1220
|
+
|
1221
|
+
[source,sh]
|
1222
|
+
----
|
1223
|
+
tebako press -m runtime -o tebako-runtime
|
1224
|
+
tebako press -m application -o tebako-application -e hello.rb -r test
|
1225
|
+
tabako-runtime --tebako-run tebako-application Maxim
|
1226
|
+
----
|
1227
|
+
where hello.rb is the Ruby application
|
1228
|
+
[source,Ruby]
|
1229
|
+
----
|
1230
|
+
# frozen_string_literal: true
|
1231
|
+
|
1232
|
+
puts "Hello, #{ARGV[0]}!"
|
1233
|
+
----
|
1234
|
+
And expected output from ```tabako-runtime --tebako-run tebako-application Maxim``` is
|
1235
|
+
[source,sh]
|
1236
|
+
----
|
1237
|
+
Hello, Maxim!
|
1238
|
+
----
|
1239
|
+
|
1240
|
+
====
|
1095
1241
|
|
1096
|
-
=== Image extraction (
|
1242
|
+
=== Image extraction (`--tebako-extract` option)
|
1097
1243
|
|
1098
1244
|
Tebako provides an option to an extract its DwarFS filesystem from a package to
|
1099
1245
|
a local folder for verification or execution.
|
@@ -1126,27 +1272,42 @@ require 'fileutils'
|
|
1126
1272
|
FileUtils.copy_entry '<in-memory filesystem root>', ARGV[2] || 'source_filesystem'
|
1127
1273
|
----
|
1128
1274
|
|
1129
|
-
=== Mounting
|
1275
|
+
=== Mounting host folder to Tebako memfs (`--tebako-mount` option)
|
1276
|
+
|
1277
|
+
Some programs unconditionally use folders located under the application root,
|
1278
|
+
and when processed by Tebako or similar tools, these folders are included in the
|
1279
|
+
packaging.
|
1280
|
+
|
1281
|
+
[example]
|
1282
|
+
====
|
1283
|
+
Rails, for example, does not provide a configuration option to change where
|
1284
|
+
it expects the `tmp` folder to be.
|
1285
|
+
|
1286
|
+
The location is hardcoded in multiple places within the Rails codebase, residing
|
1287
|
+
under the application root, and as a result, it gets included in the read-only
|
1288
|
+
Tebako memfs.
|
1130
1289
|
|
1131
|
-
|
1132
|
-
|
1290
|
+
Although patches have been proposed (e.g.,
|
1291
|
+
https://github.com/rails/rails/issues/39583), there is currently no way to
|
1292
|
+
change the paths for temporary files, caches, and sockets.
|
1293
|
+
====
|
1133
1294
|
|
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.
|
1295
|
+
To address this inevitable limitation for Ruby applications,
|
1296
|
+
Tebako provides an option to mount a host folder to the memfs tree.
|
1139
1297
|
|
1140
|
-
|
1141
|
-
|
1298
|
+
When using Tebako, consider the packaging scenario mentioned above, as it
|
1299
|
+
defines the layout of the application tree.
|
1142
1300
|
|
1143
|
-
|
1144
|
-
|
1301
|
+
The `--tebako-extract` option may be useful for understanding the placement of
|
1302
|
+
files and folders.
|
1145
1303
|
|
1146
1304
|
[example]
|
1147
1305
|
====
|
1148
|
-
The following command starts a `rails.tebako` package with `$PWD/tmp` mounted as
|
1306
|
+
The following command starts a `rails.tebako` package with `$PWD/tmp` mounted as
|
1307
|
+
`local/tmp` in the memfs.
|
1308
|
+
|
1149
1309
|
Any remaining command-line parameters are passed to the application.
|
1310
|
+
|
1150
1311
|
[source,sh]
|
1151
1312
|
----
|
1152
1313
|
rails.tebako --tebako-mount local/tmp:$PWD/tmp server
|
@@ -1154,15 +1315,17 @@ rails.tebako --tebako-mount local/tmp:$PWD/tmp server
|
|
1154
1315
|
====
|
1155
1316
|
|
1156
1317
|
The `--tebako-mount` option has the following syntax:
|
1318
|
+
|
1157
1319
|
[source,sh]
|
1158
1320
|
----
|
1159
1321
|
--tebako-mount <memfs path>:<host path>
|
1160
1322
|
----
|
1161
1323
|
|
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
|
-
|
1324
|
+
The `--tebako-mount` option can be repeated multiple times to mount more than
|
1325
|
+
one object. The `memfs path` is relative to the memfs root, and it is
|
1326
|
+
recommended to use absolute paths for host objects. Both directories and files
|
1327
|
+
can be mounted in this way. Tebako allows overlaying existing memfs objects, so
|
1328
|
+
there are no significant limitations.
|
1166
1329
|
|
1167
1330
|
== Trivia: origin of name
|
1168
1331
|
|
data/common.env
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
#include <fcntl.h>
|
2
|
+
|
3
|
+
static pm_string_init_result_t
|
4
|
+
tebako_string_file_init(pm_string_t *string, const char *filepath) {
|
5
|
+
|
6
|
+
// Open the file for reading
|
7
|
+
int fd = open(filepath, O_RDONLY);
|
8
|
+
if (fd == -1) {
|
9
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
10
|
+
}
|
11
|
+
|
12
|
+
// Stat the file to get the file size
|
13
|
+
struct stat sb;
|
14
|
+
if (fstat(fd, &sb) == -1) {
|
15
|
+
close(fd);
|
16
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
17
|
+
}
|
18
|
+
|
19
|
+
// Ensure it is a file and not a directory
|
20
|
+
if (S_ISDIR(sb.st_mode)) {
|
21
|
+
close(fd);
|
22
|
+
return PM_STRING_INIT_ERROR_DIRECTORY;
|
23
|
+
}
|
24
|
+
|
25
|
+
// Check the size to see if it's empty
|
26
|
+
size_t size = (size_t) sb.st_size;
|
27
|
+
if (size == 0) {
|
28
|
+
close(fd);
|
29
|
+
const uint8_t source[] = "";
|
30
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
31
|
+
return PM_STRING_INIT_SUCCESS;
|
32
|
+
}
|
33
|
+
|
34
|
+
size_t length = (size_t) size;
|
35
|
+
uint8_t *source = xmalloc(length);
|
36
|
+
if (source == NULL) {
|
37
|
+
close(fd);
|
38
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
39
|
+
}
|
40
|
+
|
41
|
+
long bytes_read = (long) read(fd, source, length);
|
42
|
+
close(fd);
|
43
|
+
|
44
|
+
if (bytes_read == -1) {
|
45
|
+
xfree(source);
|
46
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
47
|
+
}
|
48
|
+
|
49
|
+
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
|
50
|
+
return PM_STRING_INIT_SUCCESS;
|
51
|
+
}
|