Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

perf(termux): fast non-interactive mirror switch + APT tuning (P3)

Gotcha Contributore704bb09c22e
diff --git a/app/src/main/assets/skills/termux_repositories.json b/app/src/main/assets/skills/termux_repositories.json
index 5503217..42e91c3 100644
--- a/app/src/main/assets/skills/termux_repositories.json
+++ b/app/src/main/assets/skills/termux_repositories.json
@@ -1,9 +1,22 @@
{
"id": "termux_repositories",
- "targetPackageNames": ["com.termux", "com.gotcha"],
+ "targetPackageNames": [
+ "com.termux",
+ "com.gotcha"
+ ],
"name": "Termux Repositories",
"description": "Mirror selection and large-package handling for Termux's pkg/apt repositories.",
- "requiresTools": ["run_termux_command"],
- "keywords": ["pkg", "apt", "mirror", "ffmpeg", "install", "repository", "termux-change-repo"],
- "instructions": "1. The default Termux mirror (https://packages.termux.dev) is often slow or blocked on networks in China, parts of India, behind corporate firewalls, and on some ISPs. Symptom: `pkg install` hangs at \"0% [Connecting to packages.termux.dev]\" or fails with \"Could not resolve host\" / \"NO_PUBKEY\" / repeated 404s.\n2. To switch mirrors interactively, the user must run `termux-change-repo` INSIDE Termux (it opens a TUI picker). Gotcha cannot drive that TUI from run_termux_command. Tell the user to open Termux, run the command, pick a mirror, and not return to chat until done.\n3. To switch non-interactively from a script, overwrite TWO files:\n - `$PREFIX/etc/apt/sources.list` with: `deb <mirror> termux-main`\n - `$PREFIX/etc/apt/sources.list.d/root.list` with: `deb <mirror> termux-root`\n Then run `apt-get update -y`. `<PREFIX>` is `/data/data/com.termux/files/usr`.\n4. Known mirrors (substitute the user's geography):\n - Official primary: https://packages.termux.dev/apt/termux-main\n - Official secondary: https://termux.mentality.org/apt/termux-main\n - Tsinghua (China): https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main\n - USTC (China): https://mirrors.ustc.edu.cn/termux/apt/termux-main\n - ISCAS (China): https://mirror.iscas.ac.cn/termux/apt/termux-main\n - CERN (China): https://mirrors.cernet.edu.cn/termux/apt/termux-main\n - NJU (China): https://mirror.nju.edu.cn/termux/apt/termux-main\n - Netherlands: https://ftp.snt.utwente.nl/termux/apt/termux-main\n5. After a mirror change, ALWAYS run `pkg update -y` to verify the new server. A `NO_PUBKEY` error means the mirror is missing the signing key — fall back to the official primary.\n6. Large packages — ffmpeg, python, rust, chromium, golang, nodejs-lts, texlive, qt — typically take 5-15 minutes to install even on a fast mirror. Always raise timeout_seconds to 600 and warn the user before kicking one off.\n7. If `pkg install` keeps failing midway, split the network step from the install step: `pkg download <pkg>` puts the .deb in $PREFIX/var/cache/apt/archives/; then `cd $PREFIX/var/cache/apt/archives && dpkg -i *.deb` installs from local cache. This is also useful for retrying a single bad package.\n8. For reproducible installs across mirrors, prefer `pkg install -y` over `apt install`; `pkg` is the wrapper that handles Termux-specific package names and dependencies and is the supported interface."
-}
+ "requiresTools": [
+ "run_termux_command"
+ ],
+ "keywords": [
+ "pkg",
+ "apt",
+ "mirror",
+ "ffmpeg",
+ "install",
+ "repository",
+ "termux-change-repo"
+ ],
+ "instructions": "1. The default Termux mirror (https://packages.termux.dev) is often slow or blocked on networks in China, parts of India, behind corporate firewalls, and on some ISPs. Symptom: `pkg install` hangs at \"0% [Connecting to packages.termux.dev]\" or fails with \"Could not resolve host\" / \"NO_PUBKEY\" / repeated 404s.\n2. To switch mirrors interactively, the user must run `termux-change-repo` INSIDE Termux (it opens a TUI picker). Gotcha cannot drive that TUI from run_termux_command. Tell the user to open Termux, run the command, pick a mirror, and not return to chat until done.\n3. To switch non-interactively from a script, overwrite TWO files:\n - `$PREFIX/etc/apt/sources.list` with: `deb <mirror> termux-main`\n - `$PREFIX/etc/apt/sources.list.d/root.list` with: `deb <mirror> termux-root`\n Then run `apt-get update -y`. `<PREFIX>` is `/data/data/com.termux/files/usr`.\n\n3b. Fast non-interactive switch (when user wants Gotcha to fix mirror without opening Termux TUI):\n `sed -i 's|https://packages.termux.dev/apt/termux-main|https://termux.mentality.org/apt/termux-main|g' $PREFIX/etc/apt/sources.list && sed -i 's|https://packages.termux.dev/apt/termux-root|https://termux.mentality.org/apt/termux-root|g' $PREFIX/etc/apt/sources.list.d/root.list && apt-get update -y`\n Verify with `pkg update -y`. Note: this fast sed only works if the current mirror is still packages.termux.dev; otherwise overwrite the two files as in step 3.\n3c. APT speed tuning (optional, safe):\n `echo 'Acquire::Languages \"none\";' > $PREFIX/etc/apt/apt.conf.d/00nolanguages && echo 'APT::Install-Recommends \"0\";' > $PREFIX/etc/apt/apt.conf.d/00norecommends`\n Reduces apt update download size and time.\n\n4. Known mirrors (substitute the user's geography):\n - Official primary: https://packages.termux.dev/apt/termux-main\n - Official secondary: https://termux.mentality.org/apt/termux-main\n - Tsinghua (China): https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main\n - USTC (China): https://mirrors.ustc.edu.cn/termux/apt/termux-main\n - ISCAS (China): https://mirror.iscas.ac.cn/termux/apt/termux-main\n - CERN (China): https://mirrors.cernet.edu.cn/termux/apt/termux-main\n - NJU (China): https://mirror.nju.edu.cn/termux/apt/termux-main\n - Netherlands: https://ftp.snt.utwente.nl/termux/apt/termux-main\n5. After a mirror change, ALWAYS run `pkg update -y` to verify the new server. A `NO_PUBKEY` error means the mirror is missing the signing key \u2014 fall back to the official primary.\n6. Large packages \u2014 ffmpeg, python, rust, chromium, golang, nodejs-lts, texlive, qt \u2014 typically take 5-15 minutes to install even on a fast mirror. Always raise timeout_seconds to 600 and warn the user before kicking one off.\n7. If `pkg install` keeps failing midway, split the network step from the install step: `pkg download <pkg>` puts the .deb in $PREFIX/var/cache/apt/archives/; then `cd $PREFIX/var/cache/apt/archives && dpkg -i *.deb` installs from local cache. This is also useful for retrying a single bad package.\n8. For reproducible installs across mirrors, prefer `pkg install -y` over `apt install`; `pkg` is the wrapper that handles Termux-specific package names and dependencies and is the supported interface."
+}
\ No newline at end of file