tebako 0.5.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CMakeLists.txt +24 -34
- data/README.adoc +53 -28
- data/Rakefile +1 -1
- data/common.env +2 -2
- data/exe/tebako-packager +5 -3
- data/lib/tebako/cli.rb +23 -0
- data/lib/tebako/cli_helpers.rb +3 -3
- data/lib/tebako/packager/pass1.rb +3 -1
- data/lib/tebako/packager/pass2.rb +68 -284
- data/{tests-2/fixtures/gems-expressir/gems-expressir.rb → lib/tebako/packager/patch_helpers.rb} +34 -5
- data/lib/tebako/packager/patch_literals.rb +277 -0
- data/lib/tebako/packager.rb +47 -16
- data/lib/tebako/version.rb +1 -1
- data/tebako.gemspec +1 -1
- data/version.txt +1 -1
- metadata +4 -63
- data/cmake/def_tty_colours.cmake +0 -19
- data/tests/scripts/cross-tests.sh +0 -34
- data/tests/scripts/functional-tests.sh +0 -335
- data/tests/test-00/test.rb +0 -4
- data/tests/test-01/tebako-test-run.rb +0 -5
- data/tests/test-09/tebako-test-0.0.1.gem +0 -0
- data/tests/test-11/bin/tebako-test-run.rb +0 -10
- data/tests/test-11/lib/tebako-test.rb +0 -20
- data/tests/test-11/tebako-test.gemspec +0 -15
- data/tests/test-12/tebako-test-a.gemspec +0 -15
- data/tests/test-12/tebako-test-b.gemspec +0 -15
- data/tests/test-13/bin/tebako-test-run.rb +0 -10
- data/tests/test-13/lib/tebako-test.rb +0 -20
- data/tests/test-13/tebako-test.gemspec +0 -15
- data/tests/test-15/Gemfile +0 -8
- data/tests/test-15/Rakefile +0 -4
- data/tests/test-15/bin/tebako-test-run.rb +0 -10
- data/tests/test-15/lib/tebako/bundle/test/version.rb +0 -9
- data/tests/test-15/lib/tebako/bundle/test.rb +0 -29
- data/tests/test-15/tebako-bundle-test.gemspec +0 -30
- data/tests/test-16/Gemfile +0 -8
- data/tests/test-16/Rakefile +0 -4
- data/tests/test-16/bin/tebako-test-run.rb +0 -10
- data/tests/test-16/lib/tebako/bundle/test/version.rb +0 -9
- data/tests/test-16/lib/tebako/bundle/test.rb +0 -29
- data/tests/test-16/tebako-bundle-test.gemspec +0 -24
- data/tests/test-18/Gemfile +0 -5
- data/tests/test-18/tebako-test-run.rb +0 -12
- data/tests/test-19/Gemfile +0 -6
- data/tests/test-19/tebako-test-run.rb +0 -11
- data/tests-2/fixtures/gems-bundler/Gemfile +0 -4
- data/tests-2/fixtures/gems-bundler/gems-bundler.rb +0 -34
- data/tests-2/fixtures/gems-byebug/Gemfile +0 -5
- data/tests-2/fixtures/gems-byebug/gems-byebug.rb +0 -31
- data/tests-2/fixtures/gems-expressir/Gemfile +0 -7
- data/tests-2/fixtures/gems-libmspack/Gemfile +0 -5
- data/tests-2/fixtures/gems-libmspack/gems-libmspack.rb +0 -91
- data/tests-2/fixtures/gems-sassc/Gemfile +0 -6
- data/tests-2/fixtures/gems-sassc/base_style/all.scss +0 -1
- data/tests-2/fixtures/gems-sassc/base_style/reset.scss +0 -100
- data/tests-2/fixtures/gems-sassc/gems-sassc.rb +0 -129
- data/tests-2/fixtures/gems-seven-zip/Gemfile +0 -7
- data/tests-2/fixtures/gems-seven-zip/gems-seven-zip.rb +0 -53
- data/tests-2/fixtures/launcher-coreincl/launcher-coreincl.rb +0 -29
- data/tests-2/fixtures/launcher-package/launcher-package.rb +0 -29
- data/tests-2/fixtures/launcher-pwd/launcher-pwd.rb +0 -28
- data/tests-2/fixtures/launcher-stdinredir/input.txt +0 -1
- data/tests-2/fixtures/launcher-stdinredir/launcher-stdinredir.rb +0 -31
- data/tests-2/fixtures/launcher-stdoutredir/launcher-stdoutredir.rb +0 -28
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-1.txt +0 -1
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-2.txt +0 -1
- data/tests-2/fixtures/patches-dir/level-1/level-2/file-3.txt +0 -1
- data/tests-2/fixtures/patches-dir/patches-dir.rb +0 -154
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-1.txt +0 -1
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-2.txt +0 -2
- data/tests-2/fixtures/patches-io-and-file/level-1/level-2/file-3.txt +0 -1
- data/tests-2/fixtures/patches-io-and-file/level-1/link-3 +0 -1
- data/tests-2/fixtures/patches-io-and-file/patches-io-and-file.rb +0 -87
- data/tests-2/fixtures/patches-main/patches-main.rb +0 -6
- data/tests-2/tebako-test.rb +0 -313
@@ -0,0 +1,277 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2023 [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
|
+
# Tebako - an executable packager
|
29
|
+
module Tebako
|
30
|
+
module Packager
|
31
|
+
# Ruby patching literals (pass2)
|
32
|
+
# rubocop:disable Metrics/ModuleLength
|
33
|
+
module PatchLiterals
|
34
|
+
TOOL_MKCONFIG_RB_PATCH = {
|
35
|
+
" if fast[name]" => <<~SUBST
|
36
|
+
# -- Start of tebako patch --
|
37
|
+
v_head_comp = " CONFIG[\\"prefix\\"] \#{eq} "
|
38
|
+
if v_head_comp == v[0...(v_head_comp.length)]
|
39
|
+
if win32
|
40
|
+
v = "\#{v[0...(v_head_comp.length)]}CONFIG[\\"RUBY_EXEC_PREFIX\\"] = '/__tebako_memfs__'
|
41
|
+
"
|
42
|
+
else
|
43
|
+
v = "\#{v[0...(v_head_comp.length)]}'/__tebako_memfs__'
|
44
|
+
"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
v_head_comp = " CONFIG[\\"RUBY_EXEC_PREFIX\\"] \#{eq} "
|
48
|
+
if v_head_comp == v[0...(v_head_comp.length)]
|
49
|
+
v = "\#{v[0...(v_head_comp.length)]}'/__tebako_memfs__'
|
50
|
+
"
|
51
|
+
end
|
52
|
+
# -- End of tebako patch --
|
53
|
+
if fast[name]
|
54
|
+
SUBST
|
55
|
+
}.freeze
|
56
|
+
|
57
|
+
# Alpine-specific patches https://github.com/docker-library/ruby/blob/master/3.1/alpine3.15/Dockerfile
|
58
|
+
# -- Patch no. 1 --
|
59
|
+
# https://github.com/docker-library/ruby/issues/196
|
60
|
+
# https://bugs.ruby-lang.org/issues/14387#note-13 (patch source)
|
61
|
+
# https://bugs.ruby-lang.org/issues/14387#note-16
|
62
|
+
# ("Therefore ncopa's patch looks good for me in general." -- only breaks glibc which doesn't matter here)
|
63
|
+
|
64
|
+
# -- Patch no. 2 -- not needed: isnan, isinf are detected correctly by configure script
|
65
|
+
# the configure script does not detect isnan/isinf as macros
|
66
|
+
# export ac_cv_func_isnan=yes ac_cv_func_isinf=yes;
|
67
|
+
|
68
|
+
# -- Patch no. 3 --
|
69
|
+
# hack in "ENABLE_PATH_CHECK" disabling to suppress: "warning: Insecure world writable dir"
|
70
|
+
# Applied in CMakeLists.txt
|
71
|
+
|
72
|
+
LINUX_MUSL_THREAD_PTHREAD_PATCH = {
|
73
|
+
"#if MAINSTACKADDR_AVAILABLE && !defined(get_main_stack)" => <<~SUBST
|
74
|
+
/* -- Start of tebako patch -- */
|
75
|
+
#if defined(__linux__) && !defined(__GLIBC__) && defined(HAVE_GETRLIMIT)
|
76
|
+
#ifndef PAGE_SIZE
|
77
|
+
#include <unistd.h>
|
78
|
+
#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
|
79
|
+
#endif
|
80
|
+
static int
|
81
|
+
get_main_stack(void **addr, size_t *size)
|
82
|
+
{
|
83
|
+
size_t start, end, limit, prevend = 0;
|
84
|
+
struct rlimit r;
|
85
|
+
FILE *f;
|
86
|
+
char buf[PATH_MAX+80], s[8];
|
87
|
+
int n;
|
88
|
+
STACK_GROW_DIR_DETECTION;
|
89
|
+
f = fopen("/proc/self/maps", "re");
|
90
|
+
if (!f)
|
91
|
+
return -1;
|
92
|
+
n = 0;
|
93
|
+
while (fgets(buf, sizeof buf, f)) {
|
94
|
+
n = sscanf(buf, "%zx-%zx %*s %*s %*s %*s %7s", &start, &end, s);
|
95
|
+
if (n >= 2) {
|
96
|
+
if (n == 3 && strcmp(s, "[stack]") == 0)
|
97
|
+
break;
|
98
|
+
prevend = end;
|
99
|
+
}
|
100
|
+
n = 0;
|
101
|
+
}
|
102
|
+
fclose(f);
|
103
|
+
if (n == 0)
|
104
|
+
return -1;
|
105
|
+
limit = 100 << 20; /* 100MB stack limit */
|
106
|
+
if (getrlimit(RLIMIT_STACK, &r)==0 && r.rlim_cur < limit)
|
107
|
+
limit = r.rlim_cur & -PAGE_SIZE;
|
108
|
+
if (limit > end) limit = end;
|
109
|
+
if (prevend < end - limit) prevend = end - limit;
|
110
|
+
if (start > prevend) start = prevend;
|
111
|
+
*addr = IS_STACK_DIR_UPPER() ? (void *)start : (void *)end;
|
112
|
+
*size = end - start;
|
113
|
+
return 0;
|
114
|
+
}
|
115
|
+
#else
|
116
|
+
/* -- End of tebako patch -- */
|
117
|
+
SUBST
|
118
|
+
}.freeze
|
119
|
+
|
120
|
+
MAIN_C_PATCH = {
|
121
|
+
"int\nmain(int argc, char **argv)" =>
|
122
|
+
"#include <tebako/tebako-main.h>\n\nint\nmain(int argc, char **argv)",
|
123
|
+
|
124
|
+
" ruby_sysinit(&argc, &argv);" => <<~SUBST
|
125
|
+
ruby_sysinit(&argc, &argv);
|
126
|
+
/* -- Start of tebako patch -- */
|
127
|
+
if (tebako_main(&argc, &argv) != 0) {
|
128
|
+
return -1;
|
129
|
+
}
|
130
|
+
/* -- End of tebako patch -- */
|
131
|
+
SUBST
|
132
|
+
}.freeze
|
133
|
+
|
134
|
+
# Compensate ruby incorrect processing of (f)getattrlist returning ENOTSUP
|
135
|
+
# Note. We are not patching need_normalization function
|
136
|
+
# In this function (f)getattrlist failure with ENOTSUP is processed correctly
|
137
|
+
|
138
|
+
DIR_C_BASE_PATCH_ONE = <<~SUBST
|
139
|
+
#if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT
|
140
|
+
/* tebako patch */ if (!within_tebako_memfs(path))
|
141
|
+
SUBST
|
142
|
+
|
143
|
+
DIR_C_BASE_PATCH_TWO = <<~SUBST
|
144
|
+
#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME
|
145
|
+
/* tebako patch */ if (!within_tebako_memfs(path)) plain = 1; else magical = 1;
|
146
|
+
SUBST
|
147
|
+
|
148
|
+
DIR_C_BASE_PATCH = {
|
149
|
+
"#if defined HAVE_GETATTRLIST && defined ATTR_DIR_ENTRYCOUNT" => DIR_C_BASE_PATCH_ONE,
|
150
|
+
"#if USE_NAME_ON_FS == USE_NAME_ON_FS_REAL_BASENAME\n plain = 1;" => DIR_C_BASE_PATCH_TWO,
|
151
|
+
"if (is_case_sensitive(dirp, path) == 0)" =>
|
152
|
+
"if (is_case_sensitive(dirp, path) == 0 /* tebako patch */ && !within_tebako_memfs(path))",
|
153
|
+
"if ((*cur)->type == ALPHA) {" =>
|
154
|
+
"if ((*cur)->type == ALPHA /* tebako patch */ && !within_tebako_memfs(buf)) {",
|
155
|
+
"else if (e == EIO) {" =>
|
156
|
+
"else if (e == EIO /* tebako patch */ && !within_tebako_memfs(path)) {"
|
157
|
+
}.freeze
|
158
|
+
|
159
|
+
COMMON_MK_PATCH = {
|
160
|
+
"ext/extinit.c: $(srcdir)/template/extinit.c.tmpl $(PREP)" =>
|
161
|
+
"ext/extinit.c: $(srcdir)/template/extinit.c.tmpl $(PREP) $(EXTS_MK)"
|
162
|
+
}.freeze
|
163
|
+
|
164
|
+
C_FILES_TO_PATCH = [
|
165
|
+
["file.c", "/* define system APIs */"],
|
166
|
+
["io.c", "/* define system APIs */"],
|
167
|
+
["util.c", "#ifndef S_ISDIR"],
|
168
|
+
["dln.c", "static const char funcname_prefix[sizeof(FUNCNAME_PREFIX) - 1] = FUNCNAME_PREFIX;"]
|
169
|
+
].freeze
|
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
|
+
|
179
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO_PRE_3_1 =
|
180
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
181
|
+
"$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
182
|
+
|
183
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO_PRE_3_1 =
|
184
|
+
"# -- Start of tebako patch --\n" \
|
185
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
186
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(LIBS) $(OUTFLAG)$@\n" \
|
187
|
+
"# -- End of tebako patch --"
|
188
|
+
|
189
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATTERN_TWO =
|
190
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
191
|
+
"$(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@"
|
192
|
+
|
193
|
+
TEMPLATE_MAKEFILE_IN_BASE_PATCH_TWO =
|
194
|
+
"# -- Start of tebako patch --\n" \
|
195
|
+
"\t\t$(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) " \
|
196
|
+
"$(EXTOBJS) $(LIBRUBYARG_STATIC) $(LIBS) $(OUTFLAG)$@\n" \
|
197
|
+
"# -- End of tebako patch --"
|
198
|
+
|
199
|
+
C_FILE_SUBST = <<~SUBST
|
200
|
+
/* -- Start of tebako patch -- */
|
201
|
+
#ifndef NO_TEBAKO_INCLUDES
|
202
|
+
#include <tebako/tebako-config.h>
|
203
|
+
#include <tebako/tebako-defines.h>
|
204
|
+
#include <tebako/tebako-io-rb-w32.h>
|
205
|
+
#include <tebako/tebako-io.h>
|
206
|
+
#endif
|
207
|
+
/* -- End of tebako patch -- */
|
208
|
+
SUBST
|
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
|
+
|
224
|
+
MSYS_PATCHES = {
|
225
|
+
"ruby.c" => {
|
226
|
+
"#define RUBY_RELATIVE(path, len) rb_str_buf_cat(BASEPATH(), (path), (len))" =>
|
227
|
+
"#define RUBY_RELATIVE(path, len) rubylib_path_new((path), (len)) /* tebako patched */",
|
228
|
+
"#define PREFIX_PATH() sopath" =>
|
229
|
+
"#define PREFIX_PATH() rubylib_path_new(tebako_mount_point(), " \
|
230
|
+
"strlen(tebako_mount_point())) /* tebako patched */",
|
231
|
+
'#include "mjit.h"' =>
|
232
|
+
"#include \"mjit.h\"\n" \
|
233
|
+
"/* -- Start of tebako patch -- */\n" \
|
234
|
+
"#include <tebako/tebako-main.h>\n" \
|
235
|
+
"/* -- End of tebako patch -- */"
|
236
|
+
},
|
237
|
+
"/win32/win32.c" => {
|
238
|
+
"#undef __STRICT_ANSI__" =>
|
239
|
+
"#undef __STRICT_ANSI__\n" \
|
240
|
+
"/* -- Start of tebako patch -- */\n" \
|
241
|
+
"#define NO_TEBAKO_INCLUDES\n" \
|
242
|
+
"/* -- End of tebako patch -- */"
|
243
|
+
},
|
244
|
+
"win32/dir.h" => {
|
245
|
+
"#define opendir(s) rb_w32_opendir((s))" => "#{C_FILE_SUBST}\n#define opendir(s) rb_w32_opendir((s))"
|
246
|
+
},
|
247
|
+
"file.c" => {
|
248
|
+
" wpath = mbstr_to_wstr(CP_UTF8, path, -1, &len);" =>
|
249
|
+
"/* -- Start of tebako patch -- */\n" \
|
250
|
+
"if (tebako_file_load_ok(path)) return 1;\n" \
|
251
|
+
"/* -- End of tebako patch -- */\n" \
|
252
|
+
"wpath = mbstr_to_wstr(CP_UTF8, path, -1, &len);",
|
253
|
+
'#include "win32/file.h' =>
|
254
|
+
"#include \"win32/file.h\"\n" \
|
255
|
+
"/* -- Start of tebako patch -- */\n" \
|
256
|
+
"#include <tebako/tebako-main.h>\n" \
|
257
|
+
"/* -- End of tebako patch -- */"
|
258
|
+
}
|
259
|
+
|
260
|
+
}.freeze
|
261
|
+
|
262
|
+
# rubocop:disable Style/WordArray
|
263
|
+
DARWIN_BREW_LIBS = [
|
264
|
+
["openssl@1.1", "ssl"], ["openssl@1.1", "crypto"], ["zlib", "z"], ["gdbm", "gdbm"],
|
265
|
+
["readline", "readline"], ["libffi", "ffi"], ["ncurses", "ncurses"], ["fmt", "fmt"],
|
266
|
+
["lz4", "lz4"], ["xz", "lzma"], ["libyaml", "yaml"],
|
267
|
+
["double-conversion", "double-conversion"]
|
268
|
+
].freeze
|
269
|
+
|
270
|
+
DARWIN_BREW_LIBS_32 = [["libyaml", "yaml"]].freeze
|
271
|
+
|
272
|
+
DARWIN_DEP_LIBS = ["glog", "gflags"].freeze
|
273
|
+
# rubocop:enable Style/WordArray
|
274
|
+
end
|
275
|
+
# rubocop:enable Metrics/ModuleLength
|
276
|
+
end
|
277
|
+
end
|
data/lib/tebako/packager.rb
CHANGED
@@ -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 '
|
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
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
data/lib/tebako/version.rb
CHANGED
data/tebako.gemspec
CHANGED
@@ -51,7 +51,7 @@ Gem::Specification.new do |spec|
|
|
51
51
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
52
52
|
`git ls-files --recurse-submodules -z`.split("\x0").reject do |f|
|
53
53
|
(f == __FILE__) ||
|
54
|
-
f.match(%r{\A(?:(?:
|
54
|
+
f.match(%r{\A(?:(?:tests|tests-2|features|deps|output|common\.env)/|\.(?:git|cirrus|tebako|rubocop))})
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
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.
|
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-
|
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
|
@@ -70,71 +69,13 @@ files:
|
|
70
69
|
- lib/tebako/packager.rb
|
71
70
|
- lib/tebako/packager/pass1.rb
|
72
71
|
- lib/tebako/packager/pass2.rb
|
72
|
+
- lib/tebako/packager/patch_helpers.rb
|
73
|
+
- lib/tebako/packager/patch_literals.rb
|
73
74
|
- lib/tebako/version.rb
|
74
75
|
- resources/tebako-fs.cpp.in
|
75
76
|
- resources/tebako-version.h.in
|
76
77
|
- src/tebako-main.cpp
|
77
78
|
- tebako.gemspec
|
78
|
-
- tests-2/fixtures/gems-bundler/Gemfile
|
79
|
-
- tests-2/fixtures/gems-bundler/gems-bundler.rb
|
80
|
-
- tests-2/fixtures/gems-byebug/Gemfile
|
81
|
-
- tests-2/fixtures/gems-byebug/gems-byebug.rb
|
82
|
-
- tests-2/fixtures/gems-expressir/Gemfile
|
83
|
-
- tests-2/fixtures/gems-expressir/gems-expressir.rb
|
84
|
-
- tests-2/fixtures/gems-libmspack/Gemfile
|
85
|
-
- tests-2/fixtures/gems-libmspack/gems-libmspack.rb
|
86
|
-
- tests-2/fixtures/gems-sassc/Gemfile
|
87
|
-
- tests-2/fixtures/gems-sassc/base_style/all.scss
|
88
|
-
- tests-2/fixtures/gems-sassc/base_style/reset.scss
|
89
|
-
- tests-2/fixtures/gems-sassc/gems-sassc.rb
|
90
|
-
- tests-2/fixtures/gems-seven-zip/Gemfile
|
91
|
-
- tests-2/fixtures/gems-seven-zip/gems-seven-zip.rb
|
92
|
-
- tests-2/fixtures/launcher-coreincl/launcher-coreincl.rb
|
93
|
-
- tests-2/fixtures/launcher-package/launcher-package.rb
|
94
|
-
- tests-2/fixtures/launcher-pwd/launcher-pwd.rb
|
95
|
-
- tests-2/fixtures/launcher-stdinredir/input.txt
|
96
|
-
- tests-2/fixtures/launcher-stdinredir/launcher-stdinredir.rb
|
97
|
-
- tests-2/fixtures/launcher-stdoutredir/launcher-stdoutredir.rb
|
98
|
-
- tests-2/fixtures/patches-dir/level-1/level-2/file-1.txt
|
99
|
-
- tests-2/fixtures/patches-dir/level-1/level-2/file-2.txt
|
100
|
-
- tests-2/fixtures/patches-dir/level-1/level-2/file-3.txt
|
101
|
-
- tests-2/fixtures/patches-dir/patches-dir.rb
|
102
|
-
- tests-2/fixtures/patches-io-and-file/level-1/level-2/file-1.txt
|
103
|
-
- tests-2/fixtures/patches-io-and-file/level-1/level-2/file-2.txt
|
104
|
-
- tests-2/fixtures/patches-io-and-file/level-1/level-2/file-3.txt
|
105
|
-
- tests-2/fixtures/patches-io-and-file/level-1/link-3
|
106
|
-
- tests-2/fixtures/patches-io-and-file/patches-io-and-file.rb
|
107
|
-
- tests-2/fixtures/patches-main/patches-main.rb
|
108
|
-
- tests-2/tebako-test.rb
|
109
|
-
- tests/scripts/cross-tests.sh
|
110
|
-
- tests/scripts/functional-tests.sh
|
111
|
-
- tests/test-00/test.rb
|
112
|
-
- tests/test-01/tebako-test-run.rb
|
113
|
-
- tests/test-09/tebako-test-0.0.1.gem
|
114
|
-
- tests/test-11/bin/tebako-test-run.rb
|
115
|
-
- tests/test-11/lib/tebako-test.rb
|
116
|
-
- tests/test-11/tebako-test.gemspec
|
117
|
-
- tests/test-12/tebako-test-a.gemspec
|
118
|
-
- tests/test-12/tebako-test-b.gemspec
|
119
|
-
- tests/test-13/bin/tebako-test-run.rb
|
120
|
-
- tests/test-13/lib/tebako-test.rb
|
121
|
-
- tests/test-13/tebako-test.gemspec
|
122
|
-
- tests/test-15/Gemfile
|
123
|
-
- tests/test-15/Rakefile
|
124
|
-
- tests/test-15/bin/tebako-test-run.rb
|
125
|
-
- tests/test-15/lib/tebako/bundle/test.rb
|
126
|
-
- tests/test-15/lib/tebako/bundle/test/version.rb
|
127
|
-
- tests/test-15/tebako-bundle-test.gemspec
|
128
|
-
- tests/test-16/Gemfile
|
129
|
-
- tests/test-16/Rakefile
|
130
|
-
- tests/test-16/bin/tebako-test-run.rb
|
131
|
-
- tests/test-16/lib/tebako/bundle/test.rb
|
132
|
-
- tests/test-16/lib/tebako/bundle/test/version.rb
|
133
|
-
- tests/test-16/tebako-bundle-test.gemspec
|
134
|
-
- tests/test-18/Gemfile
|
135
|
-
- tests/test-18/tebako-test-run.rb
|
136
|
-
- tests/test-19/Gemfile
|
137
|
-
- tests/test-19/tebako-test-run.rb
|
138
79
|
- tools/.gitattributes
|
139
80
|
- tools/.github/workflows/lint.yml
|
140
81
|
- tools/README.md
|
data/cmake/def_tty_colours.cmake
DELETED
@@ -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()
|
@@ -1,34 +0,0 @@
|
|
1
|
-
#! /bin/bash
|
2
|
-
#
|
3
|
-
# Copyright (c) 2021, [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
|
-
# More safety, by turning some bugs into errors.
|
29
|
-
# Without `errexit` you don’t need ! and can replace
|
30
|
-
# PIPESTATUS with a simple $?
|
31
|
-
set -o errexit -o pipefail -o noclobber -o nounset
|
32
|
-
|
33
|
-
chmod +x test-*-package
|
34
|
-
for TP in test-*-package; do "./$TP"; done
|