tebako 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22aea474f49445f022530cf4cc3c16c2bce29da88bb1c3bc0c4d0a64838676a8
4
- data.tar.gz: 3f3efc915bcde108bdd14b6f21946cf6c2e20edc7d48e2703db54f9ea9ed5dfb
3
+ metadata.gz: 23a76520703c1526cb92a3aaeac6c215a117b5dd6f27f18b286c7dc165d95b98
4
+ data.tar.gz: 2078da7a9009225a1d50435dac76b75579068f8683e4f0d5c6f1c80f501a98f8
5
5
  SHA512:
6
- metadata.gz: 78be29f984b8505a537327970820f91151411dde2fd0bbb6d760741cd373e61324d1b225ca2e1792f22f53b32a52ad0b3bcfa8c23ec7ede3df221c6435d8cb45
7
- data.tar.gz: 13f0505477b14079016a48c83f44da433dcabf1858ea99ae2e8ab3892d7231493d5d46f02defdf57908ad5b652c6b8713d5ef0129b25ae979798bc549e3442f7
6
+ metadata.gz: f1102354529402a3ac5d30830d602f203d0c89ded810e44d4caeabd407ccda5a7b72bda9a03c15732cf451a5716d9875c6d51ae8dfb669af15d4a0c9f1ae255a
7
+ data.tar.gz: ff70d7dfbe6ce10b6689ed97860b87909e18e4a29c44c2d7a0cc1895667121010810b1aa702d2ec6869e844e214ad2be17b66ee67dd58f2fbe8254b984a8fc63
data/CMakeLists.txt CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2021-2023 [Ribose Inc](https://www.ribose.com).
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
  #
@@ -245,14 +245,6 @@ endif(IS_MSYS)
245
245
  def_ext_prj_g(INCBIN "348e36b")
246
246
  def_ext_prj_g(DWARFS_WR "v0.4.0")
247
247
 
248
- if (DEFINED ENV{BUNDLER_VER})
249
- set(BUNDLER_VER $ENV{BUNDLER_VER})
250
- set(BUNDLER_ANNOTATION "environment")
251
- else()
252
- set(BUNDLER_VER "2.3.22")
253
- set(BUNDLER_ANNOTATION "default")
254
- endif()
255
-
256
248
  find_library(_LIBNCURSES "libncurses.a")
257
249
  if(${_LIBNCURSES} STREQUAL "_LIBNCURSES-NOTFOUND")
258
250
  set(WITH_NCURSES_BUILD ON)
@@ -268,7 +260,6 @@ endif(${RUBY_VER} VERSION_LESS "3.2.0")
268
260
 
269
261
  message("Configuration summary:")
270
262
  message(STATUS "ruby: v${RUBY_VER} at ${RUBY_SOURCE_DIR}")
271
- message(STATUS "bundler version: ${BUNDLER_VER} (${BUNDLER_ANNOTATION})")
272
263
  if(WITH_OPENSSL_BUILD)
273
264
  message(STATUS "openssl: building @${OPENSSL_TAG} at ${OPENSSL_SOURCE_DIR}")
274
265
  endif(WITH_OPENSSL_BUILD)
@@ -511,7 +502,7 @@ else (${SETUP_MODE})
511
502
  list(LENGTH GEMS GLENGTH)
512
503
 
513
504
  add_custom_target(clean_filesystem
514
- COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${TBD} ${TGD}
505
+ COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${GFLENGTH}
515
506
  DEPENDS ${RUBY_PRJ}
516
507
  )
517
508
  if(GSLENGTH GREATER 0)
@@ -527,8 +518,6 @@ else (${SETUP_MODE})
527
518
  add_custom_target(source_filesystem
528
519
  COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${DATA_PRE_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
529
520
  COMMAND ${CMAKE_COMMAND} -E make_directory ${TGD}
530
- COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
531
- ${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}' --source 'https://rubygems.org/' --no-document --install-dir ${TGD}
532
521
  COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
533
522
  ${TBD}/bundle${CMD_SUFFIX} config set --local force_ruby_platform ${FORCE_RUBY_PLATFORM}
534
523
  COMMAND ${CMAKE_COMMAND} -E chdir ${DATA_PRE_DIR} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
@@ -572,9 +561,6 @@ else (${SETUP_MODE})
572
561
  ${CMAKE_COMMAND} -E false )
573
562
  COMMAND ${CMAKE_COMMAND} -E make_directory ${TLD}
574
563
  COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${FS_ROOT} -DTARGET_DIR=${TLD} -P ${CMAKE_SOURCE_DIR}/cmake/copy_dir.cmake
575
- COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
576
- ${TBD}/gem${CMD_SUFFIX} install bundler -v '${BUNDLER_VER}'
577
- --source 'https://rubygems.org/' --no-document --install-dir ${TGD}
578
564
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
579
565
  ${TBD}/bundle${CMD_SUFFIX} config build.ffi --disable-system-libffi
580
566
  COMMAND ${CMAKE_COMMAND} -E chdir ${TLD} ${CMAKE_COMMAND} -E env --unset=GEM_HOME --unset=GEM_PATH TEBAKO_PASS_THROUGH=1
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.16
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.7
44
+ * 2.7.8
45
45
  * 3.0.6
46
46
  * 3.1.4
47
- * 3.2.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++ 9+ or Clang C/C++ 11+
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-9 g++-9
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.7|3.0.6|3.1.4|3.2.2>] \
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.0.6)
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.7|3.0.6|3.1.4|3.2.2>]
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.7|3.0.6|3.1.4|3.2.2>]
260
+ [-R|--Ruby=<2.7.8|3.0.6|3.1.4|3.2.3>]
261
261
  ----
