tebako 0.12.6 → 0.12.7

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: efd5e24ab291f702599ee180136e5a8d63a38a7a82211d7249f3d239bddd8d8e
4
- data.tar.gz: '049f52115bd0dd9097d7ef2eac3a2ba3794a15be60ecca8ab27f8996fee44515'
3
+ metadata.gz: c5b1ebb29eeb477173ec41d8380aa728bbc79d3d2bc44a84e9c3f6b1090ca751
4
+ data.tar.gz: 8fa4fc2ad1e8de867d4a4929ed97c97cd69ad7b1ee1027b6b21e581d1e100bd2
5
5
  SHA512:
6
- metadata.gz: a51153f34c63de0cc636f3cb6322ad0b4f855f7aec76a5226f8163fad79b6250d54612cb65ce00654d3c8051445181007c89b3c2c4fa1de1c039a92ba3a3541d
7
- data.tar.gz: 3e3dd8c766b8d56db8cb6f93ddf2a9092a89de3ab1c3ccfbab57f6cbe920d9875d02bc1b45ff0282152f0ca2b49b996accb9200185bab8b96bf0ae3ce20576ab
6
+ metadata.gz: f9c1188f49ef1e8931b88e6e92fa80f363a24ee169d3b21f7be6f2fcb545913f0ccd5015304259f1da6b43af19a35c3b00e8b28da6758d1806130ef2da63964b
7
+ data.tar.gz: c7978b7655bd25d36f2d49231d7be1106a3e6a35b5e611d075d910252b2d1d0bb44fb23255471c8a52838581a50833e3c26887d676857d1d7028be4ed58d6cd0
data/CMakeLists.txt CHANGED
@@ -229,7 +229,7 @@ message(STATUS "DATA_BIN_FILE: ${DATA_BIN_FILE}")
229
229
  message(STATUS "Target binary directory: ${TBD}")
230
230
  message(STATUS "Target library directory: ${TLIBD}")
231
231
  message(STATUS "Target local directory: ${TLD}")
232
- message(STATUS "Target Gem directory:: ${TGD}")
232
+ message(STATUS "Target Gem directory: ${TGD}")
233
233
  message(STATUS "FS_MOUNT_POINT: ${FS_MOUNT_POINT}")
234
234
  message(STATUS "Building for Win32 Ruby (RB_W32): ${RB_W32}")
235
235
  message(STATUS "Removing GLIBC_PRIVATE reference: ${WITH_PATCHELF}")
data/README.adoc CHANGED
@@ -90,7 +90,7 @@ can opt to run `strip -S` manually, it most cases it works.
90
90
 
91
91
  MacOS build caveats:
92
92
 
93
- * We saw `clang` compiler segmentation fault when during packaging of very large
93
+ * We saw `clang` compiler segmentation fault when packaging of very large
94
94
  projects with XCode 14.3.1. This issue is not reproducible with XCode 15.0.1 or
95
95
  higher.
96
96
  ====
@@ -905,7 +905,8 @@ Where:
905
905
 
906
906
  `<tebako-root-folder>`:: the Tebako root folder (see details: <<root-folder-selection>>)
907
907
 
908
- `Ruby`:: parameter defines Ruby version that will be packaged (optional, defaults to `3.2.6`)
908
+ `Ruby`:: parameter defines package Ruby version (optional). This version is used in conjuction with requirements
909
+ from the Gemfile as explained below in 'Package Ruby version selection rules' section.
909
910
 
910
911
  `tebafile`::
911
912
  the tebako configuration file (optional, defaults to `$PWD/.tebako.yml`).
@@ -1056,13 +1057,37 @@ operation. The following table lists the possible exit codes and their meanings.
1056
1057
 
1057
1058
  | 0 | No error
1058
1059
  | 1 | Invalid command line
