-
Notifications
You must be signed in to change notification settings - Fork 2
/
source.env
352 lines (315 loc) · 9.92 KB
/
source.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#!/data/data/com.termux/files/usr/bin/bash
_PROC_CAP_LAST_CAP='40'
_PROC_VM_STAT='nr_free_pages 1743136
nr_zone_inactive_anon 179281
nr_zone_active_anon 7183
nr_zone_inactive_file 22858
nr_zone_active_file 51328
nr_zone_unevictable 642
nr_zone_write_pending 0
nr_mlock 0
nr_bounce 0
nr_zspages 0
nr_free_cma 0
numa_hit 1259626
numa_miss 0
numa_foreign 0
numa_interleave 720
numa_local 1259626
numa_other 0
nr_inactive_anon 179281
nr_active_anon 7183
nr_inactive_file 22858
nr_active_file 51328
nr_unevictable 642
nr_slab_reclaimable 8091
nr_slab_unreclaimable 7804
nr_isolated_anon 0
nr_isolated_file 0
workingset_nodes 0
workingset_refault_anon 0
workingset_refault_file 0
workingset_activate_anon 0
workingset_activate_file 0
workingset_restore_anon 0
workingset_restore_file 0
workingset_nodereclaim 0
nr_anon_pages 7723
nr_mapped 8905
nr_file_pages 253569
nr_dirty 0
nr_writeback 0
nr_writeback_temp 0
nr_shmem 178741
nr_shmem_hugepages 0
nr_shmem_pmdmapped 0
nr_file_hugepages 0
nr_file_pmdmapped 0
nr_anon_transparent_hugepages 1
nr_vmscan_write 0
nr_vmscan_immediate_reclaim 0
nr_dirtied 0
nr_written 0
nr_throttled_written 0
nr_kernel_misc_reclaimable 0
nr_foll_pin_acquired 0
nr_foll_pin_released 0
nr_kernel_stack 2780
nr_page_table_pages 344
nr_sec_page_table_pages 0
nr_swapcached 0
pgpromote_success 0
pgpromote_candidate 0
nr_dirty_threshold 356564
nr_dirty_background_threshold 178064
pgpgin 890508
pgpgout 0
pswpin 0
pswpout 0
pgalloc_dma 272
pgalloc_dma32 261
pgalloc_normal 1328079
pgalloc_movable 0
pgalloc_device 0
allocstall_dma 0
allocstall_dma32 0
allocstall_normal 0
allocstall_movable 0
allocstall_device 0
pgskip_dma 0
pgskip_dma32 0
pgskip_normal 0
pgskip_movable 0
pgskip_device 0
pgfree 3077011
pgactivate 0
pgdeactivate 0
pglazyfree 0
pgfault 176973
pgmajfault 488
pglazyfreed 0
pgrefill 0
pgreuse 19230
pgsteal_kswapd 0
pgsteal_direct 0
pgsteal_khugepaged 0
pgdemote_kswapd 0
pgdemote_direct 0
pgdemote_khugepaged 0
pgscan_kswapd 0
pgscan_direct 0
pgscan_khugepaged 0
pgscan_direct_throttle 0
pgscan_anon 0
pgscan_file 0
pgsteal_anon 0
pgsteal_file 0
zone_reclaim_failed 0
pginodesteal 0
slabs_scanned 0
kswapd_inodesteal 0
kswapd_low_wmark_hit_quickly 0
kswapd_high_wmark_hit_quickly 0
pageoutrun 0
pgrotated 0
drop_pagecache 0
drop_slab 0
oom_kill 0
numa_pte_updates 0
numa_huge_pte_updates 0
numa_hint_faults 0
numa_hint_faults_local 0
numa_pages_migrated 0
pgmigrate_success 0
pgmigrate_fail 0
thp_migration_success 0
thp_migration_fail 0
thp_migration_split 0
compact_migrate_scanned 0
compact_free_scanned 0
compact_isolated 0
compact_stall 0
compact_fail 0
compact_success 0
compact_daemon_wake 0
compact_daemon_migrate_scanned 0
compact_daemon_free_scanned 0
htlb_buddy_alloc_success 0
htlb_buddy_alloc_fail 0
cma_alloc_success 0
cma_alloc_fail 0
unevictable_pgs_culled 27002
unevictable_pgs_scanned 0
unevictable_pgs_rescued 744
unevictable_pgs_mlocked 744
unevictable_pgs_munlocked 744
unevictable_pgs_cleared 0
unevictable_pgs_stranded 0
thp_fault_alloc 13
thp_fault_fallback 0
thp_fault_fallback_charge 0
thp_collapse_alloc 4
thp_collapse_alloc_failed 0
thp_file_alloc 0
thp_file_fallback 0
thp_file_fallback_charge 0
thp_file_mapped 0
thp_split_page 0
thp_split_page_failed 0
thp_deferred_split_page 1
thp_split_pmd 1
thp_scan_exceed_none_pte 0
thp_scan_exceed_swap_pte 0
thp_scan_exceed_share_pte 0
thp_split_pud 0
thp_zero_page_alloc 0
thp_zero_page_alloc_failed 0
thp_swpout 0
thp_swpout_fallback 0
balloon_inflate 0
balloon_deflate 0
balloon_migrate 0
swap_ra 0
swap_ra_hit 0
ksm_swpin_copy 0
cow_ksm 0
zswpin 0
zswpout 0
direct_map_level2_splits 29
direct_map_level3_splits 0
nr_unstable 0'
_PROC_VERSION='Linux version 6.2.1 (user@localhost) (gcc (GCC) 12.2.1 20230201, GNU ld (GNU Binutils) 2.40) #1 SMP PREEMPT_DYNAMIC Wed, 01 Mar 2023 00:00:00 +0000'
_PROC_UPTIME='124.08 932.80'
_PROC_STAT='cpu 1957 0 2877 93280 262 342 254 87 0 0
cpu0 31 0 226 12027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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 140223
btime 1680020856
processes 772
procs_running 2
procs_blocked 0
softirq 75663 0 5903 6 25375 10774 0 243 11685 0 21677'
_PROC_LOADAVG='0.12 0.07 0.02 2/165 765'
install_udocker(){
apt update
yes | pkg install -y python-pip patch proot
if pip freeze | grep -Eq "^udocker=="; then
pip uninstall -y udocker
fi
pip install -U udocker
}
fix_udocker(){
fix_udocker_conf(){
mkdir -p "${HOME}/.udocker/lib"
cat <<'EOF' > "${HOME}/.udocker/udocker.conf"
[DEFAULT]
use_proot_executable = /data/data/com.termux/files/usr/bin/proot
proot_link2symlink = True
verbose_level = 1
EOF
echo "2.9.9" > "${HOME}/.udocker/lib/VERSION"
}
fix_udocker_hardlinks(){
# Fix errors when extracting hardlinks from Docker images
# https://github.com/indigo-dc/udocker/issues/388#issuecomment-1527277800
UDOCKER_PATCH='
--- udocker/container/structure.py
+++ udocker.mod/container/structure.py
@@ -281,7 +281,7 @@
if Msg.level >= Msg.VER:
verbose = '\'v'\''
Msg().out("Info: extracting:", tarf, l=Msg.INF)
- cmd = ["tar", "-C", destdir, "-x" + verbose,
+ cmd = ["proot", "--link2symlink", "tar", "-C", destdir, "-x" + verbose,
"--one-file-system", "--no-same-owner", "--overwrite",
"--exclude=dev/*", "--exclude=etc/udev/devices/*",
"--no-same-permissions", r"--exclude=.wh.*",
'
TMP_PATCH_FILE="$(mktemp)"
patch -p0 --no-backup-if-mismatch -r "${TMP_PATCH_FILE}" -d "$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo "${PREFIX}/lib/python3.11/site-packages")" 2>/dev/null >/dev/null <<< "${UDOCKER_PATCH}" || true
rm -rf "${TMP_PATCH_FILE}"
return 0
}
fix_udocker_qemu(){
# Fix qemu not found errors that occurs when running non-native platform containers
# Not needed for g4f container, but helpful for your other platform containers if any
UDOCKER_PATCH='
--- udocker/engine/base.py
+++ udocker.mod/engine/base.py
@@ -690,4 +690,4 @@
if not qemu_path:
Msg().err("Warning: qemu required but not available", l=Msg.WAR)
return ""
- return qemu_path if return_path else qemu_filename
+ return qemu_path if return_path else qemu_path
'
TMP_PATCH_FILE="$(mktemp)"
patch -p0 --no-backup-if-mismatch -r "${TMP_PATCH_FILE}" -d "$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo "${PREFIX}/lib/python3.11/site-packages")" 2>/dev/null >/dev/null <<< "${UDOCKER_PATCH}" || true
rm -rf "${TMP_PATCH_FILE}"
return 0
}
fix_udocker_proot(){
# Fix shm errors
# https://github.com/termux/proot-distro/issues/19
# Fix hardcoded bad port errors
#https://github.com/termux/proot-distro/issues/22
UDOCKER_PATCH='
--- udocker/engine/proot.py
+++ udocker.mod/engine/proot.py
@@ -166,7 +166,7 @@
if (Config.conf['proot_link2symlink'] and
self._has_option("--link2symlink")):
- proot_link2symlink = ["--link2symlink", ]
+ proot_link2symlink = ["--link2symlink", "--sysvipc", "-L", "-p", ]
else:
proot_link2symlink = []
'
TMP_PATCH_FILE="$(mktemp)"
patch -p0 --no-backup-if-mismatch -r "${TMP_PATCH_FILE}" -d "$(python -c "import sysconfig; print(sysconfig.get_path('platlib'))" 2>/dev/null || echo "${PREFIX}/lib/python3.11/site-packages")" 2>/dev/null >/dev/null <<< "${UDOCKER_PATCH}" || true
rm -rf "${TMP_PATCH_FILE}"
return 0
}
fix_udocker_conf
fix_udocker_hardlinks
fix_udocker_qemu
fix_udocker_proot
return 0
}
proot_write_tmp(){
[ -z "$1" ] && return 1
_TMP_FILE="$(mktemp)"
echo -n "$1" > "$_TMP_FILE"
echo -n "$_TMP_FILE"
return 0
}
udocker_create(){
[ -z "$1" ] && exit 1
[ -z "$2" ] && exit 1
if ! udocker inspect "$1" &>/dev/null; then
udocker rm "$1" &>/dev/null
UDOCKER_LOGLEVEL=3 udocker pull "$2" || exit 1
fi
udocker create --name="$1" "$2" &>/dev/null
return 0
}
udocker_prune(){
for i in $(udocker ps | cut -d\ -f1 | tail -n +2); do
if ! udocker inspect "${i}" &>/dev/null; then
udocker rm -f "${i}" &>/dev/null || true
fi
done
return 0
}
udocker_check(){
udocker -V &>/dev/null && command -v patch &>/dev/null && fix_udocker || { install_udocker; fix_udocker; }
}
udocker_run(){
udocker run -v "$(mktemp -d):/dev/shm" -v "$(mktemp -d):/tmp" -v "$(proot_write_tmp "nameserver 8.8.8.8"):/etc/resolv.conf" -v "$(proot_write_tmp "$_PROC_CAP_LAST_CAP"):/proc/sys/kernel/cap_last_cap" -v "$(proot_write_tmp "$_PROC_VM_STAT"):/proc/vmstat" -v "$(proot_write_tmp "$_PROC_VERSION"):/proc/version" -v "$(proot_write_tmp "$_PROC_UPTIME"):/proc/uptime" -v "$(proot_write_tmp "$_PROC_STAT"):/proc/stat" -v "$(proot_write_tmp "$_PROC_LOADAVG"):/proc/loadavg" -v /proc/self/fd/2:/dev/stderr -v /proc/self/fd/1:/dev/stdout -v /proc/self/fd/0:/dev/stdin -v /proc/self/fd:/dev/fd -v /dev/urandom:/dev/random -e QTWEBENGINE_DISABLE_SANDBOX="1" -e MOZ_FAKE_NO_SANDBOX="1" -e XDG_RUNTIME_DIR="/tmp/runtime-root" -e PULSE_SERVER="127.0.0.1" "$@"
}