tebako 0.5.0 → 0.5.1

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.
@@ -0,0 +1,447 @@
1
+ #! /bin/bash
2
+ # Copyright (c) 2022, [Ribose Inc](https://www.ribose.com).
3
+ # All rights reserved.
4
+ # This file is a part of tebako
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions
8
+ # are met:
9
+ # 1. Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ # 2. Redistributions in binary form must reproduce the above copyright
12
+ # notice, this list of conditions and the following disclaimer in the
13
+ # documentation and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
19
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ # POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ set -o errexit -o pipefail -o noclobber -o nounset
28
+
29
+ # ....................................................
30
+ restore_and_save() {
31
+ echo "Patching $1"
32
+ test -e "$1.old" && cp -f "$1.old" "$1"
33
+ cp -f "$1" "$1.old"
34
+ }
35
+
36
+ do_patch() {
37
+ restore_and_save "$1"
38
+ sed -i "s/$2/$3/g" "$1"
39
+ }
40
+
41
+ do_patch_multiline() {
42
+ restore_and_save "$1"
43
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1"
44
+ }
45
+
46
+ defined_win32_to_msc_ver() {
47
+ re="defined(_WIN32)"
48
+ sbst="defined(_MSC_VER) \/* tebako patched *\/ "
49
+ do_patch "$1" "$re" "$sbst"
50
+
51
+ re="#ifdef _WIN32"
52
+ sbst="#ifdef _MSC_VER \/* tebako patched *\/ "
53
+ sed -i "s/$re/$sbst/g" "$1"
54
+ }
55
+
56
+ defined_n_win32_to_msc_ver() {
57
+ re="!defined(_WIN32)"
58
+ sbst="!defined(_MSC_VER) \/* tebako patched *\/ "
59
+ do_patch "$1" "$re" "$sbst"
60
+
61
+ re="#ifndef _WIN32"
62
+ sbst="#ifndef _MSC_VER \/* tebako patched *\/ "
63
+ sed -i "s/$re/$sbst/g" "$1"
64
+ }
65
+
66
+ defined_msc_ver_to_win32() {
67
+ re="defined(_MSC_VER)"
68
+ sbst="defined(_WIN32) \/* tebako patched *\/ "
69
+ do_patch "$1" "$re" "$sbst"
70
+
71
+ re="#ifdef _MSC_VER"
72
+ sbst="#ifdef _WIN32 \/* tebako patched *\/ "
73
+ sed -i "s/$re/$sbst/g" "$1"
74
+ }
75
+
76
+ funky_stdio_patch() {
77
+ re="int pclose(FILE\* f)"
78
+ sbst="int _folly_pclose(FILE* f) \/* tebako patched *\/"
79
+ do_patch "$1" "$re" "$sbst"
80
+
81
+ re="FILE\* popen(const char\* name, const char\* mode)"
82
+ sbst="FILE* _folly_popen(const char* name, const char* mode) \/* tebako patched *\/"
83
+ sed -i "s/$re/$sbst/g" "$1"
84
+
85
+ re="int vasprintf(char\*\* dest, const char\* format, va_list ap)"
86
+ sbst="int _folly_vasprintf(char** dest, const char* format, va_list ap) \/* tebako patched *\/"
87
+ sed -i "s/$re/$sbst/g" "$1"
88
+ }
89
+
90
+ funky_sysstat_patch() {
91
+ re="int chmod(char const\* fn, int am)"
92
+ sbst="int _folly_chmod(char const* fn, int am) \/* tebako patched *\/"
93
+ do_patch "$1" "$re" "$sbst"
94
+
95
+ re="int mkdir(const char\* fn, int mode)"
96
+ sbst="int _folly_mkdir(const char* fn, int mode) \/* tebako patched *\/"
97
+ sed -i "s/$re/$sbst/g" "$1"
98
+
99
+ re="int mkdir(const char\* fn, int \/\* mode \*\/)"
100
+ sbst="int _folly_mkdir(const char* fn, int \/* mode *\/) \/* tebako patched *\/"
101
+ sed -i "s/$re/$sbst/g" "$1"
102
+
103
+ re="int umask(int md)"
104
+ sbst="int _folly_umask(int md) \/* tebako patched *\/"
105
+ sed -i "s/$re/$sbst/g" "$1"
106
+ }
107
+
108
+ funky_string_patch() {
109
+ re="int strcasecmp(const char\* a, const char\* b)"
110
+ sbst="int _folly_strcasecmp(const char* a, const char* b) \/* tebako patched *\/"
111
+ do_patch "$1" "$re" "$sbst"
112
+
113
+ re="int strncasecmp(const char\* a, const char\* b, size_t c)"
114
+ sbst="int _folly_strncasecmp(const char* a, const char* b, size_t c) \/* tebako patched *\/"
115
+ sed -i "s/$re/$sbst/g" "$1"
116
+ }
117
+
118
+ funky_time_patch() {
119
+ re="char\* asctime_r(const tm\* tm, char\* buf)"
120
+ sbst="char* _folly_asctime_r(const tm* tm, char* buf) \/* tebako patched *\/"
121
+ do_patch "$1" "$re" "$sbst"
122
+
123
+ re="tm\* gmtime_r(const time_t\* t, tm\* res)"
124
+ sbst="tm* _folly_gmtime_r(const time_t* t, tm* res) \/* tebako patched *\/"
125
+ sed -i "s/$re/$sbst/g" "$1"
126
+
127
+ re="tm\* localtime_r(const time_t\* t, tm\* o)"
128
+ sbst="tm* _folly_localtime_r(const time_t* t, tm* o) \/* tebako patched *\/"
129
+ sed -i "s/$re/$sbst/g" "$1"
130
+ }
131
+
132
+ funky_formatter_patch() {
133
+ re="if (!localtime_r(&unixTimestamp, &ltime)) {"
134
+ sbst="if (!_folly_localtime_r(\&unixTimestamp, \&ltime)) { \/* tebako patched *\/"
135
+ do_patch "$1" "$re" "$sbst"
136
+ }
137
+
138
+ if [[ "$OSTYPE" == "linux-musl"* ]]; then
139
+ # https://github.com/facebook/folly/issues/1478
140
+ re="#elif defined(__FreeBSD__)"
141
+ sbst="#else \/* Tebako patched *\/"
142
+ do_patch "$1/folly/experimental/symbolizer/Elf.cpp" "$re" "$sbst"
143
+
144
+ restore_and_save "$1/CMake/FollyConfigChecks.cmake"
145
+ re="FOLLY_HAVE_IFUNC"
146
+ sbst="FOLLY_HAVE_IFUNC_NOT_PATCHED"
147
+ sed -i "s/$re/$sbst/g" "$1/CMake/FollyConfigChecks.cmake"
148
+
149
+ re="set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")"
150
+
151
+ # shellcheck disable=SC2251
152
+ ! IFS= read -r -d '' sbst << EOM
153
+ set(CMAKE_REQUIRED_FLAGS \"\${FOLLY_ORIGINAL_CMAKE_REQUIRED_FLAGS}\")
154
+
155
+ # -- Start of tebako patch --
156
+ check_cxx_source_runs(\"
157
+ #pragma GCC diagnostic error \\\"-Wattributes\\\"
158
+ extern \\\"C\\\" int resolved_ifunc(void) { return 0; }
159
+ extern \\\"C\\\" int (*test_ifunc(void))() { return resolved_ifunc; }
160
+ int func() __attribute__((ifunc(\\\"test_ifunc\\\")));
161
+ int main() { return func(); }\"
162
+ FOLLY_HAVE_IFUNC
163
+ )
164
+ # -- End of tebako patch --
165
+ EOM
166
+
167
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/CMake/FollyConfigChecks.cmake"
168
+
169
+ elif [[ "$OSTYPE" == "msys"* ]]; then
170
+ # --- folly/portability/Stdlib.h ---
171
+ re="#define PATH_MAX _MAX_PATH"
172
+ sbst="\/* #define PATH_MAX _MAX_PATH --- tebako patched *\/"
173
+ do_patch "$1/folly/portability/Stdlib.h" "$re" "$sbst"
174
+
175
+ # --- folly/portability/Stdlib.cpp ---
176
+ re="ret = mkdir(ptr, 0700);"
177
+ sbst="ret = _folly_mkdir(ptr, 0700); \/* tebako patched *\/"
178
+ do_patch "$1/folly/portability/Stdlib.cpp" "$re" "$sbst"
179
+
180
+ # --- folly/portability/SysTypes.h ---
181
+ re="using pid_t = int;"
182
+ sbst="\/* using pid_t = int; --- tebako patched *\/"
183
+ do_patch "$1/folly/portability/SysTypes.h" "$re" "$sbst"
184
+
185
+ re="using mode_t = unsigned int;"
186
+ sbst="\/* using mode_t = unsigned int; --- tebako patched *\/"
187
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
188
+
189
+ re="using uid_t = int;"
190
+ sbst="using uid_t = short; \/* --- tebako patched *\/"
191
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/SysTypes.h"
192
+
193
+ re="using gid_t = int;"
194
+ # shellcheck disable=SC2251
195
+ ! IFS= read -r -d '' sbst << EOM
196
+ using gid_t = short; \/* --- tebako patched *\/
197
+ using nlink_t = short; \/* --- tebako patched *\/
198
+ EOM
199
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysTypes.h"
200
+
201
+ # --- folly/portability/SysStat.cpp ---
202
+ funky_sysstat_patch "$1/folly/portability/SysStat.cpp"
203
+
204
+ # --- folly/portability/SysStat.h ---
205
+ funky_sysstat_patch "$1/folly/portability/SysStat.h"
206
+
207
+ re="#define S_IXUSR 0"
208
+ # shellcheck disable=SC2251
209
+ ! IFS= read -r -d '' sbst << EOM
210
+ \/* -- Start of tebako patch --
211
+ #define S_IXUSR 0
212
+ EOM
213
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
214
+
215
+ re="#define S_ISREG(mode) (((mode) & (_S_IFREG)) == (_S_IFREG) ? 1 : 0)"
216
+ # shellcheck disable=SC2251
217
+ ! IFS= read -r -d '' sbst << EOM
218
+ #define S_ISREG(mode) (((mode) \& (_S_IFREG)) == (_S_IFREG) ? 1 : 0)
219
+ *\/
220
+ #define _S_IFLNK 0xA000
221
+ #define S_IFLNK _S_IFLNK
222
+ #define S_ISLNK(mode) (((mode) \& (_S_IFLNK)) == (_S_IFLNK) ? 1 : 0)
223
+
224
+ \/* -- End of tebako patch -- *\/
225
+ EOM
226
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/portability/SysStat.h"
227
+
228
+ # --- folly/portability/SysTime.h ---
229
+ re="int gettimeofday(timeval\* tv, folly_port_struct_timezone\*);"
230
+ sbst="\/* int gettimeofday(timeval* tv, folly_port_struct_timezone*); --- tebako patched *\/"
231
+ do_patch "$1/folly/portability/SysTime.h" "$re" "$sbst"
232
+
233
+ # --- folly/FileUtil.cpp ---
234
+ defined_msc_ver_to_win32 "$1/folly/FileUtil.cpp"
235
+ re="(open,"
236
+ sbst="(\/* tebako patched *\/ folly::portability::fcntl::open,"
237
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
238
+
239
+ re="close(tmpFD)"
240
+ sbst="\/* tebako patched *\/ folly::portability::unistd::close(tmpFD)"
241
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
242
+
243
+ re="(close(fd))"
244
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::close(fd))"
245
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
246
+
247
+ re="(read,"
248
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::read,"
249
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
250
+
251
+ re="(write,"
252
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::write,"
253
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
254
+
255
+ re="(dup,"
256
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::dup,"
257
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
258
+
259
+ re="(dup2,"
260
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::dup2,"
261
+ sed -i "s/$re/$sbst/g" "$1/folly/FileUtil.cpp"
262
+
263
+ # --- folly/experimental/TestUtil.cpp ---
264
+ defined_win32_to_msc_ver "$1/folly/experimental/TestUtil.cpp"
265
+ re="dup("
266
+ sbst="\/* tebako patched *\/ folly::portability::unistd::dup("
267
+ sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
268
+
269
+ re="dup2("
270
+ sbst="\/* tebako patched *\/ folly::portability::unistd::dup2("
271
+ sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
272
+
273
+ re="lseek("
274
+ sbst="\/* tebako patched *\/ folly::portability::unistd::lseek("
275
+ sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
276
+
277
+ re="(close("
278
+ sbst="(\/* tebako patched *\/ folly::portability::unistd::close("
279
+ sed -i "s/$re/$sbst/g" "$1/folly/experimental/TestUtil.cpp"
280
+
281
+ # --- folly/system/MemoryMapping.cpp ---
282
+ re="0 == ftruncate("
283
+ sbst="0 == \/* tebako patched *\/ folly::portability::unistd::ftruncate("
284
+ sed -i "s/$re/$sbst/g" "$1/folly/system/MemoryMapping.cpp"
285
+
286
+ # --- folly/portability/SysUio.cpp ---
287
+ re="lseek(fd,"
288
+ sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
289
+ do_patch "$1/folly/portability/SysUio.cpp" "$re" "$sbst"
290
+
291
+ # --- folly/portability/Unistd.cpp ---
292
+ re="(lseek(fd,"
293
+ sbst="( \/* tebako patched *\/ folly::portability::unistd::lseek(fd,"
294
+ do_patch "$1/folly/portability/Unistd.cpp" "$re" "$sbst"
295
+
296
+ re="lseek(fd, 0,"
297
+ sbst=" \/* tebako patched *\/ folly::portability::unistd::lseek(fd, 0,"
298
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.cpp"
299
+
300
+ # --- folly/logging/ImmediateFileWriter.h ---
301
+ re="isatty(file"
302
+ sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
303
+ do_patch "$1/folly/logging/ImmediateFileWriter.h" "$re" "$sbst"
304
+
305
+ # --- folly/logging/AsyncFileWriter.cpp ---
306
+ re="isatty(file"
307
+ sbst=" \/* tebako patched *\/ folly::portability::unistd::isatty(file"
308
+ do_patch "$1/folly/logging/AsyncFileWriter.cpp" "$re" "$sbst"
309
+
310
+ # --- folly/portability/Unistd.h ---
311
+ re="#define X_OK F_OK"
312
+ sbst="#define X_OK 1 \/* tebako patched *\/"
313
+ do_patch "$1/folly/portability/Unistd.h" "$re" "$sbst"
314
+
315
+ re="int getuid();"
316
+ sbst="uid_t getuid(); \/* tebako patched *\/"
317
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
318
+
319
+ re="int getgid();"
320
+ sbst="gid_t getgid(); \/* tebako patched *\/"
321
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/Unistd.h"
322
+
323
+ # --- folly/portability/Fcntl.cpp ---
324
+ re="#include <folly\/portability\/Windows\.h>"
325
+
326
+ # shellcheck disable=SC2251
327
+ ! IFS= read -r -d '' sbst << EOM
328
+ #include <folly\/portability\/Windows.h>
329
+ \/* -- Start of tebako patch -- *\/
330
+ #include <share.h>
331
+ \/* -- End of tebako patch -- *\/
332
+ EOM
333
+ do_patch_multiline "$1/folly/portability/Fcntl.cpp" "$re" "$sbst"
334
+
335
+ # --- folly/net/detail/SocketFileDescriptorMap.cpp --
336
+ re="#include <fcntl\.h>"
337
+
338
+ # shellcheck disable=SC2251
339
+ ! IFS= read -r -d '' sbst << EOM
340
+ #include <fcntl.h>
341
+
342
+ \/* -- Start of tebako patch -- *\/
343
+ #include <mutex>
344
+ \/* -- End of tebako patch -- *\/
345
+
346
+ EOM
347
+ do_patch_multiline "$1/folly/net/detail/SocketFileDescriptorMap.cpp" "$re" "$sbst"
348
+
349
+ re=" __try {"
350
+ # shellcheck disable=SC2251
351
+ ! IFS= read -r -d '' sbst << EOM
352
+ #ifndef __MINGW32__ \/* -- Tebako patched -- *\/
353
+ __try {
354
+ EOM
355
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
356
+
357
+ re="\/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because"
358
+ # shellcheck disable=SC2251
359
+ ! IFS= read -r -d '' sbst << EOM
360
+ #endif \/* -- Tebako patched -- *\/
361
+ \/\/ We're at the core, we don't get the luxery of SCOPE_EXIT because
362
+ EOM
363
+ sed -i "s/$re/${sbst//$'\n'/"\\n"}/g" "$1/folly/net/detail/SocketFileDescriptorMap.cpp"
364
+
365
+ # --- folly/portability/Sockets.h ---
366
+ restore_and_save "$1/folly/portability/Sockets.h"
367
+ re="#ifdef _WIN32"
368
+
369
+ # shellcheck disable=SC2251
370
+ ! IFS= read -r -d '' sbst << EOM
371
+ #ifdef _WIN32
372
+
373
+ \/* -- Start of tebako patch -- *\/
374
+ #ifdef __MINGW32__
375
+ #include <mswsock.h>
376
+ using cmsghdr = WSACMSGHDR;
377
+ #endif
378
+ \/* -- End of tebako patch -- *\/
379
+
380
+ EOM
381
+ sed -i -i "0,/$re/s||${sbst//$'\n'/"\\n"}|g" "$1/folly/portability/Sockets.h"
382
+
383
+ # --- folly/portability/Time.cpp ---
384
+ funky_time_patch "$1/folly/portability/Time.cpp"
385
+
386
+ re="(asctime_s(tmpBuf, tm))"
387
+ sbst="(asctime_s(tmpBuf, 64\/* tebako patched *\/, tm))"
388
+ sed -i "s/$re/$sbst/g" "$1/folly/portability/Time.cpp"
389
+
390
+ # ---
391
+ re="#if (defined(USE_JEMALLOC) || FOLLY_USE_JEMALLOC) && !FOLLY_SANITIZE"
392
+ # shellcheck disable=SC2251
393
+ ! IFS= read -r -d '' sbst << EOM
394
+ \/* -- Start of tebako patch -- *\/
395
+ #if defined(FOLLY_ASSUME_NO_JEMALLOC)
396
+ #undef USE_JEMALLOC
397
+ #undef FOLLY_USE_JEMALLOC
398
+ #endif
399
+ \/* -- End of tebako patch -- *\/
400
+ #if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) \&\& !FOLLY_SANITIZE \/* tebako patched *\/
401
+ EOM
402
+ do_patch_multiline "$1/folly/portability/Malloc.h" "$re" "$sbst"
403
+
404
+ # ---
405
+ re="#include <folly\/Portability\.h>"
406
+ # shellcheck disable=SC2251
407
+ ! IFS= read -r -d '' sbst << EOM
408
+ #include <folly\/Portability.h>
409
+ \/* -- Start of tebako patch -- *\/
410
+ #include <folly\/portability\/Malloc.h>
411
+ \/* -- End of tebako patch -- *\/
412
+
413
+ EOM
414
+ do_patch_multiline "$1/folly/memory/detail/MallocImpl.h" "$re" "$sbst"
415
+
416
+ # --- folly/system/ThreadName.cpp ---
417
+ defined_win32_to_msc_ver "$1/folly/system/ThreadName.cpp"
418
+
419
+ re="#if defined(__XROS__)"
420
+ sbst="#if defined(__XROS__) || defined(__MINGW32__) \/* tebako patched *\/"
421
+ sed -i "s/$re/$sbst/g" "$1/folly/system/ThreadName.cpp"
422
+
423
+ # ---
424
+ defined_msc_ver_to_win32 "$1/folly/external/farmhash/farmhash.cpp"
425
+ defined_msc_ver_to_win32 "$1/folly/detail/IPAddressSource.h"
426
+ defined_msc_ver_to_win32 "$1/folly/portability/Sockets.cpp"
427
+
428
+ defined_n_win32_to_msc_ver "$1/folly/portability/Dirent.h"
429
+ defined_win32_to_msc_ver "$1/folly/portability/Dirent.cpp"
430
+
431
+ funky_stdio_patch "$1/folly/portability/Stdio.h"
432
+ funky_stdio_patch "$1/folly/portability/Stdio.cpp"
433
+ funky_string_patch "$1/folly/portability/String.h"
434
+ funky_string_patch "$1/folly/portability/String.cpp"
435
+ funky_time_patch "$1/folly/portability/Time.h"
436
+ funky_formatter_patch "$1/folly/logging/CustomLogFormatter.cpp"
437
+ funky_formatter_patch "$1/folly/logging/GlogStyleFormatter.cpp"
438
+
439
+ # Note: the patch below comments out
440
+ # int gettimeofday(timeval* tv, folly_port_struct_timezone*);
441
+ # void timeradd(timeval* a, timeval* b, timeval* res);
442
+ # void timersub(timeval* a, timeval* b, timeval* res);
443
+ # while gettimeofday is provided by MSys, the other two functions are lost
444
+ defined_n_win32_to_msc_ver "$1/folly/portability/SysTime.h"
445
+ defined_win32_to_msc_ver "$1/folly/portability/SysTime.cpp"
446
+
447
+ fi
@@ -0,0 +1,59 @@
1
+ #! /bin/bash
2
+ # Copyright (c) 2022, [Ribose Inc](https://www.ribose.com).
3
+ # All rights reserved.
4
+ # This file is a part of tebako
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions
8
+ # are met:
9
+ # 1. Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ # 2. Redistributions in binary form must reproduce the above copyright
12
+ # notice, this list of conditions and the following disclaimer in the
13
+ # documentation and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17
+ # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
19
+ # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ # POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ # Alpine headers define malloc and other memory functions without nothrow attribute
28
+ # while jemalloc and folly have nothrow
29
+ # clang (as opposed to gcc) considers it syntax error and there is no easier workaround
30
+
31
+ set -o errexit -o pipefail -o noclobber -o nounset
32
+
33
+ # ....................................................
34
+ restore_and_save() {
35
+ echo "Patching $1"
36
+ test -e "$1.old" && cp -f "$1.old" "$1"
37
+ cp -f "$1" "$1.old"
38
+ }
39
+
40
+ patch() {
41
+ echo "Processing $2"
42
+ re="$2"
43
+ sbst="__attribute__((nothrow)) \/*Tebako patched *\/ $2"
44
+ sed -i "s/$re/$sbst/g" "$1"
45
+ }
46
+
47
+ f_stdlib=( "\*malloc" "\*calloc" "\*realloc" "free" "\*aligned_alloc" "posix_memalign" "\*valloc" "\*memalign" )
48
+ restore_and_save "/usr/include/stdlib.h"
49
+ for f in "${f_stdlib[@]}"
50
+ do
51
+ patch "/usr/include/stdlib.h" "$f"
52
+ done
53
+
54
+ f_sched=( "\*calloc" "free" )
55
+ restore_and_save "/usr/include/sched.h"
56
+ for f in "${f_sched[@]}"
57
+ do
58
+ patch "/usr/include/sched.h" "$f"
59
+ done
@@ -0,0 +1,43 @@
1
+ #! /bin/bash
2
+ #
3
+ # Copyright (c) 2022, [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
+ set -o errexit -o pipefail -o noclobber -o nounset
29
+
30
+ # for zsh
31
+ # https://stackoverflow.com/questions/6715388/variable-expansion-is-different-in-zsh-from-that-in-bash
32
+ # setopt sh_word_split
33
+
34
+ DIR0="$( cd "$1" && pwd )"
35
+ DIR1="$DIR0/x86-homebrew"
36
+
37
+ for bottle in "${@:2}"
38
+ do
39
+ echo "Installing $bottle"
40
+ response=$("$DIR1/bin/brew" fetch --force --bottle-tag=x86_64_big_sur "$bottle" | grep "Downloaded to")
41
+ IFS=" " read -r -a parsed <<< "$response"
42
+ "$DIR1/bin/brew" install "${parsed[2]}"
43
+ done
@@ -0,0 +1,33 @@
1
+ #! /bin/bash
2
+ #
3
+ # Copyright (c) 2022, [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
+ set -o errexit -o pipefail -o noclobber -o nounset
29
+
30
+ DIR0="$( cd "$1" && pwd )"
31
+ DIR1="$DIR0/x86-homebrew"
32
+ mkdir "$DIR1"
33
+ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "$DIR1"
@@ -0,0 +1,96 @@
1
+ # Copyright (c) 2021-2022 [Ribose Inc](https://www.ribose.com).
2
+ # All rights reserved.
3
+ # This file is a part of tebako
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
+
27
+ # ...................................................................
28
+ # DEF_EXT_PRJ_T
29
+ # This function defines version number and archieve hash for
30
+ # external project that is build from tarball
31
+ # For external project XXX this function will set the following variables:
32
+ # XXX_VER -- package version
33
+ # XXX_HASH -- tarball hash
34
+ # Version and hash value come from environment variables (GHA case)
35
+ # If environment variables are not set then default values are used
36
+ # XXX_NAME = xxx (lowercase)
37
+ # XXX_PRJ = _xxx (lowercase) -- CMake ExternalProject name
38
+ # XXX_SOURCE_DIR = ${DEPS}/src/_xxx -- Source folder for ExternalProject_Add
39
+ # XXX_BINARY_DIR = ${DEPS}/src/_xxx-build -- Build folder for ExternalProject_Add
40
+
41
+ function(DEF_EXT_PRJ_T NAME DEFAULT_VER DEFAULT_HASH)
42
+ set(VER ${NAME}_VER)
43
+ if (DEFINED ENV{${VER}})
44
+ set(${VER} $ENV{${VER}} PARENT_SCOPE)
45
+ else ()
46
+ set(${VER} ${DEFAULT_VER} PARENT_SCOPE)
47
+ endif()
48
+
49
+ set(HASH ${NAME}_HASH)
50
+ if (DEFINED ENV{${HASH})
51
+ set(${HASH} $ENV{${HASH}} PARENT_SCOPE)
52
+ else()
53
+ set(${HASH} ${DEFAULT_HASH} PARENT_SCOPE)
54
+ endif()
55
+
56
+ set(R_NAME ${NAME}_NAME)
57
+ string(TOLOWER ${NAME} TMP)
58
+ set(${R_NAME} ${TMP} PARENT_SCOPE)
59
+ set(R_PRJ ${NAME}_PRJ)
60
+ set(${R_PRJ} _${TMP} PARENT_SCOPE)
61
+ set(R_DIR ${NAME}_SOURCE_DIR)
62
+ set(${R_DIR} ${DEPS}/src/_${TMP} PARENT_SCOPE)
63
+ set(R_DIR ${NAME}_BINARY_DIR)
64
+ set(${R_DIR} ${DEPS}/src/_${TMP}-build PARENT_SCOPE)
65
+ endfunction()
66
+
67
+ # ...................................................................
68
+ # DEF_EXT_PRJ_G
69
+ # This function defines git tag for external project that is build from git
70
+ # For external project XXX this function will set the following variables:
71
+ # XXX_TAG -- git tag
72
+ # Version and tag come from environment variables (GHA case)
73
+ # If environment variables are not set then default values are used
74
+ # XXX_NAME = xxx (lowercase)
75
+ # XXX_PRJ = _xxx (lowercase) -- CMake ExternalProject name
76
+ # XXX_SOURCE_DIR = ${DEPS}/src/_xxx -- Source folder for ExternalProject_Add
77
+ # XXX_BINARY_DIR = ${DEPS}/src/_xxx-build -- Build folder for ExternalProject_Add
78
+
79
+ function(DEF_EXT_PRJ_G NAME DEFAULT_TAG)
80
+ set(TAG ${NAME}_TAG)
81
+ if (DEFINED ENV{${TAG})
82
+ set(${TAG} $ENV{${TAG}} PARENT_SCOPE)
83
+ else()
84
+ set(${TAG} ${DEFAULT_TAG} PARENT_SCOPE)
85
+ endif()
86
+
87
+ set(R_NAME ${NAME}_NAME)
88
+ string(TOLOWER ${NAME} TMP)
89
+ set(${R_NAME} ${TMP} PARENT_SCOPE)
90
+ set(R_PRJ ${NAME}_PRJ)
91
+ set(${R_PRJ} _${TMP} PARENT_SCOPE)
92
+ set(R_DIR ${NAME}_SOURCE_DIR)
93
+ set(${R_DIR} ${DEPS}/src/_${TMP} PARENT_SCOPE)
94
+ set(R_DIR ${NAME}_BINARY_DIR)
95
+ set(${R_DIR} ${DEPS}/src/_${TMP}-build PARENT_SCOPE)
96
+ endfunction()