1059
- | 101 | `tebako setup` failed at configuration step
1060
- | 102 | `tebako setup` failed at build step
1061
- | 103 | `tebako press` failed at configuration step
1062
- | 104 | `tebako press` failed at build step
1063
- | 253 | Unsupported Ruby version
1064
- | 254 | Unsupported operating systems
1065
- | 255 | Internal error
1060
+ | 101 | 'tebako setup' configure step failed
1061
+ | 102 | 'tebako setup' build step failed
1062
+ | 103 | 'tebako press' configure step failed
1063
+ | 104 | 'tebako press' build step failed
1064
+ | 105 | Failed to map MSys path to Windows
1065
+ | 106 | Entry point does not exist or is not accessible
1066
+ | 107 | Project root does not exist or is not accessible
1067
+ | 108 | Package working directory does not exist
1068
+ | 109 | Invalid Ruby version format
1069
+ | 110 | Ruby version is not supported
1070
+ | 111 | Ruby version is not supported on Windows
1071
+ | 112 | OS is not supported
1072
+ | 113 | Path to root shall be absolute. Relative path is not allowed
1073
+ | 114 | Entry point is not within the project root
1074
+ | 115 | Failed to load Gemfile
1075
+ | 116 | Ruby version does not satify Gemfile requirements
1076
+ |===
1077
+
1078
+ == Package Ruby version selection rules
1079
+
1080
+ During packaging tebako creates its own Ruby execution environment that is independent from the host Ruby environment.
1081
+ The version of Ruby that is used in the package is defined by the combination of the `--Ruby` option and ruby requirement
1082
+ specified in Gemfile.
1083
+
1084
+ .Package Ruby version selection Rules
1085
+ [cols="3", options="header"]
1086
+ |===
1087
+ | Gemfile requirement\--Ruby option | Specified | Not specified
1088
+
1089
+ | Specified | The version specified by --Ruby option if it is supported and satisfies Gemfile requirement; error otherwise | The minimal supported Ruby option that satisfies Gemfile requirement; error otherwise
1090
+ | Not specified | The version specified by --Ruby option if it is supported; error otherwise | Default Tebako Ruby version (3.2.6).
1066
1091
 
1067
1092
  |===
1068
1093
 
@@ -48,12 +48,18 @@ module Tebako
48
48
  * WARNING: You are packaging in-place, i.e.: tebako package will be placed inside application root. *
49
49
  * It is not an error but we do not recommend it because it is a way to keep packaging old versions recrsively. *
50
50
  * *
51
+ * For example, ensure that `--root=` differs from `--output=` as described in README.adoc: *
52
+ * tebako press --root='~/projects/myproject' --entry=start.rb --output=/temp/myproject.tebako *
53
+ * *
51
54
  ******************************************************************************************************************
52
55
 
53
56
  WARN
54
57
 
55
58
  def do_press(options_manager)
56
59
  scenario_manager = Tebako::ScenarioManager.new(options_manager.root, options_manager.fs_entrance)
60
+ scenario_manager.configure_scenario
61
+ options_manager.process_gemfile(scenario_manager.gemfile_path) if scenario_manager.with_gemfile
62
+
57
63
  puts options_manager.press_announce(scenario_manager.msys?)
58
64
 
59
65
  if options_manager.package_within_root?
@@ -91,7 +97,6 @@ module Tebako
91
97
 
92
98
  def generate_files(options_manager, scenario_manager)
93
99
  puts "-- Generating files"
94
- scenario_manager.configure_scenario
95
100
 
96
101
  v_parts = Tebako::VERSION.split(".")
97
102
  Tebako::Codegen.generate_tebako_version_h(options_manager, v_parts)
@@ -100,7 +100,7 @@ module Tebako
100
100
  end
101
101
 
102
102
  def needs_bundler?
103
- @gf_length.positive? && !@ruby_ver.ruby31?
103
+ @with_gemfile && !@ruby_ver.ruby31?
104
104
  end
105
105
 
106
106
  def update_rubygems
data/lib/tebako/error.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2023-204 [Ribose Inc](https://www.ribose.com).
3
+ # Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
5
  # This file is a part of tebako
6
6
  #
@@ -42,12 +42,15 @@ module Tebako
42
42
  112 => "OS is not supported",
43
43
  113 => "Path to root shall be absolute. Relative path is not allowed",
44
44
  114 => "Entry point is not within the project root",
45
+ 115 => "Failed to load Gemfile",
46
+ 116 => "Ruby version does not satify Gemfile requirements",
45
47
  201 => "Warning. Could not create cache version file"
46
48
  }.freeze
47
49
 
48
50
  class << self
