Skip to content

Commit e9227c7

Browse files
committed
refactor: move bun-termux-loader auto-clone into project third-party/
Instead of cloning to ~/develop/ or ~/ (external pollution), auto-clone bun-termux-loader into third-party/bun-termux-loader/ within the project root. This keeps all external dependencies contained, versionable via .gitignore, and project-scoped. Resolution order: 1. BUN_TERMUX_LOADER env var (explicit override) 2. third-party/bun-termux-loader/ (project-internal, auto-cloned) 3. ~/bun-termux-loader, ~/develop/bun-termux-loader (existing user setups) 4. Auto-clone to third-party/ if nothing found Also add third-party/ to .gitignore.
1 parent f863e47 commit e9227c7

2 files changed

Lines changed: 23 additions & 40 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ packages/
99
*.tar.gz
1010
*.zip
1111
packaging/dpkg/work/
12+
13+
# Vendored third-party dependencies (auto-cloned)
14+
third-party/

‎tools/produce-local.sh‎

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,67 +32,47 @@ UPSTREAM_TGZ="opencode-linux-arm64-$VER.tgz"
3232
UPSTREAM_BIN="$WORK_DIR/package/bin/opencode"
3333
GITHUB_URL="https://github.com/anomalyco/opencode/releases/download/v${VER}/opencode-linux-arm64.tar.gz"
3434

35-
find_loader_repo() {
36-
# Allow explicit override via environment variable
35+
LOADER_VENDOR="$ROOT_DIR/third-party/bun-termux-loader"
36+
LOADER_URL="${BUN_TERMUX_LOADER_URL:-https://github.com/kaan-escober/bun-termux-loader}"
37+
38+
resolve_loader_repo() {
39+
# 1. Explicit env override
3740
if [[ -n "${BUN_TERMUX_LOADER:-}" ]]; then
3841
if [[ -f "$BUN_TERMUX_LOADER/build.py" ]]; then
3942
printf '%s' "$BUN_TERMUX_LOADER"
4043
return 0
4144
fi
4245
return 1
4346
fi
47+
48+
# 2. Project-internal third-party (preferred auto-clone target)
49+
if [[ -f "$LOADER_VENDOR/build.py" ]]; then
50+
printf '%s' "$LOADER_VENDOR"
51+
return 0
52+
fi
53+
54+
# 3. External common paths (existing user setups)
4455
local c
4556
for c in "$HOME/bun-termux-loader" "$HOME/develop/bun-termux-loader"; do
4657
if [[ -f "$c/build.py" ]]; then
4758
printf '%s' "$c"
4859
return 0
4960
fi
5061
done
51-
return 1
52-
}
5362

54-
clone_loader_repo() {
55-
local target="${1:?target dir required}"
56-
local url="${2:?repo URL required}"
57-
log "bun-termux-loader not found locally, cloning from $url"
63+
# 4. Auto-clone into project-internal third-party
64+
log "bun-termux-loader not found locally, cloning into third-party/"
5865
if ! command -v git >/dev/null 2>&1; then
5966
return 1
6067
fi
61-
local parent
62-
parent="$(dirname "$target")"
63-
mkdir -p "$parent"
64-
git clone --depth 1 "$url" "$target" 2>&1 || return 1
65-
if [[ ! -f "$target/build.py" ]]; then
68+
rm -rf "$LOADER_VENDOR"
69+
git clone --depth 1 "$LOADER_URL" "$LOADER_VENDOR" 2>&1 || return 1
70+
if [[ ! -f "$LOADER_VENDOR/build.py" ]]; then
6671
log "warning: cloned repo missing build.py, cleaning up"
67-
rm -rf "$target"
72+
rm -rf "$LOADER_VENDOR"
6873
return 1
6974
fi
70-
return 0
71-
}
72-
73-
resolve_loader_repo() {
74-
local found
75-
if found="$(find_loader_repo)"; then
76-
printf '%s' "$found"
77-
return 0
78-
fi
79-
80-
# Auto-clone fallback: try common upstream locations
81-
local candidates=(
82-
"$HOME/develop/bun-termux-loader:https://github.com/kaan-escober/bun-termux-loader"
83-
"$HOME/bun-termux-loader:https://github.com/kaan-escober/bun-termux-loader"
84-
)
85-
local c target url
86-
for c in "${candidates[@]}"; do
87-
target="${c%%:*}"
88-
url="${c#*:}"
89-
if clone_loader_repo "$target" "$url"; then
90-
printf '%s' "$target"
91-
return 0
92-
fi
93-
done
94-
95-
return 1
75+
printf '%s' "$LOADER_VENDOR"
9676
}
9777

9878
download_upstream_binary() {

0 commit comments

Comments
 (0)