rbe-tebako 0.15.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.
- checksums.yaml +7 -0
- data/.clang-format +4 -0
- data/Brewfile +23 -0
- data/CMakeLists.txt +464 -0
- data/CODE_OF_CONDUCT.adoc +128 -0
- data/CONTRIBUTING.adoc +294 -0
- data/Gemfile +31 -0
- data/INSTALLATION.adoc +233 -0
- data/LICENSE.md +33 -0
- data/README.adoc +1363 -0
- data/Rakefile +35 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/cmake/copy_dir.cmake +29 -0
- data/common.env +5 -0
- data/exe/rbe-tebako +32 -0
- data/exe/rbe-tebako-packager +77 -0
- data/include/tebako/tebako-fs.h +43 -0
- data/include/tebako/tebako-main.h +42 -0
- data/include/tebako/tebako-prism.h +51 -0
- data/lib/rbe-tebako.rb +6 -0
- data/lib/tebako/build_helpers.rb +77 -0
- data/lib/tebako/cache_manager.rb +112 -0
- data/lib/tebako/cli.rb +220 -0
- data/lib/tebako/cli_helpers.rb +165 -0
- data/lib/tebako/codegen.rb +252 -0
- data/lib/tebako/deploy_helper.rb +258 -0
- data/lib/tebako/error.rb +70 -0
- data/lib/tebako/options_manager.rb +338 -0
- data/lib/tebako/package_descriptor.rb +143 -0
- data/lib/tebako/packager/pass1_patch.rb +266 -0
- data/lib/tebako/packager/pass1a_patch.rb +55 -0
- data/lib/tebako/packager/pass2_patch.rb +140 -0
- data/lib/tebako/packager/pass2_patch_crt.rb +46 -0
- data/lib/tebako/packager/pass2msys_patch.rb +190 -0
- data/lib/tebako/packager/patch.rb +54 -0
- data/lib/tebako/packager/patch_buildsystem.rb +124 -0
- data/lib/tebako/packager/patch_helpers.rb +109 -0
- data/lib/tebako/packager/patch_libraries.rb +188 -0
- data/lib/tebako/packager/patch_literals.rb +275 -0
- data/lib/tebako/packager/patch_main.rb +93 -0
- data/lib/tebako/packager/rubygems_patch.rb +83 -0
- data/lib/tebako/packager.rb +210 -0
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/ruby_builder.rb +71 -0
- data/lib/tebako/ruby_version.rb +206 -0
- data/lib/tebako/scenario_manager.rb +251 -0
- data/lib/tebako/stripper.rb +135 -0
- data/lib/tebako/version.rb +30 -0
- data/lib/tebako.rb +34 -0
- data/src/tebako-main.cpp +168 -0
- data/tools/.gitattributes +4 -0
- data/tools/.github/workflows/build-containers.yml +190 -0
- data/tools/.github/workflows/lint.yml +41 -0
- data/tools/.github/workflows/test.yml +331 -0
- data/tools/.gitignore +1 -0
- data/tools/README.md +49 -0
- data/tools/ci-scripts/arm-brew-install.sh +43 -0
- data/tools/ci-scripts/arm-brew-setup.sh +33 -0
- data/tools/ci-scripts/level-up.sh +35 -0
- data/tools/ci-scripts/patch-fbthrift.sh +94 -0
- data/tools/ci-scripts/patch-folly.sh +551 -0
- data/tools/ci-scripts/patch-glog.sh +57 -0
- data/tools/ci-scripts/patch-zstd.sh +57 -0
- data/tools/ci-scripts/tools.sh +63 -0
- data/tools/ci-scripts/x86-brew-install.sh +43 -0
- data/tools/ci-scripts/x86-brew-setup.sh +33 -0
- data/tools/cmake-scripts/def-external-project.cmake +96 -0
- data/tools/cmake-scripts/macos-environment.cmake +91 -0
- data/tools/cmake-scripts/msys-environment.cmake +78 -0
- data/tools/cmake-scripts/setup-libarchive.cmake +93 -0
- data/tools/cmake-scripts/setup-libfmt.cmake +61 -0
- data/tools/cmake-scripts/setup-libhowardhinnerdate.cmake +55 -0
- data/tools/cmake-scripts/setup-libutfcpp.cmake +56 -0
- data/tools/cmake-scripts/version.cmake +162 -0
- data/tools/docker/alpine-3.17-dev.Dockerfile +49 -0
- data/tools/docker/tools/tools.sh +66 -0
- data/tools/docker/ubuntu-20.04-dev.Dockerfile +51 -0
- data/tools/dwarfs-test-helper/CMakeLists.txt +34 -0
- data/tools/include/pro-statvfs.h +57 -0
- data/tools/tests/cmake/CMakeLists.txt +81 -0
- data/tools/tests/setup-libfmt/CMakeLists.txt +35 -0
- data/tools/tests/setup-libhowardhinnerdate/CMakeLists.txt +35 -0
- data/tools/tests/setup-librachive/CMakeLists.txt +35 -0
- data/tools/tests/setup-libutfcpp/CMakeLists.txt +36 -0
- data/tools/tests/setup-openssl/CMakeLists.txt +36 -0
- metadata +312 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2024-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
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
|
+
require "fileutils"
|
|
29
|
+
require "find"
|
|
30
|
+
|
|
31
|
+
require_relative "packager/patch_helpers"
|
|
32
|
+
|
|
33
|
+
# Tebako - an executable packager
|
|
34
|
+
module Tebako
|
|
35
|
+
# Tebako packaging support (stripper)
|
|
36
|
+
module Stripper
|
|
37
|
+
DELETE_EXTENSIONS = %w[o lo obj a la lib].freeze
|
|
38
|
+
BIN_FILES = %w[
|
|
39
|
+
bundle bundler rbs erb gem irb racc racc2y
|
|
40
|
+
rake rdoc ri y2racc rdbg syntax_suggest typeprof
|
|
41
|
+
].freeze
|
|
42
|
+
CMD_SUFFIX = ".cmd"
|
|
43
|
+
BAT_SUFFIX = ".bat"
|
|
44
|
+
|
|
45
|
+
class << self
|
|
46
|
+
# Strip
|
|
47
|
+
# Removes build artefacts, strip shared objects
|
|
48
|
+
def strip(scm, src_dir)
|
|
49
|
+
puts " ... stripping the output"
|
|
50
|
+
strip_bs(src_dir)
|
|
51
|
+
strip_dsym(src_dir) if scm.macos?
|
|
52
|
+
strip_fi(scm, src_dir)
|
|
53
|
+
strip_li(scm, src_dir)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Remove macOS .dSYM debug companions before stripping. They are external debug info
|
|
57
|
+
# (useless in the packaged memfs) and the DWARF Mach-O inside them is named "<ext>.bundle",
|
|
58
|
+
# so strip_li would try to `strip -S` it and fail with
|
|
59
|
+
# "string table not at the end of the file (can't be processed)".
|
|
60
|
+
def strip_dsym(src_dir)
|
|
61
|
+
Dir.glob(File.join(src_dir, "**", "*.dSYM")).each { |d| FileUtils.rm_rf(d) }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def strip_file(file_in, file_out = nil)
|
|
65
|
+
params = ["strip", "-S", file_in]
|
|
66
|
+
params << "-o" << file_out unless file_out.nil?
|
|
67
|
+
out, st = Open3.capture2e(*params)
|
|
68
|
+
|
|
69
|
+
# Some gems (well, libmspack) has bundled extensions for several architectures)
|
|
70
|
+
# Getting something like:
|
|
71
|
+
# strip: Unable to recognise the format of the input file
|
|
72
|
+
# `/tmp/cirrus-ci-build/o/s/lib/ruby/gems/3.1.0/gems/libmspack-0.11.0/ext/x86_64-linux/libmspack.so'
|
|
73
|
+
# on aarch64
|
|
74
|
+
|
|
75
|
+
puts "Warning: could not strip #{file_in}:\n #{out}" unless st.exitstatus.zero?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# `strip` drops the Mach-O code signature. On macOS (notably >= 26) the dynamic loader
|
|
79
|
+
# SIGKILLs any dlopen of an unsigned / invalidly-signed .bundle/.dylib with
|
|
80
|
+
# "Code Signature Invalid" — and tebako dlopens native extensions extracted from the
|
|
81
|
+
# memfs at runtime. Re-apply an ad-hoc signature so the stripped extensions still load.
|
|
82
|
+
def resign_macho(file)
|
|
83
|
+
_out, st = Open3.capture2e("codesign", "--force", "--sign", "-", file)
|
|
84
|
+
puts "Warning: could not ad-hoc re-sign #{file}" unless st.exitstatus.zero?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def get_files(scm)
|
|
90
|
+
exe_suffix = scm.exe_suffix
|
|
91
|
+
files = BIN_FILES.flat_map do |f|
|
|
92
|
+
[f, "#{f}#{CMD_SUFFIX}", "#{f}#{BAT_SUFFIX}"]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
files += ["ruby#{exe_suffix}", "rubyw#{exe_suffix}"]
|
|
96
|
+
files
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def strip_bs(src_dir)
|
|
100
|
+
FileUtils.rm_rf([
|
|
101
|
+
File.join(src_dir, "share"),
|
|
102
|
+
File.join(src_dir, "include"),
|
|
103
|
+
File.join(src_dir, "lib", "pkgconfig")
|
|
104
|
+
])
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def strip_fi(scm, src_dir)
|
|
108
|
+
files = get_files(scm).map { |f| "#{src_dir}/bin/#{f}" }
|
|
109
|
+
FileUtils.rm(files, force: true)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def strip_li(scm, src_dir)
|
|
113
|
+
sext = strip_extensions(scm)
|
|
114
|
+
Find.find(src_dir) do |file|
|
|
115
|
+
next if File.directory?(file)
|
|
116
|
+
|
|
117
|
+
extension = File.extname(file).delete_prefix(".").downcase
|
|
118
|
+
if DELETE_EXTENSIONS.include?(extension)
|
|
119
|
+
FileUtils.rm(file)
|
|
120
|
+
elsif sext.include?(extension)
|
|
121
|
+
strip_file(file)
|
|
122
|
+
resign_macho(file) if scm.macos?
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def strip_extensions(scm)
|
|
128
|
+
sext = ["so"]
|
|
129
|
+
sext << "dll" if scm.msys?
|
|
130
|
+
sext << "dylib" << "bundle" if scm.macos?
|
|
131
|
+
sext
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
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 Tebako
|
|
29
|
+
VERSION = "0.15.0"
|
|
30
|
+
end
|
data/lib/tebako.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
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
|
+
# Tebako - an executable packager
|
|
29
|
+
# Core module
|
|
30
|
+
module Tebako
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
require_relative "tebako/version"
|
|
34
|
+
require_relative "tebako/error"
|
data/src/tebako-main.cpp
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2021-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* This file is a part of the Tebako project.
|
|
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
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include <unistd.h>
|
|
31
|
+
#include <stdlib.h>
|
|
32
|
+
#include <stdio.h>
|
|
33
|
+
#include <string.h>
|
|
34
|
+
#include <memory.h>
|
|
35
|
+
#include <sys/stat.h>
|
|
36
|
+
#include <fcntl.h>
|
|
37
|
+
#include <stdint.h>
|
|
38
|
+
|
|
39
|
+
#include <string>
|
|
40
|
+
#include <cstdint>
|
|
41
|
+
#include <vector>
|
|
42
|
+
#include <stdexcept>
|
|
43
|
+
#include <tuple>
|
|
44
|
+
|
|
45
|
+
#ifdef _WIN32
|
|
46
|
+
#include <winsock2.h>
|
|
47
|
+
#include <windows.h>
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#include <tebako/tebako-config.h>
|
|
51
|
+
#include <tebako/tebako-io.h>
|
|
52
|
+
|
|
53
|
+
#include <tebako/tebako-version.h>
|
|
54
|
+
#include <tebako/tebako-main.h>
|
|
55
|
+
#include <tebako/tebako-fs.h>
|
|
56
|
+
#include <tebako/tebako-cmdline.h>
|
|
57
|
+
|
|
58
|
+
static int running_miniruby = 0;
|
|
59
|
+
static tebako::cmdline_args* args = nullptr;
|
|
60
|
+
static std::vector<char> package;
|
|
61
|
+
|
|
62
|
+
static void tebako_clean(void)
|
|
63
|
+
{
|
|
64
|
+
unmount_root_memfs();
|
|
65
|
+
if (args) {
|
|
66
|
+
delete args;
|
|
67
|
+
args = nullptr;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
extern "C" int tebako_main(int* argc, char*** argv)
|
|
72
|
+
{
|
|
73
|
+
int ret = -1, fsret = -1;
|
|
74
|
+
char** new_argv = nullptr;
|
|
75
|
+
char* argv_memory = nullptr;
|
|
76
|
+
|
|
77
|
+
if (strstr((*argv)[0], "miniruby") != nullptr) {
|
|
78
|
+
// Ruby build script is designed in such a way that this patch is also applied towards miniruby
|
|
79
|
+
// Just pass through in such case
|
|
80
|
+
ret = 0;
|
|
81
|
+
running_miniruby = -1;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
std::string mount_point = tebako::fs_mount_point;
|
|
85
|
+
std::string entry_point = tebako::fs_entry_point;
|
|
86
|
+
std::optional<std::string> cwd;
|
|
87
|
+
if (tebako::package_cwd != nullptr) {
|
|
88
|
+
cwd = tebako::package_cwd;
|
|
89
|
+
}
|
|
90
|
+
const void* data = &gfsData[0];
|
|
91
|
+
size_t size = gfsSize;
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
args = new tebako::cmdline_args(*argc, (const char**)*argv);
|
|
95
|
+
args->parse_arguments();
|
|
96
|
+
if (args->with_application()) {
|
|
97
|
+
args->process_package();
|
|
98
|
+
auto descriptor = args->get_descriptor();
|
|
99
|
+
package = std::move(args->get_package());
|
|
100
|
+
if (descriptor.has_value()) {
|
|
101
|
+
mount_point = descriptor->get_mount_point().c_str();
|
|
102
|
+
entry_point = descriptor->get_entry_point().c_str();
|
|
103
|
+
cwd = descriptor->get_cwd();
|
|
104
|
+
data = package.data();
|
|
105
|
+
size = package.size();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fsret = mount_root_memfs(data, size, tebako::fs_log_level, nullptr, nullptr, nullptr, nullptr, "auto");
|
|
110
|
+
if (fsret == 0) {
|
|
111
|
+
args->process_mountpoints();
|
|
112
|
+
args->build_arguments(mount_point.c_str(), entry_point.c_str());
|
|
113
|
+
*argc = args->get_argc();
|
|
114
|
+
*argv = args->get_argv();
|
|
115
|
+
ret = 0;
|
|
116
|
+
atexit(tebako_clean);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (std::exception e) {
|
|
120
|
+
printf("Failed to process command line: %s\n", e.what());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (getcwd(tebako::original_cwd, sizeof(tebako::original_cwd)) == nullptr) {
|
|
124
|
+
printf("Failed to get current directory: %s\n", strerror(errno));
|
|
125
|
+
ret = -1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (cwd.has_value()) {
|
|
129
|
+
if (tebako_chdir(cwd->c_str()) != 0) {
|
|
130
|
+
printf("Failed to chdir to '%s' : %s\n", cwd->c_str(), strerror(errno));
|
|
131
|
+
ret = -1;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (ret != 0) {
|
|
137
|
+
try {
|
|
138
|
+
printf("Tebako initialization failed\n");
|
|
139
|
+
tebako_clean();
|
|
140
|
+
}
|
|
141
|
+
catch (...) {
|
|
142
|
+
// Nested error, no recovery :(
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return ret;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
extern "C" const char* tebako_mount_point(void)
|
|
149
|
+
{
|
|
150
|
+
return tebako::fs_mount_point;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
extern "C" const char* tebako_original_pwd(void)
|
|
154
|
+
{
|
|
155
|
+
return tebako::original_cwd;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
extern "C" int tebako_is_running_miniruby(void)
|
|
159
|
+
{
|
|
160
|
+
return running_miniruby;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
#ifdef RB_W32_PRE_33
|
|
164
|
+
extern "C" ssize_t rb_w32_pread(int /* fd */, void* /* buf */, size_t /* size */, size_t /* offset */)
|
|
165
|
+
{
|
|
166
|
+
return -1;
|
|
167
|
+
}
|
|
168
|
+
#endif
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Copyright (c) 2025 [Ribose Inc](https://www.ribose.com).
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
# This file is a part of the Tebako project.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions
|
|
7
|
+
# are met:
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
# notice, this list of conditions and the following disclaimer.
|
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
# documentation and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
16
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
18
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
name: build-containers
|
|
27
|
+
|
|
28
|
+
on:
|
|
29
|
+
workflow_dispatch:
|
|
30
|
+
inputs:
|
|
31
|
+
next_version:
|
|
32
|
+
description: |
|
|
33
|
+
Next container version: x.y.z or major/minor/patch
|
|
34
|
+
required: true
|
|
35
|
+
default: 'patch'
|
|
36
|
+
push:
|
|
37
|
+
description: |
|
|
38
|
+
Push the container images to the registry
|
|
39
|
+
required: false
|
|
40
|
+
default: 'false'
|
|
41
|
+
|
|
42
|
+
concurrency:
|
|
43
|
+
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
|
|
44
|
+
cancel-in-progress: true
|
|
45
|
+
|
|
46
|
+
jobs:
|
|
47
|
+
build-containers:
|
|
48
|
+
name: ${{ matrix.container }} ${{ matrix.architecture.platform }}
|
|
49
|
+
runs-on: ${{ matrix.architecture.host }}
|
|
50
|
+
permissions:
|
|
51
|
+
contents: read
|
|
52
|
+
packages: write
|
|
53
|
+
strategy:
|
|
54
|
+
fail-fast: false
|
|
55
|
+
matrix:
|
|
56
|
+
container:
|
|
57
|
+
- 'ubuntu-20.04-dev'
|
|
58
|
+
- 'alpine-3.17-dev'
|
|
59
|
+
architecture:
|
|
60
|
+
- { host: 'ubuntu-22.04', platform: linux/amd64, suffix: 'x64', suffix2: 'amd64' }
|
|
61
|
+
- { host: 'ubuntu-22.04-arm', platform: linux/arm64, suffix: 'arm64', suffix2: 'arm64' }
|
|
62
|
+
|
|
63
|
+
outputs:
|
|
64
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
65
|
+
|
|
66
|
+
steps:
|
|
67
|
+
- name: Checkout
|
|
68
|
+
uses: actions/checkout@v4
|
|
69
|
+
with:
|
|
70
|
+
fetch-depth: 0
|
|
71
|
+
|
|
72
|
+
- name: Set GITHUB_REF
|
|
73
|
+
if: github.event_name == 'workflow_dispatch'
|
|
74
|
+
run: |
|
|
75
|
+
if [[ "${{ github.event.inputs.next_version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
76
|
+
# Direct version number provided
|
|
77
|
+
VERSION="${{ github.event.inputs.next_version }}"
|
|
78
|
+
echo "Using provided version: $VERSION"
|
|
79
|
+
elif [[ "${{ github.event.inputs.next_version }}" == "major" || "${{ github.event.inputs.next_version }}" == "minor" || "${{ github.event.inputs.next_version }}" == "patch" ]]; then
|
|
80
|
+
# Get latest version tag
|
|
81
|
+
LATEST_TAG=$(git tag --sort=-v:refname | grep -v '\.rc[0-9]\+$' | head -n 1)
|
|
82
|
+
LATEST_VERSION=${LATEST_TAG#v}
|
|
83
|
+
|
|
84
|
+
# Split the version numbers
|
|
85
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
|
|
86
|
+
|
|
87
|
+
# Calculate the next version based on the increment type
|
|
88
|
+
if [[ "${{ github.event.inputs.next_version }}" == "major" ]]; then
|
|
89
|
+
VERSION="$((MAJOR + 1)).0.0"
|
|
90
|
+
elif [[ "${{ github.event.inputs.next_version }}" == "minor" ]]; then
|
|
91
|
+
VERSION="${MAJOR}.$((MINOR + 1)).0"
|
|
92
|
+
else
|
|
93
|
+
VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
|
|
94
|
+
fi
|
|
95
|
+
echo "Calculated next ${{ github.event.inputs.next_version }} version: $VERSION"
|
|
96
|
+
else
|
|
97
|
+
echo "::error::Invalid version format. Please use semantic version (x.y.z) or specify 'major', 'minor', or 'patch'"
|
|
98
|
+
exit 1
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
TAG="v$VERSION"
|
|
102
|
+
echo "Setting VERSION to $VERSION"
|
|
103
|
+
echo "Setting GITHUB_REF to refs/tags/$TAG"
|
|
104
|
+
echo "GITHUB_REF=refs/tags/$TAG" >> $GITHUB_ENV
|
|
105
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
106
|
+
|
|
107
|
+
- name: Log in to the Container registry
|
|
108
|
+
uses: docker/login-action@v3
|
|
109
|
+
with:
|
|
110
|
+
registry: ghcr.io
|
|
111
|
+
username: ${{ github.repository_owner }}
|
|
112
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
113
|
+
|
|
114
|
+
- name: Docker meta
|
|
115
|
+
id: meta
|
|
116
|
+
uses: docker/metadata-action@v5
|
|
117
|
+
with:
|
|
118
|
+
images: |
|
|
119
|
+
ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}
|
|
120
|
+
tags: |
|
|
121
|
+
type=semver,pattern={{version}}-${{ matrix.architecture.suffix2 }},value=${{ env.VERSION }}
|
|
122
|
+
type=semver,pattern={{major}}.{{minor}}-${{ matrix.architecture.suffix2 }},value=${{ env.VERSION }}
|
|
123
|
+
type=semver,pattern={{major}}-${{ matrix.architecture.suffix2 }},value=${{ env.VERSION }}
|
|
124
|
+
type=sha,suffix=-${{ matrix.architecture.suffix2 }}
|
|
125
|
+
labels: |
|
|
126
|
+
org.opencontainers.image.vendor=Ribose Inc.
|
|
127
|
+
org.opencontainers.image.licenses=BSD-2-Clause
|
|
128
|
+
org.opencontainers.image.documentation=https://www.tamatebako.org
|
|
129
|
+
org.opencontainers.image.source==${{ github.repositoryUrl }}
|
|
130
|
+
org.opencontainers.image.description=Tebako executable packager ${{ matrix.container }} ${{ matrix.architecture.platform }} development container
|
|
131
|
+
annotations: |
|
|
132
|
+
org.opencontainers.image.licenses=BSD-2-Clause
|
|
133
|
+
org.opencontainers.image.description=Tebako executable packager ${{ matrix.container }} ${{ matrix.architecture.platform }} development container
|
|
134
|
+
|
|
135
|
+
- name: Build and push Docker image
|
|
136
|
+
uses: docker/build-push-action@v6
|
|
137
|
+
with:
|
|
138
|
+
context: docker
|
|
139
|
+
file: docker/${{ matrix.container }}.Dockerfile
|
|
140
|
+
push: ${{ github.event.inputs.push == 'true' }}
|
|
141
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
142
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
143
|
+
annotations: ${{ steps.meta.outputs.annotations }}
|
|
144
|
+
platforms: ${{ matrix.architecture.platform }}
|
|
145
|
+
build-args: ARCH=${{ matrix.architecture.suffix }}
|
|
146
|
+
|
|
147
|
+
create-manifests:
|
|
148
|
+
name: Create multiarchitecture manifests for ${{ matrix.container }}
|
|
149
|
+
if: ${{ github.event.inputs.push == 'true' }}
|
|
150
|
+
runs-on: ubuntu-22.04
|
|
151
|
+
needs: build-containers
|
|
152
|
+
permissions:
|
|
153
|
+
contents: read
|
|
154
|
+
packages: write
|
|
155
|
+
strategy:
|
|
156
|
+
fail-fast: false
|
|
157
|
+
matrix:
|
|
158
|
+
container:
|
|
159
|
+
- 'ubuntu-20.04-dev'
|
|
160
|
+
- 'alpine-3.17-dev'
|
|
161
|
+
steps:
|
|
162
|
+
- name: Log in to the Container registry
|
|
163
|
+
uses: docker/login-action@v3
|
|
164
|
+
with:
|
|
165
|
+
registry: ghcr.io
|
|
166
|
+
username: ${{ github.repository_owner }}
|
|
167
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
168
|
+
|
|
169
|
+
- name: Create multiarchitecture manifests and push
|
|
170
|
+
run: |
|
|
171
|
+
for tag in $(echo "${{ needs.build-containers.outputs.tags }}" | tr ',' '\n'); do
|
|
172
|
+
if [[ $tag != *:latest ]]; then
|
|
173
|
+
base_tag=$(echo $tag | sed -E 's/.*:(.*)-(amd64|arm64)/\1/')
|
|
174
|
+
echo "Processing $tag, using base tag $base_tag"
|
|
175
|
+
docker manifest create \
|
|
176
|
+
ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag \
|
|
177
|
+
--amend ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag-amd64 \
|
|
178
|
+
--amend ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag-arm64
|
|
179
|
+
docker manifest push ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag
|
|
180
|
+
|
|
181
|
+
if [[ $base_tag == sha* ]]; then
|
|
182
|
+
docker manifest push ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag
|
|
183
|
+
docker manifest create \
|
|
184
|
+
ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:latest \
|
|
185
|
+
--amend ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag-amd64 \
|
|
186
|
+
--amend ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:$base_tag-arm64
|
|
187
|
+
docker manifest push ghcr.io/${{ github.repository_owner }}/tebako-${{ matrix.container }}:latest
|
|
188
|
+
fi
|
|
189
|
+
fi
|
|
190
|
+
done
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (c) 2022-2025 [Ribose Inc](https://www.ribose.com).
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
# This file is a part of the Tebako project.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions
|
|
7
|
+
# are met:
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
# notice, this list of conditions and the following disclaimer.
|
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
# documentation and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
16
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
18
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
name: lint
|
|
27
|
+
|
|
28
|
+
on:
|
|
29
|
+
push:
|
|
30
|
+
branches: [ master, main ]
|
|
31
|
+
pull_request:
|
|
32
|
+
workflow_dispatch:
|
|
33
|
+
|
|
34
|
+
jobs:
|
|
35
|
+
shellcheck:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
- uses: ludeeus/action-shellcheck@master
|
|
40
|
+
env:
|
|
41
|
+
SHELLCHECK_OPTS: -x
|