tebako 0.5.3 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 573cd1ec24b37fafbebc82a0a8a11a4a1c05e22b6feeba1af89dc8670923c5e2
4
- data.tar.gz: 03d3c8f200d209a6b419960f76f499c4ccad0a0b726cf8ba85a780fb6c6d3aa4
3
+ metadata.gz: b93ceda3b8a6329b0a332f3ebfbf4c24ff030eda6c1727109623a98bbf868eae
4
+ data.tar.gz: 78e53009d65e1841a8c706b3be9fcbe17f7976864d23e5f70bf07357f3f2701f
5
5
  SHA512:
6
- metadata.gz: 5a362b80444f6288964158034d58fd4e86749127f173d0f4d30445790d4a86481467b3b82e75a4d7398729633bdb537f0f146ff168d5893db57f155d0d16776c
7
- data.tar.gz: 3da8e9e840d4bbf72f28c6b4e3b4c75bcdc076da51c000ef2e9a2d63121b8a694154be279d787694ee9728961e045a98e4f919740112c36579104b7d3565291e
6
+ metadata.gz: c256ed82865bea01ac84c9c5bc33f7ef0c99df2d143eb78ac1f6b486492d42affb10fe14f590665a7a00b2c397ae57d9ba7cd3c52b6742b5740965340eeb1c77
7
+ data.tar.gz: 2d5dd78d7ccdf95f06b7453b4939ebc81e759242fbf37259edd95e598901adc6a5af6828cf1c57c081c7c7f487c6a4609e3f1c8d2b59e070a5be0869448781f1
data/CMakeLists.txt CHANGED
@@ -73,8 +73,6 @@ include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/macos-environment.cmake)
73
73
  include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/msys-environment.cmake)
74
74
  include(${CMAKE_SOURCE_DIR}/tools/cmake-scripts/def-external-project.cmake)
75
75
 
76
- include(${CMAKE_SOURCE_DIR}/cmake/def_tty_colours.cmake)
77
-
78
76
  option(SETUP_MODE "Tebako setup" OFF)
79
77
  if(NOT LOG_LEVEL)
80
78
  set(LOG_LEVEL "error")
