tebako-runtime 0.5.5 → 0.8.0

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -36,6 +36,11 @@ class Jing
36
36
 
37
37
  def initialize(schema, options = nil)
38
38
  original_initialize(TebakoRuntime.extract_memfs(schema, wild: true), options)
39
+ # ruby-jing captures `:default => DEFAULT_JAR` at class-load time —
40
+ # before this adapter replaced the constant with the extracted host
41
+ # path. Force the extracted path per-instance (a nil option hash
42
+ # leaves @options empty, and the builder's stale default would win).
43
+ @options[:jar] = DEFAULT_JAR
39
44
  end
40
45
 
41
46
  def validate(xml)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -29,12 +29,38 @@ require "fileutils"
29
29
  require "pathname"
30
30
  require "rubygems"
31
31
  require "tempfile"
32
+ require "fiddle"
32
33
 
33
34
  require_relative "string"
34
35
 
35
36
  # Module TebakoRuntime
36
37
  # Methods to extract files from memfs to temporary folder
37
38
  module TebakoRuntime
39
+ # The v2 multi-mount world: an extractable path is one HELD by the TFS
40
+ # mounts (the env image at COMPILER_MEMFS, payloads at their declared
41
+ # points) — the compiled-in prefix can no longer express it. The
42
+ # runtime executable's own tebako_fs_stat is the discriminator: it
43
+ # answers only mounted content (0); host paths (and jail-denied ones)
44
+ # answer otherwise. Fiddle::Handle::DEFAULT addresses the process
45
+ # image WITHOUT this gem's own fiddle adapter (dlopen(nil) routes
46
+ # through it and chokes on the nil).
47
+ MEMFS_STAT_FN = begin
48
+ Fiddle::Function.new(Fiddle::Handle::DEFAULT["tebako_fs_stat"],
49
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP], Fiddle::TYPE_INT)
50
+ rescue StandardError
51
+ nil
52
+ end
53
+
54
+ # struct stat is at most 512 bytes on every supported platform
55
+ # (darwin-arm64 and linux x86_64 use 144).
56
+ MEMFS_STAT_BUF = "\0".b * 512
57
+
58
+ def self.embedded_path?(path)
59
+ return path.start_with?(COMPILER_MEMFS) if MEMFS_STAT_FN.nil?
60
+
61
+ MEMFS_STAT_FN.call(path, MEMFS_STAT_BUF).zero? || path.start_with?(COMPILER_MEMFS)
62
+ end
63
+
38
64
  def self.initialize_compiler_memfs_lib_cache
39
65
  Pathname.new(Dir.mktmpdir("tebako-runtime-"))
40
66
  rescue StandardError
@@ -64,7 +90,7 @@ module TebakoRuntime
64
90
  def self.extract_memfs(file, wild: false, cache_path: COMPILER_MEMFS_LIB_CACHE)
65
91
  is_quoted = file.quoted?
66
92
  file = file.unquote if is_quoted
67
- return is_quoted ? file.quote : file unless File.exist?(file) && file.start_with?(COMPILER_MEMFS)
93
+ return is_quoted ? file.quote : file unless File.exist?(file) && embedded_path?(file)
68
94
 
69
95
  memfs_extracted_file = cache_path + File.basename(file)
70
96
  extract(file, wild, cache_path) unless memfs_extracted_file.exist?
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
3
+ # Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -26,5 +26,5 @@
26
26
  # POSSIBILITY OF SUCH DAMAGE.
27
27
 
28
28
  module TebakoRuntime
29
- VERSION = "0.5.5"
29
+ VERSION = "0.8.0"
30
30
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
3
+ # Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
@@ -81,7 +81,7 @@ module TebakoRuntime
81
81
  # Very special deploy-time patching
82
82
  # It targets ffi-compiler/ffi-compiler2 that use some functions of
83
83
  # deployed ffi to process other gems
84
- # THis approach is not compatible with tebako on Windows because ffi
84
+ # This approach is not compatible with tebako on Windows because ffi
85
85
  # is deployed with (implib) reference to target tebako package that is
86
86
  # not available at deploy time
87
87
  def self.process_pass_through(name)
@@ -93,6 +93,13 @@ module TebakoRuntime
93
93
  end
94
94
  res
95
95
  end
96
+
97
+ def self.set_bundle_gemfile
98
+ return if ENV["TEBAKO_PASS_THROUGH"]
99
+
100
+ bundle_gemfile = File.join(COMPILER_MEMFS, ".bundle", "Gemfile")
101
+ ENV["BUNDLE_GEMFILE"] = bundle_gemfile if File.exist?(bundle_gemfile)
102
+ end
96
103
  end
97
104
 
98
105
  # Some would call it 'monkey patching' but in reality we are adding
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Copyright (c) 2023-2024 [Ribose Inc](https://www.ribose.com).
4
4
  # All rights reserved.
5
- # This file is a part of tebako
5
+ # This file is a part of the Tebako project.
6
6
  #
7
7
  # Redistribution and use in source and binary forms, with or without
8
8
  # modification, are permitted provided that the following conditions
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tebako-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rspec
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  requirements: []
246
- rubygems_version: 3.6.2
246
+ rubygems_version: 3.6.9
247
247
  specification_version: 4
248
248
  summary: Run-time support of tebako executable packager
249
249
  test_files: []