49
- def packaging_error(code)
51
+ def packaging_error(code, extm = nil)
50
52
  msg = PACKAGING_ERRORS[code]
53
+ msg += ": #{extm}" unless extm.nil?
51
54
  msg = "Unknown packaging error" if msg.nil?
52
55
  raise Tebako::Error.new msg, code
53
56
  end
@@ -282,6 +282,19 @@ module Tebako
282
282
  @press_options ||= "-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{l_level}' " \
283
283
  end
284
284
 
285
+ def process_gemfile(gemfile_path)
286
+ folder = File.dirname(gemfile_path)
287
+ filename = File.basename(gemfile_path)
288
+ # Change directory to the folder containing the Gemfile
289
+ # Because Bundler::Definition.build *sometimes* requires to be in
290
+ # the Gemfile directory
291
+ Dir.chdir(folder) do
292
+ @rv = Tebako::RubyVersionWithGemfile.new(@options["Ruby"], filename)
293
+ end
294
+ @ruby_ver, @ruby_hash = @rv.extend_ruby_version
295
+ @ruby_src_dir = nil
296
+ end
297
+
285
298
  def relative?(path)
286
299
  Pathname.new(path).relative?
287
300
  end
@@ -25,11 +25,12 @@
25
25
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
+ require "bundler"
28
29
  require_relative "error"
29
30
 
30
31
  # Tebako - an executable packager
31
32
  module Tebako
32
- # Ruby version checks
33
+ # Ruby version
33
34
  class RubyVersion