@@ -85,7 +83,7 @@ set(START_WITH_PACKAGED_FILESYSTEM OFF CACHE BOOL "Start workflow from 'packaged
85
83
  if (NOT ${SETUP_MODE})
86
84
  message("Running tebako press script")
87
85
  if (${START_WITH_PACKAGED_FILESYSTEM})
88
- message("${ColourBoldRed}*** Starting workflow from 'packaged filesystem' target ***${ColourReset}")
86
+ message("*** Starting workflow from 'packaged filesystem' target ***")
89
87
  endif(${START_WITH_PACKAGED_FILESYSTEM})
90
88
 
91
89
  if ("-${ROOT}" STREQUAL "-")
@@ -174,7 +172,12 @@ elseif("${OSTYPE_TXT}" MATCHES "^msys*")
174
172
  set(RUBY_MAKEFILE "--file=GNUmakefile")
175
173
  elseif("${OSTYPE_TXT}" MATCHES "^darwin.*")
176
174
  set(IS_DARWIN ON)
177
- set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@1.1")
175
+ if(${RUBY_VER} VERSION_LESS "3.2.0")
176
+ set(OPENSSL_VER "1.1")
177
+ else(${RUBY_VER} VERSION_LESS "3.2.0")
178
+ set(OPENSSL_VER "3")
179
+ endif(${RUBY_VER} VERSION_LESS "3.2.0")
180
+ set(BUILD_OPENSSL_ROOT_DIR "${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
178
181
  endif()
179
182
 
180
183
  # Various locations for external projects
@@ -217,7 +220,7 @@ if(IS_MSYS)
217
220
  endif(IS_MSYS)
218
221
 
219
222
  def_ext_prj_g(INCBIN "348e36b")
220
- def_ext_prj_g(DWARFS_WR "v0.3.4")
223
+ def_ext_prj_g(DWARFS_WR "v0.3.5")
221
224
 
222
225
  if (DEFINED ENV{BUNDLER_VER})
223
226
  set(BUNDLER_VER $ENV{BUNDLER_VER})
@@ -411,11 +414,6 @@ endif()
411
414
  set(C_FLAGS_DEST cppflags)
412
415
 
413
416
  if(IS_DARWIN)
414
- if(${RUBY_VER} VERSION_LESS "3.2.2")
415
- set(OPENSSL_VER "1.1")
416
- else(${RUBY_VER} VERSION_LESS "3.2.2")
417
- set(OPENSSL_VER "3")
418
- endif(${RUBY_VER} VERSION_LESS "3.2.2")
419
417
  string(CONCAT RUBY_C_FLAGS ${RUBY_C_FLAGS} " -I${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/include -I${BUILD_BREW_PREFIX}/opt/zlib/include -I${BUILD_BREW_PREFIX}/include")
420
418
  string(CONCAT RUBY_L_FLAGS ${RUBY_L_FLAGS} " -L${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}/lib -L${BUILD_BREW_PREFIX}/opt/zlib/lib -L${BUILD_BREW_PREFIX}/lib")
421
419
  set(OPENSSL_RUBY_OPTION "--with-openssl-dir=${BUILD_BREW_PREFIX}/opt/openssl@${OPENSSL_VER}")
@@ -488,7 +486,7 @@ else (${SETUP_MODE})
488
486
  list(LENGTH GEMS GLENGTH)
489
487
 
490
488
  add_custom_target(clean_filesystem
491
- COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR}
489
+ COMMAND ruby ${EXE}/tebako-packager deploy ${RUBY_STASH_DIR} ${DATA_SRC_DIR} ${DATA_PRE_DIR} ${DATA_BIN_DIR} ${TBD} ${TGD}
492
490
  DEPENDS ${RUBY_PRJ}
493
491
  )
494
492
  if(GSLENGTH GREATER 0)
data/common.env CHANGED
@@ -1,6 +1,6 @@
1
1
  BUILD_TYPE=Release
2
2
  DEPS=deps
3
3
  INCBIN_TAG=348e36b
4
- DWARFS_WR_TAG=v0.3.4
4
+ DWARFS_WR_TAG=v0.3.5
5
5
  BUNDLER_VER=2.3.22
6
6
  RUBY_VER=3.1.4
data/exe/tebako-packager CHANGED
@@ -78,11 +78,13 @@ begin
78
78
  # ARGV[2] -- DATA_SRC_DIR
79
79
  # ARGV[3] -- DATA_PRE_DIR
80
80
  # ARGV[4] -- DATA_BIN_DIR
81
- unless ARGV.length == 5
81
+ # ARGV[5] -- TARGET_BIN_DIR (TBD)
82
+ # ARGV[6] -- TARGET_GEM_DIR (TGD)
83
+ unless ARGV.length == 7
82
84
  raise Tebako::Error,
83
- "tebako-packager deploy command expects 5 arguments, #{ARGV.length} has been provided."
85
+ "tebako-packager deploy command expects 7 arguments, #{ARGV.length} has been provided."
84
86
  end
85
- Tebako::Packager.deploy(ARGV[1], ARGV[2], ARGV[3], ARGV[4])
87
+ Tebako::Packager.deploy(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ARGV[5])
86
88
  else
87
89
  raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
88
90
  end
@@ -34,18 +34,8 @@ module Tebako
34
34
  # Ruby patching definitions (pass2)
35
35
  module Pass2
36
36
  class << self
37
- def get_dir_c_patch(ostype)
38
- dir_c_patch = patch_c_file(ostype =~ /msys/ ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST")
39
- dir_c_patch.merge!(DIR_C_BASE_PATCH)
40
- end
41
-
42
37
  def get_patch_map(ostype, deps_lib_dir, ruby_ver)
43
- patch_map = {
44
- "template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
45
- "main.c" => MAIN_C_PATCH,
46
- "tool/mkconfig.rb" => TOOL_MKCONFIG_RB_PATCH,
47
- "dir.c" => get_dir_c_patch(ostype)
48
- }
38
+ patch_map = get_patch_map_base(ostype, deps_lib_dir, ruby_ver)
49
39
 
50
40
  C_FILES_TO_PATCH.each { |patch| patch_map.store(patch[0], patch_c_file(patch[1])) }
51
41
  patch_map.store("thread_pthread.c", LINUX_MUSL_THREAD_PTHREAD_PATCH) if ostype =~ /linux-musl/
@@ -58,6 +48,21 @@ module Tebako
58
48
 
59
49
  include Tebako::Packager::PatchLiterals
60
50
 
51
+ def get_dir_c_patch(ostype)
52
+ dir_c_patch = patch_c_file(ostype =~ /msys/ ? "/* define system APIs */" : "#ifdef HAVE_GETATTRLIST")
53
+ dir_c_patch.merge!(DIR_C_BASE_PATCH)
54
+ end
55
+
56
+ def get_patch_map_base(ostype, deps_lib_dir, ruby_ver)
57
+ {
58
+ "template/Makefile.in" => template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver),
59
+ "main.c" => MAIN_C_PATCH,
60
+ "tool/mkconfig.rb" => TOOL_MKCONFIG_RB_PATCH,
61
+ "gem_prelude.rb" => GEM_PRELUDE_RB_PATCH,
62
+ "dir.c" => get_dir_c_patch(ostype)
63
+ }
64
+ end
65
+
61
66
  def process_brew_libs!(libs, brew_libs)
62
67
  brew_libs.each { |lib| libs << "#{PatchHelpers.get_prefix(lib[0]).chop}/lib/lib#{lib[1]}.a " }
63
68
  end
@@ -73,16 +78,12 @@ module Tebako
73
78
  SUBST
74
79
  end
75
80
 
76
- def yaml_reference(ruby_ver)
77
- PatchHelpers.ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
78
- end
79
-
80
81
  def linux_gnu_libs(ruby_ver)
81
82
  <<~SUBST
82
83
  -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
83
84
  -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
84
85
  -l:libzstd.a -l:libgdbm.a -l:libreadline.a -l:libtinfo.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:libcrypt.a -l:libanl.a -l:liblzma.a \
85
- #{yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
86
+ #{PatchHelpers.yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
86
87
  SUBST
87
88
  end
88
89
 
@@ -91,7 +92,7 @@ module Tebako
91
92
  -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
92
93
  -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libiberty.a -l:libacl.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
93
94
  -l:libzstd.a -l:libgdbm.a -l:libreadline.a -l:libffi.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:libcrypt.a -l:liblzma.a \
94
- #{yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
95
+ #{PatchHelpers.yaml_reference(ruby_ver)} -l:libboost_system.a -l:libstdc++.a -l:librt.a -ldl -lpthread
95
96
  SUBST
96
97
  end
97
98
 
@@ -100,7 +101,7 @@ module Tebako
100
101
  -l:libtebako-fs.a -l:libdwarfs-wr.a -l:libdwarfs.a -l:libfolly.a -l:libfsst.a -l:libmetadata_thrift.a -l:libthrift_light.a -l:libxxhash.a \
101
102
  -l:libfmt.a -l:libdouble-conversion.a -l:libglog.a -l:libgflags.a -l:libevent.a -l:libssl.a -l:libcrypto.a -l:liblz4.a -l:libz.a \
102
103
  -l:libzstd.a -l:libffi.a -l:libgdbm.a -l:libncurses.a -l:libjemalloc.a -l:libunwind.a -l:liblzma.a -l:libiberty.a \
103
- #{yaml_reference(ruby_ver)} -l:libstdc++.a -l:libdl.a -lole32 -loleaut32 -luuid
104
+ #{PatchHelpers.yaml_reference(ruby_ver)} -l:libstdc++.a -l:libdl.a -lole32 -loleaut32 -luuid
104
105
  SUBST
105
106
  end
106
107
 
@@ -138,14 +139,7 @@ module Tebako
138
139
  end
139
140
 
140
141
  def template_makefile_in_patch(ostype, deps_lib_dir, ruby_ver)
141
- base_patch = {
142
- "LIBS = @LIBS@ $(EXTLIBS)" => <<~SUBST
143
- # -- Start of tebako patch --
144
- LIBS = $(MAINLIBS) @LIBS@
145
- # -- End of tebako patch --
146
- SUBST
147
- }
148
- base_patch.merge!(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
142
+ base_patch = TEMPLATE_MAKEFILE_IN_BASE_PATCH_ONE.merge(mlibs_subst(ostype, deps_lib_dir, ruby_ver))
149
143
  base_patch.merge!(template_makefile_in_patch_two(ruby_ver))
150
144
  end
151
145
 
@@ -52,6 +52,10 @@ module Tebako
52
52
  def ruby32?(ruby_ver)
53
53
  ruby3x?(ruby_ver) && ruby_ver[2].to_i >= 2
54
54
  end
55
+
56
+ def yaml_reference(ruby_ver)
57
+ ruby32?(ruby_ver) ? "-l:libyaml.a" : ""
58
+ end
55
59
  end
56
60
  end
57
61
  end
@@ -168,6 +168,14 @@ module Tebako
168
168
  ["dln.c", "static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;"]
169
169
  ].freeze
170
170
 
171
+ TEMPLATE_MAKEFILE_IN_BASE_PATCH_ONE = {
172
+ "LIBS = @LIBS@ $(EXTLIBS)" => <<~SUBST
173
+ # -- Start of tebako patch --
174
+ LIBS = $(MAINLIBS) @LIBS@
175
+ # -- End of tebako patch --
176
+ SUBST
177
+ }.freeze
178
+
171
179
  TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO_PRE_3_1 =
172
180
  "\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
173
181
  "$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
@@ -199,6 +207,20 @@ module Tebako
199
207
  /* -- End of tebako patch -- */
200
208
  SUBST
201
209
 
210
+ GEM_PRELUDE_RB_PATCH = {
211
+ "if defined?(DidYouMean)" => <<~SUBST
212
+ if defined?(DidYouMean)
213
+
214
+ # -- Start of tebako patch --
215
+ begin
216
+ require 'tebako-runtime'
217
+ rescue LoadError
218
+ warn "'tebako-runtime' was not loaded."
219
+ end
220
+ # -- End of tebako patch --
221
+ SUBST
222
+ }.freeze
223
+
202
224
  MSYS_PATCHES = {
203
225
  "ruby.c" => {
204
226
  "#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))" =>
@@ -42,6 +42,7 @@ module Tebako
42
42
  file.c
43
43
  io.c
44
44
  tool/mkconfig.rb
45
+ gem_prelude.rb
45
46
  ].freeze
46
47
 
47
48
  FILES_TO_RESTORE_MSYS = %w[
@@ -55,6 +56,12 @@ module Tebako
55
56
  thread_pthread.c
56
57
  ].freeze
57
58
 
59
+ DEPLOY_ENV = {
60
+ "GEM_HOME" => nil,
61
+ "GEM_PATH" => nil,
62
+ "TEBAKO_PASS_THROUGH" => "1"
63
+ }.freeze
64
+
58
65
  class << self
59
66
  # Pass1
60
67
  # Executed before Ruby build, patching ensures that Ruby itself is linked statically
@@ -83,7 +90,7 @@ module Tebako
83
90
  # Saves pristine Ruby environment that is used to deploy applications for packaging
84
91
  def stash(src_dir, stash_dir)
85
92
  puts "-- Running stash script"
86
- # .... this code snippet is executed 'outdside' of Ruby scripts
93
+ # .... this code snippet is executed 'outside' of Ruby scripts
87
94
  # shall be reconsidered
88
95
  # FileUtils.cd ruby_source_dir do
89
96
  # puts " ... creating pristine ruby environment at #{src_dir} [patience, it will take some time]"
@@ -98,18 +105,40 @@ module Tebako
98
105
  end
99
106
 
100
107
  # Deploy
101
- # To be extended
102
- # Now it just recreates Ruby prostine environment from stash
103
- def deploy(stash_dir, src_dir, pre_dir, bin_dir)
108
+ def deploy(stash_dir, src_dir, pre_dir, bin_dir, tbd)
104
109
  puts "-- Running deploy script"
105
110
 
106
111
  puts " ... creating packaging environment at #{src_dir}"
107
112
  recreate([src_dir, pre_dir, bin_dir])
108
113
  FileUtils.cp_r "#{stash_dir}/.", src_dir
114
+
115
+ install_gem tbd, "tebako-runtime"
109
116
  end
110
117
 
111
118
  private
112
119
 
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")
124
+ raise Tebako::Error, "Failed to install #{name} (#{st}):\n #{out}" unless st.exitstatus.zero?
125
+ end
126
+ end
127
+
128
+ def do_patch(patch_map, root)
129
+ patch_map.each { |fname, mapping| patch_file("#{root}/#{fname}", mapping) }
130
+ end
131
+
132
+ def patch_file(fname, mapping)
133
+ raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
134
+
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
+
113
142
  def recreate(dirname)
114
143
  FileUtils.rm_rf(dirname, noop: nil, verbose: nil, secure: true)
115
144
  FileUtils.mkdir(dirname)
@@ -132,18 +161,20 @@ module Tebako
132
161
  end
133
162
  end
134
163
 
135
- def patch_file(fname, mapping)
136
- raise Tebako::Error, "Could not patch #{fname} because it does not exist." unless File.exist?(fname)
137
-
138
- puts " ... patching #{fname}"
139
- restore_and_save(fname)
140
- contents = File.read(fname)
141
- mapping.each { |pattern, subst| contents.sub!(pattern, subst) }
142
- File.open(fname, "w") { |file| file << contents }
143
- end
144
-
145
- def do_patch(patch_map, root)
146
- patch_map.each { |fname, mapping| patch_file("#{root}/#{fname}", mapping) }
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] }
177
+ end
147
178
  end
