tebako 0.8.1 → 0.8.3
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 +12 -15
- data/Gemfile +0 -4
- data/README.adoc +64 -19
- data/Rakefile +4 -2
- data/common.env +2 -2
- data/exe/tebako-packager +17 -11
- data/include/tebako/tebako-fs.h +4 -1
- data/include/tebako/tebako-main.h +1 -0
- data/lib/tebako/build_helpers.rb +123 -0
- data/lib/tebako/cli.rb +19 -27
- data/lib/tebako/cli_helpers.rb +49 -13
- data/lib/tebako/cli_rubies.rb +6 -4
- data/lib/tebako/deploy_helper.rb +33 -52
- data/lib/tebako/error.rb +2 -1
- data/lib/tebako/packager/pass1.rb +2 -2
- data/lib/tebako/packager/pass2.rb +8 -7
- data/lib/tebako/packager/patch_buildsystem.rb +4 -4
- data/lib/tebako/packager/patch_helpers.rb +1 -37
- data/lib/tebako/packager/patch_libraries.rb +1 -1
- data/lib/tebako/packager/patch_literals.rb +0 -15
- data/lib/tebako/packager/patch_main.rb +94 -0
- data/lib/tebako/packager.rb +6 -4
- data/lib/tebako/ruby_builder.rb +52 -0
- data/lib/tebako/version.rb +1 -1
- data/resources/tebako-fs.cpp.in +7 -4
- data/src/tebako-main.cpp +20 -0
- data/tebako.gemspec +9 -1
- data/version.txt +1 -1
- metadata +104 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf7f343e3ed1cef12b766eaa2cc0834c31882f7cf78629b5079856d9c5b94765
|
4
|
+
data.tar.gz: 852554fa13a1c95a22bef4234a2063f0879b66ffd53b0cc2635b232c8dbfa1bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad25d6a39cb8a2b3ff00d2f109299682da1cdceda1b852e9ea6b144b6bfbc4e087a70e9441295196623e10f5f9281390fefa2c9d9b40858e7beb622d6a860275
|
7
|
+
data.tar.gz: fdcf01004d51fafd178f76fc7684140653cdf84dc8ea400c2956713c7034e0b8f99b7ff46f236babc1b8b313ac4f199b128d0c6fb8d5f71af93baa215c23e743
|
data/CMakeLists.txt
CHANGED
@@ -194,7 +194,7 @@ string(SUBSTRING ${RUBY_VER} 0 3 RUBY_VER_BASE)
|
|
194
194
|
string(CONCAT RUBY_API_VER ${RUBY_VER_BASE} ".0")
|
195
195
|
|
196
196
|
#if(DWARFS_PRELOAD)
|
197
|
-
# def_ext_prj_t(LIBDWARFS_WR "0.5.
|
197
|
+
# def_ext_prj_t(LIBDWARFS_WR "0.5.8" "7bf8e5b4432f35b65f6034f614067c2018995c1bebaf935e8cdddc1a3e045c01")
|
198
198
|
#
|
199
199
|
# string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1;\\2;\\3" LIBDWARFS_WR_VER_COMPONENTS ${LIBDWARFS_WR_VER})
|
200
200
|
#
|
@@ -203,7 +203,7 @@ string(CONCAT RUBY_API_VER ${RUBY_VER_BASE} ".0")
|
|
203
203
|
# list(GET LIBDWARFS_WR_VER_COMPONENTS 2 LIBDWARFS_WR_VER_PATCH)
|
204
204
|
# set (LIBDWARFS_WR_VER_M ${LIBDWARFS_WR_VER_MAJOR}.${LIBDWARFS_WR_VER_MINOR}.${LIBDWARFS_WR_VER_PATCH})
|
205
205
|
#else(DWARFS_PRELOAD)
|
206
|
-
def_ext_prj_g(DWARFS_WR "v0.5.
|
206
|
+
def_ext_prj_g(DWARFS_WR "v0.5.8")
|
207
207
|
#endif(DWARFS_PRELOAD)
|
208
208
|
|
209
209
|
set(LIBYAML_RUBY_OPTION "")
|
@@ -246,6 +246,14 @@ else(${IS_MSYS})
|
|
246
246
|
set(FS_MOUNT_POINT "/__tebako_memfs__")
|
247
247
|
endif(${IS_MSYS})
|
248
248
|
|
249
|
+
if(PACKAGE_NEEDS_CWD)
|
250
|
+
set(NEEDS_CWD true)
|
251
|
+
set(PACKAGE_CWD_FULL ${FS_MOUNT_POINT}/${PACKAGE_CWD})
|
252
|
+
else(PACKAGE_NEEDS_CWD)
|
253
|
+
set(NEEDS_CWD false)
|
254
|
+
set(PACKAGE_CWD "")
|
255
|
+
set(PACKAGE_CWD_FULL "")
|
256
|
+
endif(PACKAGE_NEEDS_CWD)
|
249
257
|
|
250
258
|
message(STATUS "DATA_SRC_DIR: ${DATA_SRC_DIR}")
|
251
259
|
message(STATUS "DATA_PRE_DIR: ${DATA_PRE_DIR}")
|
@@ -435,6 +443,7 @@ else (${SETUP_MODE})
|
|
435
443
|
COMMAND ruby ${EXE}/tebako-packager deploy ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${RUBY_STASH_DIR}
|
436
444
|
${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR}
|
437
445
|
${FS_ROOT} ${FS_ENTRANCE} ${FS_MOUNT_POINT} ${APP_NAME} ${RUBY_VER}
|
446
|
+
${PACKAGE_CWD}
|
438
447
|
DEPENDS ${RUBY_PRJ}
|
439
448
|
)
|
440
449
|
|
@@ -481,19 +490,7 @@ else (${SETUP_MODE})
|
|
481
490
|
|
482
491
|
add_dependencies(tebako-fs packaged_filesystem)
|
483
492
|
|
484
|
-
|
485
|
-
add_custom_target(tebako
|
486
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make -j${NCORES}
|
487
|
-
COMMAND ruby ${EXE}/tebako-packager finalize ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${APP_NAME}
|
488
|
-
)
|
489
|
-
else()
|
490
|
-
add_custom_target(tebako
|
491
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby -j${NCORES}
|
492
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make -j${NCORES}
|
493
|
-
COMMAND ruby ${EXE}/tebako-packager finalize ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${APP_NAME}
|
494
|
-
)
|
495
|
-
endif()
|
496
|
-
|
493
|
+
add_custom_target(tebako COMMAND ruby ${EXE}/tebako-packager finalize ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${APP_NAME} ${RUBY_VER})
|
497
494
|
add_dependencies(tebako setup tebako-fs)
|
498
495
|
|
499
496
|
endif(${SETUP_MODE})
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -10,7 +10,8 @@ Platform tests on Cirrus:
|
|
10
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"]
|
11
11
|
|
12
12
|
Quality:
|
13
|
-
image:https://github.com/tamatebako/tebako/actions/workflows/lint.yml/badge.svg["lint", link="https://github.com/tamatebako/tebako/actions/workflows/lint.yml"]
|
13
|
+
image:https://github.com/tamatebako/tebako/actions/workflows/lint-and-rspec.yml/badge.svg["lint and rspec", link="https://github.com/tamatebako/tebako/actions/workflows/lint-and-rspec.yml"]
|
14
|
+
image:https://codecov.io/gh/tamatebako/tebako/graph/badge.svg?token=XD3emQ5qsY["Tebako cli rspec coverage", link="https://codecov.io/gh/tamatebako/tebako"]
|
14
15
|
|
15
16
|
== Purpose
|
16
17
|
|
@@ -86,8 +87,8 @@ with debug information unstripped. You can opt to run 'strip -S' manually, it mo
|
|
86
87
|
|
87
88
|
| 2.7.8 | Linux, macOS
|
88
89
|
| 3.0.7 | Linux, macOS
|
89
|
-
| 3.1.
|
90
|
-
| 3.2.{
|
90
|
+
| 3.1.6 | Linux, macOS, Windows
|
91
|
+
| 3.2.{4,5} | Linux, macOS, Windows
|
91
92
|
| 3.3.{3,4} | Linux, macOS, Windows
|
92
93
|
|
93
94
|
|===
|
@@ -232,8 +233,6 @@ Displays the Tebako version.
|
|
232
233
|
Displays the help message.
|
233
234
|
|
234
235
|
|
235
|
-
|
236
|
-
|
237
236
|
== Usage
|
238
237
|
|
239
238
|
=== General
|
@@ -291,9 +290,6 @@ docker run -v <application_folder>:/mnt/w \
|
|
291
290
|
tebako {command} {parameters}
|
292
291
|
----
|
293
292
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
293
|
==== Packaging from outside the container
|
298
294
|
|
299
295
|
To package your application from outside the container, just run a single Docker
|
@@ -659,7 +655,9 @@ tebako press \
|
|
659
655
|
[-R|--Ruby=<ruby-version>] \
|
660
656
|
[-o|--output=<packaged-file-name>] \
|
661
657
|
[-l|--log-level=<error|warn|debug|trace>] \
|
662
|
-
[-
|
658
|
+
[-c|--cwd=<package current working directory>]
|
659
|
+
[-D|--devmode] \
|
660
|
+
[-t|--tebafile=<path-to-tebafile>]
|
663
661
|
----
|
664
662
|
|
665
663
|
Where:
|
@@ -668,13 +666,13 @@ Where:
|
|
668
666
|
the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
669
667
|
|
670
668
|
`Ruby`::
|
671
|
-
|
669
|
+
this parameter defines Ruby version that will be packaged (optional, defaults to
|
672
670
|
`3.1.6`)
|
673
671
|
|
674
|
-
|
672
|
+
`project-root`::
|
675
673
|
a folder at the host source file system where project files are located
|
676
674
|
|
677
|
-
|
675
|
+
`entry-point`::
|
678
676
|
an executable file (binary executable or script) that shall be started when
|
679
677
|
packaged file is called
|
680
678
|
|
@@ -685,11 +683,22 @@ the output file name (optional, defaults to `<current folder>/<entry point base
|
|
685
683
|
logging level for the Tebako built-in memory filesystem driver
|
686
684
|
(optional, defaults to `error`)
|
687
685
|
|
686
|
+
`cwd`::
|
687
|
+
a folder within Tebako memfs where the packaged application will start. This folder should be specified relative to the memfs root.
|
688
|
+
If not provided, the application will start within the current folder of the host (i.e., at $PWD).
|
689
|
+
This option is required because it is not possible to change the directory to a memfs folder until the package is started, as opposed to any host folder
|
690
|
+
that can be set as the current directory before Tebako package invocation. Tebako saves original working directory in a global Ruby variable `$tebako_original_pwd`.
|
691
|
+
|
692
|
+
`tebafile`::
|
693
|
+
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
694
|
+
Please refer to the separate section below for tebafile description.
|
695
|
+
|
688
696
|
`devmode`:: flag that activates development mode, in which Tebako's cache and
|
689
697
|
packaging consistency checks are relaxed.
|
690
698
|
+
|
691
|
-
|
692
|
-
used during development.
|
699
|
+
NOTES:
|
700
|
+
* Development mode is *not intended for production use* and should only be used during development.
|
701
|
+
* `entry-point` and `project-root-folder` are required parameters and may be provided either via command-line or in `tebafile`.
|
693
702
|
|
694
703
|
[example]
|
695
704
|
====
|
@@ -724,16 +733,21 @@ based on `tebako press` may create inconsistent environment upon restore.
|
|
724
733
|
$ tebako setup \
|
725
734
|
[-p|--prefix=<tebako-root-folder>] \
|
726
735
|
[-R|--Ruby=<ruby-version>] \
|
727
|
-
[-D|--devmode]
|
736
|
+
[-D|--devmode] \
|
737
|
+
[-t|--tebafile=<path-to-tebafile>]
|
728
738
|
----
|
729
739
|
|
730
740
|
Where:
|
731
741
|
|
732
742
|
`<tebako-root-folder>`:: the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
733
743
|
|
734
|
-
`Ruby
|
744
|
+
`Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
|
745
|
+
|
746
|
+
`tebafile`::
|
747
|
+
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
748
|
+
Please refer to the separate section below for tebafile description.
|
735
749
|
|
736
|
-
`devmode
|
750
|
+
`devmode`:: flag activates development mode, in which Tebako's cache and packaging consistency checks are relaxed.
|
737
751
|
Please note that this mode is not intended for production use and should only be used during development.
|
738
752
|
|
739
753
|
==== Clean
|
@@ -746,13 +760,18 @@ Normally you do not need to do it since tebako packager optimizes artifacts life
|
|
746
760
|
[source,sh]
|
747
761
|
----
|
748
762
|
$ tebako clean \
|
749
|
-
[-p|--prefix=<tebako-root-folder>]
|
763
|
+
[-p|--prefix=<tebako-root-folder>] \
|
764
|
+
[-t|--tebafile=<path-to-tebafile>]
|
750
765
|
----
|
751
766
|
|
752
767
|
Where:
|
753
768
|
|
754
769
|
`<tebako-root-folder>`:: the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
755
770
|
|
771
|
+
`tebafile`::
|
772
|
+
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
773
|
+
Please refer to the separate section below for tebafile description.
|
774
|
+
|
756
775
|
[example]
|
757
776
|
====
|
758
777
|
[source,sh]
|
@@ -777,7 +796,9 @@ NOTE: Compiled DwarFS libraries are not cleaned.
|
|
777
796
|
----
|
778
797
|
$ tebako clean_ruby
|
779
798
|
[-p|--prefix=<tebako-root-folder>] \
|
780
|
-
[-R|--Ruby=<ruby-version>]
|
799
|
+
[-R|--Ruby=<ruby-version>] \
|
800
|
+
[-t|--tebafile=<path-to-tebafile>]
|
801
|
+
|
781
802
|
----
|
782
803
|
|
783
804
|
Where:
|
@@ -788,6 +809,10 @@ the Tebako setup folder (optional, defaults to current folder)
|
|
788
809
|
`Ruby`::
|
789
810
|
defines Ruby version that will cleaned (optional, cleans all versions by default)
|
790
811
|
|
812
|
+
`tebafile`::
|
813
|
+
the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
|
814
|
+
Please refer to the separate section below for tebafile description.
|
815
|
+
|
791
816
|
[example]
|
792
817
|
====
|
793
818
|
[source,sh]
|
@@ -806,6 +831,26 @@ as a cache key in CI/CD pipelines.
|
|
806
831
|
$ tebako hash
|
807
832
|
----
|
808
833
|
|
834
|
+
=== Tebako configuration file
|
835
|
+
|
836
|
+
It is possible to provide all or some options for the `tebako setup/press/clean/clean_ruby` commands via Tebako configuration file ('tebafile').
|
837
|
+
Tebafile is a YAML file with a single section 'options'. The options are the same as long names for the command line. For, example for the prefix option
|
838
|
+
|
839
|
+
[source]
|
840
|
+
----
|
841
|
+
-p|--prefix=<tebako-root-folder>
|
842
|
+
----
|
843
|
+
the key in the YAML file would be 'prefix'.
|
844
|
+
|
845
|
+
Below is an example tebafile that sets values for prefix and Ruby options
|
846
|
+
[source,yaml]
|
847
|
+
----
|
848
|
+
options:
|
849
|
+
prefix: /tmp/tebako
|
850
|
+
Ruby: 3.2.4
|
851
|
+
----
|
852
|
+
|
853
|
+
Please note that the options provided on the command line have preference over tebafile settings.
|
809
854
|
|
810
855
|
=== Image extraction
|
811
856
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
|
3
|
+
# Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
|
4
4
|
# All rights reserved.
|
5
5
|
# This file is a part of tebako
|
6
6
|
#
|
@@ -27,10 +27,12 @@
|
|
27
27
|
|
28
28
|
require "bundler/gem_tasks"
|
29
29
|
require "rubocop/rake_task"
|
30
|
+
require "rspec/core/rake_task"
|
30
31
|
|
31
32
|
RuboCop::RakeTask.new
|
33
|
+
RSpec::Core::RakeTask.new(:spec)
|
32
34
|
|
33
|
-
task default: %i[rubocop]
|
35
|
+
task default: %i[rubocop spec]
|
34
36
|
|
35
37
|
desc "Generate version.txt"
|
36
38
|
task "generate_version_txt" do
|
data/common.env
CHANGED
data/exe/tebako-packager
CHANGED
@@ -28,6 +28,7 @@
|
|
28
28
|
|
29
29
|
require_relative "../lib/tebako/packager"
|
30
30
|
require_relative "../lib/tebako/stripper"
|
31
|
+
require_relative "../lib/tebako/build_helpers"
|
31
32
|
|
32
33
|
begin
|
33
34
|
unless ARGV.length.positive?
|
@@ -46,8 +47,8 @@ begin
|
|
46
47
|
raise Tebako::Error,
|
47
48
|
"tebako-packager pass1 command expects 6 arguments, #{ARGV.length} has been provided."
|
48
49
|
end
|
49
|
-
|
50
|
-
Tebako::Packager.pass1(ARGV[1], ARGV[2], ARGV[3], ARGV[4],
|
50
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[5])
|
51
|
+
Tebako::Packager.pass1(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ruby_ver)
|
51
52
|
|
52
53
|
when "pass1a"
|
53
54
|
# ARGV[0] -- command
|
@@ -69,9 +70,9 @@ begin
|
|
69
70
|
raise Tebako::Error,
|
70
71
|
"tebako-packager pass2 command expects 7 arguments, #{ARGV.length} has been provided."
|
71
72
|
end
|
72
|
-
|
73
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[6])
|
73
74
|
Tebako::Packager.stash(ARGV[4], ARGV[5])
|
74
|
-
Tebako::Packager.pass2(ARGV[1], ARGV[2], ARGV[3],
|
75
|
+
Tebako::Packager.pass2(ARGV[1], ARGV[2], ARGV[3], ruby_ver)
|
75
76
|
when "deploy"
|
76
77
|
# ARGV[0] -- command
|
77
78
|
# ARGV[1] -- OSTYPE
|
@@ -85,26 +86,31 @@ begin
|
|
85
86
|
# ARGV[9] -- FS_MOUNT_POINT
|
86
87
|
# ARGV[10] -- APP_NAME
|
87
88
|
# ARGV[11] -- RUBY_VER
|
88
|
-
|
89
|
+
# ARGV[12] -- CWD
|
90
|
+
unless ARGV.length == 13 || ARGV.length == 12
|
89
91
|
raise Tebako::Error,
|
90
|
-
"tebako-packager deploy command expects 12 arguments, #{ARGV.length} has been provided."
|
92
|
+
"tebako-packager deploy command expects 12 or 13 arguments, #{ARGV.length} has been provided."
|
91
93
|
end
|
94
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[11])
|
92
95
|
Tebako::Packager.init(ARGV[3], ARGV[4], ARGV[5], ARGV[6])
|
93
|
-
Tebako::Packager.create_implib(ARGV[2], ARGV[4], File.basename(ARGV[10]),
|
96
|
+
Tebako::Packager.create_implib(ARGV[2], ARGV[4], File.basename(ARGV[10]), ruby_ver) if ARGV[1] =~ /msys/
|
94
97
|
# Assume that "<TARGET_BIN_DIR (TBD)>" is <DATA_SRC_DIR>/bin"
|
95
98
|
# That shall match CMakeLists.txt settings
|
96
|
-
Tebako::Packager.deploy(ARGV[1], ARGV[4], ARGV[5],
|
99
|
+
Tebako::Packager.deploy(ARGV[1], ARGV[4], ARGV[5], ruby_ver, ARGV[7], ARGV[8], ARGV[9],
|
100
|
+
ARGV.length == 13 ? ARGV[12] : nil)
|
97
101
|
|
98
102
|
when "finalize"
|
99
103
|
# ARGV[0] -- command
|
100
104
|
# ARGV[1] -- OSTYPE
|
101
105
|
# ARGV[2] -- RUBY_SOURCE_DIR
|
102
106
|
# ARGV[3] -- APP_NAME
|
103
|
-
|
107
|
+
# ARGV[4] -- RUBY_VER
|
108
|
+
unless ARGV.length == 5
|
104
109
|
raise Tebako::Error,
|
105
|
-
"tebako-packager finalize command expects
|
110
|
+
"tebako-packager finalize command expects 5 arguments, #{ARGV.length} has been provided."
|
106
111
|
end
|
107
|
-
Tebako::
|
112
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[4])
|
113
|
+
Tebako::Packager.finalize(ARGV[1], ARGV[2], ARGV[3], ruby_ver)
|
108
114
|
else
|
109
115
|
raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
|
110
116
|
end
|
data/include/tebako/tebako-fs.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
*
|
3
|
-
* Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
|
3
|
+
* Copyright (c) 2021-2024, [Ribose Inc](https://www.ribose.com).
|
4
4
|
* All rights reserved.
|
5
5
|
* This file is a part of tebako
|
6
6
|
*
|
@@ -37,4 +37,7 @@ namespace tebako {
|
|
37
37
|
extern const char* fs_log_level;
|
38
38
|
extern const char* fs_mount_point;
|
39
39
|
extern const char* fs_entry_point;
|
40
|
+
extern bool needs_cwd;
|
41
|
+
extern const char* package_cwd;
|
42
|
+
extern char original_cwd[PATH_MAX];
|
40
43
|
}
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions
|
9
|
+
# are met:
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
require "open3"
|
29
|
+
|
30
|
+
# Tebako - an executable packager
|
31
|
+
module Tebako
|
32
|
+
# Ruby build helpers
|
33
|
+
module BuildHelpers
|
34
|
+
class << self
|
35
|
+
def ncores
|
36
|
+
if RUBY_PLATFORM.include?("darwin")
|
37
|
+
out, st = Open3.capture2e("sysctl", "-n", "hw.ncpu")
|
38
|
+
else
|
39
|
+
out, st = Open3.capture2e("nproc", "--all")
|
40
|
+
end
|
41
|
+
|
42
|
+
if st.exitstatus.zero?
|
43
|
+
out.strip.to_i
|
44
|
+
else
|
45
|
+
4
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def run_with_capture(args)
|
50
|
+
puts " ... @ #{args.join(" ")}"
|
51
|
+
out, st = Open3.capture2e(*args)
|
52
|
+
raise Tebako::Error, "Failed to run #{args.join(" ")} (#{st}):\n #{out}" unless st.exitstatus.zero?
|
53
|
+
|
54
|
+
out
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_with_capture_v(args)
|
58
|
+
if @verbose
|
59
|
+
args_v = args.dup
|
60
|
+
args_v.push("--verbose")
|
61
|
+
puts run_with_capture(args_v)
|
62
|
+
else
|
63
|
+
run_with_capture(args)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Sets up temporary environment variables and yields to the
|
68
|
+
# block. When the block exits, the environment variables are set
|
69
|
+
# back to their original values.
|
70
|
+
def with_env(hash)
|
71
|
+
old = {}
|
72
|
+
hash.each do |k, v|
|
73
|
+
old[k] = ENV.fetch(k, nil)
|
74
|
+
ENV[k] = v
|
75
|
+
end
|
76
|
+
begin
|
77
|
+
yield
|
78
|
+
ensure
|
79
|
+
hash.each_key { |k| ENV[k] = old[k] }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Ruby version checks
|
86
|
+
class RubyVersion
|
87
|
+
def initialize(ruby_ver)
|
88
|
+
unless ruby_ver =~ /^\d+\.\d+\.\d+$/
|
89
|
+
raise Tebako::Error, "Invalid Ruby version format '#{ruby_ver}'. Expected format: x.y.z"
|
90
|
+
end
|
91
|
+
|
92
|
+
@ruby_ver = ruby_ver
|
93
|
+
end
|
94
|
+
|
95
|
+
def ruby3x?
|
96
|
+
@ruby3x ||= @ruby_ver[0] == "3"
|
97
|
+
end
|
98
|
+
|
99
|
+
def ruby31?
|
100
|
+
@ruby31 ||= ruby3x? && @ruby_ver[2].to_i >= 1
|
101
|
+
end
|
102
|
+
|
103
|
+
def ruby32?
|
104
|
+
@ruby32 ||= ruby3x? && @ruby_ver[2].to_i >= 2
|
105
|
+
end
|
106
|
+
|
107
|
+
def ruby32only?
|
108
|
+
@ruby32only ||= ruby3x? && @ruby_ver[2] == "2"
|
109
|
+
end
|
110
|
+
|
111
|
+
def ruby33?
|
112
|
+
@ruby33 ||= ruby3x? && @ruby_ver[2].to_i >= 3
|
113
|
+
end
|
114
|
+
|
115
|
+
def api_version
|
116
|
+
@api_version ||= "#{@ruby_ver.split(".")[0..1].join(".")}.0"
|
117
|
+
end
|
118
|
+
|
119
|
+
def lib_version
|
120
|
+
@lib_version ||= "#{@ruby_ver.split(".")[0..1].join}0"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/tebako/cli.rb
CHANGED
@@ -40,7 +40,7 @@ require_relative "version"
|
|
40
40
|
# Tebako - an executable packager
|
41
41
|
# Implementation of tebako command-line interface
|
42
42
|
module Tebako
|
43
|
-
|
43
|
+
DEFAULT_TEBAFILE = ".tebako.yml"
|
44
44
|
# Tebako packager front-end
|
45
45
|
class Cli < Thor
|
46
46
|
package_name "Tebako"
|
@@ -48,7 +48,8 @@ module Tebako
|
|
48
48
|
desc: "A path to tebako packaging environment, '~/.tebako' ('$HOME/.tebako') by default"
|
49
49
|
class_option :devmode, type: :boolean, aliases: "-D", required: false,
|
50
50
|
desc: "Developer mode, please do not use if unsure"
|
51
|
-
|
51
|
+
class_option :tebafile, type: :string, aliases: "-t", required: false,
|
52
|
+
desc: "tebako configuration file 'tebafile', '$PWD/.tebako.yml' by default"
|
52
53
|
desc "clean", "Clean tebako packaging environment"
|
53
54
|
def clean
|
54
55
|
clean_cache
|
@@ -72,7 +73,14 @@ module Tebako
|
|
72
73
|
print Digest::SHA256.hexdigest [File.read(File.join(source, "CMakeLists.txt")), Tebako::VERSION].join
|
73
74
|
end
|
74
75
|
|
76
|
+
CWD_DESCRIPTION = <<~DESC
|
77
|
+
Current working directory for packaged application. This directory shall be specified relative to root.
|
78
|
+
#{" " * 62}# If this parameter is not set, the application will start in the current directory of the host file system.
|
79
|
+
DESC
|
80
|
+
|
75
81
|
desc "press", "Press tebako image"
|
82
|
+
method_option :cwd, type: :string, aliases: "-c", required: false,
|
83
|
+
desc: CWD_DESCRIPTION
|
76
84
|
method_option :"entry-point", type: :string, aliases: ["-e", "--entry"], required: true,
|
77
85
|
desc: "Ruby application entry point"
|
78
86
|
method_option :"log-level", type: :string, aliases: "-l", required: false, enum: %w[error warn debug trace],
|
@@ -123,35 +131,19 @@ module Tebako
|
|
123
131
|
|
124
132
|
def options
|
125
133
|
original_options = super
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
134
|
+
tebafile = original_options["tebafile"].nil? ? DEFAULT_TEBAFILE : original_options["tebafile"]
|
135
|
+
if File.exist?(tebafile)
|
136
|
+
Thor::CoreExt::HashWithIndifferentAccess.new(options_from_tebafile(tebafile).merge(original_options))
|
137
|
+
else
|
138
|
+
puts "Warning: Tebako configuration file '#{tebafile}' not found." unless original_options["tebafile"].nil?
|
139
|
+
original_options
|
140
|
+
end
|
131
141
|
end
|
132
142
|
end
|
133
143
|
|
134
|
-
private
|
135
|
-
|
136
144
|
no_commands do
|
137
|
-
|
138
|
-
|
139
|
-
build_cmd = "cmake --build #{output} --target tebako --parallel #{Etc.nprocessors}"
|
140
|
-
merged_env = ENV.to_h.merge(b_env)
|
141
|
-
Tebako.packaging_error(103) unless system(merged_env, cfg_cmd)
|
142
|
-
Tebako.packaging_error(104) unless system(merged_env, build_cmd)
|
143
|
-
end
|
144
|
-
|
145
|
-
def do_setup
|
146
|
-
cfg_cmd = "cmake -DSETUP_MODE:BOOLEAN=ON #{cfg_options}"
|
147
|
-
build_cmd = "cmake --build \"#{output}\" --target setup --parallel #{Etc.nprocessors}"
|
148
|
-
merged_env = ENV.to_h.merge(b_env)
|
149
|
-
Tebako.packaging_error(101) unless system(merged_env, cfg_cmd)
|
150
|
-
Tebako.packaging_error(102) unless system(merged_env, build_cmd)
|
151
|
-
end
|
145
|
+
include Tebako::CliHelpers
|
146
|
+
include Tebako::CliRubies
|
152
147
|
end
|
153
|
-
|
154
|
-
include Tebako::CliHelpers
|
155
|
-
include Tebako::CliRubies
|
156
148
|
end
|
157
149
|
end
|