tebako 0.7.1 → 0.7.2.rc1

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: edab24288967cc4085b927ef069adab649b24282a6cc320a595bc2b20cb636e9
4
- data.tar.gz: 7964a2bcf62cf28d4cd34ee1f1744afe21980e934a4fa1a649f0b854b15b1ca3
3
+ metadata.gz: 9814ddc341bfd35eda55c9622169d70a833f244925ca8f5e49e401e0dd73f930
4
+ data.tar.gz: 2df44f4d1a0c899d6d432f33ec69b5abf6642c0d83621382eb8eb9aec0a08b80
5
5
  SHA512:
6
- metadata.gz: 1a77dc3a2c810aad7597cab4a3d5a8f3c6378d2f9313e129edf17097700a0210eb9008b73bb5402921af53e5cccf450602865b4cc1518e5f8a2fd0e34e15163c
7
- data.tar.gz: 40b417b5bb8e13e40618015d04f5f3c085bc08325d798bba5fb1cf6c43c0e44daef392755473f2110cb21c95134dcee24c6559933226eee0f41a5f9fc074d602
6
+ metadata.gz: 1952f88ddc52932de24a43ff8899296021cd91494bdbc45ed9617401fef8a16d25523c45fb8bd9e92c8cba89bb83e528f47111884ecb8e3ab9b9ebb9cb01c4f8
7
+ data.tar.gz: 1acfc8e2974572083e5d12aa436da559a2c2190fb4598c8190ac7829332d5b1d51af8c652ffb5ef499ae0fbca181bb508ab90c8ece1ae89b5631bd354ec8a495
data/Rakefile CHANGED
@@ -35,8 +35,9 @@ task default: %i[rubocop]
35
35
  desc "Generate version.txt"
36
36
  task "generate_version_txt" do
37
37
  require_relative "lib/tebako/version"
38
- File.write(File.join(__dir__, "version.txt"), "#{Tebako::VERSION}\n")
39
- puts "Generating #{File.join(__dir__, "version.txt")}; version = #{Tebako::VERSION}"
38
+ version_without_rc = Tebako::VERSION.gsub(/\.rc\d+/, "")
39
+ File.write(File.join(__dir__, "version.txt"), "#{version_without_rc}\n")
40
+ puts "Generating #{File.join(__dir__, "version.txt")}; version = #{version_without_rc}"
40
41
  end
41
42
 
42
43
  task build: :generate_version_txt
data/exe/tebako-packager CHANGED
@@ -110,7 +110,7 @@ begin
110
110
  Tebako::Packager.create_implib(ARGV[2], ARGV[4], File.basename(ARGV[8]), ARGV[9]) if ARGV[1] =~ /msys/
111
111
  # Assume that "<TARGET_BIN_DIR (TBD)>" is <DATA_SRC_DIR>/bin"
112
112
  # That shall match CMakeLists.txt settings
113
- Tebako::Packager.deploy(ARGV[4], "#{ARGV[4]}/bin", ARGV[7])
113
+ Tebako::Packager.deploy(ARGV[4], ARGV[9], ARGV[7])
114
114
 
115
115
  else
116
116
  raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
data/lib/tebako/cli.rb CHANGED
@@ -35,6 +35,7 @@ require "yaml"
35
35
  require_relative "cli_helpers"
36
36
  require_relative "cli_rubies"
37
37
  require_relative "error"
38
+ require_relative "version"
38
39
 
39
40
  # Tebako - an executable packager
40
41
  # Implementation of tebako command-line interface
@@ -45,12 +46,12 @@ module Tebako
45
46
  package_name "Tebako"
46
47
  class_option :prefix, type: :string, aliases: "-p", required: false,
47
48
  desc: "A path to tebako packaging environment, '~/.tebako' ('$HOME/.tebako') by default"
49
+ class_option :devmode, type: :boolean, aliases: "-D", required: false,
50
+ desc: "Developer mode, please do not use if unsure"
48
51
 
49
52
  desc "clean", "Clean tebako packaging environment"
50
53
  def clean
51
- puts "Cleaning tebako packaging environment"
52
- # Using File.join(deps, "") to ensure that the slashes are appropriate
53
- FileUtils.rm_rf([File.join(deps, ""), File.join(output, "")], secure: true)
54
+ clean_cache
54
55
  end
55
56
 
56
57
  desc "clean_ruby", "Clean Ruby source from tebako packaging environment"
@@ -68,7 +69,7 @@ module Tebako
68
69
 
69
70
  desc "hash", "Print build script hash (ci cache key)"
70
71
  def hash
71
- print Digest::SHA256.hexdigest File.read File.join(__dir__, "../..", "CMakeLists.txt")
72
+ print Digest::SHA256.hexdigest File.read File.join(source, "CMakeLists.txt")
72
73
  end
73
74
 
74
75
  desc "press", "Press tebako image"
@@ -83,8 +84,11 @@ module Tebako
83
84
  enum: Tebako::CliRubies::RUBY_VERSIONS.keys,
