tebako 0.7.1 → 0.7.2.rc2
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/Rakefile +3 -2
- data/exe/tebako-packager +1 -1
- data/lib/tebako/cli.rb +18 -4
- data/lib/tebako/cli_helpers.rb +50 -0
- data/lib/tebako/packager.rb +26 -25
- data/lib/tebako/version.rb +1 -1
- data/version.txt +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c6393e228f7a9b35f5e4e134145d61d050e043b3f71fd6b7470bc6ae9fe84c
|
4
|
+
data.tar.gz: 950729b6f6eeed71c400f114fc45a0820919cbd8ddf22c8682e4d5cc77ed38b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 547a0f3dca568dc52dd40cd0fbca7e09d96ab51de383edfb70e7e1bb16fde23c81135250ba7cdd4bf9c7fe7658e1241e753ef62dea0c96181496fbcf7da06ea3
|
7
|
+
data.tar.gz: 9653a599391afb40aed074d456b3d04e779091501223f1d6e41aa4c85ad1071838e6a90a7f4b1c2eb834061e5b9f8d875346c8438c904ac221a05d3a22d0571a
|
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
|
-
|
39
|
-
|
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],
|
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
|
-
|
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(
|
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
|
|
data/lib/tebako/cli_helpers.rb
CHANGED
@@ -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,39 @@ 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 and Ruby build files"
|
69
|
+
# Using File.join(output, "") to ensure that the slashes are appropriate
|
70
|
+
|
71
|
+
nmr = "src/_ruby_*"
|
72
|
+
nms = "stash_*"
|
73
|
+
FileUtils.rm_rf(Dir.glob(File.join(deps, nmr)), secure: true)
|
74
|
+
FileUtils.rm_rf(Dir.glob(File.join(deps, nms)), secure: true)
|
75
|
+
|
76
|
+
FileUtils.rm_rf(File.join(output, ""), secure: true)
|
77
|
+
end
|
78
|
+
|
60
79
|
def deps
|
61
80
|
@deps ||= File.join(prefix, "deps")
|
62
81
|
end
|
63
82
|
|
83
|
+
def ensure_version_file
|
84
|
+
version_file_path = File.join(prefix, E_VERSION_FILE)
|
85
|
+
|
86
|
+
begin
|
87
|
+
File.write(version_file_path, version_key)
|
88
|
+
# puts "Set version information for tebako packaging environment to #{Tebako::VERSION}"
|
89
|
+
rescue StandardError => e
|
90
|
+
puts "An error occurred while creating or updating #{E_VERSION_FILE}: #{e.message}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
64
94
|
def fs_current
|
65
95
|
fs_current = Dir.pwd
|
66
96
|
if RUBY_PLATFORM =~ /msys|mingw|cygwin/
|
@@ -169,5 +199,25 @@ module Tebako
|
|
169
199
|
c_path = Pathname.new(__FILE__).realpath
|
170
200
|
@source ||= File.expand_path("../../..", c_path)
|
171
201
|
end
|
202
|
+
|
203
|
+
def version_key
|
204
|
+
@version_key ||= "#{Tebako::VERSION} at #{source}"
|
205
|
+
end
|
206
|
+
|
207
|
+
def version_match? # rubocop:disable Metrics/MethodLength
|
208
|
+
begin
|
209
|
+
version_file_path = File.join(prefix, E_VERSION_FILE)
|
210
|
+
file_version = File.open(version_file_path, &:readline).strip
|
211
|
+
rs = file_version == version_key
|
212
|
+
unless rs
|
213
|
+
puts "CMake cache was created by a gem version #{file_version} " \
|
214
|
+
"and cannot be used for gem version #{version_key}"
|
215
|
+
end
|
216
|
+
rescue StandardError
|
217
|
+
# In case of any error (e.g., file not readable), return false
|
218
|
+
rs = false
|
219
|
+
end
|
220
|
+
rs
|
221
|
+
end
|
172
222
|
end
|
173
223
|
end
|
data/lib/tebako/packager.rb
CHANGED
@@ -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(
|
80
|
+
def deploy(target_dir, ruby_ver, gflength)
|
87
81
|
puts "-- Running deploy script"
|
88
82
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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(
|
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
|
-
|
184
|
-
|
185
|
-
|
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(
|
209
|
+
def update_rubygems(target_dir, ruby_api_ver, gem_ver)
|
207
210
|
puts " ... updating rubygems to #{gem_ver}"
|
208
|
-
|
209
|
-
|
210
|
-
|
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("#{
|
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
|
data/lib/tebako/version.rb
CHANGED
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
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.
|
4
|
+
version: 0.7.2.rc2
|
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-
|
11
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|