262
262
 
263
263
  Where:
data/common.env CHANGED
@@ -2,5 +2,4 @@ BUILD_TYPE=Release
2
2
  DEPS=deps
3
3
  INCBIN_TAG=348e36b
4
4
  DWARFS_WR_TAG=v0.4.0
5
- BUNDLER_VER=2.3.22
6
5
  RUBY_VER=3.1.4
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] -- TARGET_BIN_DIR (TBD)
82
- # ARGV[6] -- TARGET_GEM_DIR (TGD)
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 7 arguments, #{ARGV.length} has been provided."
84
+ "tebako-packager deploy command expects 6 arguments, #{ARGV.length} has been provided."
86
85
  end
87
- Tebako::Packager.deploy(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5])
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
@@ -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
  #
@@ -59,10 +59,11 @@ module Tebako
59
59
  end
60
60
 
61
61
  RUBY_VERSIONS = {
62
- "2.7.7" => "e10127db691d7ff36402cfe88f418c8d025a3f1eea92044b162dd72f0b8c7b90",
62
+ "2.7.8" => "c2dab63cbc8f2a05526108ad419efa63a67ed4074dbbcf9fc2b1ca664cb45ba0",
63
63
  "3.0.6" => "6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e",
64
64
  "3.1.4" => "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6",
65
- "3.2.2" => "96c57558871a6748de5bc9f274e93f4b5aad06cd8f37befa0e8d94e7b8a423bc"
65
+ "3.2.3" => "af7f1757d9ddb630345988139211f1fd570ff5ba830def1cc7c468ae9b65c9ba",
66
+ "3.3.0" => "96518814d9832bece92a85415a819d4893b307db5921ae1f0f751a9a89a56b7d"
66
67
  }.freeze
67
68
 
68
69
  DEFAULT_RUBY_VERSION = "3.1.4"
@@ -130,6 +131,7 @@ module Tebako
130
131
 
131
132
  def prefix
132
133
  @prefix ||= if options["prefix"].nil?
134
+ puts "No prefix specified, using ~/.tebako"
133
135
  File.expand_path("~/.tebako")
134
136
  elsif options["prefix"] == "PWD"
135
137
  Dir.pwd
@@ -140,7 +140,7 @@ module Tebako
140
140
  # rubocop:enable Metrics/MethodLength
141
141
 
142
142
  def mlibs_subst(ostype, deps_lib_dir, ruby_ver)
143
- yjit_libs = PatchHelpers.ruby32?(ruby_ver) ? "$(YJIT_LIBS) " : ""
143
+ yjit_libs = PatchHelpers.ruby32only?(ruby_ver) ? "$(YJIT_LIBS) " : ""
144
144
  {
145
145
  "MAINLIBS = #{yjit_libs}@MAINLIBS@" =>
146
146
  "# -- Start of tebako patch -- \n" \
@@ -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,6 +34,16 @@ module Tebako
34
34
  # Ruby patching helpers (pass2)
35
35
  module PatchHelpers
36
36
  class << self
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
+
37
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?
@@ -51,6 +61,28 @@ module Tebako
51
61
  out
52
62
  end
53
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
+
54
86
  def ruby3x?(ruby_ver)
55
87
  ruby_ver[0] == "3"
56
88
  end
@@ -63,6 +95,30 @@ module Tebako
63
95
  ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
64
96
  end
65
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
+
66
122
  def yaml_reference(ruby_ver)
67
123
  ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
68
124
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2021-2023 [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
  #
@@ -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
- out, st = Open3.capture2e("#{tbd}/gem", "install", name.to_s, "--no-doc")
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 patch_file(fname, mapping)
133
- raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
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
- puts " ... patching #{fname}"
136
- restore_and_save(fname)
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
- old_fname = "#{fname}.old"
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
- FileUtils.cp(fname, old_fname)
161
+ ruby_version
156
162
  end
157
163
 
158
- def restore_and_save_files(files, ruby_source_dir)
159
- files.each do |fname|
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
- # Sets up temporary environment variables and yields to the
165
- # block. When the block exits, the environment variables are set
166
- # back to their original values.
167
- def with_env(hash)
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
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.5.5"
29
+ VERSION = "0.5.6"
30
30
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.5.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.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: 2023-10-22 00:00:00.000000000 Z
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.4.10
127
+ rubygems_version: 3.5.3
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Packager for Ruby executables