@bash0816/copilot-termux 1.0.83 → 1.0.88
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/LICENSE +1 -2
- package/THIRD-PARTY-NOTICES.md +14 -35
- package/bin/copilot +16 -62
- package/config/copilot-termux-release-manifest.json +4 -4
- package/config/manifest.json +3 -7
- package/lib/setup.js +5 -157
- package/package.json +1 -5
- package/lib/bionic-compat.so +0 -0
- package/lib/native/pty.node +0 -0
- package/lib/platform-patch.js +0 -1633
- package/scripts/bionic-compat.c +0 -85
package/LICENSE
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
This license (GPL-3.0-only) applies to the wrapper code in this package:
|
|
2
|
-
bin/copilot
|
|
3
|
-
and all other files not listed in THIRD-PARTY-NOTICES.md.
|
|
2
|
+
bin/copilot and all other files not listed in THIRD-PARTY-NOTICES.md.
|
|
4
3
|
|
|
5
4
|
Bundled third-party software is covered by separate licenses.
|
|
6
5
|
See THIRD-PARTY-NOTICES.md for details.
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -7,25 +7,15 @@ This package includes third-party software with the following licenses.
|
|
|
7
7
|
## GitHub Copilot CLI
|
|
8
8
|
|
|
9
9
|
- Source: https://github.com/github/copilot-cli (private)
|
|
10
|
-
-
|
|
10
|
+
- Package: @github/copilot-linux-arm64
|
|
11
11
|
- License: GitHub Copilot CLI License
|
|
12
12
|
- License text: THIRD-PARTY-LICENSES/COPILOT-LICENSE.md
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Node.js
|
|
22
|
-
|
|
23
|
-
- Source: https://nodejs.org/
|
|
24
|
-
- License: MIT (main), with bundled components under various licenses
|
|
25
|
-
(see THIRD-PARTY-LICENSES/NODE-LICENSE.txt for full attribution)
|
|
26
|
-
- License text: THIRD-PARTY-LICENSES/NODE-LICENSE.txt
|
|
27
|
-
|
|
28
|
-
Files: lib/node
|
|
14
|
+
Not bundled in this npm package. Downloaded in unmodified form at
|
|
15
|
+
`copilot-termux setup` time from the npm registry, in accordance with
|
|
16
|
+
Section 2 of the GitHub Copilot CLI License. The exact version fetched is
|
|
17
|
+
pinned in `config/manifest.json` (`copilot.version`), and the downloaded
|
|
18
|
+
binary is cached under `~/.copilot-termux/<version>/copilot`.
|
|
29
19
|
|
|
30
20
|
---
|
|
31
21
|
|
|
@@ -35,10 +25,11 @@ Files: lib/node
|
|
|
35
25
|
- License: LGPL-2.1+
|
|
36
26
|
- License text: THIRD-PARTY-LICENSES/LGPL-2.1.txt
|
|
37
27
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
Not bundled in this npm package. Copied at `copilot-termux setup` time from
|
|
29
|
+
the system `glibc-repo` package (`pkg install glibc-repo && pkg install
|
|
30
|
+
glibc`) into `~/.copilot-termux/glibc-wrap-libs/`:
|
|
31
|
+
ld-linux-aarch64.so.1
|
|
32
|
+
libc.so.6
|
|
42
33
|
|
|
43
34
|
---
|
|
44
35
|
|
|
@@ -49,18 +40,6 @@ Files:
|
|
|
49
40
|
- Exception text: THIRD-PARTY-LICENSES/GCC-RUNTIME-EXCEPTION.txt
|
|
50
41
|
- Base license text: THIRD-PARTY-LICENSES/GPL-3.0.txt
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## node-pty
|
|
59
|
-
|
|
60
|
-
- Source: https://github.com/microsoft/node-pty
|
|
61
|
-
- Version: 1.1.0
|
|
62
|
-
- License: MIT
|
|
63
|
-
- License text: THIRD-PARTY-LICENSES/NODE-PTY-LICENSE.txt
|
|
64
|
-
|
|
65
|
-
Compiled natively for Android aarch64 (bionic) and bundled as `lib/native/pty.node`.
|
|
66
|
-
Used to provide pseudo-terminal support for the interactive TUI mode of @github/copilot.
|
|
43
|
+
Not bundled in this npm package. Copied at `copilot-termux setup` time from
|
|
44
|
+
the system `glibc-repo` package into `~/.copilot-termux/glibc-wrap-libs/`:
|
|
45
|
+
libgcc_s.so.1
|
package/bin/copilot
CHANGED
|
@@ -7,9 +7,6 @@ while [ -L "${SELF}" ]; do
|
|
|
7
7
|
case "${SELF}" in /*) ;; *) SELF="${DIR}/${SELF}" ;; esac
|
|
8
8
|
done
|
|
9
9
|
PACKAGE_DIR=$(CDPATH= cd -- "$(dirname -- "${SELF}")/.." && pwd)
|
|
10
|
-
_COMPAT="${PACKAGE_DIR}/lib/bionic-compat.so"
|
|
11
|
-
[ -f "${_COMPAT}" ] || { echo '[copilot-termux] ERROR: lib/bionic-compat.so missing. Reinstall package.' >&2; exit 1; }
|
|
12
|
-
PRELOAD="${_COMPAT}${LD_PRELOAD:+:${LD_PRELOAD}}"
|
|
13
10
|
|
|
14
11
|
if [ "${1:-}" = "update" ]; then
|
|
15
12
|
shift
|
|
@@ -25,75 +22,32 @@ if [ ! -d "${CURRENT}" ]; then
|
|
|
25
22
|
exit 1
|
|
26
23
|
fi
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
if [ ! -f "${
|
|
25
|
+
COPILOT_BIN="${CURRENT}/copilot"
|
|
26
|
+
if [ ! -f "${COPILOT_BIN}" ]; then
|
|
30
27
|
echo "[copilot-termux] Installation broken. Run: copilot-termux setup" >&2
|
|
31
28
|
exit 1
|
|
32
29
|
fi
|
|
33
30
|
|
|
34
|
-
MXC_WRAP="${CACHE_DIR}/mxc-wrap"
|
|
35
|
-
if [ -d "${MXC_WRAP}/arm64" ] && [ -x "${MXC_WRAP}/arm64/lxc-exec" ]; then
|
|
36
|
-
export MXC_BIN_DIR="${MXC_WRAP}"
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
# glibc mode: glibc Node.js + glibc runtime.node + platform-patch.js (authManager* stubs still needed)
|
|
40
31
|
_GLIBC_LD="${PREFIX}/glibc/lib/ld-linux-aarch64.so.1"
|
|
41
32
|
_GLIBC_LIBS="${PREFIX}/glibc/lib"
|
|
42
|
-
_GLIBC_RUNTIME="${CURRENT}/prebuilds/linux-arm64/runtime.node"
|
|
43
|
-
_GLIBC_CLI_NATIVE="${CURRENT}/prebuilds/linux-arm64/cli-native.node"
|
|
44
|
-
_GLIBC_NODE_AUTO="${CACHE_DIR}/glibc-node/node"
|
|
45
33
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
elif [ -x "${_GLIBC_NODE_AUTO}" ]; then
|
|
50
|
-
_USE_GLIBC_NODE="${_GLIBC_NODE_AUTO}"
|
|
34
|
+
if [ ! -f "${_GLIBC_LD}" ]; then
|
|
35
|
+
echo "[copilot-termux] ERROR: glibc not found. Please install: pkg install glibc-repo && pkg install glibc" >&2
|
|
36
|
+
exit 1
|
|
51
37
|
fi
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
[ -
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
_GLIBC_ANY=0
|
|
60
|
-
[ -n "${_USE_GLIBC_NODE}" ] && _GLIBC_ANY=1
|
|
61
|
-
[ -f "${_GLIBC_RUNTIME}" ] && _GLIBC_ANY=1
|
|
62
|
-
[ -f "${_GLIBC_CLI_NATIVE}" ] && _GLIBC_ANY=1
|
|
63
|
-
[ -f "${_GLIBC_LD}" ] && _GLIBC_ANY=1
|
|
64
|
-
|
|
65
|
-
if [ "${_GLIBC_READY}" = "1" ]; then
|
|
66
|
-
_SSL_CERT="${PREFIX}/etc/tls/cert.pem"
|
|
67
|
-
_SSL_CERT_DIR="${PREFIX}/etc/tls"
|
|
68
|
-
if [ ! -r "${_SSL_CERT}" ]; then
|
|
69
|
-
echo "[copilot-termux] ERROR: CA bundle not readable: ${_SSL_CERT}" >&2
|
|
70
|
-
echo "[copilot-termux] Run: pkg install ca-certificates" >&2
|
|
71
|
-
exit 1
|
|
72
|
-
fi
|
|
73
|
-
exec env LD_PRELOAD="" COPILOT_TERMUX_GLIBC_MODE=1 \
|
|
74
|
-
SSL_CERT_FILE="${_SSL_CERT}" \
|
|
75
|
-
SSL_CERT_DIR="${_SSL_CERT_DIR}" \
|
|
76
|
-
"${_GLIBC_LD}" --library-path "${_GLIBC_LIBS}" \
|
|
77
|
-
"${_USE_GLIBC_NODE}" \
|
|
78
|
-
--require "${PACKAGE_DIR}/lib/platform-patch.js" \
|
|
79
|
-
"${COPILOT_INDEX}" \
|
|
80
|
-
"$@"
|
|
81
|
-
elif [ "${_GLIBC_ANY}" = "1" ]; then
|
|
82
|
-
# 注: システムの glibc-repo パッケージ(_GLIBC_LD)を別目的で入れているだけで
|
|
83
|
-
# copilot-termux 自身の glibc mode セットアップ(setup.js の setupGlibcRuntime/setupGlibcNode)が
|
|
84
|
-
# 未完の場合も、ここでは「glibc mode 設定が部分的」としてエラー扱いにする。
|
|
85
|
-
# これは意図的な判断(Free auto mode の既知の壊れた bionic 経路への黙示的フォールバックを防ぐため)。
|
|
86
|
-
echo "[copilot-termux] ERROR: glibc mode partially configured. Missing:" >&2
|
|
87
|
-
[ -n "${_USE_GLIBC_NODE}" ] || echo " - glibc node (${_GLIBC_NODE_AUTO})" >&2
|
|
88
|
-
[ -f "${_GLIBC_RUNTIME}" ] || echo " - glibc runtime.node (${_GLIBC_RUNTIME})" >&2
|
|
89
|
-
[ -f "${_GLIBC_CLI_NATIVE}" ] || echo " - glibc cli-native.node (${_GLIBC_CLI_NATIVE})" >&2
|
|
90
|
-
[ -f "${_GLIBC_LD}" ] || echo " - glibc loader (${_GLIBC_LD})" >&2
|
|
91
|
-
echo "[copilot-termux] Run: copilot-termux setup" >&2
|
|
39
|
+
_SSL_CERT="${PREFIX}/etc/tls/cert.pem"
|
|
40
|
+
_SSL_CERT_DIR="${PREFIX}/etc/tls"
|
|
41
|
+
if [ ! -r "${_SSL_CERT}" ]; then
|
|
42
|
+
echo "[copilot-termux] ERROR: CA bundle not readable: ${_SSL_CERT}" >&2
|
|
43
|
+
echo "[copilot-termux] Run: pkg install ca-certificates" >&2
|
|
92
44
|
exit 1
|
|
93
45
|
fi
|
|
94
46
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
47
|
+
exec env -u LD_PRELOAD \
|
|
48
|
+
SSL_CERT_FILE="${_SSL_CERT}" \
|
|
49
|
+
SSL_CERT_DIR="${_SSL_CERT_DIR}" \
|
|
50
|
+
COPILOT_TERMUX_GLIBC_MODE=1 \
|
|
51
|
+
"${_GLIBC_LD}" --library-path "${_GLIBC_LIBS}" \
|
|
52
|
+
"${COPILOT_BIN}" \
|
|
99
53
|
"$@"
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 1,
|
|
3
3
|
"package_name": "@bash0816/copilot-termux",
|
|
4
|
-
"copilot_version": "1.0.
|
|
5
|
-
"latest_audited_version": "1.0.
|
|
4
|
+
"copilot_version": "1.0.88",
|
|
5
|
+
"latest_audited_version": "1.0.83",
|
|
6
6
|
"latest_candidate_version": null,
|
|
7
|
-
"previous_stable_version": "1.0.
|
|
7
|
+
"previous_stable_version": "1.0.82",
|
|
8
8
|
"candidate_state": "none",
|
|
9
9
|
"canonical_package_status": "not_published",
|
|
10
10
|
"public_distribution_status": "staged",
|
|
11
11
|
"nodejs_glibc_version": "node-glibc-v24.15.0",
|
|
12
12
|
"build_run_id": null,
|
|
13
|
-
"last_updated": "2026-09-
|
|
13
|
+
"last_updated": "2026-09-19",
|
|
14
14
|
"manifest_url": "https://raw.githubusercontent.com/bash0816/Github-Copilot-Termux/main/packages/copilot-termux/config/copilot-termux-release-manifest.json"
|
|
15
15
|
}
|
package/config/manifest.json
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"wrapperVersion": "2.0.0",
|
|
3
3
|
"copilot": {
|
|
4
|
-
"package": "@github/copilot-
|
|
5
|
-
"version": "1.0.
|
|
6
|
-
"integrity": "sha512-
|
|
7
|
-
},
|
|
8
|
-
"glibcNode": {
|
|
9
|
-
"version": "26.2.0",
|
|
10
|
-
"sha256": "bf52461d25017479cdc549642c4e7a2303ac5c5395d7c3d026d5d8b3fa283c05"
|
|
4
|
+
"package": "@github/copilot-linux-arm64",
|
|
5
|
+
"version": "1.0.88",
|
|
6
|
+
"integrity": "sha512-aqtfMpA0B2cdKWydFXnlXawaqNRjG4gC5Dpe+sO/qVXQllSEi8moqiYzkUaVo4W5VEPwIXDLxCbDzsRw7Jt66w=="
|
|
11
7
|
}
|
|
12
8
|
}
|
package/lib/setup.js
CHANGED
|
@@ -48,11 +48,11 @@ async function fetchWithIntegrity(url, expectedIntegrity) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
async function setup() {
|
|
51
|
-
const { package: pkg = '@github/copilot-
|
|
51
|
+
const { package: pkg = '@github/copilot-linux-arm64', version, integrity } = manifest.copilot;
|
|
52
52
|
const versionDir = path.join(CACHE_DIR, version);
|
|
53
53
|
const stagingDir = `${versionDir}.staging`;
|
|
54
54
|
|
|
55
|
-
if (fs.existsSync(path.join(versionDir, '
|
|
55
|
+
if (fs.existsSync(path.join(versionDir, 'copilot'))) {
|
|
56
56
|
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
57
57
|
console.log(`${pkg}@${version} already installed, refreshing symlink...`);
|
|
58
58
|
} else {
|
|
@@ -75,8 +75,8 @@ async function setup() {
|
|
|
75
75
|
fs.mkdirSync(stagingDir, { recursive: true });
|
|
76
76
|
execFileSync('tar', ['-xzf', tarballPath, '-C', stagingDir, '--strip-components=1']);
|
|
77
77
|
|
|
78
|
-
if (!fs.existsSync(path.join(stagingDir, '
|
|
79
|
-
throw new Error(`installation incomplete: missing ${path.join(stagingDir, '
|
|
78
|
+
if (!fs.existsSync(path.join(stagingDir, 'copilot'))) {
|
|
79
|
+
throw new Error(`installation incomplete: missing ${path.join(stagingDir, 'copilot')}`);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
if (fs.existsSync(versionDir)) {
|
|
@@ -92,8 +92,6 @@ async function setup() {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
await setupGlibcWrap();
|
|
95
|
-
await setupGlibcRuntime(versionDir, version);
|
|
96
|
-
await setupGlibcNode();
|
|
97
95
|
|
|
98
96
|
const currentLink = path.join(CACHE_DIR, 'current');
|
|
99
97
|
const tmp = path.join(CACHE_DIR, `current.tmp.${process.pid}`);
|
|
@@ -113,11 +111,9 @@ async function setupGlibcWrap() {
|
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
const wrapLibsDir = path.join(CACHE_DIR, 'glibc-wrap-libs');
|
|
116
|
-
const mxcWrapDir = path.join(CACHE_DIR, 'mxc-wrap', 'arm64');
|
|
117
114
|
|
|
118
115
|
fs.rmSync(wrapLibsDir, { recursive: true, force: true });
|
|
119
116
|
fs.mkdirSync(wrapLibsDir, { recursive: true });
|
|
120
|
-
fs.mkdirSync(mxcWrapDir, { recursive: true });
|
|
121
117
|
|
|
122
118
|
for (const lib of ['ld-linux-aarch64.so.1', 'libc.so.6', 'libgcc_s.so.1']) {
|
|
123
119
|
const src = path.join(glibcDir, lib);
|
|
@@ -129,155 +125,7 @@ async function setupGlibcWrap() {
|
|
|
129
125
|
try { fs.unlinkSync(libcSo); } catch (_) {}
|
|
130
126
|
fs.symlinkSync('libc.so.6', libcSo);
|
|
131
127
|
|
|
132
|
-
|
|
133
|
-
const wrapperContent = [
|
|
134
|
-
'#!/bin/sh',
|
|
135
|
-
'_CACHE="${HOME}/.copilot-termux"',
|
|
136
|
-
'_LIBS="${_CACHE}/glibc-wrap-libs"',
|
|
137
|
-
'_LD="${_LIBS}/ld-linux-aarch64.so.1"',
|
|
138
|
-
'_LXC="${_CACHE}/current/mxc-bin/arm64/lxc-exec"',
|
|
139
|
-
'exec env -u LD_PRELOAD "$_LD" --library-path "$_LIBS" "$_LXC" "$@"',
|
|
140
|
-
].join('\n') + '\n';
|
|
141
|
-
fs.writeFileSync(wrapperPath, wrapperContent, { mode: 0o755 });
|
|
142
|
-
|
|
143
|
-
console.log('✓ glibc wrap for lxc-exec ready');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function setupGlibcRuntime(versionDir, version) {
|
|
147
|
-
const linux64Dir = path.join(versionDir, 'prebuilds', 'linux-arm64');
|
|
148
|
-
const runtimeNode = path.join(linux64Dir, 'runtime.node');
|
|
149
|
-
const cliNativeNode = path.join(linux64Dir, 'cli-native.node');
|
|
150
|
-
if (fs.existsSync(runtimeNode) && fs.existsSync(cliNativeNode)) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const glibcPkg = '@github/copilot-linux-arm64';
|
|
155
|
-
console.log(`Fetching ${glibcPkg}@${version} metadata...`);
|
|
156
|
-
const metaBuf = await httpsGet(`${REGISTRY}/${glibcPkg}/${version}`, { Accept: 'application/json' });
|
|
157
|
-
const meta = JSON.parse(metaBuf.toString());
|
|
158
|
-
const tarballUrl = meta.dist.tarball;
|
|
159
|
-
const integrity = meta.dist.integrity;
|
|
160
|
-
|
|
161
|
-
console.log(`Downloading ${glibcPkg}@${version} (glibc runtime)...`);
|
|
162
|
-
const tarball = await fetchWithIntegrity(tarballUrl, integrity);
|
|
163
|
-
|
|
164
|
-
const tarballPath = path.join(CACHE_DIR, `copilot-glibc-${version}.tgz`);
|
|
165
|
-
try {
|
|
166
|
-
fs.writeFileSync(tarballPath, tarball);
|
|
167
|
-
fs.mkdirSync(linux64Dir, { recursive: true });
|
|
168
|
-
|
|
169
|
-
console.log('Extracting glibc runtime.node...');
|
|
170
|
-
execFileSync('tar', [
|
|
171
|
-
'-xzf', tarballPath,
|
|
172
|
-
'-C', path.join(versionDir, 'prebuilds'),
|
|
173
|
-
'--strip-components=2',
|
|
174
|
-
'package/prebuilds/linux-arm64/runtime.node',
|
|
175
|
-
'package/prebuilds/linux-arm64/cli-native.node',
|
|
176
|
-
]);
|
|
177
|
-
} finally {
|
|
178
|
-
fs.rmSync(tarballPath, { force: true });
|
|
179
|
-
}
|
|
180
|
-
console.log('✓ glibc runtime.node ready');
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
async function setupGlibcNode() {
|
|
184
|
-
const { version, sha256: expectedSha256 } = manifest.glibcNode;
|
|
185
|
-
const nodeVersionDir = path.join(CACHE_DIR, `glibc-node-${version}`);
|
|
186
|
-
const nodeBin = path.join(nodeVersionDir, 'node');
|
|
187
|
-
const currentLink = path.join(CACHE_DIR, 'glibc-node');
|
|
188
|
-
|
|
189
|
-
const PREFIX = process.env.PREFIX || '/data/data/com.termux/files/usr';
|
|
190
|
-
const glibcLd = path.join(PREFIX, 'glibc', 'lib', 'ld-linux-aarch64.so.1');
|
|
191
|
-
const glibcLibs = path.join(PREFIX, 'glibc', 'lib');
|
|
192
|
-
|
|
193
|
-
// glibc動的リンカ経由でないとTermux(bionic)上ではglibc Nodeバイナリを実行できないため、
|
|
194
|
-
// ld-linux 経由で `node -v` を実行しバージョン文字列を確認する。
|
|
195
|
-
function verifyNodeBinary(binPath) {
|
|
196
|
-
// bin/copilot と同様、Termux由来の LD_PRELOAD (bionic向けexecフック) を明示的にクリアしないと
|
|
197
|
-
// glibc loaderがロードするlibc.soがinvalid ELF headerエラーになる(2026-07-06実機確認)。
|
|
198
|
-
const out = execFileSync(glibcLd, ['--library-path', glibcLibs, binPath, '-v'], {
|
|
199
|
-
encoding: 'utf8',
|
|
200
|
-
env: { ...process.env, LD_PRELOAD: '' },
|
|
201
|
-
}).trim();
|
|
202
|
-
return out === `v${version}`;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
let needsDownload = true;
|
|
206
|
-
if (fs.existsSync(nodeBin)) {
|
|
207
|
-
try {
|
|
208
|
-
if (verifyNodeBinary(nodeBin)) {
|
|
209
|
-
needsDownload = false;
|
|
210
|
-
} else {
|
|
211
|
-
console.log(`glibc node at ${nodeVersionDir} failed version check, re-downloading...`);
|
|
212
|
-
fs.rmSync(nodeVersionDir, { recursive: true, force: true });
|
|
213
|
-
}
|
|
214
|
-
} catch (e) {
|
|
215
|
-
// 破損バイナリ・実行不可などpartial stateからの自己修復
|
|
216
|
-
console.log(`glibc node at ${nodeVersionDir} failed to execute (${e.message}), re-downloading...`);
|
|
217
|
-
fs.rmSync(nodeVersionDir, { recursive: true, force: true });
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (needsDownload) {
|
|
222
|
-
const tarballUrl = `https://nodejs.org/dist/v${version}/node-v${version}-linux-arm64.tar.gz`;
|
|
223
|
-
console.log(`Downloading Node.js v${version} (glibc)...`);
|
|
224
|
-
const tarball = await httpsGet(tarballUrl);
|
|
225
|
-
|
|
226
|
-
const actualSha256 = crypto.createHash('sha256').update(tarball).digest('hex');
|
|
227
|
-
if (actualSha256 !== expectedSha256) {
|
|
228
|
-
throw new Error(`Node.js integrity check failed: expected ${expectedSha256}, got ${actualSha256}`);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const stagingDir = `${nodeVersionDir}.staging.${process.pid}`;
|
|
232
|
-
const tarballPath = path.join(CACHE_DIR, `node-glibc-${version}.tgz`);
|
|
233
|
-
try {
|
|
234
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
235
|
-
fs.writeFileSync(tarballPath, tarball);
|
|
236
|
-
fs.mkdirSync(stagingDir, { recursive: true });
|
|
237
|
-
|
|
238
|
-
console.log('Extracting node binary...');
|
|
239
|
-
execFileSync('tar', [
|
|
240
|
-
'-xzf', tarballPath,
|
|
241
|
-
'-C', stagingDir,
|
|
242
|
-
'--strip-components=2',
|
|
243
|
-
`node-v${version}-linux-arm64/bin/node`,
|
|
244
|
-
]);
|
|
245
|
-
const stagingBin = path.join(stagingDir, 'node');
|
|
246
|
-
fs.chmodSync(stagingBin, 0o755);
|
|
247
|
-
|
|
248
|
-
// staging側で実行検証(glibcローダー経由)。失敗すれば例外がそのまま
|
|
249
|
-
// 呼び出し元に伝播し、stagingはcatchで削除、nodeVersionDirには一切触れない。
|
|
250
|
-
if (!verifyNodeBinary(stagingBin)) {
|
|
251
|
-
throw new Error(`Downloaded glibc node binary failed version check (expected v${version})`);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 既存の nodeVersionDir が壊れた状態で残っている場合に備え、rename前にクリア
|
|
255
|
-
// (ここまで到達した時点で staging 側の検証は完了済みなので安全)
|
|
256
|
-
fs.rmSync(nodeVersionDir, { recursive: true, force: true });
|
|
257
|
-
fs.renameSync(stagingDir, nodeVersionDir);
|
|
258
|
-
} catch (err) {
|
|
259
|
-
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
260
|
-
throw err;
|
|
261
|
-
} finally {
|
|
262
|
-
fs.rmSync(tarballPath, { force: true });
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Migration: 1.0.68以前の glibc-node は実ディレクトリだった。
|
|
267
|
-
// 新バージョンの用意(既存流用 or 新規ダウンロード、どちらもverifyNodeBinary通過済み)が
|
|
268
|
-
// 完全に成功した後(ここまで到達した時点)でのみ、旧実ディレクトリを削除する。
|
|
269
|
-
let currentLinkStat = null;
|
|
270
|
-
try { currentLinkStat = fs.lstatSync(currentLink); } catch (_) {}
|
|
271
|
-
if (currentLinkStat && currentLinkStat.isDirectory() && !currentLinkStat.isSymbolicLink()) {
|
|
272
|
-
fs.rmSync(currentLink, { recursive: true, force: true });
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const tmpLink = path.join(CACHE_DIR, `glibc-node.tmp.${process.pid}`);
|
|
276
|
-
try { fs.unlinkSync(tmpLink); } catch (_) {}
|
|
277
|
-
fs.symlinkSync(nodeVersionDir, tmpLink);
|
|
278
|
-
fs.renameSync(tmpLink, currentLink);
|
|
279
|
-
|
|
280
|
-
console.log('✓ glibc node ready');
|
|
128
|
+
console.log('✓ glibc wrap ready');
|
|
281
129
|
}
|
|
282
130
|
|
|
283
131
|
module.exports = { setup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bash0816/copilot-termux",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.88",
|
|
4
4
|
"description": "GitHub Copilot CLI for Termux (Android aarch64)",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -23,12 +23,8 @@
|
|
|
23
23
|
"scripts": {},
|
|
24
24
|
"files": [
|
|
25
25
|
"bin",
|
|
26
|
-
"lib/platform-patch.js",
|
|
27
26
|
"lib/setup.js",
|
|
28
27
|
"lib/check-updates.js",
|
|
29
|
-
"lib/bionic-compat.so",
|
|
30
|
-
"lib/native/pty.node",
|
|
31
|
-
"scripts/bionic-compat.c",
|
|
32
28
|
"config",
|
|
33
29
|
"LICENSE",
|
|
34
30
|
"THIRD-PARTY-NOTICES.md",
|
package/lib/bionic-compat.so
DELETED
|
Binary file
|
package/lib/native/pty.node
DELETED
|
Binary file
|