84
85
  desc: "Tebako package Ruby version, #{Tebako::CliRubies::DEFAULT_RUBY_VERSION} by default"
85
86
  def press
87
+ (clean_output unless version_match?) unless options[:devmode]
88
+
86
89
  puts press_announce
87
90
  do_press
91
+ ensure_version_file
88
92
  rescue Tebako::Error => e
89
93
  puts "Tebako script failed: #{e.message} [#{e.error_code}]"
90
94
  exit e.error_code
@@ -95,8 +99,11 @@ module Tebako
95
99
  enum: Tebako::CliRubies::RUBY_VERSIONS.keys,
96
100
  desc: "Tebako package Ruby version, #{Tebako::CliRubies::DEFAULT_RUBY_VERSION} by default."
97
101
  def setup
102
+ (clean_output unless version_match?) unless options[:devmode]
103
+
98
104
  puts "Setting up tebako packaging environment"
99
105
  do_setup
106
+ ensure_version_file
100
107
  rescue Tebako::Error => e
101
108
  puts "Tebako script failed: #{e.message} [#{e.error_code}]"
102
109
  exit e.error_code
@@ -107,6 +114,13 @@ module Tebako
107
114
  end
108
115
 
109
116
  no_commands do
117
+ def initialize(*args)
118
+ super
119
+ return if args[2][:current_command].name.include?("hash")
120
+
121
+ puts "Tebako executable packager version #{Tebako::VERSION}"
122
+ end
123
+
110
124
  def options
111
125
  original_options = super
112
126
 
@@ -37,6 +37,7 @@ require_relative "version"
37
37
  # Tebako - an executable packager
38
38
  # Command-line interface methods
39
39
  module Tebako
40
+ E_VERSION_FILE = ".environment.version"
40
41
  # Cli helpers
41
42
  module CliHelpers
42
43
  def b_env
@@ -57,10 +58,33 @@ module Tebako
57
58
  "-DDEPS:STRING=\"#{deps}\" -G \"#{m_files}\" -B \"#{output}\" -S \"#{source}\""
58
59
  end
59
60
 
61
+ def clean_cache
62
+ puts "Cleaning tebako packaging environment"
63
+ # Using File.join(deps, "") to ensure that the slashes are appropriate
64
+ FileUtils.rm_rf([File.join(deps, ""), File.join(output, "")], secure: true)
65
+ end
66
+
67
+ def clean_output
68
+ puts "Cleaning CMake cache"
69
+ # Using File.join(output, "") to ensure that the slashes are appropriate
70
+ FileUtils.rm_rf(File.join(output, ""), secure: true)
71
+ end
72
+
60
73
  def deps
61
74
  @deps ||= File.join(prefix, "deps")
62
75
  end
63
76
 
77
+ def ensure_version_file
78
+ version_file_path = File.join(prefix, E_VERSION_FILE)
79
+
80
+ begin
81
+ File.write(version_file_path, version_key)
82
+ # puts "Set version information for tebako packaging environment to #{Tebako::VERSION}"
83
+ rescue StandardError => e
84
+ puts "An error occurred while creating or updating #{E_VERSION_FILE}: #{e.message}"
85
+ end
86
+ end
87
+
64
88
  def fs_current
65
89
  fs_current = Dir.pwd
66
90
  if RUBY_PLATFORM =~ /msys|mingw|cygwin/
@@ -169,5 +193,25 @@ module Tebako
169
193
  c_path = Pathname.new(__FILE__).realpath
170
194
  @source ||= File.expand_path("../../..", c_path)
171
195
  end
196
+
197
+ def version_key
198
+ @version_key ||= "#{Tebako::VERSION} at #{source}"
199
+ end
200
+
201
+ def version_match? # rubocop:disable Metrics/MethodLength
202
+ begin
203
+ version_file_path = File.join(prefix, E_VERSION_FILE)
204
+ file_version = File.open(version_file_path, &:readline).strip
205
+ rs = file_version == version_key
206
+ unless rs
207
+ puts "CMake cache was created by a gem version #{file_version} " \
208
+ "and cannot be used for gem version #{version_key}"
209
+ end
210
+ rescue StandardError
211
+ # In case of any error (e.g., file not readable), return false
212
+ rs = false
213
+ end
214
+ rs
215
+ end
172
216
  end
173
217
  end
@@ -59,12 +59,6 @@ module Tebako
59
59
  thread_pthread.c
60
60
  ].freeze
61
61
 
62
- DEPLOY_ENV = {
63
- "GEM_HOME" => nil,
64
- "GEM_PATH" => nil,
65
- "TEBAKO_PASS_THROUGH" => "1"
66
- }.freeze
67
-
68
62
  # Magic version numbers used to ensure compatibility for Ruby 2.7.x, 3.0.x
69
63
  # These are the minimal versions required to provide linux-gnu / linux-musl differentiation by bundler
70
64
  # Ruby 3.1+ default rubygems versions work correctly out of the box
