tebako 0.6.6 → 0.7.1
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 +37 -43
- data/README.adoc +33 -15
- data/common.env +1 -1
- data/exe/tebako-packager +11 -0
- data/lib/tebako/cli_helpers.rb +13 -3
- data/lib/tebako/cli_rubies.rb +3 -1
- data/lib/tebako/packager/pass2.rb +12 -4
- data/lib/tebako/packager/patch_helpers.rb +12 -2
- data/lib/tebako/packager.rb +11 -4
- data/lib/tebako/stripper.rb +94 -0
- data/lib/tebako/version.rb +1 -1
- data/version.txt +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edab24288967cc4085b927ef069adab649b24282a6cc320a595bc2b20cb636e9
|
4
|
+
data.tar.gz: 7964a2bcf62cf28d4cd34ee1f1744afe21980e934a4fa1a649f0b854b15b1ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a77dc3a2c810aad7597cab4a3d5a8f3c6378d2f9313e129edf17097700a0210eb9008b73bb5402921af53e5cccf450602865b4cc1518e5f8a2fd0e34e15163c
|
7
|
+
data.tar.gz: 40b417b5bb8e13e40618015d04f5f3c085bc08325d798bba5fb1cf6c43c0e44daef392755473f2110cb21c95134dcee24c6559933226eee0f41a5f9fc074d602
|
data/CMakeLists.txt
CHANGED
@@ -117,6 +117,7 @@ set(IS_MSYS OFF)
|
|
117
117
|
set(IS_DARWIN OFF)
|
118
118
|
set(RB_W32 OFF)
|
119
119
|
set(FORCE_RUBY_PLATFORM "false")
|
120
|
+
set(NOKOGIRI_OPTION "--no-use-system-libraries")
|
120
121
|
set(RUBY_WITHOUT_EXT "dbm,win32,win32ole")
|
121
122
|
set(RUBY_NAME "ruby")
|
122
123
|
set(RUBY_SUFFIX "")
|
@@ -132,6 +133,7 @@ if("${OSTYPE_TXT}" MATCHES "^linux-musl.*")
|
|
132
133
|
elseif("${OSTYPE_TXT}" MATCHES "^msys*")
|
133
134
|
set(IS_MSYS ON)
|
134
135
|
set(FORCE_RUBY_PLATFORM "true")
|
136
|
+
set(NOKOGIRI_OPTION "--use-system-libraries")
|
135
137
|
# set(DWARFS_PRELOAD ON)
|
136
138
|
set(RB_W32 ON)
|
137
139
|
set(RUBY_WITHOUT_EXT "dbm,syslog,pty,gdbm,readline")
|
@@ -235,11 +237,11 @@ endif(DWARFS_PRELOAD)
|
|
235
237
|
# Filesystem locations
|
236
238
|
|
237
239
|
# DATA_SRC_DIR folder is used to collect all files that need to be packaged
|
238
|
-
set(DATA_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/
|
240
|
+
set(DATA_SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/s)
|
239
241
|
# DATA_PRE_DIR folder is used to build gems that need to be packaged
|
240
|
-
set(DATA_PRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/
|
242
|
+
set(DATA_PRE_DIR ${CMAKE_CURRENT_BINARY_DIR}/r)
|
241
243
|
# DATA_BIN_DIR folder is used to create packaged filesystem
|
242
|
-
set(DATA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/
|
244
|
+
set(DATA_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/p)
|
243
245
|
# DATA_BIN_FILE is packaged filesystem itself
|
244
246
|
set(DATA_BIN_FILE ${DATA_BIN_DIR}/fs.bin)
|
245
247
|
# Target binary directory
|
@@ -368,6 +370,7 @@ message(STATUS "Ruby build ${C_FLAGS_DEST}='${RUBY_C_FLAGS}'")
|
|
368
370
|
message(STATUS "Ruby build LDFLAGS='${RUBY_L_FLAGS}'")
|
369
371
|
message(STATUS "openssl Ruby option='${OPENSSL_RUBY_OPTION}'")
|
370
372
|
message(STATUS "libyaml Ruby option='${LIBYAML_RUBY_OPTION}'")
|
373
|
+
message(STATUS "nokogiri build option='${NOKOGIRI_OPTION}'")
|
371
374
|
|
372
375
|
ExternalProject_Add(${RUBY_PRJ}
|
373
376
|
PREFIX ${DEPS}
|
@@ -433,27 +436,31 @@ else (${SETUP_MODE})
|
|
433
436
|
message("Collecting gem from gemspec ${GEMSPEC} and Gemfile")
|
434
437
|
set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
|
435
438
|
add_custom_target(source_filesystem
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
439
|
+
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
|
440
|
+
COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
|
441
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
442
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local build.ffi --disable-system-libffi
|
443
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
444
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local build.nokogiri ${NOKOGIRI_OPTION}
|
445
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
446
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
|
447
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
448
|
+
${TBD}/bundle${BAT_SUFFIX} install
|
449
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
450
|
+
${TBD}/bundle${BAT_SUFFIX} exec ${TBD}/gem${CMD_SUFFIX} build ${GEMSPEC}
|
451
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
452
|
+
${TBD}/gem${CMD_SUFFIX} install *.gem --verbose --no-document --install-dir ${TGD}
|
453
|
+
COMMAND test -f ${DATA_SRC_DIR}${FS_ENTRY_POINT} ||
|
447
454
|
(${CMAKE_COMMAND} -E echo "Entry point ${DATA_SRC_DIR}${FS_ENTRY_POINT} does not exist" &&
|
448
455
|
${CMAKE_COMMAND} -E false )
|
449
|
-
|
456
|
+
DEPENDS clean_filesystem
|
450
457
|
)
|
451
458
|
else(GFLENGTH GREATER 0)
|
452
459
|
# Found xxx.gemspec but no Gemfile
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
460
|
+
message("Collecting gem from gemspec ${GEMSPEC}")
|
461
|
+
set(FS_ENTRY_POINT "/bin/${FS_ENTRANCE}")
|
462
|
+
message("Target entry point will be at ${FS_MOUNT_POINT}${FS_ENTRY_POINT}")
|
463
|
+
add_custom_target(source_filesystem
|
457
464
|
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
|
458
465
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
|
459
466
|
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
@@ -476,14 +483,16 @@ else (${SETUP_MODE})
|
|
476
483
|
COMMAND test -f ${FS_ROOT}/${FS_ENTRANCE} ||
|
477
484
|
(${CMAKE_COMMAND} -E echo "Entry point ${FS_ROOT}/${FS_ENTRANCE} does not exist or is not accessible" &&
|
478
485
|
${CMAKE_COMMAND} -E false )
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
486
|
+
COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
|
487
|
+
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
|
488
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
489
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local build.ffi --disable-system-libffi
|
490
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
491
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local build.nokogiri ${NOKOGIRI_OPTION}
|
492
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
493
|
+
${TBD}/bundle${BAT_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
|
494
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
495
|
+
${TBD}/bundle${BAT_SUFFIX} install --jobs=${NCORES}
|
487
496
|
# COMMAND_EXPAND_LISTS
|
488
497
|
# [TODO] Open question - how to deploy a project to source filesystem
|
489
498
|
# ruby packer does bundle install --deployment --binstubs
|
@@ -544,22 +553,7 @@ else (${SETUP_MODE})
|
|
544
553
|
)
|
545
554
|
|
546
555
|
add_custom_target(packaged_filesystem
|
547
|
-
|
548
|
-
# For debugging purposes it is very handy to have it here
|
549
|
-
#
|
550
|
-
COMMAND ${CMAKE_COMMAND} -E rm -rf ${DATA_SRC_DIR}/share ${DATA_SRC_DIR}/include ${DATA_SRC_DIR}/lib/pkgconfig
|
551
|
-
${DATA_SRC_DIR}/bin/bundle${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundle
|
552
|
-
${DATA_SRC_DIR}/bin/bundler${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/bundler
|
553
|
-
${DATA_SRC_DIR}/bin/bundle${BAT_SUFFIX} ${DATA_SRC_DIR}/bin/bundler${BAT_SUFFIX}
|
554
|
-
${DATA_SRC_DIR}/bin/erb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/gem${CMD_SUFFIX}
|
555
|
-
${DATA_SRC_DIR}/bin/irb${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/racc${CMD_SUFFIX}
|
556
|
-
${DATA_SRC_DIR}/bin/racc2y${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/rake${BAT_SUFFIX}
|
557
|
-
${DATA_SRC_DIR}/bin/rake ${DATA_SRC_DIR}/bin/rdoc${CMD_SUFFIX}
|
558
|
-
${DATA_SRC_DIR}/bin/ri${CMD_SUFFIX} ${DATA_SRC_DIR}/bin/y2racc${CMD_SUFFIX}
|
559
|
-
${DATA_SRC_DIR}/bin/ruby${EXE_SUFFIX} ${DATA_SRC_DIR}/bin/ruby${RUBY_SUFFIX}${EXE_SUFFIX}
|
560
|
-
|
561
|
-
COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.a"
|
562
|
-
COMMAND ${GNU_BASH} -c "rm -f ${DATA_SRC_DIR}/**/*.o"
|
556
|
+
COMMAND ruby ${EXE}/tebako-packager strip ${OSTYPE_TXT} ${DATA_SRC_DIR}
|
563
557
|
COMMAND ${GNU_BASH} -c "chmod +x ${DEPS_BIN_DIR}/mkdwarfs${EXE_SUFFIX}"
|
564
558
|
# No progress below is critical since in reporting mode mkdwarfs tries to work directly with terminal
|
565
559
|
# and it creates issues for stderr redirects (&2 > 1) used by Ninja and our test srcipts
|
data/README.adoc
CHANGED
@@ -46,7 +46,7 @@ The Tebako packager supports the following versions of Ruby for packaging:
|
|
46
46
|
|
47
47
|
* 2.7.8 (Linux, MacOS)
|
48
48
|
* 3.0.7 (Linux, MacOS)
|
49
|
-
* 3.1.4, 3.1.5 (Linux, MacOS, Windows)
|
49
|
+
* 3.1.4, 3.1.5, 3.1.6 (Linux, MacOS, Windows)
|
50
50
|
* 3.2.3, 3.2.4 (Linux, MacOS, Windows)
|
51
51
|
|
52
52
|
Support of specific version including minor release requires some effort, sometimes extensive
|
@@ -119,7 +119,7 @@ apk --no-cache --upgrade add build-base cmake git bash autoconf boost-static \
|
|
119
119
|
brotli-static jemalloc-dev fmt-dev xz-static
|
120
120
|
----
|
121
121
|
|
122
|
-
=== macOS 12 (Monterey)
|
122
|
+
=== macOS 12 (Monterey) through macOS 14 (Sonoma)
|
123
123
|
|
124
124
|
[source,sh]
|
125
125
|
----
|
@@ -128,10 +128,9 @@ brew install gnu-sed bash pkg-config bison flex binutils libffi gdbm zlib ncurse
|
|
128
128
|
double-conversion boost jemalloc fmt glog libevent libsodium lz4 xz libyaml openssl@3
|
129
129
|
----
|
130
130
|
|
131
|
-
=== Windows (2019, 2022)
|
131
|
+
=== Windows (workstation 10, 11; Server 2019, 2022)
|
132
132
|
|
133
133
|
The simplest approach is to use Ruby development environment provided by RubyInstaller, for example Ruby+Devkit 3.1.4-1.
|
134
|
-
|
135
134
|
Once it is installed use the following commands:
|
136
135
|
|
137
136
|
[source,sh]
|
@@ -142,6 +141,11 @@ Once it is installed use the following commands:
|
|
142
141
|
fmt glog dlfcn gtest autotools ncurses libyaml
|
143
142
|
----
|
144
143
|
|
144
|
+
Please note that on Windows tebako may face issues related by CMake path length limitations.
|
145
|
+
(https://gitlab.kitware.com/cmake/cmake/-/issues/25936)
|
146
|
+
This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
|
147
|
+
There is no workaround for this issue as it lloks like is a limitation of the manifest used to build CMake executable.
|
148
|
+
|
145
149
|
== Installation
|
146
150
|
|
147
151
|
=== General
|
@@ -207,6 +211,23 @@ gem install tebako
|
|
207
211
|
gem install tebako
|
208
212
|
----
|
209
213
|
|
214
|
+
=== Tebako Root Folder (aka Prefix) Selection
|
215
|
+
|
216
|
+
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.
|
217
|
+
The selection of the prefix follows a specific order of precedence to ensure flexibility and ease of use:
|
218
|
+
|
219
|
+
. *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.
|
220
|
+
|
221
|
+
. *Current Working Directory (PWD)*: If the prefix option is explicitly set to "PWD", Tebako uses the current working directory as Tebako root folder.
|
222
|
+
|
223
|
+
. *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.
|
224
|
+
|
225
|
+
. *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.
|
226
|
+
|
227
|
+
|
228
|
+
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
|
229
|
+
directory and expanding user directory shortcuts like `~`.
|
230
|
+
|
210
231
|
==== Press
|
211
232
|
|
212
233
|
This command "presses" a Ruby project using the Tebako setup from the Tebako root
|
@@ -223,7 +244,7 @@ cmmands below.
|
|
223
244
|
----
|
224
245
|
tebako press \
|
225
246
|
[-p|--prefix=<tebako-root-folder>] \
|
226
|
-
[-R|--Ruby=<2.7.8|3.0.
|
247
|
+
[-R|--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>] \
|
227
248
|
-r|--root=<project-root-folder> \
|
228
249
|
-e|--entry-point=<entry-point> \
|
229
250
|
[-o|--output=<packaged file name>] \
|
@@ -232,10 +253,9 @@ tebako press \
|
|
232
253
|
|
233
254
|
Where:
|
234
255
|
|
235
|
-
* `<tebako-root-folder>`, the Tebako
|
236
|
-
folder)
|
256
|
+
* `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
237
257
|
|
238
|
-
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.
|
258
|
+
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
|
239
259
|
|
240
260
|
* `<project-root>`, a folder at the host source file system where project files
|
241
261
|
are located
|
@@ -275,15 +295,14 @@ based on ```tebako setup``` output. Building cache based on ```tebako press``` m
|
|
275
295
|
----
|
276
296
|
tebako setup \
|
277
297
|
[-p |--prefix=<tebako-root-folder>] \
|
278
|
-
[-R |--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.2.3|3.2.4>]
|
298
|
+
[-R |--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>]
|
279
299
|
----
|
280
300
|
|
281
301
|
Where:
|
282
302
|
|
283
|
-
* `<tebako-root-folder>`, the Tebako
|
284
|
-
folder)
|
303
|
+
* `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
285
304
|
|
286
|
-
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.
|
305
|
+
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.6)
|
287
306
|
|
288
307
|
==== Clean
|
289
308
|
|
@@ -298,8 +317,7 @@ tebako clean \
|
|
298
317
|
|
299
318
|
Where:
|
300
319
|
|
301
|
-
* `<tebako-root-folder>`, the Tebako
|
302
|
-
folder)
|
320
|
+
* `<tebako-root-folder>`, the Tebako root folder (see details in the Tebako Root Folder Selection section)
|
303
321
|
|
304
322
|
[example]
|
305
323
|
====
|
@@ -318,7 +336,7 @@ Normally you do not need to do it since tebako packager optimizes artifacts life
|
|
318
336
|
----
|
319
337
|
tebako clean_ruby
|
320
338
|
[-p|--prefix=<tebako-root-folder>]
|
321
|
-
[-R|--Ruby=<2.7.8|3.0.
|
339
|
+
[-R|--Ruby=<2.7.8|3.0.7|3.1.4|3.1.5|3.1.6|3.2.3|3.2.4>]
|
322
340
|
----
|
323
341
|
|
324
342
|
Where:
|
data/common.env
CHANGED
data/exe/tebako-packager
CHANGED
@@ -27,6 +27,7 @@
|
|
27
27
|
# POSSIBILITY OF SUCH DAMAGE.
|
28
28
|
|
29
29
|
require_relative "../lib/tebako/packager"
|
30
|
+
require_relative "../lib/tebako/stripper"
|
30
31
|
|
31
32
|
begin
|
32
33
|
unless ARGV.length.positive?
|
@@ -57,6 +58,16 @@ begin
|
|
57
58
|
end
|
58
59
|
|
59
60
|
Tebako::Packager.stash(ARGV[1], ARGV[2])
|
61
|
+
when "strip"
|
62
|
+
# ARGV[0] -- command
|
63
|
+
# ARGV[1] -- OSTYPE
|
64
|
+
# ARGV[2] -- DATA_SRC_DIR
|
65
|
+
unless ARGV.length == 3
|
66
|
+
raise Tebako::Error,
|
67
|
+
"tebako-packager strip command expects 3 arguments, #{ARGV.length} has been provided."
|
68
|
+
end
|
69
|
+
|
70
|
+
Tebako::Stripper.strip(ARGV[1], ARGV[2])
|
60
71
|
when "pass1a"
|
61
72
|
# ARGV[0] -- command
|
62
73
|
# ARGV[1] -- RUBY_SOURCE_DIR
|
data/lib/tebako/cli_helpers.rb
CHANGED
@@ -99,7 +99,7 @@ module Tebako
|
|
99
99
|
# rubocop:enable Metrics/MethodLength
|
100
100
|
|
101
101
|
def output
|
102
|
-
@output ||= File.join(prefix, "
|
102
|
+
@output ||= File.join(prefix, "o")
|
103
103
|
end
|
104
104
|
|
105
105
|
def package
|
@@ -115,10 +115,20 @@ module Tebako
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def handle_nil_prefix
|
119
|
+
env_prefix = ENV.fetch("TEBAKO_PREFIX", nil)
|
120
|
+
if env_prefix.nil?
|
121
|
+
puts "No prefix specified, using ~/.tebako"
|
122
|
+
File.expand_path("~/.tebako")
|
123
|
+
else
|
124
|
+
puts "Using TEBAKO_PREFIX environment variable as prefix"
|
125
|
+
File.expand_path(env_prefix)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
118
129
|
def prefix
|
119
130
|
@prefix ||= if options["prefix"].nil?
|
120
|
-
|
121
|
-
File.expand_path("~/.tebako")
|
131
|
+
handle_nil_prefix
|
122
132
|
elsif options["prefix"] == "PWD"
|
123
133
|
Dir.pwd
|
124
134
|
else
|
data/lib/tebako/cli_rubies.rb
CHANGED
@@ -42,11 +42,13 @@ module Tebako
|
|
42
42
|
"3.0.7" => "2a3411977f2850431136b0fab8ad53af09fb74df2ee2f4fb7f11b378fe034388",
|
43
43
|
"3.1.4" => "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6",
|
44
44
|
"3.1.5" => "3685c51eeee1352c31ea039706d71976f53d00ab6d77312de6aa1abaf5cda2c5",
|
45
|
+
"3.1.6" => "0d0dafb859e76763432571a3109d1537d976266be3083445651dc68deed25c22",
|
45
46
|
"3.2.3" => "af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba",
|
46
47
|
"3.2.4" => "c72b3c5c30482dca18b0f868c9075f3f47d8168eaf626d4e682ce5b59c858692"
|
48
|
+
# "3.3.3" => "83c05b2177ee9c335b631b29b8c077b4770166d02fa527f3a9f6a40d13f3cce2"
|
47
49
|
}.freeze
|
48
50
|
|
49
|
-
DEFAULT_RUBY_VERSION = "3.1.
|
51
|
+
DEFAULT_RUBY_VERSION = "3.1.6"
|
50
52
|
|
51
53
|
def version_check(version)
|
52
54
|
return if RUBY_VERSIONS.key?(version)
|
@@ -58,7 +58,7 @@ module Tebako
|
|
58
58
|
|
59
59
|
def get_dir_c_patch(ostype)
|
60
60
|
pattern = PatchHelpers.msys?(ostype) ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST"
|
61
|
-
dir_c_patch = PatchHelpers.
|
61
|
+
dir_c_patch = PatchHelpers.patch_c_file_pre(pattern)
|
62
62
|
dir_c_patch.merge!(DIR_C_BASE_PATCH)
|
63
63
|
dir_c_patch
|
64
64
|
end
|
@@ -85,11 +85,19 @@ module Tebako
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def get_io_c_patch(ostype, ruby_ver)
|
88
|
-
io_c_patch = PatchHelpers.
|
88
|
+
io_c_patch = PatchHelpers.patch_c_file_pre("/* define system APIs */")
|
89
89
|
io_c_patch.merge!(get_io_c_msys_patch(ruby_ver)) if PatchHelpers.msys?(ostype)
|
90
90
|
io_c_patch
|
91
91
|
end
|
92
92
|
|
93
|
+
def get_util_c_patch(ruby_ver)
|
94
|
+
if PatchHelpers.ruby316?(ruby_ver)
|
95
|
+
PatchHelpers.patch_c_file_post("#endif /* !HAVE_GNU_QSORT_R */")
|
96
|
+
else
|
97
|
+
PatchHelpers.patch_c_file_pre("#ifndef S_ISDIR")
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
93
101
|
def get_msys_mkconfig_rb_patches(ruby_ver)
|
94
102
|
{
|
95
103
|
" if fast[name]" => TOOLS_MKCONFIG_RB_SUBST,
|
@@ -117,8 +125,8 @@ module Tebako
|
|
117
125
|
"tool/mkconfig.rb" => mcrb_subst,
|
118
126
|
"dir.c" => get_dir_c_patch(ostype), "dln.c" => get_dln_c_patch(ostype, ruby_ver),
|
119
127
|
"io.c" => get_io_c_patch(ostype, ruby_ver), "main.c" => MAIN_C_PATCH,
|
120
|
-
"file.c" => PatchHelpers.
|
121
|
-
"util.c" =>
|
128
|
+
"file.c" => PatchHelpers.patch_c_file_pre("/* define system APIs */"),
|
129
|
+
"util.c" => get_util_c_patch(ruby_ver)
|
122
130
|
}
|
123
131
|
end
|
124
132
|
|
@@ -66,12 +66,18 @@ module Tebako
|
|
66
66
|
ostype =~ /msys|cygwin|mingw/
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def patch_c_file_pre(pattern)
|
70
70
|
{
|
71
71
|
pattern => "#{PatchLiterals::C_FILE_SUBST}\n#{pattern}"
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
75
|
+
def patch_c_file_post(pattern)
|
76
|
+
{
|
77
|
+
pattern => "#{pattern}\n\n#{PatchLiterals::C_FILE_SUBST}"
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
75
81
|
def recreate(dirname)
|
76
82
|
FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
|
77
83
|
FileUtils.mkdir(dirname)
|
@@ -102,12 +108,16 @@ module Tebako
|
|
102
108
|
ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 1
|
103
109
|
end
|
104
110
|
|
111
|
+
def ruby316?(ruby_ver)
|
112
|
+
ruby3x?(ruby_ver) && ruby_ver[2] == "1" && ruby_ver[4].to_i >= 6
|
113
|
+
end
|
114
|
+
|
105
115
|
def ruby32?(ruby_ver)
|
106
116
|
ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
|
107
117
|
end
|
108
118
|
|
109
119
|
def ruby32only?(ruby_ver)
|
110
|
-
ruby3x?(ruby_ver) && ruby_ver[2]
|
120
|
+
ruby3x?(ruby_ver) && ruby_ver[2] == "2"
|
111
121
|
end
|
112
122
|
|
113
123
|
def ruby33?(ruby_ver)
|
data/lib/tebako/packager.rb
CHANGED
@@ -74,11 +74,8 @@ module Tebako
|
|
74
74
|
class << self
|
75
75
|
# Create implib
|
76
76
|
def create_implib(src_dir, package_src_dir, app_name, ruby_ver)
|
77
|
+
create_def(src_dir, app_name)
|
77
78
|
puts " ... creating Windows import library"
|
78
|
-
File.open(def_fname(src_dir, app_name), "w") do |file|
|
79
|
-
file.puts "LIBRARY #{out_fname(app_name)}"
|
80
|
-
file.puts File.read(File.join(src_dir, "tebako.def"))
|
81
|
-
end
|
82
79
|
params = ["dlltool", "-d", def_fname(src_dir, app_name), "-D", out_fname(app_name),
|
83
80
|
"--output-lib", lib_fname(package_src_dir, ruby_ver)]
|
84
81
|
out, st = Open3.capture2e(*params)
|
@@ -155,6 +152,16 @@ module Tebako
|
|
155
152
|
|
156
153
|
private
|
157
154
|
|
155
|
+
def create_def(src_dir, app_name)
|
156
|
+
puts " ... creating Windows def file"
|
157
|
+
File.open(def_fname(src_dir, app_name), "w") do |file|
|
158
|
+
file.puts "LIBRARY #{out_fname(app_name)}"
|
159
|
+
File.readlines(File.join(src_dir, "tebako.def")).each do |line|
|
160
|
+
file.puts line unless line.include?("DllMain")
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
158
165
|
def def_fname(src_dir, app_name)
|
159
166
|
File.join(src_dir, "#{app_name}.def")
|
160
167
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 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 "fileutils"
|
29
|
+
require "find"
|
30
|
+
|
31
|
+
# Tebako - an executable packager
|
32
|
+
module Tebako
|
33
|
+
# Tebako packaging support (stripper)
|
34
|
+
module Stripper
|
35
|
+
DELETE_EXTENSIONS = %w[o lo obj a lib].freeze
|
36
|
+
STRIP_EXTENSIONS = %w[dll so].freeze
|
37
|
+
BIN_FILES = %w[
|
38
|
+
bundle bundler rbs erb gem irb racc racc2y rake rdoc ri y2racc rdbg typeprof
|
39
|
+
].freeze
|
40
|
+
CMD_SUFFIX = ".cmd"
|
41
|
+
BAT_SUFFIX = ".bat"
|
42
|
+
|
43
|
+
class << self
|
44
|
+
# Strip
|
45
|
+
# Removes build artefacts, strip shared objects
|
46
|
+
# [TODO] We probably need debug option/flag to say whether we shall delete ruby binaries
|
47
|
+
# from memfs or not. For debugging purposes it is very handy to have it here
|
48
|
+
def strip(ostype, src_dir)
|
49
|
+
puts " ... stripping the output"
|
50
|
+
strip_bs(ostype, src_dir)
|
51
|
+
strip_fi(ostype, src_dir)
|
52
|
+
strip_li(ostype, src_dir)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def get_files(ostype)
|
58
|
+
exe_suffix = ostype =~ /msys/ ? ".exe" : ""
|
59
|
+
files = BIN_FILES.flat_map do |f|
|
60
|
+
[f, "#{f}#{CMD_SUFFIX}", "#{f}#{BAT_SUFFIX}"]
|
61
|
+
end
|
62
|
+
|
63
|
+
files += ["ruby#{exe_suffix}", "rubyw#{exe_suffix}"]
|
64
|
+
files
|
65
|
+
end
|
66
|
+
|
67
|
+
def strip_bs(_ostype, src_dir)
|
68
|
+
FileUtils.rm_rf([
|
69
|
+
File.join(src_dir, "share"),
|
70
|
+
File.join(src_dir, "include"),
|
71
|
+
File.join(src_dir, "lib", "pkgconfig")
|
72
|
+
])
|
73
|
+
end
|
74
|
+
|
75
|
+
def strip_fi(ostype, src_dir)
|
76
|
+
files = get_files(ostype).map { |f| "#{src_dir}/bin/#{f}" }
|
77
|
+
FileUtils.rm(files, force: true)
|
78
|
+
end
|
79
|
+
|
80
|
+
def strip_li(ostype, src_dir)
|
81
|
+
Find.find(src_dir) do |file|
|
82
|
+
next if File.directory?(file)
|
83
|
+
|
84
|
+
extension = File.extname(file).delete_prefix(".").downcase
|
85
|
+
if DELETE_EXTENSIONS.include?(extension)
|
86
|
+
FileUtils.rm(file)
|
87
|
+
elsif STRIP_EXTENSIONS.include?(extension)
|
88
|
+
system("strip \"#{file}\"") unless ostype =~ /darwin/
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/tebako/version.rb
CHANGED
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tebako
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/tebako/packager/patch_helpers.rb
|
76
76
|
- lib/tebako/packager/patch_libraries.rb
|
77
77
|
- lib/tebako/packager/patch_literals.rb
|
78
|
+
- lib/tebako/stripper.rb
|
78
79
|
- lib/tebako/version.rb
|
79
80
|
- resources/tebako-fs.cpp.in
|
80
81
|
- resources/tebako-version.h.in
|
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
137
|
- !ruby/object:Gem::Version
|
137
138
|
version: '0'
|
138
139
|
requirements: []
|
139
|
-
rubygems_version: 3.5.
|
140
|
+
rubygems_version: 3.5.11
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
143
|
summary: Packager for Ruby executables
|