@nemoobc/opencode-termux 1.18.22 → 1.18.24

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/bin/opencode.js CHANGED
@@ -26,14 +26,16 @@ if (!ready()) {
26
26
 
27
27
  if (!ready()) process.exit(1)
28
28
 
29
- // Diagnosa awal: Android sering tidak punya /etc/resolv.conf yang dibaca musl.
29
+ // DNS fix: musl hasil build kita membaca config dari prefix Termux —
30
+ // pastikan filenya ada (bisa ditulis tanpa root).
30
31
  try {
31
- if (!fs.existsSync("/etc/resolv.conf")) {
32
- console.error("[opencode-termux] ⚠️ /etc/resolv.conf tidak ada di device ini;")
33
- console.error(" kalau perintah jaringan (models/login) gagal/gantung, itu sebabnya.")
34
- console.error(" Solusi sementara (butuh akses root):")
35
- console.error(' su -c \'mkdir -p /etc && echo "nameserver 8.8.8.8" > /etc/resolv.conf\'')
36
- }
32
+ const PREFIX = process.env.TERMUX_PREFIX || "/data/data/com.termux/files/usr"
33
+ const etc = path.join(PREFIX, "etc")
34
+ fs.mkdirSync(etc, { recursive: true })
35
+ const rc = path.join(etc, "resolv.conf")
36
+ if (!fs.existsSync(rc)) fs.writeFileSync(rc, "nameserver 1.1.1.1\nnameserver 8.8.8.8\n")
37
+ const hh = path.join(etc, "hosts")
38
+ if (!fs.existsSync(hh)) fs.writeFileSync(hh, "127.0.0.1 localhost\n")
37
39
  } catch {}
38
40
 
39
41
  // LD_PRELOAD bawaan Termux (libtermux-exec) dibuat untuk Bionic dan akan
package/install.mjs CHANGED
@@ -54,32 +54,53 @@ const untar = (tgz, dest, members = []) => {
54
54
  const work = path.join(__dirname, ".build")
55
55
  fs.rmSync(work, { recursive: true, force: true })
56
56
  fs.mkdirSync(work, { recursive: true })
57
+ const AV = "v3.21", AL = "3.21.3"
57
58
 
58
59
  // 1) binary opencode (musl) dari npm resmi
59
60
  await dl(`https://registry.npmjs.org/opencode-linux-${ARCH}-musl/-/opencode-linux-${ARCH}-musl-${V}.tgz`, `${work}/oc.tgz`)
60
61
  untar(`${work}/oc.tgz`, `${work}/oc`)
61
62
 
62
- // 2) loader+libc musl dari Alpine minirootfs
63
- const AV = "v3.21", AL = "3.21.3"
64
- await dl(`https://dl-cdn.alpinelinux.org/alpine/${AV}/releases/${A}/alpine-minirootfs-${AL}-${A}.tar.gz`, `${work}/ap.tgz`)
65
- untar(`${work}/ap.tgz`, `${work}/ap`, ["lib"])
66
-
67
- // 3) libgcc + libstdc++
63
+ // 2) libgcc + libstdc++
68
64
  const apkDir = `${work}/apk`; fs.mkdirSync(apkDir, { recursive: true })
69
65
  for (const f of [`libgcc-14.2.0-r4.apk`, `libstdc%2B%2B-14.2.0-r4.apk`]) {
70
66
  await dl(`https://dl-cdn.alpinelinux.org/alpine/${AV}/main/${A}/${f}`, `${apkDir}/${f}`)
71
67
  untar(`${apkDir}/${f}`, apkDir)
72
68
  }
73
69
 
74
- // 4) rakit vendor/
70
+ // 3) rakit vendor/
75
71
  const vendor = path.join(__dirname, "vendor")
76
72
  fs.rmSync(vendor, { recursive: true, force: true }); fs.mkdirSync(vendor)
77
- const cp = (from, name) => fs.copyFileSync(path.join(from, name), path.join(vendor, name))
78
- cp(`${work}/ap/lib`, `ld-musl-${A}.so.1`); fs.renameSync(path.join(vendor, `ld-musl-${A}.so.1`), path.join(vendor, "ld-musl.so"))
73
+ const cp = (dir, name) => fs.copyFileSync(path.join(dir, name), path.join(vendor, name))
74
+ if (A === "aarch64") {
75
+ // loader hasil build khusus: resolv.conf & hosts menunjuk ke prefix Termux
76
+ cp(path.join(__dirname, "prebuilt"), "ld-musl-aarch64-termux.so")
77
+ fs.renameSync(path.join(vendor, "ld-musl-aarch64-termux.so"), path.join(vendor, "ld-musl.so"))
78
+ } else {
79
+ const mini = `${work}/ap`; await dl(
80
+ `https://dl-cdn.alpinelinux.org/alpine/${AV}/releases/${A}/alpine-minirootfs-${AL}-${A}.tar.gz`, `${work}/ap.tgz`)
81
+ untar(`${work}/ap.tgz`, mini, ["lib"])
82
+ cp(`${mini}/lib`, `ld-musl-${A}.so.1`); fs.renameSync(path.join(vendor, `ld-musl-${A}.so.1`), path.join(vendor, "ld-musl.so"))
83
+ }
79
84
  cp(`${work}/oc/package/bin`, "opencode")
80
85
  cp(`${apkDir}/usr/lib`, "libstdc++.so.6"); cp(`${apkDir}/usr/lib`, "libstdc++.so.6.0.33"); cp(`${apkDir}/usr/lib`, "libgcc_s.so.1")
81
86
  for (const f of fs.readdirSync(vendor)) fs.chmodSync(path.join(vendor, f), 0o755)
82
87
 
88
+ // 4) siapkan DNS config di prefix Termux (bisa ditulis TANPA root)
89
+ function ensureEtc() {
90
+ try {
91
+ const PREFIX = process.env.TERMUX_PREFIX || "/data/data/com.termux/files/usr"
92
+ const etc = path.join(PREFIX, "etc")
93
+ fs.mkdirSync(etc, { recursive: true })
94
+ const rc = path.join(etc, "resolv.conf")
95
+ if (!fs.existsSync(rc)) fs.writeFileSync(rc, "nameserver 1.1.1.1\nnameserver 8.8.8.8\n")
96
+ const hh = path.join(etc, "hosts")
97
+ if (!fs.existsSync(hh)) fs.writeFileSync(hh, "127.0.0.1 localhost\n")
98
+ } catch (e) {
99
+ if (!FORCE && IS_ANDROID) throw e
100
+ }
101
+ }
102
+ ensureEtc()
103
+
83
104
  // 5) smoke test (LD_PRELOAD termux-exec dibuang: tidak kompatibel dengan musl)
84
105
  console.log("[opencode-termux] smoke test…")
85
106
  const { LD_PRELOAD, LD_PRELOAD_32BIT, ...cleanEnv } = process.env
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemoobc/opencode-termux",
3
- "version": "1.18.22",
3
+ "version": "1.18.24",
4
4
  "description": "opencode CLI native untuk Termux/Android tanpa proot — membundel loader musl + binary opencode resmi (upstream opencode-ai)",
5
5
  "bin": {
6
6
  "opencode-termux": "./bin/opencode.js"
@@ -22,6 +22,8 @@
22
22
  "files": [
23
23
  "bin",
24
24
  "install.mjs",
25
+ "prebuilt",
25
26
  "README.md"
26
- ]
27
+ ],
28
+ "opencodeUpstream": "1.18.21"
27
29
  }