@@ -83,13 +77,19 @@ module Tebako
83
77
  end
84
78
 
85
79
  # Deploy
86
- def deploy(src_dir, tbd, gflength)
80
+ def deploy(target_dir, ruby_ver, gflength)
87
81
  puts "-- Running deploy script"
88
82
 
89
- ruby_ver = ruby_version(tbd)
90
- update_rubygems(tbd, "#{src_dir}/lib", ruby_ver, RUBYGEMS_VERSION) unless PatchHelpers.ruby31?(ruby_ver)
91
- install_gem tbd, "tebako-runtime"
92
- install_gem(tbd, "bundler", BUNDLER_VERSION) if gflength.to_i != 0
83
+ ruby_api_ver = ruby_api_version(ruby_ver)
84
+ gem_home = "#{target_dir}/lib/ruby/gems/#{ruby_api_ver}"
85
+
86
+ deploy_env = { "GEM_HOME" => gem_home, "GEM_PATH" => gem_home, "TEBAKO_PASS_THROUGH" => "1" }
87
+
88
+ PatchHelpers.with_env(deploy_env) do
89
+ update_rubygems(target_dir, ruby_api_ver, RUBYGEMS_VERSION) unless PatchHelpers.ruby31?(ruby_ver)
90
+ install_gem(target_dir, "tebako-runtime")
91
+ install_gem(target_dir, "bundler", BUNDLER_VERSION) if gflength.to_i != 0
92
+ end
93
93
  end
94
94
 
95
95
  # Init
@@ -174,21 +174,24 @@ module Tebako
174
174
  File.join(src_dir, "lib", "libx64-ucrt-ruby#{ruby_ver[0]}#{ruby_ver[2]}0.a")
175
175
  end
176
176
 
177
- def install_gem(tbd, name, ver = nil)
177
+ def install_gem(target_dir, name, ver = nil)
178
178
  puts " ... installing #{name} gem#{" version #{ver}" if ver}"
179
- PatchHelpers.with_env(DEPLOY_ENV) do
180
- params = ["#{tbd}/gem", "install", name.to_s]
181
- params.push("-v", ver.to_s) if ver
182
179
 
183
- out, st = Open3.capture2e(*params)
184
- raise Tebako::Error, "Failed to install #{name} (#{st}):\n #{out}" unless st.exitstatus.zero?
185
- end
180
+ params = ["#{target_dir}/bin/gem", "install", name.to_s]
181
+ params.push("-v", ver.to_s) if ver
182
+
183
+ out, st = Open3.capture2e(*params)
184
+ raise Tebako::Error, "Failed to install #{name} (#{st}):\n #{out}" unless st.exitstatus.zero?
186
185
  end
187
186
 
188
187
  def do_patch(patch_map, root)
189
188
  patch_map.each { |fname, mapping| PatchHelpers.patch_file("#{root}/#{fname}", mapping) }
190
189
  end
191
190
 
191
+ def ruby_api_version(ruby_ver)
192
+ "#{ruby_ver.split(".")[0..1].join(".")}.0"
193
+ end
194
+
192
195
  def ruby_version(tbd)
193
196
  ruby_version = nil
194
197
  PatchHelpers.with_env(DEPLOY_ENV) do
@@ -203,16 +206,14 @@ module Tebako
203
206
  ruby_version
204
207
  end
205
208
 
206
- def update_rubygems(tbd, tld, ruby_ver, gem_ver)
209
+ def update_rubygems(target_dir, ruby_api_ver, gem_ver)
207
210
  puts " ... updating rubygems to #{gem_ver}"
208
- PatchHelpers.with_env(DEPLOY_ENV) do
209
- out, st = Open3.capture2e("#{tbd}/gem", "update", "--no-doc", "--system", gem_ver.to_s)
210
- raise Tebako::Error, "Failed to update rubugems to #{gem_ver} (#{st}):\n #{out}" unless st.exitstatus.zero?
211
- end
212
- ruby_api_ver = ruby_ver.split(".")[0..1].join(".")
211
+ out, st = Open3.capture2e("#{target_dir}/bin/gem", "update", "--no-doc", "--system", gem_ver.to_s)
212
+ raise Tebako::Error, "Failed to update rubugems to #{gem_ver} (#{st}):\n #{out}" unless st.exitstatus.zero?
213
+
213
214
  # Autoload cannot handle statically linked openssl extension
214
215
  # Changing it to require seems to be the simplest solution
215
- PatchHelpers.patch_file("#{tld}/ruby/site_ruby/#{ruby_api_ver}.0/rubygems/openssl.rb",
216
+ PatchHelpers.patch_file("#{target_dir}/lib/ruby/site_ruby/#{ruby_api_ver}/rubygems/openssl.rb",
216
217
  { "autoload :OpenSSL, \"openssl\"" => "require \"openssl\"" })
217
218
  end
218
219
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.7.1"
29
+ VERSION = "0.7.2.rc1"
30
30
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
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.7.1
4
+ version: 0.7.2.rc1
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-29 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor