karnel-termux 4.7.7 → 4.9.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.
- package/README.md +46 -5
- package/install.sh +2 -2
- package/karnel/cli/commands/backup.sh +13 -2
- package/karnel/cli/commands/doctor/fixes.sh +111 -13
- package/karnel/cli/commands/doctor.sh +112 -10
- package/karnel/cli/commands/init.sh +2 -2
- package/karnel/cli/commands/install.sh +155 -118
- package/karnel/cli/commands/list.sh +106 -13
- package/karnel/cli/commands/open.sh +28 -8
- package/karnel/cli/commands/reinstall.sh +79 -46
- package/karnel/cli/commands/restore.sh +16 -0
- package/karnel/cli/commands/robin.sh +656 -0
- package/karnel/cli/commands/search.sh +1 -0
- package/karnel/cli/commands/show.sh +1 -0
- package/karnel/cli/commands/start.sh +12 -2
- package/karnel/cli/commands/status.sh +11 -0
- package/karnel/cli/commands/uninstall.sh +47 -0
- package/karnel/cli/commands/update.sh +43 -0
- package/karnel/cli/commands/version.sh +2 -0
- package/karnel/cli/commands/voice.sh +11 -6
- package/karnel/cli/karnel.sh +115 -69
- package/karnel/modules/ai.sh +21 -6
- package/karnel/modules/deploy.sh +4 -0
- package/karnel/modules/dev.sh +19 -46
- package/karnel/modules/games.sh +81 -4
- package/karnel/modules/network.sh +88 -0
- package/karnel/modules/osint.sh +123 -0
- package/karnel/modules/shell.sh +1 -1
- package/karnel/modules/ui.sh +4 -0
- package/karnel/modules/utils.sh +88 -0
- package/karnel/modules/voice.sh +8 -2
- package/karnel/tools/ai/all.sh +1 -0
- package/karnel/tools/ai/antigravity-cli/install.sh +0 -0
- package/karnel/tools/ai/claude-code/install.sh +0 -0
- package/karnel/tools/ai/cline/install.sh +8 -8
- package/karnel/tools/ai/codegraph/install.sh +8 -5
- package/karnel/tools/ai/codex/install.sh +0 -0
- package/karnel/tools/ai/command-code/install.sh +0 -0
- package/karnel/tools/ai/copilot-termux/install.sh +0 -0
- package/karnel/tools/ai/crush/install.sh +1 -1
- package/karnel/tools/ai/ctx7/install.sh +0 -0
- package/karnel/tools/ai/engram/install.sh +5 -2
- package/karnel/tools/ai/freebuff/install.sh +0 -0
- package/karnel/tools/ai/gemini-cli/install.sh +0 -0
- package/karnel/tools/ai/gentle-ai/install.sh +1 -1
- package/karnel/tools/ai/hermes-agent/install.sh +0 -0
- package/karnel/tools/ai/kilocode-cli/install.sh +0 -0
- package/karnel/tools/ai/kimchi-code/install.sh +3 -1
- package/karnel/tools/ai/kimi-code/install.sh +0 -0
- package/karnel/tools/ai/kiro/install.sh +0 -0
- package/karnel/tools/ai/mimocode/install.sh +0 -0
- package/karnel/tools/ai/minimax-cli/install.sh +0 -0
- package/karnel/tools/ai/mistral-vibe/install.sh +0 -0
- package/karnel/tools/ai/odysseus/install.sh +0 -0
- package/karnel/tools/ai/ollama/install.sh +0 -0
- package/karnel/tools/ai/omni-route/install.sh +1 -1
- package/karnel/tools/ai/openclaude/install.sh +0 -0
- package/karnel/tools/ai/openclaw/install.sh +0 -0
- package/karnel/tools/ai/opencode/install.sh +0 -0
- package/karnel/tools/ai/openspec/install.sh +0 -0
- package/karnel/tools/ai/pi/install.sh +0 -0
- package/karnel/tools/ai/qoder/README.md +50 -0
- package/karnel/tools/ai/qoder/bin/qodercli +28 -0
- package/karnel/tools/ai/qoder/helper/qoder_helper.c +47 -0
- package/karnel/tools/ai/qoder/install.sh +367 -0
- package/karnel/tools/ai/qwen-code/install.sh +0 -0
- package/karnel/tools/auto/all.sh +1 -1
- package/karnel/tools/auto/n8n/install.sh +0 -0
- package/karnel/tools/db/all.sh +1 -1
- package/karnel/tools/db/mariadb/install.sh +0 -0
- package/karnel/tools/db/mongodb/install.sh +0 -0
- package/karnel/tools/db/postgresql/install.sh +0 -0
- package/karnel/tools/db/sqlite/install.sh +0 -0
- package/karnel/tools/deploy/all.sh +2 -2
- package/karnel/tools/deploy/netlify/install.sh +0 -0
- package/karnel/tools/deploy/railway/install.sh +1 -1
- package/karnel/tools/deploy/vercel/install.sh +0 -0
- package/karnel/tools/dev/all.sh +36 -13
- package/karnel/tools/dev/bat/install.sh +0 -0
- package/karnel/tools/dev/bc/install.sh +0 -0
- package/karnel/tools/dev/cloudflared/install.sh +0 -0
- package/karnel/tools/dev/curl/install.sh +0 -0
- package/karnel/tools/dev/fzf/install.sh +36 -9
- package/karnel/tools/dev/gh/install.sh +0 -0
- package/karnel/tools/dev/html2text/install.sh +0 -0
- package/karnel/tools/dev/imagemagick/install.sh +0 -0
- package/karnel/tools/dev/jq/install.sh +0 -0
- package/karnel/tools/dev/lsd/install.sh +0 -0
- package/karnel/tools/dev/make/install.sh +0 -0
- package/karnel/tools/dev/ncurses/install.sh +0 -0
- package/karnel/tools/dev/proot/install.sh +0 -0
- package/karnel/tools/dev/shfmt/install.sh +0 -0
- package/karnel/tools/dev/snyk/install.sh +0 -0
- package/karnel/tools/dev/tmate/install.sh +0 -0
- package/karnel/tools/dev/translate/install.sh +0 -0
- package/karnel/tools/dev/tree/install.sh +0 -0
- package/karnel/tools/dev/udocker/install.sh +0 -0
- package/karnel/tools/dev/wget/install.sh +0 -0
- package/karnel/tools/editor/all.sh +1 -1
- package/karnel/tools/editor/code-server/install.sh +0 -0
- package/karnel/tools/games/all.sh +1 -1
- package/karnel/tools/games/arcade/install.sh +0 -0
- package/karnel/tools/games/buzz/install.sh +0 -0
- package/karnel/tools/games/ctfgod/install.sh +0 -0
- package/karnel/tools/games/detective/install.sh +0 -0
- package/karnel/tools/games/pet-friends/install.sh +0 -0
- package/karnel/tools/games/tamagotchi/install.sh +0 -0
- package/karnel/tools/lang/all.sh +2 -1
- package/karnel/tools/lang/bun/bin/bun +27 -0
- package/karnel/tools/lang/bun/install.sh +318 -0
- package/karnel/tools/lang/bun/src/bun-shim.c +352 -0
- package/karnel/tools/lang/bun/src/bun_wrapper.c +55 -0
- package/karnel/tools/lang/clang/install.sh +0 -0
- package/karnel/tools/lang/golang/install.sh +0 -0
- package/karnel/tools/lang/nodejs/install.sh +0 -0
- package/karnel/tools/lang/perl/install.sh +0 -0
- package/karnel/tools/lang/php/install.sh +0 -0
- package/karnel/tools/lang/python/install.sh +0 -0
- package/karnel/tools/lang/rust/install.sh +0 -0
- package/karnel/tools/network/all.sh +65 -0
- package/karnel/tools/network/dark/README.md +45 -0
- package/karnel/tools/network/dark/dark.py +709 -0
- package/karnel/tools/network/dark/install.sh +51 -0
- package/karnel/tools/network/dedsec-network/README.md +42 -0
- package/karnel/tools/network/dedsec-network/dedsec-network.py +709 -0
- package/karnel/tools/network/dedsec-network/install.sh +50 -0
- package/karnel/tools/npm/all.sh +1 -1
- package/karnel/tools/npm/live-server/install.sh +0 -0
- package/karnel/tools/npm/localtunnel/install.sh +0 -0
- package/karnel/tools/npm/markserv/install.sh +0 -0
- package/karnel/tools/npm/ncu/install.sh +0 -0
- package/karnel/tools/npm/nestjs/install.sh +0 -0
- package/karnel/tools/npm/ngrok/install.sh +0 -0
- package/karnel/tools/npm/prettier/install.sh +0 -0
- package/karnel/tools/npm/psqlformat/install.sh +0 -0
- package/karnel/tools/npm/turbopack/install.sh +2 -0
- package/karnel/tools/npm/typescript/install.sh +0 -0
- package/karnel/tools/npm/vercel/install.sh +0 -0
- package/karnel/tools/osint/all.sh +65 -0
- package/karnel/tools/osint/robin/README.md +99 -0
- package/karnel/tools/osint/robin/common.sh +258 -0
- package/karnel/tools/osint/robin/install.sh +548 -0
- package/karnel/tools/osint/robin/requirements-termux.txt +33 -0
- package/karnel/tools/shell/all.sh +1 -1
- package/karnel/tools/shell/better-npm/install.sh +0 -0
- package/karnel/tools/shell/fzf-tab/install.sh +0 -0
- package/karnel/tools/shell/history-substring/install.sh +0 -0
- package/karnel/tools/shell/powerlevel10k/install.sh +0 -0
- package/karnel/tools/shell/you-should-use/install.sh +0 -0
- package/karnel/tools/shell/zsh-autopair/install.sh +0 -0
- package/karnel/tools/shell/zsh-autosuggestions/install.sh +0 -0
- package/karnel/tools/shell/zsh-completions/install.sh +0 -0
- package/karnel/tools/shell/zsh-defer/install.sh +0 -0
- package/karnel/tools/shell/zsh-syntax-highlighting/install.sh +0 -0
- package/karnel/tools/ui/all.sh +1 -1
- package/karnel/tools/ui/banner/install.sh +0 -0
- package/karnel/tools/ui/cursor/install.sh +0 -0
- package/karnel/tools/ui/extra-keys/install.sh +0 -0
- package/karnel/tools/ui/font/install.sh +0 -0
- package/karnel/tools/utils/all.sh +88 -0
- package/karnel/tools/utils/applaunch/README.md +43 -0
- package/karnel/tools/{dev → utils}/applaunch/install.sh +3 -3
- package/karnel/tools/utils/fconv/README.md +41 -0
- package/karnel/tools/{dev → utils}/fconv/install.sh +3 -3
- package/karnel/tools/utils/filecheck/README.md +41 -0
- package/karnel/tools/{dev → utils}/filecheck/install.sh +3 -3
- package/karnel/tools/utils/httptmux/README.md +42 -0
- package/karnel/tools/{dev → utils}/httptmux/install.sh +0 -0
- package/karnel/tools/utils/notes/README.md +41 -0
- package/karnel/tools/{dev → utils}/notes/install.sh +3 -3
- package/karnel/tools/utils/passman/README.md +42 -0
- package/karnel/tools/{dev → utils}/passman/install.sh +3 -3
- package/karnel/tools/utils/qrcode/README.md +41 -0
- package/karnel/tools/utils/qrcode/install.sh +50 -0
- package/karnel/tools/utils/qrcode/qrcode.py +89 -0
- package/karnel/tools/utils/splash/README.md +41 -0
- package/karnel/tools/{dev → utils}/splash/install.sh +3 -3
- package/karnel/tools/utils/treex/README.md +41 -0
- package/karnel/tools/{dev → utils}/treex/install.sh +3 -3
- package/karnel/tools/utils/websites/README.md +41 -0
- package/karnel/tools/{dev → utils}/websites/install.sh +3 -3
- package/karnel/tools/utils/zork/README.md +43 -0
- package/karnel/tools/{dev → utils}/zork/install.sh +3 -3
- package/karnel/utils/banner.sh +8 -6
- package/karnel/utils/bootstrap.sh +1 -1
- package/karnel/utils/env.sh +16 -2
- package/karnel/utils/log.sh +0 -1
- package/karnel/utils/tools.sh +9 -2
- package/package.json +6 -1
- package/scripts/check-package.js +45 -0
- package/scripts/completion.bash +8 -3
- package/scripts/completion.zsh +8 -13
- package/karnel/cli/commands/doctor/system.sh +0 -87
- package/karnel/tools/dev/applaunch/__pycache__/applaunch.cpython-314.pyc +0 -0
- package/karnel/tools/dev/fconv/__pycache__/fconv.cpython-314.pyc +0 -0
- package/karnel/tools/dev/filecheck/__pycache__/filecheck.cpython-314.pyc +0 -0
- package/karnel/tools/dev/notes/__pycache__/notes.cpython-314.pyc +0 -0
- package/karnel/tools/dev/passman/__pycache__/passman.cpython-314.pyc +0 -0
- package/karnel/tools/dev/splash/__pycache__/splash.cpython-314.pyc +0 -0
- package/karnel/tools/dev/websites/__pycache__/websites.cpython-314.pyc +0 -0
- package/karnel/tools/games/arcade/__pycache__/arcade.cpython-314.pyc +0 -0
- package/karnel/tools/games/buzz/__pycache__/buzz.cpython-314.pyc +0 -0
- package/karnel/tools/games/ctfgod/__pycache__/ctfgod.cpython-314.pyc +0 -0
- package/karnel/tools/games/detective/__pycache__/detective.cpython-314.pyc +0 -0
- package/karnel/tools/games/pet-friends/__pycache__/pet-friends.cpython-314.pyc +0 -0
- package/karnel/tools/games/tamagotchi/__pycache__/tamagotchi.cpython-314.pyc +0 -0
- package/karnel/tools/games/terminal-arcade/__pycache__/terminal-arcade.cpython-314.pyc +0 -0
- /package/karnel/tools/{dev → utils}/applaunch/applaunch.py +0 -0
- /package/karnel/tools/{dev → utils}/fconv/fconv.py +0 -0
- /package/karnel/tools/{dev → utils}/filecheck/filecheck.py +0 -0
- /package/karnel/tools/{dev → utils}/notes/notes.py +0 -0
- /package/karnel/tools/{dev → utils}/passman/passman.py +0 -0
- /package/karnel/tools/{dev → utils}/splash/splash.py +0 -0
- /package/karnel/tools/{dev → utils}/treex/treex.py +0 -0
- /package/karnel/tools/{dev → utils}/websites/websites.py +0 -0
|
@@ -41,18 +41,45 @@ _update_fzf_pkg_impl() {
|
|
|
41
41
|
return 0
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
_fix_fzf_zshrc() {
|
|
45
|
+
local zshrc="$HOME/.zshrc"
|
|
46
|
+
[[ -f "$zshrc" ]] || return 0
|
|
47
|
+
|
|
48
|
+
if ! grep -qs "fzf/key-bindings" "$zshrc" 2>/dev/null; then
|
|
49
|
+
return 0
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
if grep -qs "autoload.*up-line-or-beginning-search" "$zshrc" 2>/dev/null; then
|
|
53
|
+
return 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
local tmpfile
|
|
57
|
+
tmpfile=$(mktemp)
|
|
58
|
+
while IFS= read -r line; do
|
|
59
|
+
if [[ "$line" == *"fzf/key-bindings"* ]]; then
|
|
60
|
+
echo "# Ensure up-line-or-beginning-search is available for fzf" >> "$tmpfile"
|
|
61
|
+
echo "autoload -Uz up-line-or-beginning-search 2>/dev/null" >> "$tmpfile"
|
|
62
|
+
echo "zle -N up-line-or-beginning-search 2>/dev/null" >> "$tmpfile"
|
|
63
|
+
fi
|
|
64
|
+
echo "$line" >> "$tmpfile"
|
|
65
|
+
done < "$zshrc"
|
|
66
|
+
mv "$tmpfile" "$zshrc"
|
|
67
|
+
log_info "Fixed zsh up-line-or-beginning-search widget loading for fzf"
|
|
68
|
+
}
|
|
69
|
+
|
|
44
70
|
install_fzf() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
71
|
+
if command -v fzf &>/dev/null; then
|
|
72
|
+
log_info "Fzf is already installed"
|
|
73
|
+
return 2
|
|
74
|
+
fi
|
|
75
|
+
log_info "Installing Fzf..."
|
|
50
76
|
|
|
51
|
-
|
|
77
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
52
78
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
79
|
+
_install_fzf_pkg || return 1
|
|
80
|
+
_fix_fzf_zshrc
|
|
81
|
+
log_success "Fzf installed"
|
|
82
|
+
return 0
|
|
56
83
|
}
|
|
57
84
|
|
|
58
85
|
uninstall_fzf() {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/karnel/tools/lang/all.sh
CHANGED
|
@@ -5,6 +5,7 @@ import "@/utils/log"
|
|
|
5
5
|
LOG_FILE="$KARNEL_CACHE/install_lang.log"
|
|
6
6
|
|
|
7
7
|
LANGUAGE_PACKAGES=(
|
|
8
|
+
"bun"
|
|
8
9
|
"nodejs"
|
|
9
10
|
"python"
|
|
10
11
|
"perl"
|
|
@@ -42,7 +43,7 @@ _batch_lang() {
|
|
|
42
43
|
done
|
|
43
44
|
|
|
44
45
|
progress_done "$total"
|
|
45
|
-
|
|
46
|
+
printf -v "$count_var" '%s' "$count"
|
|
46
47
|
return $failed
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/data/data/com.termux/files/usr/bin/bash
|
|
2
|
+
|
|
3
|
+
UBUNTU_ROOTFS="__UBUNTU_ROOTFS__"
|
|
4
|
+
|
|
5
|
+
EXCLUDE_REGEX="^(PATH|LD_PRELOAD|LD_LIBRARY_PATH|PREFIX|HOME|PWD|OLDPWD|SHELL|IFS|_|SHLVL|PROMPT_COMMAND|TERMCAP|LS_COLORS|TERM)="
|
|
6
|
+
|
|
7
|
+
ENV_ARGS=()
|
|
8
|
+
while IFS= read -r line; do
|
|
9
|
+
if [[ -n "$line" && ! "$line" =~ $EXCLUDE_REGEX ]]; then
|
|
10
|
+
ENV_ARGS+=("--env" "$line")
|
|
11
|
+
fi
|
|
12
|
+
done < <(env)
|
|
13
|
+
|
|
14
|
+
ENV_ARGS+=(
|
|
15
|
+
"--env" "SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt"
|
|
16
|
+
"--env" "TERM=$TERM"
|
|
17
|
+
"--env" "HOME=/root"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
unset LD_PRELOAD
|
|
21
|
+
proot-distro login \
|
|
22
|
+
"${ENV_ARGS[@]}" \
|
|
23
|
+
--termux-home \
|
|
24
|
+
--shared-tmp \
|
|
25
|
+
--work-dir $PWD \
|
|
26
|
+
ubuntu \
|
|
27
|
+
-- /usr/local/bin/bun "$@"
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
import "@/utils/log"
|
|
4
|
+
import "@/utils/colors"
|
|
5
|
+
import "@/utils/version"
|
|
6
|
+
|
|
7
|
+
LOG_FILE="$KARNEL_CACHE/install_lang.log"
|
|
8
|
+
BUN_DATA_DIR="$KARNEL_DATA/bun"
|
|
9
|
+
BUN_REPO="oven-sh/bun"
|
|
10
|
+
|
|
11
|
+
_bun_detect_ubuntu_root() {
|
|
12
|
+
local root
|
|
13
|
+
root="$(find /data/data/com.termux -maxdepth 10 -type d \
|
|
14
|
+
-name "rootfs" -path "*/containers/ubuntu/*" 2>/dev/null | head -1)"
|
|
15
|
+
if [ -z "$root" ]; then
|
|
16
|
+
root="$(find /data/data/com.termux -maxdepth 10 -type d \
|
|
17
|
+
-name "ubuntu" -path "*/installed-rootfs/*" 2>/dev/null | head -1)"
|
|
18
|
+
fi
|
|
19
|
+
echo "$root"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_bun_proot_ubuntu() {
|
|
23
|
+
proot-distro login --shared-tmp ubuntu -- "$@"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_get_latest_bun_version() {
|
|
27
|
+
_get_remote_github_version "$BUN_REPO"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_bun_fetch_version() {
|
|
31
|
+
local raw tag
|
|
32
|
+
raw="$(curl -fsSL "https://api.github.com/repos/$BUN_REPO/releases/latest" 2>/dev/null)"
|
|
33
|
+
tag="$(echo "$raw" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')"
|
|
34
|
+
if [ -z "$tag" ]; then
|
|
35
|
+
raw="$(curl -fsSL "https://api.github.com/repos/$BUN_REPO/tags?per_page=100" 2>/dev/null)"
|
|
36
|
+
tag="$(echo "$raw" | grep '"name":' | sed -E 's/.*"([^"]+)".*/\1/' | sort -V | tail -1)"
|
|
37
|
+
fi
|
|
38
|
+
_parse_version "$tag"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_bun_install_deps_native() {
|
|
42
|
+
loading "Installing glibc and dependencies" _bun_install_deps_native_impl
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_bun_install_deps_native_impl() {
|
|
46
|
+
if [[ ! -f $PREFIX/etc/apt/sources.list.d/glibc.list ]]; then
|
|
47
|
+
if ! pkg install glibc-repo -y &>>"$LOG_FILE"; then
|
|
48
|
+
log_error "Failed to install glibc-repo"
|
|
49
|
+
return 1
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
if [[ ! -f $PREFIX/glibc/lib/libc.so.6 ]]; then
|
|
53
|
+
if ! pkg install glibc -y &>>"$LOG_FILE"; then
|
|
54
|
+
log_error "Failed to install glibc"
|
|
55
|
+
return 1
|
|
56
|
+
fi
|
|
57
|
+
fi
|
|
58
|
+
declare -A DEPS=(
|
|
59
|
+
["clang"]="clang"
|
|
60
|
+
["unzip"]="unzip"
|
|
61
|
+
["curl"]="curl"
|
|
62
|
+
)
|
|
63
|
+
local pkg_name bin_name
|
|
64
|
+
for pkg_name in "${!DEPS[@]}"; do
|
|
65
|
+
bin_name="${DEPS[$pkg_name]}"
|
|
66
|
+
if ! command -v "$bin_name" &>/dev/null; then
|
|
67
|
+
if ! pkg install "$pkg_name" -y &>>"$LOG_FILE"; then
|
|
68
|
+
log_error "Failed to install $pkg_name"
|
|
69
|
+
return 1
|
|
70
|
+
fi
|
|
71
|
+
fi
|
|
72
|
+
done
|
|
73
|
+
return 0
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_download_bun_binary_native() {
|
|
77
|
+
loading "Downloading Bun (glibc)" _download_bun_binary_native_impl
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_download_bun_binary_native_impl() {
|
|
81
|
+
local version
|
|
82
|
+
version="$(_bun_fetch_version)"
|
|
83
|
+
if [ -z "$version" ]; then
|
|
84
|
+
log_error "Failed to fetch latest Bun version"
|
|
85
|
+
return 1
|
|
86
|
+
fi
|
|
87
|
+
local arch
|
|
88
|
+
arch="$(uname -m)"
|
|
89
|
+
if [ "$arch" != "aarch64" ] && [ "$arch" != "arm64" ]; then
|
|
90
|
+
log_error "Bun native build only supports aarch64 (got: $arch)"
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
mkdir -p "$BUN_DATA_DIR"
|
|
94
|
+
local zip_name="bun-linux-aarch64.zip"
|
|
95
|
+
curl -fsSL "https://github.com/$BUN_REPO/releases/download/bun-v$version/$zip_name" \
|
|
96
|
+
-o "$BUN_DATA_DIR/$zip_name" &>>"$LOG_FILE" || {
|
|
97
|
+
log_error "Failed to download Bun binary"
|
|
98
|
+
return 1
|
|
99
|
+
}
|
|
100
|
+
if ! unzip -o "$BUN_DATA_DIR/$zip_name" -d "$BUN_DATA_DIR" &>>"$LOG_FILE"; then
|
|
101
|
+
log_error "Failed to extract Bun binary"
|
|
102
|
+
return 1
|
|
103
|
+
fi
|
|
104
|
+
rm -f "$BUN_DATA_DIR/$zip_name"
|
|
105
|
+
local extracted="$BUN_DATA_DIR/bun-linux-aarch64/bun"
|
|
106
|
+
if [ ! -f "$extracted" ]; then
|
|
107
|
+
log_error "Bun binary not found after extraction"
|
|
108
|
+
return 1
|
|
109
|
+
fi
|
|
110
|
+
mv -f "$extracted" "$BUN_DATA_DIR/bun.real"
|
|
111
|
+
rm -rf "$BUN_DATA_DIR/bun-linux-aarch64"
|
|
112
|
+
if [ ! -f "$BUN_DATA_DIR/bun.real" ]; then
|
|
113
|
+
log_error "Bun binary not found after extraction"
|
|
114
|
+
return 1
|
|
115
|
+
fi
|
|
116
|
+
chmod +x "$BUN_DATA_DIR/bun.real"
|
|
117
|
+
return 0
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_compile_bun_helper() {
|
|
121
|
+
loading "Compiling bun helper" _compile_bun_helper_impl
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_compile_bun_helper_impl() {
|
|
125
|
+
local shim_src="$KARNEL_PATH/tools/lang/bun/src/bun-shim.c"
|
|
126
|
+
local wrapper_src="$KARNEL_PATH/tools/lang/bun/src/bun_wrapper.c"
|
|
127
|
+
if [ ! -f "$shim_src" ]; then
|
|
128
|
+
log_error "Shim source not found at $shim_src"
|
|
129
|
+
return 1
|
|
130
|
+
fi
|
|
131
|
+
if [ ! -f "$wrapper_src" ]; then
|
|
132
|
+
log_error "Wrapper source not found at $wrapper_src"
|
|
133
|
+
return 1
|
|
134
|
+
fi
|
|
135
|
+
mkdir -p "$PREFIX/lib"
|
|
136
|
+
if ! clang -O2 -fPIC -shared -nostdlib -o "$PREFIX/lib/bun-shim.so" "$shim_src" &>>"$LOG_FILE"; then
|
|
137
|
+
log_error "Failed to compile bun shim"
|
|
138
|
+
return 1
|
|
139
|
+
fi
|
|
140
|
+
chmod +x "$PREFIX/lib/bun-shim.so"
|
|
141
|
+
local wrapper_tmp="$TMPDIR/bun_wrapper_$$.c"
|
|
142
|
+
sed "s|__BUN_REAL__|$BUN_DATA_DIR/bun.real|g" "$wrapper_src" >"$wrapper_tmp"
|
|
143
|
+
if ! clang -O2 -o "$PREFIX/bin/bun" "$wrapper_tmp" &>>"$LOG_FILE"; then
|
|
144
|
+
rm -f "$wrapper_tmp"
|
|
145
|
+
log_error "Failed to compile bun wrapper"
|
|
146
|
+
return 1
|
|
147
|
+
fi
|
|
148
|
+
chmod +x "$PREFIX/bin/bun"
|
|
149
|
+
rm -f "$wrapper_tmp"
|
|
150
|
+
return 0
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_install_bun_native() {
|
|
154
|
+
_bun_install_deps_native || return 1
|
|
155
|
+
_download_bun_binary_native || return 1
|
|
156
|
+
_compile_bun_helper || return 1
|
|
157
|
+
ln -sf bun "$PREFIX/bin/bunx"
|
|
158
|
+
log_success "Bun installed natively (glibc build)"
|
|
159
|
+
return 0
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_install_bun_proot() {
|
|
163
|
+
loading "Installing Bun (proot-distro)" _install_bun_proot_impl
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
_install_bun_proot_impl() {
|
|
167
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
168
|
+
if ! command -v proot-distro &>/dev/null; then
|
|
169
|
+
pkg install proot-distro -y &>>"$LOG_FILE"
|
|
170
|
+
fi
|
|
171
|
+
if [ ! -d "$(_bun_detect_ubuntu_root)" ]; then
|
|
172
|
+
proot-distro install ubuntu:24.04 &>>"$LOG_FILE"
|
|
173
|
+
fi
|
|
174
|
+
local version
|
|
175
|
+
version="$(_bun_fetch_version)"
|
|
176
|
+
if [ -z "$version" ]; then
|
|
177
|
+
log_error "Failed to fetch latest Bun version"
|
|
178
|
+
return 1
|
|
179
|
+
fi
|
|
180
|
+
local download_url="https://github.com/$BUN_REPO/releases/download/bun-v$version/bun-linux-aarch64.zip"
|
|
181
|
+
_bun_proot_ubuntu /bin/bash -c \
|
|
182
|
+
'apt-get update && apt-get upgrade -y && apt-get install -y curl ca-certificates unzip' \
|
|
183
|
+
&>>"$LOG_FILE"
|
|
184
|
+
_bun_proot_ubuntu /bin/bash -c "
|
|
185
|
+
export HOME=/root TMPDIR=/tmp
|
|
186
|
+
cd /tmp &&
|
|
187
|
+
curl -fsSL '$download_url' -o bun.zip &&
|
|
188
|
+
unzip -o bun.zip >/dev/null 2>&1 &&
|
|
189
|
+
mkdir -p /usr/local/bin &&
|
|
190
|
+
mv bun-linux-aarch64/bun /usr/local/bin/bun &&
|
|
191
|
+
chmod +x /usr/local/bin/bun &&
|
|
192
|
+
rm -rf bun.zip bun-linux-aarch64
|
|
193
|
+
" &>>"$LOG_FILE"
|
|
194
|
+
local ubuntu_root
|
|
195
|
+
ubuntu_root="$(_bun_detect_ubuntu_root)"
|
|
196
|
+
if [ -z "$ubuntu_root" ]; then
|
|
197
|
+
log_error "Ubuntu rootfs not found"
|
|
198
|
+
return 1
|
|
199
|
+
fi
|
|
200
|
+
local bun_bin="$ubuntu_root/usr/local/bin/bun"
|
|
201
|
+
if [ ! -f "$bun_bin" ]; then
|
|
202
|
+
log_error "Bun binary not found after install"
|
|
203
|
+
return 1
|
|
204
|
+
fi
|
|
205
|
+
local wrapper_src="$KARNEL_PATH/tools/lang/bun/bin/bun"
|
|
206
|
+
if [ ! -f "$wrapper_src" ]; then
|
|
207
|
+
log_error "Wrapper template not found at $wrapper_src"
|
|
208
|
+
return 1
|
|
209
|
+
fi
|
|
210
|
+
sed "s|__UBUNTU_ROOTFS__|$ubuntu_root|g" "$wrapper_src" >"$PREFIX/bin/bun"
|
|
211
|
+
chmod +x "$PREFIX/bin/bun"
|
|
212
|
+
return 0
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
install_bun() {
|
|
216
|
+
if command -v bun &>/dev/null; then
|
|
217
|
+
log_info "Bun is already installed"
|
|
218
|
+
return 2
|
|
219
|
+
fi
|
|
220
|
+
log_info "Select installation method for Bun:"
|
|
221
|
+
read_select "Installation method" SELECTED_METHOD \
|
|
222
|
+
"Native (recommended) - glibc build with shim" \
|
|
223
|
+
"Proot-distro (alternative) - Ubuntu container"
|
|
224
|
+
case "$SELECTED_METHOD" in
|
|
225
|
+
*Native*)
|
|
226
|
+
_install_bun_native
|
|
227
|
+
;;
|
|
228
|
+
*Proot-distro*)
|
|
229
|
+
_install_bun_proot
|
|
230
|
+
;;
|
|
231
|
+
esac
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
_uninstall_bun_native() {
|
|
235
|
+
rm -f "$PREFIX/bin/bun" "$PREFIX/bin/bunx" "$PREFIX/lib/bun-shim.so"
|
|
236
|
+
rm -rf "$BUN_DATA_DIR"
|
|
237
|
+
log_success "Bun (native) uninstalled"
|
|
238
|
+
return 0
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
_uninstall_bun_proot() {
|
|
242
|
+
_bun_proot_ubuntu /bin/bash -c 'rm -f /usr/local/bin/bun' &>>"$LOG_FILE"
|
|
243
|
+
rm -f "$PREFIX/bin/bun" &>>"$LOG_FILE"
|
|
244
|
+
log_success "Bun (proot-distro) uninstalled"
|
|
245
|
+
return 0
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
_uninstall_bun_impl() {
|
|
249
|
+
if [ -f "$BUN_DATA_DIR/bun.real" ]; then
|
|
250
|
+
_uninstall_bun_native
|
|
251
|
+
return $?
|
|
252
|
+
fi
|
|
253
|
+
_uninstall_bun_proot
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
uninstall_bun() {
|
|
257
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
258
|
+
if [ ! -f "$PREFIX/bin/bun" ]; then
|
|
259
|
+
log_warn "Bun is not installed"
|
|
260
|
+
return 2
|
|
261
|
+
fi
|
|
262
|
+
loading "Uninstalling Bun" _uninstall_bun_impl
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
_update_bun_native() {
|
|
266
|
+
_download_bun_binary_native || return 1
|
|
267
|
+
_compile_bun_helper || return 1
|
|
268
|
+
log_success "Bun (native) updated"
|
|
269
|
+
return 0
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
_update_bun_proot() {
|
|
273
|
+
local version
|
|
274
|
+
version="$(_get_latest_bun_version)"
|
|
275
|
+
if [ -z "$version" ]; then
|
|
276
|
+
log_error "Failed to fetch latest Bun version"
|
|
277
|
+
return 1
|
|
278
|
+
fi
|
|
279
|
+
local download_url="https://github.com/$BUN_REPO/releases/download/bun-v$version/bun-linux-aarch64.zip"
|
|
280
|
+
_bun_proot_ubuntu /bin/bash -c 'rm -f /usr/local/bin/bun' &>>"$LOG_FILE"
|
|
281
|
+
_bun_proot_ubuntu /bin/bash -c "
|
|
282
|
+
export HOME=/root TMPDIR=/tmp
|
|
283
|
+
cd /tmp &&
|
|
284
|
+
curl -fsSL '$download_url' -o bun.zip &&
|
|
285
|
+
unzip -o bun.zip >/dev/null 2>&1 &&
|
|
286
|
+
mkdir -p /usr/local/bin &&
|
|
287
|
+
mv bun-linux-aarch64/bun /usr/local/bin/bun &&
|
|
288
|
+
chmod +x /usr/local/bin/bun &&
|
|
289
|
+
rm -rf bun.zip bun-linux-aarch64
|
|
290
|
+
" &>>"$LOG_FILE"
|
|
291
|
+
local ubuntu_root
|
|
292
|
+
ubuntu_root="$(_bun_detect_ubuntu_root)"
|
|
293
|
+
local bun_bin="$ubuntu_root/usr/local/bin/bun"
|
|
294
|
+
if [ ! -f "$bun_bin" ]; then
|
|
295
|
+
log_error "Bun binary not found after update"
|
|
296
|
+
return 1
|
|
297
|
+
fi
|
|
298
|
+
log_success "Bun (proot-distro) updated"
|
|
299
|
+
return 0
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
_do_update_bun() {
|
|
303
|
+
mkdir -p "$(dirname "$LOG_FILE")"
|
|
304
|
+
if [ -f "$BUN_DATA_DIR/bun.real" ]; then
|
|
305
|
+
_update_bun_native
|
|
306
|
+
return $?
|
|
307
|
+
fi
|
|
308
|
+
loading "Updating Bun (proot-distro)" _update_bun_proot
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
update_bun() {
|
|
312
|
+
_check_update_needed "Bun" "$(_get_installed_version bun)" "$(_get_latest_bun_version)" _do_update_bun
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
reinstall_bun() {
|
|
316
|
+
uninstall_bun
|
|
317
|
+
install_bun
|
|
318
|
+
}
|