148
179
  end
149
180
  end
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module Tebako
29
- VERSION = "0.5.3"
29
+ VERSION = "0.5.4"
30
30
  end
data/version.txt CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.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.5.3
4
+ version: 0.5.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: 2023-07-18 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -57,7 +57,6 @@ files:
57
57
  - bin/console
58
58
  - bin/setup
59
59
  - cmake/copy_dir.cmake
60
- - cmake/def_tty_colours.cmake
61
60
  - common.env
62
61
  - exe/tebako
63
62
  - exe/tebako-packager
@@ -1,19 +0,0 @@
1
- if(NOT WIN32)
2
- string(ASCII 27 Escape)
3
- set(ColourReset "${Escape}[m")
4
- set(ColourBold "${Escape}[1m")
5
- set(ColourRed "${Escape}[31m")
6
- set(ColourGreen "${Escape}[32m")
7
- set(ColourYellow "${Escape}[33m")
8
- set(ColourBlue "${Escape}[34m")
9
- set(ColourMagenta "${Escape}[35m")
10
- set(ColourCyan "${Escape}[36m")
11
- set(ColourWhite "${Escape}[37m")
12
- set(ColourBoldRed "${Escape}[1;31m")
13
- set(ColourBoldGreen "${Escape}[1;32m")
14
- set(ColourBoldYellow "${Escape}[1;33m")
15
- set(ColourBoldBlue "${Escape}[1;34m")
16
- set(ColourBoldMagenta "${Escape}[1;35m")
17
- set(ColourBoldCyan "${Escape}[1;36m")
18
- set(ColourBoldWhite "${Escape}[1;37m")
19
- endif()