tebako 0.5.4 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +45 -35
- data/README.adoc +9 -9
- data/Rakefile +1 -1
- data/common.env +1 -2
- data/exe/tebako-packager +8 -6
- data/lib/tebako/cli_helpers.rb +5 -5
- data/lib/tebako/packager/pass2.rb +33 -17
- data/lib/tebako/packager/patch_helpers.rb +68 -2
- data/lib/tebako/packager/patch_literals.rb +24 -21
- data/lib/tebako/packager.rb +60 -61
- data/lib/tebako/version.rb +1 -1
- data/resources/tebako-fs.cpp.in +2 -2
- data/version.txt +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23a76520703c1526cb92a3aaeac6c215a117b5dd6f27f18b286c7dc165d95b98
|
4
|
+
data.tar.gz: 2078da7a9009225a1d50435dac76b75579068f8683e4f0d5c6f1c80f501a98f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1102354529402a3ac5d30830d602f203d0c89ded810e44d4caeabd407ccda5a7b72bda9a03c15732cf451a5716d9875c6d51ae8dfb669af15d4a0c9f1ae255a
|
7
|
+
data.tar.gz: ff70d7dfbe6ce10b6689ed97860b87909e18e4a29c44c2d7a0cc1895667121010810b1aa702d2ec6869e844e214ad2be17b66ee67dd58f2fbe8254b984a8fc63
|
data/CMakeLists.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2021-
|
1
|
+
# Copyright (c) 2021-2024 [Ribose Inc](https://www.ribose.com).
|
2
2
|
# All rights reserved.
|
3
3
|
# This file is a part of tebako
|
4
4
|
#
|
@@ -172,14 +172,37 @@ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
|
|
172
172
|
set(RUBY_MAKEFILE "--file=GNUmakefile")
|
173
173
|
elseif("${OSTYPE_TXT}" MATCHES "^darwin.*")
|
174
174
|
set(IS_DARWIN ON)
|
175
|
-
if(${RUBY_VER} VERSION_LESS "3.
|
175
|
+
if(${RUBY_VER} VERSION_LESS "3.1.0")
|
176
176
|
set(OPENSSL_VER "1.1")
|
177
|
-
else(${RUBY_VER} VERSION_LESS "3.
|
177
|
+
else(${RUBY_VER} VERSION_LESS "3.1.0")
|
178
178
|
set(OPENSSL_VER "3")
|
179
|
-
endif(${RUBY_VER} VERSION_LESS "3.
|
179
|
+
endif(${RUBY_VER} VERSION_LESS "3.1.0")
|
180
180
|
set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
|
181
181
|
endif()
|
182
182
|
|
183
|
+
if(IS_DARWIN)
|
184
|
+
execute_process(
|
185
|
+
COMMAND "sysctl" "-n" "hw.ncpu"
|
186
|
+
RESULT_VARIABLE NCORES_RES
|
187
|
+
OUTPUT_VARIABLE NCORES
|
188
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
189
|
+
)
|
190
|
+
else(IS_DARWIN)
|
191
|
+
execute_process(
|
192
|
+
COMMAND "nproc" "--all"
|
193
|
+
RESULT_VARIABLE NCORES_RES
|
194
|
+
OUTPUT_VARIABLE NCORES
|
195
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
196
|
+
)
|
197
|
+
endif(IS_DARWIN)
|
198
|
+
|
199
|
+
if(NCORES_RES EQUAL 0)
|
200
|
+
message(STATUS "NCORES: ${NCORES}")
|
201
|
+
else(NCORES_RES EQUAL 0)
|
202
|
+
set(NCORES 4)
|
203
|
+
message(WARNING "Failed to detect NCORES, resetting to ${NCORES} (default)")
|
204
|
+
endif(NCORES_RES EQUAL 0)
|
205
|
+
|
183
206
|
# Various locations for external projects
|
184
207
|
set(DEPS ${CMAKE_CURRENT_SOURCE_DIR}/deps CACHE STRING "Dependencies' folder'")
|
185
208
|
set(DEPS_INCLUDE_DIR ${DEPS}/include)
|
@@ -220,15 +243,7 @@ if(IS_MSYS)
|
|
220
243
|
endif(IS_MSYS)
|
221
244
|
|
222
245
|
def_ext_prj_g(INCBIN "348e36b")
|
223
|
-
def_ext_prj_g(DWARFS_WR "v0.
|
224
|
-
|
225
|
-
if (DEFINED ENV{BUNDLER_VER})
|
226
|
-
set(BUNDLER_VER $ENV{BUNDLER_VER})
|
227
|
-
set(BUNDLER_ANNOTATION "environment")
|
228
|
-
else()
|
229
|
-
set(BUNDLER_VER "2.3.22")
|
230
|
-
set(BUNDLER_ANNOTATION "default")
|
231
|
-
endif()
|
246
|
+
def_ext_prj_g(DWARFS_WR "v0.4.0")
|
232
247
|
|
233
248
|
find_library(_LIBNCURSES "libncurses.a")
|
234
249
|
if(${_LIBNCURSES} STREQUAL "_LIBNCURSES-NOTFOUND")
|
@@ -245,7 +260,6 @@ endif(${RUBY_VER} VERSION_LESS "3.2.0")
|
|
245
260
|
|
246
261
|
message("Configuration summary:")
|
247
262
|
message(STATUS "ruby: v${RUBY_VER} at ${RUBY_SOURCE_DIR}")
|
248
|
-
message(STATUS "bundler version: ${BUNDLER_VER} (${BUNDLER_ANNOTATION})")
|
249
263
|
if(WITH_OPENSSL_BUILD)
|
250
264
|
message(STATUS "openssl: building @${OPENSSL_TAG} at ${OPENSSL_SOURCE_DIR}")
|
251
265
|
endif(WITH_OPENSSL_BUILD)
|
@@ -363,7 +377,7 @@ ExternalProject_Add(${DWARFS_WR_PRJ}
|
|
363
377
|
SOURCE_DIR ${DWARFS_WR_SOURCE_DIR}
|
364
378
|
BINARY_DIR ${DWARFS_WR_BINARY_DIR}
|
365
379
|
UPDATE_COMMAND ""
|
366
|
-
BUILD_COMMAND ${CMAKE_COMMAND} --build ${DWARFS_WR_BINARY_DIR} --parallel
|
380
|
+
BUILD_COMMAND ${CMAKE_COMMAND} --build ${DWARFS_WR_BINARY_DIR} --parallel ${NCORES}
|
367
381
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS}
|
368
382
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
369
383
|
-DWITH_TESTS:BOOL=OFF
|
@@ -418,15 +432,17 @@ if(IS_DARWIN)
|
|
418
432
|
string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/lib -L${BUILD_BREW_PREFIX}/opt/zlib/lib -L${BUILD_BREW_PREFIX}/lib")
|
419
433
|
set(OPENSSL_RUBY_OPTION "--with-openssl-dir=${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
|
420
434
|
set(C_FLAGS_DEST cflags)
|
421
|
-
|
435
|
+
else(IS_DARWIN)
|
436
|
+
string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -static-libgcc")
|
422
437
|
|
423
|
-
if(IS_MUSL)
|
424
|
-
|
425
|
-
endif(IS_MUSL)
|
438
|
+
if(IS_MUSL)
|
439
|
+
string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DENABLE_PATH_CHECK=0")
|
440
|
+
endif(IS_MUSL)
|
426
441
|
|
427
|
-
if(RB_W32)
|
428
|
-
|
429
|
-
endif(RB_W32)
|
442
|
+
if(RB_W32)
|
443
|
+
string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -DRB_W32=1")
|
444
|
+
endif(RB_W32)
|
445
|
+
endif(IS_DARWIN)
|
430
446
|
|
431
447
|
message(STATUS "Ruby build ${C_FLAGS_DEST}='${RUBY_C_FLAGS}'")
|
432
448
|
message(STATUS "Ruby build LDFLAGS='${RUBY_L_FLAGS}'")
|
@@ -452,7 +468,7 @@ ExternalProject_Add(${RUBY_PRJ}
|
|
452
468
|
--prefix=${DATA_SRC_DIR} \
|
453
469
|
${C_FLAGS_DEST}=\"${RUBY_C_FLAGS}\" \
|
454
470
|
LDFLAGS=\"${RUBY_L_FLAGS}\""
|
455
|
-
BUILD_COMMAND make ${RUBY_MAKEFILE}
|
471
|
+
BUILD_COMMAND make ${RUBY_MAKEFILE} -j${NCORES}
|
456
472
|
INSTALL_COMMAND make ${RUBY_MAKEFILE} install
|
457
473
|
COMMAND ruby ${EXE}/tebako-packager pass2 ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${DEPS_LIB_DIR} ${DATA_SRC_DIR} ${RUBY_STASH_DIR} ${RUBY_VER}
|
458
474
|
)
|
@@ -486,7 +502,7 @@ else (${SETUP_MODE})
|
|
486
502
|
list(LENGTH GEMS GLENGTH)
|
487
503
|
|
488
504
|
add_custom_target(clean_filesystem
|
489
|
-
COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${
|
505
|
+
COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${GFLENGTH}
|
490
506
|
DEPENDS ${RUBY_PRJ}
|
491
507
|
)
|
492
508
|
if(GSLENGTH GREATER 0)
|
@@ -502,8 +518,6 @@ else (${SETUP_MODE})
|
|
502
518
|
add_custom_target(source_filesystem
|
503
519
|
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
|
504
520
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
|
505
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
506
|
-
${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}' --source 'https://rubygems.org/' --no-document --install-dir ${TGD}
|
507
521
|
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
508
522
|
${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
|
509
523
|
COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
@@ -547,23 +561,19 @@ else (${SETUP_MODE})
|
|
547
561
|
${CMAKE_COMMAND} -E false )
|
548
562
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
|
549
563
|
COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
|
550
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
551
|
-
${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}'
|
552
|
-
--source 'https://rubygems.org/' --no-document --install-dir ${TGD}
|
553
564
|
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
554
565
|
${TBD}/bundle${CMD_SUFFIX} config build.ffi --disable-system-libffi
|
555
566
|
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
556
567
|
${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
|
557
568
|
COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
558
|
-
${TBD}/bundle${CMD_SUFFIX} install --jobs
|
569
|
+
${TBD}/bundle${CMD_SUFFIX} install --jobs=${NCORES}
|
559
570
|
# COMMAND_EXPAND_LISTS
|
560
571
|
# [TODO] Open question - how to deploy a project to source filesystem
|
561
572
|
# ruby packer does bundle install --deployment --binstubs
|
562
|
-
# [TODO] --jobs=4 probably can be more intellectual
|
563
573
|
# COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
564
574
|
# ${TBD}/bundle lock
|
565
575
|
# COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
|
566
|
-
# ${TBD}/bundle install --deployment --jobs
|
576
|
+
# ${TBD}/bundle install --deployment --jobs=${NCORES}
|
567
577
|
DEPENDS clean_filesystem
|
568
578
|
)
|
569
579
|
elseif(GLENGTH GREATER 0)
|
@@ -663,12 +673,12 @@ else (${SETUP_MODE})
|
|
663
673
|
|
664
674
|
if (${RUBY_VER} VERSION_LESS "3.0.0")
|
665
675
|
add_custom_target(patched_ruby
|
666
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
|
676
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
|
667
677
|
)
|
668
678
|
else()
|
669
679
|
add_custom_target(patched_ruby
|
670
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE}
|
671
|
-
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE}
|
680
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE} -j${NCORES}
|
681
|
+
COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
|
672
682
|
)
|
673
683
|
endif()
|
674
684
|
|
data/README.adoc
CHANGED
@@ -33,7 +33,7 @@ In the future:
|
|
33
33
|
|
34
34
|
The Tebako packager is tested on the following platforms:
|
35
35
|
|
36
|
-
* Linux: Ubuntu 20.04; Alpine 3.
|
36
|
+
* Linux: Ubuntu 20.04; Alpine 3.17
|
37
37
|
* macOS: macOS 11.0 (Monterey)
|
38
38
|
* Windows: TBD
|
39
39
|
|
@@ -41,10 +41,10 @@ The Tebako packager is tested on the following platforms:
|
|
41
41
|
|
42
42
|
The Tebako packager supports the following versions of Ruby for packaging:
|
43
43
|
|
44
|
-
* 2.7.
|
44
|
+
* 2.7.8
|
45
45
|
* 3.0.6
|
46
46
|
* 3.1.4
|
47
|
-
* 3.2.
|
47
|
+
* 3.2.3
|
48
48
|
|
49
49
|
Support of specific version including minor release requires some effort, sometimes extensive
|
50
50
|
but our goal is to be able to package all maintained Ruby releases.
|
@@ -53,7 +53,7 @@ but our goal is to be able to package all maintained Ruby releases.
|
|
53
53
|
|
54
54
|
=== Ubuntu
|
55
55
|
|
56
|
-
==== GNU C/C++
|
56
|
+
==== GNU C/C++ 10+ or Clang C/C++ 12+
|
57
57
|
|
58
58
|
==== CMake version 3.20+
|
59
59
|
|
@@ -120,7 +120,7 @@ export TZ=Etc/UTC
|
|
120
120
|
apt-get update
|
121
121
|
apt-get install -y software-properties-common
|
122
122
|
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
123
|
-
apt-get install -y gcc-
|
123
|
+
apt-get install -y gcc-10 g++-10
|
124
124
|
|
125
125
|
apt-get install -y curl git ruby ruby-dev pkg-config bison flex make autoconf
|
126
126
|
curl https://apt.kitware.com/kitware-archive.sh | bash
|
@@ -164,7 +164,7 @@ cmmands below.
|
|
164
164
|
----
|
165
165
|
tebako press \
|
166
166
|
[-p|--prefix=<tebako-root-folder>] \
|
167
|
-
[-R|--Ruby=<2.7.
|
167
|
+
[-R|--Ruby=<2.7.8|3.0.6|3.1.4|3.2.3>] \
|
168
168
|
-r|--root=<project-root-folder> \
|
169
169
|
-e|--entry-point=<entry-point> \
|
170
170
|
[-o|--output=<packaged file name>] \
|
@@ -176,7 +176,7 @@ Where:
|
|
176
176
|
* `<tebako-root-folder>`, the Tebako setup folder (optional, defaults to current
|
177
177
|
folder)
|
178
178
|
|
179
|
-
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.
|
179
|
+
* `Ruby` parameter defines Ruby version that will be packaged (optional, defaults to 3.1.4)
|
180
180
|
|
181
181
|
* `<project-root>`, a folder at the host source file system where project files
|
182
182
|
are located
|
@@ -214,7 +214,7 @@ invocation of press command.
|
|
214
214
|
----
|
215
215
|
tebako setup \
|
216
216
|
[-p |--prefix=<tebako-root-folder>] \
|
217
|
-
[-R |--Ruby=<2.7.
|
217
|
+
[-R |--Ruby=<2.7.8|3.0.6|3.1.4|3.2.3>]
|
218
218
|
----
|
219
219
|
|
220
220
|
Where:
|
@@ -257,7 +257,7 @@ Normally you do not need to do it since tebako packager optimizes artifacts life
|
|
257
257
|
----
|
258
258
|
tebako clean_ruby
|
259
259
|
[-p|--prefix=<tebako-root-folder>]
|
260
|
-
[-R|--Ruby=<2.7.
|
260
|
+
[-R|--Ruby=<2.7.8|3.0.6|3.1.4|3.2.3>]
|
261
261
|
----
|
262
262
|
|
263
263
|
Where:
|
data/Rakefile
CHANGED
@@ -36,7 +36,7 @@ desc "Generate version.txt"
|
|
36
36
|
task "generate_version_txt" do
|
37
37
|
require_relative "lib/tebako/version"
|
38
38
|
File.write(File.join(__dir__, "version.txt"), "#{Tebako::VERSION}\n")
|
39
|
-
puts "Generating
|
39
|
+
puts "Generating #{File.join(__dir__, "version.txt")}; version = #{Tebako::VERSION}"
|
40
40
|
end
|
41
41
|
|
42
42
|
task build: :generate_version_txt
|
data/common.env
CHANGED
data/exe/tebako-packager
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
|
5
5
|
# All rights reserved.
|
6
6
|
# This file is a part of tebako
|
7
7
|
#
|
@@ -78,13 +78,15 @@ begin
|
|
78
78
|
# ARGV[2] -- DATA_SRC_DIR
|
79
79
|
# ARGV[3] -- DATA_PRE_DIR
|
80
80
|
# ARGV[4] -- DATA_BIN_DIR
|
81
|
-
# ARGV[5] --
|
82
|
-
|
83
|
-
unless ARGV.length == 7
|
81
|
+
# ARGV[5] -- GFLENGTH
|
82
|
+
unless ARGV.length == 6
|
84
83
|
raise Tebako::Error,
|
85
|
-
"tebako-packager deploy command expects
|
84
|
+
"tebako-packager deploy command expects 6 arguments, #{ARGV.length} has been provided."
|
86
85
|
end
|
87
|
-
Tebako::Packager.
|
86
|
+
Tebako::Packager.init(ARGV[1], ARGV[2], ARGV[3], ARGV[4])
|
87
|
+
# Assume that "<TARGET_BIN_DIR (TBD)>" is <DATA_SRC_DIR>/bin"
|
88
|
+
# That shall match CMakeLists.txt settings
|
89
|
+
Tebako::Packager.deploy(ARGV[2], "#{ARGV[2]}/bin", ARGV[5])
|
88
90
|
else
|
89
91
|
raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
|
90
92
|
end
|
data/lib/tebako/cli_helpers.rb
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
|
#
|
@@ -44,8 +44,6 @@ module Tebako
|
|
44
44
|
else
|
45
45
|
ENV.fetch("CXXFLAGS", nil)
|
46
46
|
end
|
47
|
-
# cc = ENV.fetch("CC", "gcc")
|
48
|
-
# cxx = ENV.fetch("CXX", "g++")
|
49
47
|
@b_env ||= { "CXXFLAGS" => u_flags }
|
50
48
|
end
|
51
49
|
|
@@ -61,10 +59,11 @@ module Tebako
|
|
61
59
|
end
|
62
60
|
|
63
61
|
RUBY_VERSIONS = {
|
64
|
-
"2.7.
|
62
|
+
"2.7.8" => "c2dab63cbc8f2a05526108ad419efa63a67ed4074dbbcf9fc2b1ca664cb45ba0",
|
65
63
|
"3.0.6" => "6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e",
|
66
64
|
"3.1.4" => "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6",
|
67
|
-
"3.2.
|
65
|
+
"3.2.3" => "af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba",
|
66
|
+
"3.3.0" => "96518814d9832bece92a85415a819d4893b307db5921ae1f0f751a9a89a56b7d"
|
68
67
|
}.freeze
|
69
68
|
|
70
69
|
DEFAULT_RUBY_VERSION = "3.1.4"
|
@@ -132,6 +131,7 @@ module Tebako
|
|
132
131
|
|
133
132
|
def prefix
|
134
133
|
@prefix ||= if options["prefix"].nil?
|
134
|
+
puts "No prefix specified, using ~/.tebako"
|
135
135
|
File.expand_path("~/.tebako")
|
136
136
|
elsif options["prefix"] == "PWD"
|
137
137
|
Dir.pwd
|
@@ -42,6 +42,7 @@ module Tebako
|
|
42
42
|
patch_map.store("common.mk", COMMON_MK_PATCH) if PatchHelpers.ruby3x?(ruby_ver)
|
43
43
|
|
44
44
|
ostype =~ /msys/ ? patch_map.merge!(MSYS_PATCHES) : patch_map
|
45
|
+
# patch_map.merge!(LINUX_PATCHES)
|
45
46
|
end
|
46
47
|
|
47
48
|
private
|
@@ -64,35 +65,51 @@ module Tebako
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def process_brew_libs!(libs, brew_libs)
|
67
|
-
brew_libs.each { |lib| libs << "#{PatchHelpers.
|
68
|
+
brew_libs.each { |lib| libs << "#{PatchHelpers.get_prefix_macos(lib[0]).chop}/lib/lib#{lib[1]}.a " }
|
68
69
|
end
|
69
70
|
|
70
71
|
def darwin_libs(deps_lib_dir, ruby_ver)
|
71
72
|
libs = String.new
|
73
|
+
|
74
|
+
process_brew_libs!(libs, PatchHelpers.ruby31?(ruby_ver) ? DARWIN_BREW_LIBS_31 : DARWIN_BREW_LIBS_PRE_31)
|
72
75
|
process_brew_libs!(libs, DARWIN_BREW_LIBS)
|
73
|
-
|
76
|
+
|
74
77
|
DARWIN_DEP_LIBS.each { |lib| libs << "#{deps_lib_dir}/lib#{lib}.a " }
|
75
78
|
<<~SUBST
|
76
|
-
-ltebako-fs -ldwarfs-wr -ldwarfs -lfolly -lfsst -lmetadata_thrift -lthrift_light -lxxhash \
|
77
|
-
-lzstd #{libs} -ljemalloc -lc++
|
79
|
+
-ltebako-fs -ldwarfs-wr -ldwarfs -force_load #{deps_lib_dir}/libdwarfs_compression.a -lfolly -lfsst -lmetadata_thrift -lthrift_light -lxxhash \
|
80
|
+
-lzstd #{libs} -ljemalloc -lc++ -lc++abi
|
78
81
|
SUBST
|
79
82
|
end
|
80
83
|
|
84
|
+
# .....................................................
|
85
|
+
# Notes re linux libraries
|
86
|
+
# 1) This order is important: -lgcc_eh -l:libunwind.a -l:liblzma.a lzma is used to process debug sections.
|
87
|
+
# gcc_eh shall be linked before unwind to avoid duplicate symbols.
|
88
|
+
# 2) -lgcc_eh assumes -static-libgcc (applied in CMakeLists.ext, RUBY_C_FLAGS)
|
89
|
+
# 3) -static-libstdc++ did not work, not sure why [TODO ?]
|
90
|
+
# 4) When clang is used linker links libraries specified in exensions in such way that they are linked shared
|
91
|
+
# (libz, libffi, libreadline, libncurses, libtinfo, ... )
|
92
|
+
# Using stuff like -l:libz.a does not help; there is a reference to libz.so anyway.
|
93
|
+
# This is fixed by ext/extmk.rb patch [TODO ?]
|
94
|
+
# .....................................................
|
95
|
+
|
81
96
|
def linux_gnu_libs(ruby_ver)
|
82
97
|
<<~SUBST
|
83
|
-
-l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -
|
84
|
-
-l:
|
85
|
-
-l:
|
86
|
-
|
98
|
+
-l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -Wl,--push-state,--whole-archive -l:libdwarfs_compression.a -Wl,--pop-state -l:libfolly.a -l:libfsst.a \
|
99
|
+
-l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a -l:libarchive.a -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a \
|
100
|
+
-l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a -l:libzstd.a -l:libbrotlienc.a -l:libbrotlidec.a -l:libbrotlicommon.a -l:libgdbm.a \
|
101
|
+
-l:libreadline.a -l:libtinfo.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libcrypt.a -l:libanl.a #{PatchHelpers.yaml_reference(ruby_ver)} \
|
102
|
+
-l:libboost_system.a -l:libboost_chrono.a -l:libutil.a -l:libstdc++.a -lgcc_eh -l:libunwind.a -l:liblzma.a -l:librt.a -ldl -lpthread -lm
|
87
103
|
SUBST
|
88
104
|
end
|
89
105
|
|
90
106
|
def linux_musl_libs(ruby_ver)
|
91
107
|
<<~SUBST
|
92
|
-
-l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -
|
93
|
-
-l:
|
94
|
-
-l:
|
95
|
-
#{PatchHelpers.yaml_reference(ruby_ver)} -l:libboost_system.a -l:
|
108
|
+
-l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -Wl,--push-state,--whole-archive -l:libdwarfs_compression.a -Wl,--pop-state -l:libfolly.a -l:libfsst.a \
|
109
|
+
-l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libiberty.a \
|
110
|
+
-l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a -l:libzstd.a -l:libbrotlienc.a -l:libbrotlidec.a -l:libbrotlicommon.a -l:libgdbm.a -l:libreadline.a \
|
111
|
+
-l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libcrypt.a #{PatchHelpers.yaml_reference(ruby_ver)} -l:libboost_system.a -l:libboost_chrono.a -l:librt.a \
|
112
|
+
-l:libstdc++.a -lgcc_eh -l:libunwind.a -l:liblzma.a -ldl -lpthread
|
96
113
|
SUBST
|
97
114
|
end
|
98
115
|
|
@@ -123,7 +140,7 @@ module Tebako
|
|
123
140
|
# rubocop:enable Metrics/MethodLength
|
124
141
|
|
125
142
|
def mlibs_subst(ostype, deps_lib_dir, ruby_ver)
|
126
|
-
yjit_libs = PatchHelpers.
|
143
|
+
yjit_libs = PatchHelpers.ruby32only?(ruby_ver) ? "$(YJIT_LIBS) " : ""
|
127
144
|
{
|
128
145
|
"MAINLIBS = #{yjit_libs}@MAINLIBS@" =>
|
129
146
|
"# -- Start of tebako patch -- \n" \
|
@@ -139,15 +156,14 @@ module Tebako
|
|
139
156
|
end
|
140
157
|
|
141
158
|
def template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver)
|
142
|
-
|
143
|
-
base_patch.merge!(template_makefile_in_patch_two(ruby_ver))
|
159
|
+
template_makefile_in_patch_two(ruby_ver).merge(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
|
144
160
|
end
|
145
161
|
|
146
162
|
def template_makefile_in_patch_two(ruby_ver)
|
147
163
|
if PatchHelpers.ruby31?(ruby_ver)
|
148
|
-
{
|
164
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN => TEMPLATE_MAKEFILE_IN_BASE_PATCH }
|
149
165
|
else
|
150
|
-
{
|
166
|
+
{ TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 => TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 }
|
151
167
|
end
|
152
168
|
end
|
153
169
|
end
|
@@ -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
|
#
|
@@ -34,13 +34,55 @@ module Tebako
|
|
34
34
|
# Ruby patching helpers (pass2)
|
35
35
|
module PatchHelpers
|
36
36
|
class << self
|
37
|
-
def
|
37
|
+
def patch_file(fname, mapping)
|
38
|
+
raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
|
39
|
+
|
40
|
+
puts " ... patching #{fname}"
|
41
|
+
restore_and_save(fname)
|
42
|
+
contents = File.read(fname)
|
43
|
+
mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
|
44
|
+
File.open(fname, "w") { |file| file << contents }
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_prefix_macos(package)
|
38
48
|
out, st = Open3.capture2("brew --prefix #{package}")
|
39
49
|
raise Tebako::Error, "brew --prefix #{package} failed with code #{st.exitstatus}" unless st.exitstatus.zero?
|
40
50
|
|
41
51
|
out
|
42
52
|
end
|
43
53
|
|
54
|
+
def get_prefix_linux(package)
|
55
|
+
out, st = Open3.capture2("pkg-config --variable=libdir #{package}")
|
56
|
+
unless st.exitstatus.zero?
|
57
|
+
raise Tebako::Error,
|
58
|
+
"pkg-config --variable=libdir #{package} failed with code #{st.exitstatus}"
|
59
|
+
end
|
60
|
+
|
61
|
+
out
|
62
|
+
end
|
63
|
+
|
64
|
+
def recreate(dirname)
|
65
|
+
FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
|
66
|
+
FileUtils.mkdir(dirname)
|
67
|
+
end
|
68
|
+
|
69
|
+
def restore_and_save(fname)
|
70
|
+
raise Tebako::Error, "Could not save #{fname} because it does not exist." unless File.exist?(fname)
|
71
|
+
|
72
|
+
old_fname = "#{fname}.old"
|
73
|
+
if File.exist?(old_fname)
|
74
|
+
FileUtils.rm_f(fname)
|
75
|
+
File.rename(old_fname, fname)
|
76
|
+
end
|
77
|
+
FileUtils.cp(fname, old_fname)
|
78
|
+
end
|
79
|
+
|
80
|
+
def restore_and_save_files(files, ruby_source_dir)
|
81
|
+
files.each do |fname|
|
82
|
+
restore_and_save "#{ruby_source_dir}/#{fname}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
44
86
|
def ruby3x?(ruby_ver)
|
45
87
|
ruby_ver[0] == "3"
|
46
88
|
end
|
@@ -53,6 +95,30 @@ module Tebako
|
|
53
95
|
ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
|
54
96
|
end
|
55
97
|
|
98
|
+
def ruby32only?(ruby_ver)
|
99
|
+
ruby3x?(ruby_ver) && ruby_ver[2].to_i == 2
|
100
|
+
end
|
101
|
+
|
102
|
+
def ruby33?(ruby_ver)
|
103
|
+
ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 3
|
104
|
+
end
|
105
|
+
|
106
|
+
# Sets up temporary environment variables and yields to the
|
107
|
+
# block. When the block exits, the environment variables are set
|
108
|
+
# back to their original values.
|
109
|
+
def with_env(hash)
|
110
|
+
old = {}
|
111
|
+
hash.each do |k, v|
|
112
|
+
old[k] = ENV.fetch(k, nil)
|
113
|
+
ENV[k] = v
|
114
|
+
end
|
115
|
+
begin
|
116
|
+
yield
|
117
|
+
ensure
|
118
|
+
hash.each_key { |k| ENV[k] = old[k] }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
56
122
|
def yaml_reference(ruby_ver)
|
57
123
|
ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
|
58
124
|
end
|
@@ -168,32 +168,24 @@ module Tebako
|
|
168
168
|
["dln.c", "static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;"]
|
169
169
|
].freeze
|
170
170
|
|
171
|
-
|
172
|
-
"LIBS = @LIBS@ $(EXTLIBS)" => <<~SUBST
|
173
|
-
# -- Start of tebako patch --
|
174
|
-
LIBS = $(MAINLIBS) @LIBS@
|
175
|
-
# -- End of tebako patch --
|
176
|
-
SUBST
|
177
|
-
}.freeze
|
178
|
-
|
179
|
-
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO_PRE_3_1 =
|
171
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_PRE_3_1 =
|
180
172
|
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
181
173
|
"$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
182
174
|
|
183
|
-
|
175
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH_PRE_3_1 =
|
184
176
|
"# -- Start of tebako patch --\n" \
|
185
177
|
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
186
|
-
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(
|
178
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
187
179
|
"# -- End of tebako patch --"
|
188
180
|
|
189
|
-
|
190
|
-
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
191
|
-
"$(
|
181
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN =
|
182
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) " \
|
183
|
+
"$(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
192
184
|
|
193
|
-
|
185
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH =
|
194
186
|
"# -- Start of tebako patch --\n" \
|
195
187
|
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
196
|
-
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(
|
188
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(OUTFLAG)$@\n" \
|
197
189
|
"# -- End of tebako patch --"
|
198
190
|
|
199
191
|
C_FILE_SUBST = <<~SUBST
|
@@ -259,17 +251,28 @@ module Tebako
|
|
259
251
|
|
260
252
|
}.freeze
|
261
253
|
|
254
|
+
LINUX_PATCHES = {
|
255
|
+
"ext/extmk.rb" => {
|
256
|
+
"mf.macro \"EXTLIBS\", $extlibs" => "# mf.macro \"EXTLIBS\", $extlibs tebako patched"
|
257
|
+
}
|
258
|
+
}.freeze
|
259
|
+
|
262
260
|
# rubocop:disable Style/WordArray
|
261
|
+
|
262
|
+
# NOTE: folly provides build-in implementation of jemalloc
|
263
|
+
|
263
264
|
DARWIN_BREW_LIBS = [
|
264
|
-
["
|
265
|
-
["
|
266
|
-
["
|
265
|
+
["zlib", "z"], ["gdbm", "gdbm"], ["readline", "readline"], ["libffi", "ffi"],
|
266
|
+
["ncurses", "ncurses"], ["fmt", "fmt"], ["lz4", "lz4"], ["xz", "lzma"],
|
267
|
+
["libyaml", "yaml"], ["boost", "boost_chrono"],
|
267
268
|
["double-conversion", "double-conversion"]
|
268
269
|
].freeze
|
269
270
|
|
270
|
-
|
271
|
+
DARWIN_BREW_LIBS_PRE_31 = [["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"]].freeze
|
272
|
+
|
273
|
+
DARWIN_BREW_LIBS_31 = [["libyaml", "yaml"], ["openssl@3", "ssl"], ["openssl@3", "crypto"]].freeze
|
271
274
|
|
272
|
-
DARWIN_DEP_LIBS = ["glog", "gflags"].freeze
|
275
|
+
DARWIN_DEP_LIBS = ["glog", "gflags", "brotlienc", "brotlidec", "brotlicommon"].freeze
|
273
276
|
# rubocop:enable Style/WordArray
|
274
277
|
end
|
275
278
|
# rubocop:enable Metrics/ModuleLength
|
data/lib/tebako/packager.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2021-
|
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
|
#
|
@@ -30,6 +30,7 @@ require "fileutils"
|
|
30
30
|
require_relative "error"
|
31
31
|
require_relative "packager/pass1"
|
32
32
|
require_relative "packager/pass2"
|
33
|
+
require_relative "packager/patch_helpers"
|
33
34
|
|
34
35
|
# Tebako - an executable packager
|
35
36
|
module Tebako
|
@@ -62,20 +63,45 @@ module Tebako
|
|
62
63
|
"TEBAKO_PASS_THROUGH" => "1"
|
63
64
|
}.freeze
|
64
65
|
|
66
|
+
# Magic version numbers used to ensure compatibility for Ruby 2.7.x, 3.0.x
|
67
|
+
# These are the minimal versions required to provide linux-gnu / linux-musl differentiantion by bundler
|
68
|
+
# Ruby 3.1+ default bubdler/rubygems versions work correctly out of the box
|
69
|
+
BUNDLER_VERSION = "2.4.22"
|
70
|
+
RUBYGEMS_VERSION = "3.4.22"
|
71
|
+
|
65
72
|
class << self
|
73
|
+
# Deploy
|
74
|
+
def deploy(src_dir, tbd, gflength)
|
75
|
+
puts "-- Running deploy script"
|
76
|
+
|
77
|
+
ruby_ver = ruby_version(tbd)
|
78
|
+
update_rubygems(tbd, "#{src_dir}/lib", ruby_ver, RUBYGEMS_VERSION)
|
79
|
+
install_gem tbd, "tebako-runtime"
|
80
|
+
install_gem tbd, "bundler", (PatchHelpers.ruby31?(ruby_ver) ? nil : BUNDLER_VERSION) if gflength.to_i != 0
|
81
|
+
end
|
82
|
+
|
83
|
+
# Deploy
|
84
|
+
def init(stash_dir, src_dir, pre_dir, bin_dir)
|
85
|
+
puts "-- Running init script"
|
86
|
+
|
87
|
+
puts " ... creating packaging environment at #{src_dir}"
|
88
|
+
PatchHelpers.recreate([src_dir, pre_dir, bin_dir])
|
89
|
+
FileUtils.cp_r "#{stash_dir}/.", src_dir
|
90
|
+
end
|
91
|
+
|
66
92
|
# Pass1
|
67
93
|
# Executed before Ruby build, patching ensures that Ruby itself is linked statically
|
68
94
|
def pass1(ostype, ruby_source_dir, mount_point, src_dir, ruby_ver)
|
69
95
|
puts "-- Running pass1 script"
|
70
96
|
|
71
|
-
recreate(src_dir)
|
97
|
+
PatchHelpers.recreate(src_dir)
|
72
98
|
do_patch(Pass1.get_patch_map(ostype, mount_point, ruby_ver), ruby_source_dir)
|
73
99
|
|
74
100
|
# Roll back pass2 patches
|
75
101
|
# Just in case we are recovering after some error
|
76
|
-
restore_and_save_files(FILES_TO_RESTORE, ruby_source_dir)
|
77
|
-
restore_and_save_files(FILES_TO_RESTORE_MUSL, ruby_source_dir) if ostype =~ /linux-musl/
|
78
|
-
restore_and_save_files(FILES_TO_RESTORE_MSYS, ruby_source_dir) if ostype =~ /msys/
|
102
|
+
PatchHelpers.restore_and_save_files(FILES_TO_RESTORE, ruby_source_dir)
|
103
|
+
PatchHelpers.restore_and_save_files(FILES_TO_RESTORE_MUSL, ruby_source_dir) if ostype =~ /linux-musl/
|
104
|
+
PatchHelpers.restore_and_save_files(FILES_TO_RESTORE_MSYS, ruby_source_dir) if ostype =~ /msys/
|
79
105
|
end
|
80
106
|
|
81
107
|
# Pass2
|
@@ -100,81 +126,54 @@ module Tebako
|
|
100
126
|
# end
|
101
127
|
|
102
128
|
puts " ... saving pristine ruby environment to #{stash_dir}"
|
103
|
-
recreate(stash_dir)
|
129
|
+
PatchHelpers.recreate(stash_dir)
|
104
130
|
FileUtils.cp_r "#{src_dir}/.", stash_dir
|
105
131
|
end
|
106
132
|
|
107
|
-
# Deploy
|
108
|
-
def deploy(stash_dir, src_dir, pre_dir, bin_dir, tbd)
|
109
|
-
puts "-- Running deploy script"
|
110
|
-
|
111
|
-
puts " ... creating packaging environment at #{src_dir}"
|
112
|
-
recreate([src_dir, pre_dir, bin_dir])
|
113
|
-
FileUtils.cp_r "#{stash_dir}/.", src_dir
|
114
|
-
|
115
|
-
install_gem tbd, "tebako-runtime"
|
116
|
-
end
|
117
|
-
|
118
133
|
private
|
119
134
|
|
120
|
-
def install_gem(tbd, name)
|
121
|
-
puts " ... installing #{name} gem"
|
122
|
-
with_env(DEPLOY_ENV) do
|
123
|
-
|
135
|
+
def install_gem(tbd, name, ver = nil)
|
136
|
+
puts " ... installing #{name} gem#{" version #{ver}" if ver}"
|
137
|
+
PatchHelpers.with_env(DEPLOY_ENV) do
|
138
|
+
params = ["#{tbd}/gem", "install", name.to_s]
|
139
|
+
params.push("-v", ver.to_s) if ver
|
140
|
+
|
141
|
+
out, st = Open3.capture2e(*params)
|
124
142
|
raise Tebako::Error, "Failed to install #{name} (#{st}):\n #{out}" unless st.exitstatus.zero?
|
125
143
|
end
|
126
144
|
end
|
127
145
|
|
128
146
|
def do_patch(patch_map, root)
|
129
|
-
patch_map.each { |fname, mapping| patch_file("#{root}/#{fname}", mapping) }
|
147
|
+
patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
|
130
148
|
end
|
131
149
|
|
132
|
-
def
|
133
|
-
|
150
|
+
def ruby_version(tbd)
|
151
|
+
ruby_version = nil
|
152
|
+
PatchHelpers.with_env(DEPLOY_ENV) do
|
153
|
+
out, st = Open3.capture2e("#{tbd}/ruby", "--version")
|
154
|
+
raise Tebako::Error, "Failed to run ruby --version" unless st.exitstatus.zero?
|
134
155
|
|
135
|
-
|
136
|
-
|
137
|
-
contents = File.read(fname)
|
138
|
-
mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
|
139
|
-
File.open(fname, "w") { |file| file << contents }
|
140
|
-
end
|
141
|
-
|
142
|
-
def recreate(dirname)
|
143
|
-
FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
|
144
|
-
FileUtils.mkdir(dirname)
|
145
|
-
end
|
146
|
-
|
147
|
-
def restore_and_save(fname)
|
148
|
-
raise Tebako::Error, "Could not save #{fname} because it does not exist." unless File.exist?(fname)
|
156
|
+
match = out.match(/ruby (\d+\.\d+\.\d+)/)
|
157
|
+
raise Tebako::Error, "Failed to parse Ruby version from #{out}" unless match
|
149
158
|
|
150
|
-
|
151
|
-
if File.exist?(old_fname)
|
152
|
-
FileUtils.rm_f(fname)
|
153
|
-
File.rename(old_fname, fname)
|
159
|
+
ruby_version = match[1]
|
154
160
|
end
|
155
|
-
|
161
|
+
ruby_version
|
156
162
|
end
|
157
163
|
|
158
|
-
def
|
159
|
-
|
160
|
-
restore_and_save "#{ruby_source_dir}/#{fname}"
|
161
|
-
end
|
162
|
-
end
|
164
|
+
def update_rubygems(tbd, tld, ruby_ver, gem_ver)
|
165
|
+
return if PatchHelpers.ruby31?(ruby_ver)
|
163
166
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
old = {}
|
169
|
-
hash.each do |k, v|
|
170
|
-
old[k] = ENV.fetch(k, nil)
|
171
|
-
ENV[k] = v
|
172
|
-
end
|
173
|
-
begin
|
174
|
-
yield
|
175
|
-
ensure
|
176
|
-
hash.each { |k, _v| ENV[k] = old[k] }
|
167
|
+
puts " ... updating rubygems to #{gem_ver}"
|
168
|
+
PatchHelpers.with_env(DEPLOY_ENV) do
|
169
|
+
out, st = Open3.capture2e("#{tbd}/gem", "update", "--no-doc", "--system", gem_ver.to_s)
|
170
|
+
raise Tebako::Error, "Failed to update rubugems to #{gem_ver} (#{st}):\n #{out}" unless st.exitstatus.zero?
|
177
171
|
end
|
172
|
+
ruby_api_ver = ruby_ver.split(".")[0..1].join(".")
|
173
|
+
# Autoload cannot handle statically linked openssl extension
|
174
|
+
# Changing it to require seems to be the simplest solution
|
175
|
+
PatchHelpers.patch_file("#{tld}/ruby/site_ruby/#{ruby_api_ver}.0/rubygems/openssl.rb",
|
176
|
+
{ "autoload :OpenSSL, \"openssl\"" => "require \"openssl\"" })
|
178
177
|
end
|
179
178
|
end
|
180
179
|
end
|
data/lib/tebako/version.rb
CHANGED
data/resources/tebako-fs.cpp.in
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
*
|
3
|
-
* Copyright (c) 2021-
|
3
|
+
* Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
|
4
4
|
* All rights reserved.
|
5
5
|
* This file is a part of tebako
|
6
6
|
*
|
@@ -34,4 +34,4 @@ namespace tebako {
|
|
34
34
|
const char * fs_mount_point = "@FS_MOUNT_POINT@";
|
35
35
|
const char * fs_entry_point = "@FS_ENTRY_POINT@";
|
36
36
|
INCBIN(fs, "@DATA_BIN_FILE@");
|
37
|
-
}
|
37
|
+
}
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.6
|
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.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.5.3
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Packager for Ruby executables
|