cicy-desktop 2.1.108 → 2.1.109
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/package.json +1 -1
- package/src/sidecar/wsl-docker.js +27 -10
package/package.json
CHANGED
|
@@ -13,10 +13,19 @@
|
|
|
13
13
|
|
|
14
14
|
const { execFile, execFileSync, spawn } = require("child_process");
|
|
15
15
|
const path = require("path");
|
|
16
|
+
const os = require("os");
|
|
17
|
+
const fs = require("fs");
|
|
16
18
|
const docker = require("./docker"); // shared: downloads, waitUntil, probeHealth, launchElevated, ensureWsl…
|
|
17
19
|
|
|
18
20
|
const DISTRO = process.env.CICY_WSL_DISTRO || "Ubuntu";
|
|
19
21
|
const IMAGE = process.env.CICY_DOCKER_IMAGE || "cicybot/cicy-code:latest";
|
|
22
|
+
// Ubuntu WSL rootfs from the Tsinghua TUNA mirror (CN-fast). We download it
|
|
23
|
+
// ourselves (real progress bar) and `wsl --import` it, instead of
|
|
24
|
+
// `wsl --install -d Ubuntu` (no parseable progress, needs the MS Store).
|
|
25
|
+
const ROOTFS_URL = process.env.CICY_WSL_ROOTFS_URL ||
|
|
26
|
+
"https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/wsl/jammy/current/ubuntu-jammy-wsl-amd64-ubuntu22.04lts.rootfs.tar.gz";
|
|
27
|
+
|
|
28
|
+
function rootfsPath() { return path.join(docker.downloadsDir(), "ubuntu-jammy-wsl-rootfs.tar.gz"); }
|
|
20
29
|
|
|
21
30
|
// Run a bash command as root inside the distro. execFile (no host shell) → the
|
|
22
31
|
// command string is passed verbatim to `bash -lc`, so only bash-level quoting
|
|
@@ -74,16 +83,24 @@ function distroInstalled(distro = DISTRO) {
|
|
|
74
83
|
// (--no-launch). We always run commands as root afterwards, so no user account
|
|
75
84
|
// is needed. Elevated via the scheduled-task path (reliable on these machines).
|
|
76
85
|
async function installDistro({ emit } = {}) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} catch {
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
// 1) Download the rootfs with a REAL progress bar (Tsinghua mirror, resumable).
|
|
87
|
+
const dest = rootfsPath();
|
|
88
|
+
await docker.ensureDownloaded(ROOTFS_URL, dest, null, { emit, phase: "install-docker", label: "下载 Ubuntu" });
|
|
89
|
+
// 2) Ensure the WSL2 kernel exists (a feature-enable + reboot leaves the kernel
|
|
90
|
+
// component missing → `--import --version 2` errors). Best-effort, non-fatal.
|
|
91
|
+
emit && emit({ phase: "install-docker", status: "running", message: "检查/更新 WSL2 内核…" });
|
|
92
|
+
await new Promise((res) => execFile("wsl", ["--update", "--web-download"], { timeout: 180000, windowsHide: true }, () => res()));
|
|
93
|
+
try { await new Promise((res) => execFile("wsl", ["--set-default-version", "2"], { timeout: 15000, windowsHide: true }, () => res())); } catch {}
|
|
94
|
+
// 3) Import it as a WSL2 distro (creates the VHD under installDir; no MS Store,
|
|
95
|
+
// no interactive first-run — we run everything as root afterwards).
|
|
96
|
+
emit && emit({ phase: "install-docker", status: "running", message: "导入 Ubuntu 到 WSL2…" });
|
|
97
|
+
const installDir = path.join(process.env["LOCALAPPDATA"] || path.join(os.homedir(), "AppData", "Local"), "cicy-ubuntu");
|
|
98
|
+
try { fs.mkdirSync(installDir, { recursive: true }); } catch {}
|
|
99
|
+
await new Promise((resolve, reject) => {
|
|
100
|
+
execFile("wsl", ["--import", DISTRO, installDir, dest, "--version", "2"],
|
|
101
|
+
{ timeout: 600000, windowsHide: true },
|
|
102
|
+
(err, _so, se) => err ? reject(Object.assign(err, { stderr: String(se || "") })) : resolve());
|
|
103
|
+
});
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
// docker CLI present inside the distro?
|