34
35
  RUBY_VERSIONS = {
35
36
  "2.7.8" => "c2dab63cbc8f2a05526108ad419efa63a67ed4074dbbcf9fc2b1ca664cb45ba0",
@@ -51,13 +52,23 @@ module Tebako
51
52
  def initialize(ruby_version)
52
53
  @ruby_version = ruby_version.nil? ? DEFAULT_RUBY_VERSION : ruby_version
53
54
 
54
- version_check_format
55
- version_check
56
- version_check_msys
55
+ run_checks
57
56
  end
58
57
 
59
58
  attr_reader :ruby_version
60
59
 
60
+ def api_version
61
+ @api_version ||= "#{@ruby_version.split(".")[0..1].join(".")}.0"
62
+ end
63
+
64
+ def extend_ruby_version
65
+ @extend_ruby_version ||= [@ruby_version, RUBY_VERSIONS[@ruby_version]]
66
+ end
67
+
68
+ def lib_version
69
+ @lib_version ||= "#{@ruby_version.split(".")[0..1].join}0"
70
+ end
71
+
61
72
  def ruby3x?
62
73
  @ruby3x ||= @ruby_version[0] == "3"
63
74
  end
@@ -82,12 +93,10 @@ module Tebako
82
93
  @ruby34 ||= ruby3x? && @ruby_version[2].to_i >= 4
83
94
  end
84
95
 
85
- def api_version
86
- @api_version ||= "#{@ruby_version.split(".")[0..1].join(".")}.0"
87
- end
88
-
89
- def lib_version
90
- @lib_version ||= "#{@ruby_version.split(".")[0..1].join}0"
96
+ def run_checks
97
+ version_check_format
98
+ version_check
99
+ version_check_msys
91
100
  end
92
101
 
93
102
  def version_check
@@ -111,9 +120,56 @@ module Tebako
111
120
  raise Tebako::Error.new("Ruby version #{@ruby_version} is not supported on Windows", 111)
112
121
  end
113
122
  end
123
+ end
114
124
 
115
- def extend_ruby_version
116
- @extend_ruby_version ||= [@ruby_version, RUBY_VERSIONS[@ruby_version]]
125
+ # Ruby version with Gemfile definition
126
+ class RubyVersionWithGemfile < RubyVersion
127
+ def initialize(ruby_version, gemfile_path)
128
+ # Assuming that it does not attempt to load any gems or resolve dependencies
129
+ # this can be done with any bundler version
130
+ gemfile = Bundler::Definition.build(gemfile_path, nil, nil)
131
+ ruby_v = gemfile.ruby_version&.versions
132
+ if ruby_v.nil?
133
+ super(ruby_version)
134
+ else
135
+ process_gemfile_ruby_version(ruby_version, ruby_v)
136
+ run_checks
137
+ end
138
+ rescue StandardError => e
139
+ Tebako.packaging_error(115, e.message)
140
+ end
141
+
142
+ def process_gemfile_ruby_version(ruby_version, ruby_v)
143
+ puts "-- Found Gemfile with Ruby requirements #{ruby_v}"
144
+ requirement = Gem::Requirement.new(ruby_v)
145
+
146
+ if ruby_version.nil?
147
+ process_gemfile_ruby_version_ud(requirement)
148
+ else
149
+ process_gemfile_ruby_version_d(ruby_version, requirement)
150
+ end
151
+ end
152
+
153
+ def process_gemfile_ruby_version_d(ruby_version, requirement)
154
+ current_version = Gem::Version.new(ruby_version)
155
+ unless requirement.satisfied_by?(current_version)
156
+ raise Tebako::Error.new("Ruby version #{ruby_version} does not satisfy requirement #{ruby_v}", 116)
157
+ end
158
+
159
+ @ruby_version = ruby_version
160
+ end
161
+
162
+ def process_gemfile_ruby_version_ud(requirement)
163
+ available_versions = RUBY_VERSIONS.keys.map { |v| Gem::Version.new(v) }
164
+ matching_version = available_versions.find { |v| requirement.satisfied_by?(v) }
165
+ puts "-- Found matching Ruby version #{matching_version}" if matching_version
166
+
167
+ unless matching_version
168
+ raise Tebako::Error.new("No available Ruby version satisfies requirement #{requirement}",
169
+ 116)
170
+ end
171
+
172
+ @ruby_version = matching_version.to_s
117
173
  end
118
174
  end
119
175
  end
@@ -26,6 +26,7 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  require "pathname"
29
+ require "bundler"
29
30
 
30
31
  require_relative "error"
31
32
 
@@ -34,11 +35,12 @@ module Tebako
34
35
  # Manages packaging scenario based on input files (gemfile, gemspec, etc)
35
36
  class ScenarioManager
36
37
  def initialize(fs_root, fs_entrance)
38
+ @with_gemfile = false
37
39
  initialize_root(fs_root)
38
40
  initialize_entry_point(fs_entrance || "stub.rb")
39
41
  end
40
42
 
41
- attr_reader :fs_entry_point, :fs_mount_point, :fs_entrance
43
+ attr_reader :fs_entry_point, :fs_mount_point, :fs_entrance, :gemfile_path, :with_gemfile
42
44
 
43
45
  def configure_scenario
44
46
  @fs_mount_point = if msys?
@@ -92,16 +94,16 @@ module Tebako
92
94
  when 0
93
95
  configure_scenario_no_gemspec
94
96
  when 1
95
- @scenario = @gf_length.positive? ? :gemspec_and_gemfile : :gemspec
97
+ @scenario = @with_gemfile ? :gemspec_and_gemfile : :gemspec
96
98
  else
97
99
  raise Tebako::Error, "Multiple Ruby gemspecs found in #{@fs_root}"
98
100
  end
99
101
  end
100
102
 
101
103
  def configure_scenario_no_gemspec
102
- @fs_entry_point = "/local/#{@fs_entrance}" if @gf_length.positive? || @g_length.zero?
104
+ @fs_entry_point = "/local/#{@fs_entrance}" if @with_gemfile || @g_length.zero?
103
105
 
104
- @scenario = if @gf_length.positive?
106
+ @scenario = if @with_gemfile
105
107
  :gemfile
106
108
  elsif @g_length.positive?
107
109
  :gem
@@ -111,8 +113,9 @@ module Tebako
111
113
  end
112
114
 
113
115
  def lookup_files
116
+ @gemfile_path = File.join(@fs_root, "Gemfile")
114
117
  @gs_length = Dir.glob(File.join(@fs_root, "*.gemspec")).length
115
- @gf_length = Dir.glob(File.join(@fs_root, "Gemfile")).length
118
+ @with_gemfile = File.exist?(@gemfile_path)
116
119
  @g_length = Dir.glob(File.join(@fs_root, "*.gem")).length
117
120
  end
118
121
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.12.6"
29
+ VERSION = "0.12.7"
30
30
  end
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.12.6
4
+ version: 0.12.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-20 00:00:00.000000000 Z
11
+ date: 2025-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor