tebako 0.7.3 → 0.7.4

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: e86bb510a0ab1997a97f8999ddd73151f99e593c4f19c3174a2f073ef5739c9e
4
- data.tar.gz: 54741b66ed07299e8455497f94e619a5fa14bd010214d3f7abee0c90972d1cc9
3
+ metadata.gz: f401cd856745a3bf5936d3805342314d03b2fb08d6972c3a3c80164333af135c
4
+ data.tar.gz: 6c6db56b7763e6e0412539b20a0d6b5f679a1da55ceb8cc722293315df2f3cea
5
5
  SHA512:
6
- metadata.gz: 40915aa707b703d62cdb0b7e1cf798d1a707db3e2b1537df821ef6b16d87b4f057c21b2204e4362aa2582a2f236be78138e7b00db01a1ed56ce40f5e8cd23991
7
- data.tar.gz: d3104d718a7001e0a8b89551b774c614daf80e37c2ce720af9c1ef3ece914dc457f3fec6fa0e17a0684e199b651beb04dd95890805ae9e5bf0339d29dd37c42e
6
+ metadata.gz: '028f3c468930c81829d693900dc9adb10a477877fdb5f65376b3c3f3a846672845389e83d4f361a207a15f1c4e824904fb4de88363c04aeb74b547504a03a01a'
7
+ data.tar.gz: a7aadebf1ec8b478e156d571ef9e7f48cb50965efdf1c629b895b96a039a8ffd116722460a80d042ab97e43a15ded8843148e0469079744f3ed8c6e5a55973bc
data/CMakeLists.txt CHANGED
@@ -116,7 +116,7 @@ set(IS_MUSL OFF)
116
116
  set(IS_MSYS OFF)
117
117
  set(IS_DARWIN OFF)
118
118
  set(RB_W32 OFF)
119
- set(RUBY_WITHOUT_EXT "dbm,win32,win32ole,'-test-'")
119
+ set(RUBY_WITHOUT_EXT "dbm,win32,win32ole,-test-\*")
120
120
  set(RUBY_NAME "ruby")
121
121
  set(RUBY_SUFFIX "")
122
122
  set(EXE_SUFFIX "")
@@ -131,7 +131,7 @@ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
131
131
  set(IS_MSYS ON)
132
132
  # set(DWARFS_PRELOAD ON)
133
133
  set(RB_W32 ON)
134
- set(RUBY_WITHOUT_EXT "dbm,syslog,pty,gdbm,readline,'-test-'")
134
+ set(RUBY_WITHOUT_EXT "dbm,syslog,pty,gdbm,readline,-test-\*")
135
135
  #set(RUBY_SUFFIX "w")
136
136
  set(EXE_SUFFIX ".exe")
137
137
  set(CMD_SUFFIX ".cmd")
@@ -462,7 +462,6 @@ else (${SETUP_MODE})
462
462
  )
463
463
 
464
464
  add_custom_target(packaged_filesystem
465
- COMMAND ruby ${EXE}/tebako-packager strip ${OSTYPE_TXT} ${DATA_SRC_DIR}
466
465
  COMMAND ${GNU_BASH} -c "chmod +x ${DEPS_BIN_DIR}/mkdwarfs${EXE_SUFFIX}"
467
466
  # No progress below is critical since in reporting mode mkdwarfs tries to work directly with terminal
468
467
  # and it creates issues for stderr redirects (&2 > 1) used by Ninja and our test srcipts
@@ -487,22 +486,18 @@ else (${SETUP_MODE})
487
486
  add_dependencies(tebako-fs packaged_filesystem)
488
487
 
489
488
  if (${RUBY_VER} VERSION_LESS "3.0.0")
490
- add_custom_target(patched_ruby
489
+ add_custom_target(tebako
491
490
  COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
492
- )
491
+ COMMAND ruby ${EXE}/tebako-packager finalize ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${APP_NAME}
492
+ )
493
493
  else()
494
- add_custom_target(patched_ruby
494
+ add_custom_target(tebako
495
495
  COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ruby ${RUBY_MAKEFILE} -j${NCORES}
496
496
  COMMAND ${CMAKE_COMMAND} -E chdir ${RUBY_SOURCE_DIR} make ${RUBY_MAKEFILE} -j${NCORES}
497
- )
497
+ COMMAND ruby ${EXE}/tebako-packager finalize ${OSTYPE_TXT} ${RUBY_SOURCE_DIR} ${APP_NAME}
498
+ )
498
499
  endif()
499
500
 
500
- add_dependencies(patched_ruby setup tebako-fs)
501
-
502
- add_custom_target(tebako ALL
503
- COMMAND ${CMAKE_COMMAND} -E copy ${RUBY_SOURCE_DIR}/ruby${RUBY_SUFFIX}${EXE_SUFFIX} ${APP_NAME}${EXE_SUFFIX}
504
- COMMAND ${CMAKE_COMMAND} -E echo "Tebako packaging has completed"
505
- DEPENDS patched_ruby
506
- )
501
+ add_dependencies(tebako setup tebako-fs)
507
502
 
508
503
  endif(${SETUP_MODE})
data/README.adoc CHANGED
@@ -38,7 +38,15 @@ The Tebako packager is tested on the following platforms:
38
38
  * MacOS: macOS 12 (Monterey), 13 (Ventura), 14 (Sonoma)
39
39
  * Windows: 2019, 2022 (using MinGW ucrt64 toolchain)
40
40
 
41
- Please note that Windows support is in pre-release and is a subject of further testing and optimization
41
+ There are two known Windows issues:
42
+
43
+ * tebako may face errors related to CMake path length limitations (https://gitlab.kitware.com/cmake/cmake/-/issues/25936).
44
+ This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
45
+ There is no workaround for this issue as it looks like is a limitation of the manifest used to build CMake executable.
46
+ * MSys strip utility creates broken executable when tebako image is processed. Linking with '-s' flag produces unusable
47
+ executables as well.
48
+ Until this issue (https://github.com/tamatebako/tebako/issues/172) is resolved we plan to produce an Windows executable
49
+ with debug information unstripped. You can opt to run 'strip -S' manually, it most cases it works.
42
50
 
43
51
  == Supported Ruby versions
44
52
 
@@ -135,7 +143,7 @@ To ensure the correct version of bison is picked, run this command before the bu
135
143
 
136
144
  [source,sh]
137
145
  ----
138
- export PATH="$(brew --prefix bison)/bin:$PATH"
146
+ export PATH="$(brew --prefix bison)/bin:$PATH"
139
147
  ----
140
148
 
141
149
  === Windows (workstation 10, 11; Server 2019, 2022)
@@ -151,11 +159,6 @@ Once it is installed use the following commands:
151
159
  fmt glog dlfcn gtest autotools ncurses libyaml
152
160
  ----
153
161
 
154
- Please note that on Windows tebako may face issues related by CMake path length limitations.
155
- (https://gitlab.kitware.com/cmake/cmake/-/issues/25936)
156
- This error may affect not tebako itself but the gems that need to be package and use CMake to build native extensions.
157
- There is no workaround for this issue as it lloks like is a limitation of the manifest used to build CMake executable.
158
-
159
162
  == Installation
160
163
 
161
164
  === General
data/exe/tebako-packager CHANGED
@@ -48,26 +48,7 @@ begin
48
48
  end
49
49
 
50
50
  Tebako::Packager.pass1(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5])
51
- when "stash"
52
- # ARGV[0] -- command
53
- # ARGV[1] -- DATA_SRC_DIR
54
- # ARGV[2] -- RUBY_STASH_DIR
55
- unless ARGV.length == 3
56
- raise Tebako::Error,
57
- "tebako-packager stash command expects 3 arguments, #{ARGV.length} has been provided."
58
- end
59
-
60
- Tebako::Packager.stash(ARGV[1], ARGV[2])
61
- when "strip"
62
- # ARGV[0] -- command
63
- # ARGV[1] -- OSTYPE
64
- # ARGV[2] -- DATA_SRC_DIR
65
- unless ARGV.length == 3
66
- raise Tebako::Error,
67
- "tebako-packager strip command expects 3 arguments, #{ARGV.length} has been provided."
68
- end
69
51
 
70
- Tebako::Stripper.strip(ARGV[1], ARGV[2])
71
52
  when "pass1a"
72
53
  # ARGV[0] -- command
73
54
  # ARGV[1] -- RUBY_SOURCE_DIR
@@ -114,6 +95,16 @@ begin
114
95
  # That shall match CMakeLists.txt settings
115
96
  Tebako::Packager.deploy(ARGV[1], ARGV[4], ARGV[5], ARGV[11], ARGV[7], ARGV[8], ARGV[9])
116
97
 
98
+ when "finalize"
99
+ # ARGV[0] -- command
100
+ # ARGV[1] -- OSTYPE
101
+ # ARGV[2] -- RUBY_SOURCE_DIR
102
+ # ARGV[3] -- APP_NAME
103
+ unless ARGV.length == 4
104
+ raise Tebako::Error,
105
+ "tebako-packager finalize command expects 4 arguments, #{ARGV.length} has been provided."
106
+ end
107
+ Tebako::Packager.finalize(ARGV[1], ARGV[2], ARGV[3])
117
108
  else
118
109
  raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
119
110
  end
@@ -121,5 +112,4 @@ rescue Tebako::Error => e
121
112
  puts "tebako-packager failed: #{e.message} [#{e.error_code}]"
122
113
  exit(e.error_code)
123
114
  end
124
-
125
115
  exit(0)
data/lib/tebako/cli.rb CHANGED
@@ -61,8 +61,8 @@ module Tebako
61
61
  def clean_ruby
62
62
  puts "Cleaning Ruby sources from tebako packaging environment"
63
63
  suffix = options["Ruby"].nil? ? "" : "_#{options["Ruby"]}"
64
- nmr = "src/_ruby_#{suffix}*"
65
- nms = "stash_#{suffix}"
64
+ nmr = "src/_ruby#{suffix}*"
65
+ nms = "stash#{suffix}*"
66
66
  FileUtils.rm_rf(Dir.glob(File.join(deps, nmr)), secure: true)
67
67
  FileUtils.rm_rf(Dir.glob(File.join(deps, nms)), secure: true)
68
68
  end
@@ -29,6 +29,7 @@ require "fileutils"
29
29
  require "find"
30
30
 
31
31
  require_relative "error"
32
+ require_relative "packager/patch_helpers"
32
33
 
33
34
  # Tebako - an executable packager
34
35
  module Tebako
@@ -65,11 +66,16 @@ module Tebako
65
66
  end
66
67
 
67
68
  def deploy
68
- system("#{gem_command} env")
69
- install_gem("tebako-runtime")
70
- install_gem("bundler", Tebako::BUNDLER_VERSION) if needs_bundler?
71
-
72
- deploy_solution
69
+ Packager::PatchHelpers.with_env(deploy_env) do
70
+ unless Packager::PatchHelpers.ruby31?(@ruby_ver)
71
+ update_rubygems
72
+ patch_after_rubygems_update(@target_dir, @ruby_api_version)
73
+ end
74
+ system("#{gem_command} env")
75
+ install_gem("tebako-runtime")
76
+ install_gem("bundler", BUNDLER_VERSION) if needs_bundler?
77
+ deploy_solution
78
+ end
73
79
  end
74
80
 
75
81
  def deploy_env
@@ -264,6 +270,13 @@ module Tebako
264
270
  end
265
271
  end
266
272
 
273
+ def patch_after_rubygems_update(target_dir, ruby_api_ver)
274
+ # Autoload cannot handle statically linked openssl extension
275
+ # Changing it to require seems to be the simplest solution
276
+ Packager::PatchHelpers.patch_file("#{target_dir}/lib/ruby/site_ruby/#{ruby_api_ver}/rubygems/openssl.rb",
277
+ { "autoload :OpenSSL, \"openssl\"" => "require \"openssl\"" })
278
+ end
279
+
267
280
  def run_with_capture(args)
268
281
  puts " ... @ #{args.join(" ")}"
269
282
  out, st = Open3.capture2e(*args)
@@ -62,10 +62,18 @@ module Tebako
62
62
  out
63
63
  end
64
64
 
65
+ def exe_suffix(ostype)
66
+ msys?(ostype) ? ".exe" : ""
67
+ end
68
+
65
69
  def msys?(ostype)
66
70
  ostype =~ /msys|cygwin|mingw/
67
71
  end
68
72
 
73
+ def macos?(ostype)
74
+ ostype =~ /darwin/
75
+ end
76
+
69
77
  def patch_c_file_pre(pattern)
70
78
  {
71
79
  pattern => "#{PatchLiterals::C_FILE_SUBST}\n#{pattern}"
@@ -40,13 +40,12 @@ module Tebako
40
40
  DARWIN_BREW_LIBS = [
41
41
  ["zlib", "z"], ["gdbm", "gdbm"], ["readline", "readline"], ["libffi", "ffi"],
42
42
  ["ncurses", "ncurses"], ["fmt", "fmt"], ["lz4", "lz4"], ["xz", "lzma"],
43
- ["libyaml", "yaml"], ["boost", "boost_chrono"],
44
- ["double-conversion", "double-conversion"]
43
+ ["libyaml", "yaml"], ["boost", "boost_chrono"], ["double-conversion", "double-conversion"]
45
44
  ].freeze
46
45
 
47
46
  DARWIN_BREW_LIBS_PRE_31 = [["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"]].freeze
48
47
 
49
- DARWIN_BREW_LIBS_31 = [["libyaml", "yaml"], ["openssl@3", "ssl"], ["openssl@3", "crypto"]].freeze
48
+ DARWIN_BREW_LIBS_31 = [["openssl@3", "ssl"], ["openssl@3", "crypto"]].freeze
50
49
 
51
50
  DARWIN_DEP_LIBS = ["glog", "gflags", "brotlienc", "brotlidec", "brotlicommon"].freeze
52
51
  # rubocop:enable Style/WordArray
@@ -31,6 +31,7 @@ require "pathname"
31
31
 
32
32
  require_relative "error"
33
33
  require_relative "deploy_helper"
34
+ require_relative "stripper"
34
35
  require_relative "packager/pass1"
35
36
  require_relative "packager/pass1a"
36
37
  require_relative "packager/pass2"
@@ -79,14 +80,22 @@ module Tebako
79
80
 
80
81
  deploy_helper = Tebako::DeployHelper.new(fs_root, fs_entrance, fs_mount_point, target_dir, pre_dir)
81
82
  deploy_helper.config(os_type, ruby_ver)
83
+ deploy_helper.deploy
84
+ Tebako::Stripper.strip(os_type, target_dir)
85
+ end
82
86
 
83
- PatchHelpers.with_env(deploy_helper.deploy_env) do
84
- unless PatchHelpers.ruby31?(ruby_ver)
85
- deploy_helper.update_rubygems
86
- patch_after_rubygems_update(target_dir, deploy_helper.ruby_api_version)
87
- end
88
- deploy_helper.deploy
87
+ def finalize(os_type, src_dir, app_name)
88
+ exe_suffix = Packager::PatchHelpers.exe_suffix(os_type)
89
+ src_name = File.join(src_dir, "ruby#{exe_suffix}")
90
+ package_name = "#{app_name}#{exe_suffix}"
91
+ # [TODO] On MSys strip sometimes creates a broken executable
92
+ # https://github.com/tamatebako/tebako/issues/172
93
+ if Packager::PatchHelpers.msys?(os_type)
94
+ FileUtils.cp(src_name, package_name)
95
+ else
96
+ Tebako::Stripper.strip_file(src_name, package_name)
89
97
  end
98
+ puts "Created tebako package at \"#{package_name}\""
90
99
  end
91
100
 
92
101
  # Init
@@ -188,13 +197,6 @@ module Tebako
188
197
  end
189
198
  ruby_version
190
199
  end
191
-
192
- def patch_after_rubygems_update(target_dir, ruby_api_ver)
193
- # Autoload cannot handle statically linked openssl extension
194
- # Changing it to require seems to be the simplest solution
195
- PatchHelpers.patch_file("#{target_dir}/lib/ruby/site_ruby/#{ruby_api_ver}/rubygems/openssl.rb",
196
- { "autoload :OpenSSL, \"openssl\"" => "require \"openssl\"" })
197
- end
198
200
  end
199
201
  end
200
202
  end
@@ -28,12 +28,13 @@
28
28
  require "fileutils"
29
29
  require "find"
30
30
 
31
+ require_relative "packager/patch_helpers"
32
+
31
33
  # Tebako - an executable packager
32
34
  module Tebako
33
35
  # Tebako packaging support (stripper)
34
36
  module Stripper
35
- DELETE_EXTENSIONS = %w[o lo obj a lib].freeze
36
- STRIP_EXTENSIONS = %w[dll so].freeze
37
+ DELETE_EXTENSIONS = %w[o lo obj a la lib].freeze
37
38
  BIN_FILES = %w[
38
39
  bundle bundler rbs erb gem irb racc racc2y rake rdoc ri y2racc rdbg typeprof
39
40
  ].freeze
@@ -47,15 +48,29 @@ module Tebako
47
48
  # from memfs or not. For debugging purposes it is very handy to have it here
48
49
  def strip(ostype, src_dir)
49
50
  puts " ... stripping the output"
50
- strip_bs(ostype, src_dir)
51
+ strip_bs(src_dir)
51
52
  strip_fi(ostype, src_dir)
52
53
  strip_li(ostype, src_dir)
53
54
  end
54
55
 
56
+ def strip_file(file_in, file_out = nil)
57
+ params = ["strip", "-S", file_in]
58
+ params << "-o" << file_out unless file_out.nil?
59
+ out, st = Open3.capture2e(*params)
60
+
61
+ # Some gems (well, libmspack) has bundled extensions for several architectures)
62
+ # Getting something like:
63
+ # strip: Unable to recognise the format of the input file
64
+ # `/tmp/cirrus-ci-build/o/s/lib/ruby/gems/3.1.0/gems/libmspack-0.11.0/ext/x86_64-linux/libmspack.so'
65
+ # on aarch64
66
+
67
+ puts "Warning: could not strip #{file_in}:\n #{out}" unless st.exitstatus.zero?
68
+ end
69
+
55
70
  private
56
71
 
57
72
  def get_files(ostype)
58
- exe_suffix = ostype =~ /msys/ ? ".exe" : ""
73
+ exe_suffix = Packager::PatchHelpers.exe_suffix(ostype)
59
74
  files = BIN_FILES.flat_map do |f|
60
75
  [f, "#{f}#{CMD_SUFFIX}", "#{f}#{BAT_SUFFIX}"]
61
76
  end
@@ -64,7 +79,7 @@ module Tebako
64
79
  files
65
80
  end
66
81
 
67
- def strip_bs(_ostype, src_dir)
82
+ def strip_bs(src_dir)
68
83
  FileUtils.rm_rf([
69
84
  File.join(src_dir, "share"),
70
85
  File.join(src_dir, "include"),
@@ -78,17 +93,25 @@ module Tebako
78
93
  end
79
94
 
80
95
  def strip_li(ostype, src_dir)
96
+ sext = strip_extensions(ostype)
81
97
  Find.find(src_dir) do |file|
82
98
  next if File.directory?(file)
83
99
 
84
100
  extension = File.extname(file).delete_prefix(".").downcase
85
101
  if DELETE_EXTENSIONS.include?(extension)
86
102
  FileUtils.rm(file)
87
- elsif STRIP_EXTENSIONS.include?(extension)
88
- system("strip \"#{file}\"") unless ostype =~ /darwin/
103
+ elsif sext.include?(extension) # && !Packager::PatchHelpers.msys?(ostype)
104
+ strip_file(file)
89
105
  end
90
106
  end
91
107
  end
108
+
109
+ def strip_extensions(ostype)
110
+ sext = ["so"]
111
+ sext << "dll" if Packager::PatchHelpers.msys?(ostype)
112
+ sext << "dylib" << "bundle" if Packager::PatchHelpers.macos?(ostype)
113
+ sext
114
+ end
92
115
  end
93
116
  end
94
117
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.7.3"
29
+ VERSION = "0.7.4"
30
30
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
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.3
4
+ version: 0.7.4
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-07-20 00:00:00.000000000 Z
11
+ date: 2024-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor