tebako-runtime 0.4.2 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +14 -9
- data/lib/tebako-runtime/memfs.rb +1 -1
- data/lib/tebako-runtime/pass-through/ffi-platform-stub.rb +102 -0
- data/lib/tebako-runtime/pre/excavate.rb +31 -0
- data/lib/tebako-runtime/pre/seven-zip.rb +3 -2
- data/lib/tebako-runtime/version.rb +1 -1
- data/lib/tebako-runtime.rb +31 -6
- data/tebako-runtime.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '097d5286d2407698d42ea62673f8ecb003f02ec6977d980ea399f7b50fbb97e5'
|
4
|
+
data.tar.gz: a7983b403f626a3f6b92a0f8d893fccadf4933c03cf13b2ebb306f221be20cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aba554f750356e8445d4cc0f4dc4d41b5af24058ebda5a7d6c1ac7ddadd82a5032903b6411023a61369def5e904b02ac71b2395a64f8e08624cb8eb5ec4ecbec
|
7
|
+
data.tar.gz: 6f9ff5b865e68681dec9dc25cf7211c7e0c733e126c734be496a00bf168bfd00c4625df26fccfd367ce68895148e2a0e6a96a4d08be7a8a526b1c08d722456b1
|
data/Rakefile
CHANGED
@@ -35,14 +35,17 @@ require "fileutils"
|
|
35
35
|
namespace :build do
|
36
36
|
desc "Download cacert.pem"
|
37
37
|
task :download_cacert do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
unless File.exist?("lib/cert/cacert.pem.mozilla")
|
39
|
+
|
40
|
+
url = URI("https://curl.se/ca/cacert.pem")
|
41
|
+
FileUtils.mkdir_p("lib/cert")
|
42
|
+
Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == "https") do |http|
|
43
|
+
request = Net::HTTP::Get.new url
|
44
|
+
http.request request do |response|
|
45
|
+
open "lib/cert/cacert.pem.mozilla", "w" do |io|
|
46
|
+
response.read_body do |chunk|
|
47
|
+
io.write chunk
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
@@ -52,7 +55,9 @@ end
|
|
52
55
|
|
53
56
|
task build: "build:download_cacert"
|
54
57
|
|
55
|
-
task
|
58
|
+
task spec: "build:download_cacert"
|
59
|
+
|
60
|
+
task default: :spec
|
56
61
|
|
57
62
|
RSpec::Core::RakeTask.new(:spec)
|
58
63
|
RuboCop::RakeTask.new
|
data/lib/tebako-runtime/memfs.rb
CHANGED
@@ -35,7 +35,7 @@ require_relative "string"
|
|
35
35
|
# Module TebakoRuntime
|
36
36
|
# Methods to extract files from memfs to temporary folder
|
37
37
|
module TebakoRuntime
|
38
|
-
COMPILER_MEMFS = RUBY_PLATFORM =~ /
|
38
|
+
COMPILER_MEMFS = RUBY_PLATFORM =~ /mswin|mingw/ ? "A:/__tebako_memfs__" : "/__tebako_memfs__"
|
39
39
|
COMPILER_MEMFS_LIB_CACHE = Pathname.new(Dir.mktmpdir("tebako-runtime-"))
|
40
40
|
|
41
41
|
class << self
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions
|
9
|
+
# are met:
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
module FFI
|
29
|
+
module Platform
|
30
|
+
ARCH = case RbConfig::CONFIG["host_cpu"].downcase
|
31
|
+
when /amd64|x86_64|x64/
|
32
|
+
"x86_64"
|
33
|
+
when /i\d86|x86|i86pc/
|
34
|
+
"i386"
|
35
|
+
when /ppc64|powerpc64/
|
36
|
+
"powerpc64"
|
37
|
+
when /ppc|powerpc/
|
38
|
+
"powerpc"
|
39
|
+
when /sparcv9|sparc64/
|
40
|
+
"sparcv9"
|
41
|
+
when /arm64|aarch64/ # MacOS calls it "arm64", other operating systems "aarch64"
|
42
|
+
"aarch64"
|
43
|
+
when /^arm/
|
44
|
+
if OS == "darwin" # Ruby before 3.0 reports "arm" instead of "arm64" as host_cpu on darwin
|
45
|
+
"aarch64"
|
46
|
+
else
|
47
|
+
"arm"
|
48
|
+
end
|
49
|
+
else
|
50
|
+
RbConfig::CONFIG["host_cpu"].downcase
|
51
|
+
end
|
52
|
+
|
53
|
+
OS =
|
54
|
+
case RbConfig::CONFIG["host_os"].downcase
|
55
|
+
when /linux/
|
56
|
+
"linux"
|
57
|
+
when /darwin/
|
58
|
+
"darwin"
|
59
|
+
when /freebsd/
|
60
|
+
"freebsd"
|
61
|
+
when /netbsd/
|
62
|
+
"netbsd"
|
63
|
+
when /openbsd/
|
64
|
+
"openbsd"
|
65
|
+
when /dragonfly/
|
66
|
+
"dragonflybsd"
|
67
|
+
when /sunos|solaris/
|
68
|
+
"solaris"
|
69
|
+
when /mingw|mswin/
|
70
|
+
"windows"
|
71
|
+
else
|
72
|
+
RbConfig::CONFIG["host_os"].downcase
|
73
|
+
end
|
74
|
+
|
75
|
+
LIBPREFIX = case OS
|
76
|
+
when /windows|msys/
|
77
|
+
""
|
78
|
+
when /cygwin/
|
79
|
+
"cyg"
|
80
|
+
else
|
81
|
+
"lib"
|
82
|
+
end
|
83
|
+
|
84
|
+
LIBSUFFIX = case OS
|
85
|
+
when /darwin/
|
86
|
+
"dylib"
|
87
|
+
when /windows|cygwin|msys/
|
88
|
+
"dll"
|
89
|
+
else
|
90
|
+
# Punt and just assume a sane unix (i.e. anything but AIX)
|
91
|
+
# when /linux|bsd|solaris/
|
92
|
+
# "so"
|
93
|
+
"so"
|
94
|
+
end
|
95
|
+
|
96
|
+
PASS_THROUGH = true
|
97
|
+
|
98
|
+
def self.mac?
|
99
|
+
RUBY_PLATFORM =~ /darwin/
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 [Ribose Inc](https://www.ribose.com).
|
4
|
+
# All rights reserved.
|
5
|
+
# This file is a part of tebako
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions
|
9
|
+
# are met:
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
27
|
+
|
28
|
+
# For some reason on Windows an attempt to require "seven_zip_ruby" from excavate fails
|
29
|
+
# I cannot debug it effectively because of https://github.com/tamatebako/tebako/issues/119
|
30
|
+
|
31
|
+
require "seven_zip_ruby"
|
@@ -32,10 +32,11 @@ require_relative "../../tebako-runtime"
|
|
32
32
|
module TebakoRuntime
|
33
33
|
sevenz_lib = RUBY_PLATFORM.downcase.match(/mswin|mingw/) ? "7z*.dll" : "7z.so"
|
34
34
|
sevenz_path = File.join(full_gem_path("seven-zip"), "lib", "seven_zip_ruby", sevenz_lib)
|
35
|
+
sevenz_paths = Dir.glob(sevenz_path)
|
35
36
|
sevenz_new_folder = COMPILER_MEMFS_LIB_CACHE / "seven_zip_ruby"
|
36
37
|
FileUtils.mkdir_p(sevenz_new_folder)
|
37
|
-
|
38
|
+
sevenz_paths.each do |file|
|
38
39
|
FileUtils.cp(file, sevenz_new_folder)
|
39
40
|
end
|
40
|
-
$LOAD_PATH.unshift(COMPILER_MEMFS_LIB_CACHE)
|
41
|
+
$LOAD_PATH.unshift(COMPILER_MEMFS_LIB_CACHE.to_s)
|
41
42
|
end
|
data/lib/tebako-runtime.rb
CHANGED
@@ -37,6 +37,7 @@ require_relative "tebako-runtime/memfs"
|
|
37
37
|
# - an option to implement adapter 'AFTER'
|
38
38
|
module TebakoRuntime
|
39
39
|
PRE_REQUIRE_MAP = {
|
40
|
+
"excavate" => "tebako-runtime/pre/excavate",
|
40
41
|
"seven_zip_ruby" => "tebako-runtime/pre/seven-zip"
|
41
42
|
}.freeze
|
42
43
|
|
@@ -65,6 +66,31 @@ module TebakoRuntime
|
|
65
66
|
puts "Tebako runtime: skipped [#{name}]" if log_enabled && !res_inner
|
66
67
|
log_enabled
|
67
68
|
end
|
69
|
+
|
70
|
+
def self.process_all(name)
|
71
|
+
f1 = process(name, PRE_REQUIRE_MAP, "pre")
|
72
|
+
res = original_require name
|
73
|
+
f2 = process(name, POST_REQUIRE_MAP, "post")
|
74
|
+
|
75
|
+
puts "Tebako runtime: req [#{name}]" unless f1 || f2
|
76
|
+
res
|
77
|
+
end
|
78
|
+
|
79
|
+
# Very special deploy-time patching
|
80
|
+
# It targets ffi-compiler/ffi-compiler2 that use some functions of
|
81
|
+
# deployed ffi to process other gems
|
82
|
+
# THis approach is not compatible with tebako on Windows because ffi
|
83
|
+
# is deployed with (implib) reference to target tebako package that is
|
84
|
+
# not available at deploy time
|
85
|
+
def self.process_pass_through(name)
|
86
|
+
if name == "ffi" && RUBY_PLATFORM =~ /mswin|mingw/
|
87
|
+
puts "Replacing ffi ffi-platform-stub" if log_enabled
|
88
|
+
res = original_require "tebako-runtime/pass-through/ffi-platform-stub"
|
89
|
+
else
|
90
|
+
res = original_require name
|
91
|
+
end
|
92
|
+
res
|
93
|
+
end
|
68
94
|
end
|
69
95
|
|
70
96
|
# Some would call it 'monkey patching' but in reality we are adding
|
@@ -72,11 +98,10 @@ end
|
|
72
98
|
module Kernel
|
73
99
|
alias original_require require
|
74
100
|
def require(name)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
res
|
101
|
+
if ENV["TEBAKO_PASS_THROUGH"]
|
102
|
+
TebakoRuntime.process_pass_through name
|
103
|
+
else
|
104
|
+
TebakoRuntime.process_all name
|
105
|
+
end
|
81
106
|
end
|
82
107
|
end
|
data/tebako-runtime.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tebako-runtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -160,6 +160,8 @@ files:
|
|
160
160
|
- lib/tebako-runtime/adapters/net-http.rb
|
161
161
|
- lib/tebako-runtime/adapters/sassc.rb
|
162
162
|
- lib/tebako-runtime/memfs.rb
|
163
|
+
- lib/tebako-runtime/pass-through/ffi-platform-stub.rb
|
164
|
+
- lib/tebako-runtime/pre/excavate.rb
|
163
165
|
- lib/tebako-runtime/pre/seven-zip.rb
|
164
166
|
- lib/tebako-runtime/string.rb
|
165
167
|
- lib/tebako-runtime/version.rb
|
@@ -185,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
187
|
- !ruby/object:Gem::Version
|
186
188
|
version: '0'
|
187
189
|
requirements: []
|
188
|
-
rubygems_version: 3.5.
|
190
|
+
rubygems_version: 3.5.11
|
189
191
|
signing_key:
|
190
192
|
specification_version: 4
|
191
193
|
summary: Run-time support of tebako executable packager
|