install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.
Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).
Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
every distro's command, root without sudo, no tty, no sudo on PATH,
Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
19 pass), green after. CI's site step (sh -n + node --test
site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
(macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
terminal kept with setpriv (su -c starts a session without one),
v0.1.2399/2400 from the real feed; then ldd (nothing missing),
`magpie version`, and the package query:
- Debian 12, sudo with a password, typed by expect at sudo's prompt,
package lists deleted first: install failed "Unable to locate", apt-get
update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
- Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
- Fedora 44, password via expect: webkit2gtk4.1, desktop app;
- Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
- openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
- Debian 12 as root: apt-get without sudo, desktop app;
- Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
nothing installed;
- Debian 12 without -t (no terminal): terminal build + the apt line, no
install tried; without sudo at a terminal: the same;
- Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
fail "Unable to locate", then the terminal build and the "didn't work
(see above)" hint.
Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
This commit is contained in:
@@ -52,7 +52,7 @@ Runs on macOS, Windows and Linux (menu bar app, window, TUI, web UI and CLI), in
|
||||
curl -fsSL https://usemagpie.ai/install.sh | sh
|
||||
```
|
||||
|
||||
<sub>Mac builds are signed and notarised, and every build updates itself. On Linux the script installs the desktop app, or the terminal build where there is no desktop or its WebKitGTK isn't installed (it says which package to add); `--gui` or `--tui` chooses. Behind a firewall, use `--proxy` or `--mirror`. Or `go install github.com/yetone/magpie@latest`, or the [Docker image](https://usemagpie.ai/docs/docker). Remove what the script installed with `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall`; your settings in `~/.config/magpie` stay unless you add `--purge`, which disconnects your agents and deletes them too.</sub>
|
||||
<sub>Mac builds are signed and notarised, and every build updates itself. On Linux the script installs the desktop app, and on a desktop without WebKitGTK 4.1 installs it first with your package manager (sudo asks for your password); with no desktop, or no terminal to ask at, it installs the terminal build and says which package to add. `--gui` or `--tui` chooses. Behind a firewall, use `--proxy` or `--mirror`. Or `go install github.com/yetone/magpie@latest`, or the [Docker image](https://usemagpie.ai/docs/docker). Remove what the script installed with `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall`; your settings in `~/.config/magpie` stay unless you add `--purge`, which disconnects your agents and deletes them too.</sub>
|
||||
|
||||
**2 · Add a provider.** Open magpie and go to **Providers → Add provider**. Pick a preset and paste a key, or sign in with a subscription.
|
||||
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
curl -fsSL https://usemagpie.ai/install.sh | sh
|
||||
```
|
||||
|
||||
<sub>Mac 版已签名并公证,每个版本都会自动更新。Linux 上脚本装桌面版;没有桌面或没装 WebKitGTK 时装终端版(并告诉你该装哪个包),用 `--gui` 或 `--tui` 可以自己选。网络受限时可用 `--proxy` 或 `--mirror`。也可以 `go install github.com/yetone/magpie@latest`,或者用 [Docker 镜像](https://usemagpie.ai/docs/zh/docker)。 用 `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall` 卸载脚本装上的东西;`~/.config/magpie` 里的设置会保留,加 `--purge` 才会断开 Agent 并一起删除。</sub>
|
||||
<sub>Mac 版已签名并公证,每个版本都会自动更新。Linux 上脚本装桌面版,桌面上没装 WebKitGTK 4.1 时会先用系统的包管理器装上(sudo 会要密码);没有桌面或没有终端可问时装终端版,并告诉你该装哪个包。用 `--gui` 或 `--tui` 可以自己选。网络受限时可用 `--proxy` 或 `--mirror`。也可以 `go install github.com/yetone/magpie@latest`,或者用 [Docker 镜像](https://usemagpie.ai/docs/zh/docker)。 用 `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall` 卸载脚本装上的东西;`~/.config/magpie` 里的设置会保留,加 `--purge` 才会断开 Agent 并一起删除。</sub>
|
||||
|
||||
**2 · 添加 provider**。打开 magpie,进入 **Providers → 添加 provider**。选一个预设、粘贴 key,或者登录一个订阅。
|
||||
|
||||
|
||||
+20
-13
@@ -2602,24 +2602,31 @@ with a link builder: <https://usemagpie.ai/docs/import>.
|
||||
|
||||
Download the app for macOS, Windows or Linux from
|
||||
[usemagpie.ai](https://usemagpie.ai), or install it from a terminal (on
|
||||
Linux, the desktop app when GTK 3 and WebKitGTK 4.1 are installed, the
|
||||
terminal build otherwise):
|
||||
Linux, the desktop app, with WebKitGTK 4.1 installed for it on a desktop
|
||||
that lacks it; the terminal build where there is no desktop):
|
||||
|
||||
```sh
|
||||
curl -fsSL https://usemagpie.ai/install.sh | sh
|
||||
```
|
||||
|
||||
On Linux the installer asks nothing. A computer with a desktop (a
|
||||
graphical session, the user's graphical login when run over ssh, or a
|
||||
desktop installed in `xsessions` / `wayland-sessions`) but without the
|
||||
app's libraries gets the terminal build, and the installer ends with the
|
||||
command that installs them on that distribution (`sudo apt install
|
||||
libwebkit2gtk-4.1-0` on Debian and Ubuntu, `sudo dnf install
|
||||
webkit2gtk4.1` on Fedora, `sudo pacman -S --needed webkit2gtk-4.1` on
|
||||
Arch, `sudo zypper install libwebkit2gtk-4_1-0` on openSUSE); run it again
|
||||
afterwards for the app. `--gui` installs the app at once, before its
|
||||
libraries; `--tui` (or `MAGPIE_CLI=1`) installs the terminal build on a
|
||||
desktop too. The libraries are looked up with `ldconfig -p`, in `/sbin`
|
||||
On a Linux computer with a desktop (a graphical session, the user's
|
||||
graphical login when run over ssh, or a desktop installed in `xsessions` /
|
||||
`wayland-sessions`) but without the app's libraries, the installer
|
||||
installs WebKitGTK 4.1 (which brings GTK 3) with the distribution's
|
||||
package manager, says so in one line first, and then installs the desktop
|
||||
app: `apt-get install -y libwebkit2gtk-4.1-0` on Debian and Ubuntu
|
||||
(`apt-get update` and once more when the lists are missing or stale),
|
||||
`dnf install -y webkit2gtk4.1` on Fedora, `pacman -S --needed --noconfirm
|
||||
webkit2gtk-4.1` on Arch, `zypper --non-interactive install
|
||||
libwebkit2gtk-4_1-0` on openSUSE, through `sudo` (which asks for the
|
||||
password) unless it runs as root. It does so only when someone is at the
|
||||
terminal: `curl … | sh` gives the script the pipe for stdin, so it reads
|
||||
`/dev/tty`. With no terminal (CI, a Dockerfile), no `sudo`, another
|
||||
distribution, or an install that fails, it installs the terminal build and
|
||||
ends with the command that installs the libraries; run it again afterwards
|
||||
for the app. `--gui` installs the app either way (the libraries too, at a
|
||||
terminal); `--tui` (or `MAGPIE_CLI=1`) installs the terminal build on a
|
||||
desktop and installs no package. The libraries are looked up with `ldconfig -p`, in `/sbin`
|
||||
as well, since a Debian user's `PATH` doesn't have it, and in the usual
|
||||
library folders where there is no cache. On musl (Alpine) it is always the
|
||||
terminal build.
|
||||
|
||||
+109
-4
@@ -1,7 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync } from "node:fs";
|
||||
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync, symlinkSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { spawnSync } from "node:child_process";
|
||||
@@ -9,7 +9,19 @@ import { fileURLToPath } from "node:url";
|
||||
|
||||
const installer = fileURLToPath(new URL("./public/install.sh", import.meta.url));
|
||||
|
||||
function install(t, { termux = true, arch = "aarch64", override = false, prefixOnly = false, missing = false, corrupt = false, desktop = false, github = false, args = [], env: extra = {}, tamper = "", libs = desktop, cli = !desktop, distro = "ID=ubuntu\nID_LIKE=debian\n", sessions = [], login = "" } = {}) {
|
||||
// systemPath: a folder of links to what the script runs, without sudo, for
|
||||
// a computer that has none
|
||||
function systemPath(dir) {
|
||||
const sys = join(dir, "sys");
|
||||
mkdirSync(sys, { recursive: true });
|
||||
for (const n of ["sh", "dash", "bash", "sed", "head", "tr", "grep", "cut", "mktemp", "rm", "mkdir", "install", "cat", "sha256sum", "shasum", "ls", "rmdir", "mv", "ln", "chmod", "env", "perl"]) {
|
||||
const w = spawnSync("sh", ["-c", `command -v ${n}`], { encoding: "utf8" }).stdout.trim();
|
||||
if (w.startsWith("/")) symlinkSync(w, join(sys, n));
|
||||
}
|
||||
return sys;
|
||||
}
|
||||
|
||||
function install(t, { termux = true, arch = "aarch64", override = false, prefixOnly = false, missing = false, corrupt = false, desktop = false, github = false, args = [], env: extra = {}, tamper = "", libs = desktop, cli = !desktop, distro = "ID=ubuntu\nID_LIKE=debian\n", sessions = [], login = "", tty = false, uid = 1000, sudo = true, pmFails = false } = {}) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "magpie-install-"));
|
||||
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
||||
const tools = join(dir, "tools");
|
||||
@@ -47,6 +59,26 @@ id=\${INSTALL_LOGIN%% *} type=\${INSTALL_LOGIN#* }
|
||||
[ "$1 $3 $4 $5" = "show-user -p Display --value" ] && [ -n "$id" ] && echo "$id"
|
||||
[ "$1 $2 $3 $4 $5" = "show-session $id -p Type --value" ] && [ -n "$id" ] && echo "$type"
|
||||
exit 0
|
||||
`, { mode: 0o755 });
|
||||
// the package managers, sudo and id: each call logged ("sudo" before a
|
||||
// command sudo ran), and an install puts the libraries in ldconfig's
|
||||
// cache unless it fails
|
||||
const pmLog = join(dir, "pm-log");
|
||||
const ldTxt = join(tools, "ldconfig.txt").replaceAll("\\", "/");
|
||||
for (const pm of ["apt-get", "dnf", "pacman", "zypper"]) {
|
||||
writeFileSync(join(tools, pm), `#!/bin/sh
|
||||
echo "\${INSTALL_SUDO:+sudo }${pm} $*" >> "$INSTALL_PM_LOG"
|
||||
case "$*" in update|"") exit 0 ;; esac
|
||||
[ -z "$INSTALL_PM_FAILS" ] || exit 100
|
||||
[ "$INSTALL_PM_FAILS_ONCE" != 1 ] || [ -e "$INSTALL_PM_LOG.once" ] || { : > "$INSTALL_PM_LOG.once"; exit 100; }
|
||||
printf '\\tlibgtk-3.so.0 (libc6,x86-64) => /usr/lib/libgtk-3.so.0\\n\\tlibwebkit2gtk-4.1.so.0 (libc6,x86-64) => /usr/lib/libwebkit2gtk-4.1.so.0\\n' >> "${ldTxt}"
|
||||
`, { mode: 0o755 });
|
||||
}
|
||||
if (sudo) writeFileSync(join(tools, "sudo"), `#!/bin/sh
|
||||
INSTALL_SUDO=1 exec "$@"
|
||||
`, { mode: 0o755 });
|
||||
writeFileSync(join(tools, "id"), `#!/bin/sh
|
||||
case "$1" in -u) echo ${uid};; *) echo tester;; esac
|
||||
`, { mode: 0o755 });
|
||||
const dataDirs = join(dir, "data-dirs");
|
||||
for (const s of sessions) {
|
||||
@@ -88,7 +120,12 @@ else fs.writeFileSync(args[args.indexOf("-o") + 1], tamper && url.startsWith(tam
|
||||
XDG_DATA_DIRS: dataDirs,
|
||||
INSTALL_LOGIN: login,
|
||||
MAGPIE_OS_RELEASE: join(dir, "os-release"),
|
||||
PATH: tools + ":" + process.env.PATH,
|
||||
// no terminal unless a test gives it one: the run never reaches a real
|
||||
// sudo or package manager
|
||||
MAGPIE_TTY: tty ? join(dir, "tty") : join(dir, "no-tty"),
|
||||
INSTALL_PM_LOG: pmLog,
|
||||
INSTALL_PM_FAILS: pmFails ? "1" : "",
|
||||
PATH: tools + ":" + (sudo ? process.env.PATH : systemPath(dir)),
|
||||
XDG_CONFIG_HOME: join(dir, "config"),
|
||||
XDG_DATA_HOME: join(dir, "share"),
|
||||
INSTALL_REQUESTS: requests,
|
||||
@@ -100,13 +137,14 @@ else fs.writeFileSync(args[args.indexOf("-o") + 1], tamper && url.startsWith(tam
|
||||
MAGPIE_MIRROR: "",
|
||||
...extra,
|
||||
};
|
||||
if (tty) writeFileSync(join(dir, "tty"), "");
|
||||
const read = (p) => (existsSync(p) ? readFileSync(p, "utf8") : "");
|
||||
const run = (args) => {
|
||||
rmSync(requests, { force: true });
|
||||
rmSync(env.INSTALL_ARGS, { force: true });
|
||||
const result = spawnSync("sh", [installer, ...args], { env, encoding: "utf8" });
|
||||
const calls = read(env.INSTALL_ARGS).trim().split("\n").filter(Boolean).map((l) => JSON.parse(l));
|
||||
return { ...result, requests: read(requests), calls };
|
||||
return { ...result, requests: read(requests), calls, pm: read(pmLog) };
|
||||
};
|
||||
return { ...run(args), run, bin, file, payload, home, env, share: env.XDG_DATA_HOME, config: env.XDG_CONFIG_HOME };
|
||||
}
|
||||
@@ -411,3 +449,70 @@ test("--tui and MAGPIE_CLI=1 install the terminal build on a desktop with WebKit
|
||||
assert.match(help.stdout, /--gui .*desktop app/);
|
||||
assert.match(help.stdout, /--tui .*terminal build/);
|
||||
});
|
||||
|
||||
// shuhai on Discord: "为什么不能帮用户直接装好?" A desktop without
|
||||
// WebKitGTK 4.1 has it installed with the distribution's package manager,
|
||||
// through sudo, when someone is at the terminal (curl | sh: /dev/tty, not
|
||||
// stdin), and then gets the desktop app. Anything else keeps the terminal
|
||||
// build and the command.
|
||||
test("a desktop without WebKitGTK at a terminal has it installed through sudo and gets the desktop app", (t) => {
|
||||
for (const [distro, want] of [
|
||||
["ID=ubuntu\nID_LIKE=debian\n", "sudo apt-get install -y libwebkit2gtk-4.1-0"],
|
||||
["ID=fedora\n", "sudo dnf install -y webkit2gtk4.1"],
|
||||
["ID=endeavouros\nID_LIKE=arch\n", "sudo pacman -S --needed --noconfirm webkit2gtk-4.1"],
|
||||
['ID="opensuse-tumbleweed"\nID_LIKE="opensuse suse"\n', "sudo zypper --non-interactive install libwebkit2gtk-4_1-0"],
|
||||
]) {
|
||||
const r = linux(t, { libs: false, tty: true, distro, env: { DISPLAY: ":0" } });
|
||||
assert.ok(r.gui, distro + r.stdout);
|
||||
assert.equal(r.pm, want + "\n", distro);
|
||||
// what and why, said before sudo asks
|
||||
assert.match(r.stdout, new RegExp(`needs WebKitGTK 4\\.1, so installing it: ${want.replace(/[.+]/g, "\\$&")} \\(sudo may ask for your password\\)`));
|
||||
assert.doesNotMatch(r.stdout, /aren't installed|didn't work|run this again/);
|
||||
}
|
||||
});
|
||||
|
||||
test("as root the package manager runs without sudo", (t) => {
|
||||
const r = linux(t, { libs: false, tty: true, uid: 0, env: { DISPLAY: ":0" } });
|
||||
assert.ok(r.gui);
|
||||
assert.equal(r.pm, "apt-get install -y libwebkit2gtk-4.1-0\n");
|
||||
assert.doesNotMatch(r.stdout, /sudo/);
|
||||
});
|
||||
|
||||
test("with no terminal, no sudo, an unknown distribution or a failed install, the terminal build and the command", (t) => {
|
||||
for (const opts of [
|
||||
{ tty: false },
|
||||
{ tty: true, sudo: false },
|
||||
{ tty: true, distro: "ID=void\n" },
|
||||
{ tty: true, distro: "ID=nixos\n" },
|
||||
]) {
|
||||
const r = linux(t, { libs: false, env: { DISPLAY: ":0" }, ...opts });
|
||||
assert.equal(r.gui, false, JSON.stringify(opts));
|
||||
assert.equal(r.pm, "", JSON.stringify(opts));
|
||||
assert.doesNotMatch(r.stdout, /installing it|didn't work/);
|
||||
assert.match(r.stdout, /has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4\.1, which aren't installed/);
|
||||
}
|
||||
const f = linux(t, { libs: false, tty: true, pmFails: true, env: { DISPLAY: ":0" } });
|
||||
assert.equal(f.gui, false);
|
||||
// apt read its lists again and tried once more
|
||||
assert.equal(f.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\nsudo apt-get update\nsudo apt-get install -y libwebkit2gtk-4.1-0\n");
|
||||
assert.match(last(f, 5), /installing GTK 3 and WebKitGTK 4\.1 for the desktop app didn't work/);
|
||||
assert.match(last(f, 4), /sudo apt install libwebkit2gtk-4\.1-0/);
|
||||
});
|
||||
|
||||
test("a stale apt list is read again and the install tried once more", (t) => {
|
||||
const r = linux(t, { libs: false, tty: true, env: { DISPLAY: ":0", INSTALL_PM_FAILS_ONCE: "1" } });
|
||||
assert.ok(r.gui, r.stdout);
|
||||
assert.equal(r.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\nsudo apt-get update\nsudo apt-get install -y libwebkit2gtk-4.1-0\n");
|
||||
});
|
||||
|
||||
test("--gui installs WebKitGTK at a terminal too; --tui, MAGPIE_CLI=1 and a headless computer never do", (t) => {
|
||||
const g = linux(t, { libs: false, tty: true, args: ["--gui"] });
|
||||
assert.ok(g.gui);
|
||||
assert.equal(g.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\n");
|
||||
assert.doesNotMatch(g.stdout, /aren't installed/);
|
||||
for (const opts of [{ args: ["--tui"], env: { DISPLAY: ":0" } }, { cli: true, env: { DISPLAY: ":0" } }, {}]) {
|
||||
const r = linux(t, { libs: false, tty: true, ...opts });
|
||||
assert.equal(r.gui, false, JSON.stringify(opts));
|
||||
assert.equal(r.pm, "", JSON.stringify(opts));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -287,7 +287,7 @@ magpie claude group/opus-anywhere <span class="c"># これを使う</span></p
|
||||
<p>インストーラと <code>magpie update</code> にプロキシを渡します:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>、または <code>magpie update --proxy socks5://127.0.0.1:1080</code>(http・https・socks5・socks5h に対応。<code>HTTPS_PROXY</code> と <code>ALL_PROXY</code> も使われます)。<code>--mirror <prefix></code> を付けると、指定した GitHub ダウンロードミラーから <code><prefix>https://github.com/…</code> としてリリースファイルを取得します。<code>magpie update mirror <prefix></code> でアプリ自身の更新を含め毎回使い、<code>magpie update mirror off</code> で解除します。指定しない限りミラーは使われず、ファイルの SHA-256 はミラーではなく常に usemagpie.ai から取得するので、ミラーが書き換えたファイルはインストールされません。アプリ自身の更新は <span class="ui">Settings</span> → <span class="ui">Proxy</span> を通ります。</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Linux ではインストーラはどのビルドを入れますか?</a></h3>
|
||||
<p>GTK 3 と WebKitGTK 4.1 が入っていればデスクトップアプリ(ウィンドウ、トレイアイコン、アプリメニューの項目)です。デスクトップがあってもそれらが無いときはターミナル版(<code>magpie tui</code>、<code>magpie web</code> と CLI)を入れ、最後にそのディストリビューションで入れるコマンドを表示します。Debian・Ubuntu なら <code>sudo apt install libwebkit2gtk-4.1-0</code>、Fedora なら <code>sudo dnf install webkit2gtk4.1</code> です。入れたあとインストーラをもう一度実行するとアプリになります。デスクトップ上で実行しても ssh 越しでも、グラフィカルなセッション、あなたのグラフィカルなログイン、ログインできるデスクトップ環境のどれかがあればデスクトップありと判断します。デスクトップの無いサーバーにはターミナル版です。何も質問しないので <code>curl … | sh</code> はそのまま無人で動きます。自分で選ぶには <code>--gui</code>(アプリを先に、ライブラリは後で)か <code>--tui</code> を付けます:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
<p>GTK 3 と WebKitGTK 4.1 が入っていればデスクトップアプリ(ウィンドウ、トレイアイコン、アプリメニューの項目)です。デスクトップがあってもそれらが無いときは、パッケージマネージャー(apt、dnf、pacman、zypper)で <code>sudo</code> を通して WebKitGTK 4.1 を入れ(sudo がパスワードを尋ねます)、それからアプリを入れます。パスワードを尋ねる前に何を入れるかを表示します。端末が無いとき(CI、Dockerfile)、<code>sudo</code> が無いとき、知らないディストリビューションやインストールに失敗したときはターミナル版(<code>magpie tui</code>、<code>magpie web</code> と CLI)を入れ、最後に入れるコマンドを表示します。Debian・Ubuntu なら <code>sudo apt install libwebkit2gtk-4.1-0</code>、Fedora なら <code>sudo dnf install webkit2gtk4.1</code> です。入れたあとインストーラをもう一度実行するとアプリになります。デスクトップ上で実行しても ssh 越しでも、グラフィカルなセッション、あなたのグラフィカルなログイン、ログインできるデスクトップ環境のどれかがあればデスクトップありと判断します。デスクトップの無いサーバーにはターミナル版です。自分で選ぶには <code>--gui</code>(ライブラリを今入れられなくてもアプリ)か <code>--tui</code>(ターミナル版、パッケージは入れない)を付けます:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
|
||||
<h3 id="uninstall"><a class="anchor" href="#uninstall">magpie をアンインストールするには?</a></h3>
|
||||
<p>スクリプトでインストールした場合:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall</code> で、スクリプトが置いたものを取り除きます。<code>magpie</code> コマンド、macOS ではアプリ、Linux ではメニュー項目・アイコン・<code>magpie://</code> のハンドラ、それに Linux ではもう無い magpie を起動してしまうサービスとログイン時の起動です。<code>~/.config/magpie</code> の設定・プロバイダ・使用量は残るので、再インストールすれば戻ります。接続したエージェントはそれまで magpie のアドレスを指したままです。<code>--purge</code> を付けると先に <code>magpie uninstall --yes</code> を実行し、すべてのエージェントの接続を外して元の設定に戻してから、magpie の設定・プロバイダ・使用量を削除します。ほかの方法でインストールした場合は、<code>magpie uninstall</code> または <span class="ui">Settings</span> → <span class="ui">magpie をアンインストール</span> が <code>--purge</code> と同じことを行い、プログラム本体は手動で削除します。</p>
|
||||
|
||||
@@ -287,7 +287,7 @@ magpie claude group/opus-anywhere <span class="c"># use it</span></pre>
|
||||
<p>Give the installer and <code>magpie update</code> a proxy: <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>, or <code>magpie update --proxy socks5://127.0.0.1:1080</code> (http, https, socks5 and socks5h; <code>HTTPS_PROXY</code> and <code>ALL_PROXY</code> are honoured too). <code>--mirror <prefix></code> fetches the release file from a GitHub download mirror you choose, as <code><prefix>https://github.com/…</code>; <code>magpie update mirror <prefix></code> keeps it for every update, the app’s too, and <code>magpie update mirror off</code> removes it. No mirror is used unless you give one, and the file’s SHA-256 still comes from usemagpie.ai, never from the mirror: a file the mirror changed is refused. The app’s own updates go through <span class="ui">Settings</span> → <span class="ui">Proxy</span>.</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Which build does the installer put on Linux?</a></h3>
|
||||
<p>The desktop app (window, tray icon and a menu entry) when GTK 3 and WebKitGTK 4.1 are installed. A computer with a desktop but without them gets the terminal build (<code>magpie tui</code>, <code>magpie web</code> and the CLI), and the installer ends with the command that installs them on your distribution, such as <code>sudo apt install libwebkit2gtk-4.1-0</code> on Debian and Ubuntu or <code>sudo dnf install webkit2gtk4.1</code> on Fedora; run the installer again afterwards for the app. A desktop counts whether you run it there or over ssh: a graphical session, your graphical login, or a desktop installed to log in to. A server without one gets the terminal build. Nothing is asked, so <code>curl … | sh</code> runs unattended; to choose yourself, add <code>--gui</code> (the app now, the libraries after) or <code>--tui</code>: <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>.</p>
|
||||
<p>The desktop app (window, tray icon and a menu entry) when GTK 3 and WebKitGTK 4.1 are installed. On a computer with a desktop but without them, the installer installs WebKitGTK 4.1 with your package manager (apt, dnf, pacman or zypper), through <code>sudo</code>, which asks for your password, and then the app; it says what it installs before it asks. Run without a terminal (CI, a Dockerfile), without <code>sudo</code>, on another distribution or when that install fails, it installs the terminal build (<code>magpie tui</code>, <code>magpie web</code> and the CLI) and ends with the command that installs them, such as <code>sudo apt install libwebkit2gtk-4.1-0</code> on Debian and Ubuntu or <code>sudo dnf install webkit2gtk4.1</code> on Fedora; run the installer again afterwards for the app. A desktop counts whether you run it there or over ssh: a graphical session, your graphical login, or a desktop installed to log in to. A server without one gets the terminal build. To choose yourself, add <code>--gui</code> (the app even when its libraries can't be installed now) or <code>--tui</code> (the terminal build, and no package installed): <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>.</p>
|
||||
|
||||
<h3 id="uninstall"><a class="anchor" href="#uninstall">How do I uninstall magpie?</a></h3>
|
||||
<p>Installed with the script: <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall</code> takes off what it put there: the <code>magpie</code> command, and the app on macOS or its menu entry, icon and <code>magpie://</code> handler on Linux, with magpie’s service and opening at login there, which would start a magpie that is gone. Your settings, providers and usage in <code>~/.config/magpie</code> stay, for when you install again; agents you connected keep magpie’s address until then. Add <code>--purge</code> to have <code>magpie uninstall --yes</code> run first: it disconnects every agent and puts back what each had, then deletes magpie’s settings, providers and usage. Installed another way, <code>magpie uninstall</code> or <span class="ui">Settings</span> → <span class="ui">Uninstall magpie</span> does what <code>--purge</code> does and leaves the program itself for you to delete.</p>
|
||||
|
||||
@@ -287,7 +287,7 @@ magpie claude group/opus-anywhere <span class="c"># 使用它</span></pre>
|
||||
<p>给安装脚本和 <code>magpie update</code> 加代理:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>,或 <code>magpie update --proxy socks5://127.0.0.1:1080</code>(支持 http、https、socks5、socks5h;环境变量 <code>HTTPS_PROXY</code>、<code>ALL_PROXY</code> 同样生效)。<code>--mirror <前缀></code> 从你指定的 GitHub 下载镜像取发布文件,即 <code><前缀>https://github.com/…</code>;<code>magpie update mirror <前缀></code> 让之后每次更新(包括应用自己的更新)都用它,<code>magpie update mirror off</code> 取消。不指定就不用任何镜像;文件的 SHA-256 始终来自 usemagpie.ai,而不是镜像,镜像改过的文件会被拒绝安装。应用自己的更新走 <span class="ui">设置</span> → <span class="ui">代理</span>。</p>
|
||||
|
||||
<h3 id="linux-build"><a class="anchor" href="#linux-build">Linux 上安装脚本装的是哪个版本?</a></h3>
|
||||
<p>装了 GTK 3 和 WebKitGTK 4.1 时装桌面版(窗口、托盘图标和应用菜单项)。有桌面但缺这两个库时,先装终端版(<code>magpie tui</code>、<code>magpie web</code> 和命令行),脚本最后会给出你这个发行版装库的命令,比如 Debian、Ubuntu 上是 <code>sudo apt install libwebkit2gtk-4.1-0</code>,Fedora 上是 <code>sudo dnf install webkit2gtk4.1</code>;装好后再运行一次安装脚本就换成桌面版。在桌面上运行还是 ssh 进去运行都算有桌面:有图形会话、你登录着图形界面,或者装了可登录的桌面环境。没有桌面的服务器装终端版。脚本什么都不问,<code>curl … | sh</code> 可以无人值守;想自己选,加 <code>--gui</code>(先装桌面版,库之后再装)或 <code>--tui</code>:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
<p>装了 GTK 3 和 WebKitGTK 4.1 时装桌面版(窗口、托盘图标和应用菜单项)。有桌面但缺这两个库时,脚本会用系统的包管理器(apt、dnf、pacman 或 zypper)通过 <code>sudo</code> 装上 WebKitGTK 4.1(sudo 会要你的密码),再装桌面版;要密码之前会先说要装什么。没有终端(CI、Dockerfile)、没有 <code>sudo</code>、发行版不认识或者装库失败时,先装终端版(<code>magpie tui</code>、<code>magpie web</code> 和命令行),最后给出装库的命令,比如 Debian、Ubuntu 上是 <code>sudo apt install libwebkit2gtk-4.1-0</code>,Fedora 上是 <code>sudo dnf install webkit2gtk4.1</code>;装好后再运行一次安装脚本就换成桌面版。在桌面上运行还是 ssh 进去运行都算有桌面:有图形会话、你登录着图形界面,或者装了可登录的桌面环境。没有桌面的服务器装终端版。想自己选,加 <code>--gui</code>(库现在装不上也装桌面版)或 <code>--tui</code>(装终端版,不装任何系统包):<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui</code>。</p>
|
||||
|
||||
<h3 id="uninstall"><a class="anchor" href="#uninstall">怎么卸载 magpie?</a></h3>
|
||||
<p>用安装脚本装的:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall</code> 会拿掉它装上的东西:<code>magpie</code> 命令,macOS 上的应用,Linux 上的菜单项、图标和 <code>magpie://</code> 链接处理,以及 Linux 上会去启动一个已不存在的 magpie 的后台服务和开机启动。<code>~/.config/magpie</code> 里的设置、provider 和用量都保留,重新安装就回来;已连接的 Agent 在那之前仍指向 magpie 的地址。加上 <code>--purge</code> 会先运行 <code>magpie uninstall --yes</code>:断开每个 Agent 并恢复它原来的配置,再删除 magpie 的设置、provider 和用量。用其他方式装的,<code>magpie uninstall</code> 或 <span class="ui">设置</span> → <span class="ui">卸载 magpie</span> 做的就是 <code>--purge</code> 那些事,程序本身留给你删除。</p>
|
||||
|
||||
+71
-22
@@ -5,9 +5,12 @@
|
||||
# writable) and links the magpie command into ~/.local/bin.
|
||||
# Linux: puts magpie in ~/.local/bin — the desktop app (with a menu entry)
|
||||
# when GTK 3 and WebKitGTK 4.1 are installed, the terminal build otherwise.
|
||||
# A computer with a desktop but without them gets the terminal build and
|
||||
# the command that installs them on its distribution; --gui and --tui
|
||||
# choose instead (MAGPIE_CLI=1 is --tui). Nothing is asked.
|
||||
# A computer with a desktop but without them has WebKitGTK 4.1 installed
|
||||
# with its package manager (apt-get, dnf, pacman or zypper, through sudo,
|
||||
# which asks for the password) when someone is at the terminal, then gets
|
||||
# the desktop app; with no terminal, no sudo or a failed install, the
|
||||
# terminal build and the command that installs them. --gui and --tui
|
||||
# choose instead (MAGPIE_CLI=1 is --tui).
|
||||
# Termux: installs the Android terminal build into $PREFIX/bin.
|
||||
# Every download is checked against the release's SHA-256.
|
||||
#
|
||||
@@ -22,8 +25,8 @@
|
||||
# list and its SHA-256 still come from usemagpie.ai,
|
||||
# never from the mirror, so a file the mirror changed is
|
||||
# refused.
|
||||
# --gui the desktop app, on Linux even before its libraries are
|
||||
# installed (it opens once they are)
|
||||
# --gui the desktop app, on Linux even when its libraries can't
|
||||
# be installed now (it opens once they are)
|
||||
# --tui the terminal build (TUI, web UI and CLI), on Linux even
|
||||
# with a desktop (MAGPIE_CLI=1 does the same)
|
||||
# --uninstall takes off what this script put there: the magpie
|
||||
@@ -65,7 +68,7 @@ while [ $# -gt 0 ]; do
|
||||
" --proxy <url> http://, https://, socks5:// or socks5h:// proxy for the downloads (or MAGPIE_PROXY=)" \
|
||||
" --mirror <prefix> GitHub download mirror put before the release's github.com URL (or MAGPIE_MIRROR=);" \
|
||||
" the SHA-256 is still checked against $site's" \
|
||||
" --gui Linux: the desktop app, even before GTK 3 and WebKitGTK 4.1 are installed" \
|
||||
" --gui Linux: the desktop app, even when GTK 3 and WebKitGTK 4.1 can't be installed now" \
|
||||
" --tui Linux: the terminal build (TUI, web UI, CLI), even on a desktop (or MAGPIE_CLI=1)" \
|
||||
" --uninstall take off what this script installed; your settings in ~/.config/magpie stay" \
|
||||
" --purge with --uninstall: also disconnect every agent and delete magpie's settings (magpie uninstall)"
|
||||
@@ -248,9 +251,13 @@ has_desktop() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# gui_packages: the command that installs the desktop app's libraries on
|
||||
# this distribution, or nothing when it isn't one we know
|
||||
# gui_packages: sets pkg, the package that brings WebKitGTK 4.1 (and GTK 3
|
||||
# with it) on this distribution, pm, the package manager this script runs
|
||||
# to install it, and hint, the command to tell the user; each is empty when
|
||||
# the distribution isn't one we know (pm too where installing it isn't
|
||||
# quick: Gentoo builds it from source)
|
||||
gui_packages() {
|
||||
pkg='' pm='' hint=''
|
||||
id='' like=''
|
||||
# MAGPIE_OS_RELEASE: another os-release, for the installer's tests
|
||||
rel=${MAGPIE_OS_RELEASE:-/etc/os-release}
|
||||
@@ -262,21 +269,58 @@ gui_packages() {
|
||||
for d in $id $like; do
|
||||
case "$d" in
|
||||
debian|ubuntu|linuxmint|pop|elementary|zorin|kali|raspbian|deepin|uos)
|
||||
echo "sudo apt install libwebkit2gtk-4.1-0"; return ;;
|
||||
pm=apt-get pkg=libwebkit2gtk-4.1-0 hint="sudo apt install libwebkit2gtk-4.1-0" ;;
|
||||
fedora|rhel|centos|rocky|almalinux|nobara|openeuler|anolis)
|
||||
echo "sudo dnf install webkit2gtk4.1"; return ;;
|
||||
pm=dnf pkg=webkit2gtk4.1 hint="sudo dnf install webkit2gtk4.1" ;;
|
||||
arch|manjaro|endeavouros|cachyos|garuda)
|
||||
echo "sudo pacman -S --needed webkit2gtk-4.1"; return ;;
|
||||
pm=pacman pkg=webkit2gtk-4.1 hint="sudo pacman -S --needed webkit2gtk-4.1" ;;
|
||||
opensuse*|suse|sles)
|
||||
echo "sudo zypper install libwebkit2gtk-4_1-0"; return ;;
|
||||
pm=zypper pkg=libwebkit2gtk-4_1-0 hint="sudo zypper install libwebkit2gtk-4_1-0" ;;
|
||||
void)
|
||||
echo "sudo xbps-install -S libwebkit2gtk41"; return ;;
|
||||
hint="sudo xbps-install -S libwebkit2gtk41" ;;
|
||||
gentoo)
|
||||
echo "sudo emerge net-libs/webkit-gtk:4.1"; return ;;
|
||||
hint="sudo emerge net-libs/webkit-gtk:4.1" ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
return 0
|
||||
done
|
||||
}
|
||||
|
||||
# install_gui_libs: installs WebKitGTK 4.1 with the distribution's package
|
||||
# manager, saying first what and why, when someone is at the terminal to
|
||||
# answer sudo's password (or the script runs as root). curl | sh gives the
|
||||
# script the pipe for stdin, so the terminal is /dev/tty, and every command
|
||||
# here reads it. Fails, and the caller falls back to the terminal build,
|
||||
# with no terminal, no sudo, a package manager we don't run, or a failed
|
||||
# install. MAGPIE_TTY: another terminal, for the installer's tests.
|
||||
install_gui_libs() {
|
||||
tried=
|
||||
gui_packages
|
||||
[ -n "$pm" ] && command -v "$pm" >/dev/null 2>&1 || return 1
|
||||
tty=${MAGPIE_TTY:-/dev/tty}
|
||||
# a subshell: a redirection that fails would end the script itself
|
||||
(: <"$tty") 2>/dev/null || return 1
|
||||
as=
|
||||
if [ "$(id -u 2>/dev/null)" != 0 ]; then
|
||||
command -v sudo >/dev/null 2>&1 || return 1
|
||||
as=sudo
|
||||
fi
|
||||
case "$pm" in
|
||||
apt-get) set -- apt-get install -y "$pkg" ;;
|
||||
dnf) set -- dnf install -y "$pkg" ;;
|
||||
pacman) set -- pacman -S --needed --noconfirm "$pkg" ;;
|
||||
zypper) set -- zypper --non-interactive install "$pkg" ;;
|
||||
esac
|
||||
tried=1
|
||||
say "the desktop app needs WebKitGTK 4.1, so installing it: ${as:+$as }$*${as:+ (sudo may ask for your password)}"
|
||||
# apt's package lists can be missing (a fresh system) or out of date
|
||||
# (a 404 for a version gone from the mirror): read them again and retry
|
||||
if $as "$@" <"$tty"; then :
|
||||
elif [ "$pm" = apt-get ] && $as apt-get update <"$tty" && $as "$@" <"$tty"; then :
|
||||
else return 1; fi
|
||||
has_gui_libs
|
||||
}
|
||||
|
||||
case "$(uname -m)" in
|
||||
arm64|aarch64) arch=arm64 ;;
|
||||
x86_64|amd64) arch=amd64 ;;
|
||||
@@ -289,11 +333,14 @@ case "$os" in
|
||||
file="magpie-cli-linux-$arch"
|
||||
case "$build" in
|
||||
gui) ! musl || die "the desktop app is built for glibc and can't run on musl (Alpine): install the terminal build with --tui"
|
||||
file="magpie-linux-$arch" ;;
|
||||
file="magpie-linux-$arch"
|
||||
has_gui_libs || install_gui_libs || true ;;
|
||||
tui) ;;
|
||||
*) if musl; then :
|
||||
elif has_gui_libs; then file="magpie-linux-$arch"
|
||||
elif has_desktop; then nolibs=1; fi ;;
|
||||
elif has_desktop; then
|
||||
if install_gui_libs; then file="magpie-linux-$arch"; else nolibs=1; fi
|
||||
fi ;;
|
||||
esac ;;
|
||||
esac
|
||||
|
||||
@@ -380,16 +427,18 @@ esac
|
||||
# the desktop app without what it needs: what installs it, said last so it
|
||||
# is what the user reads
|
||||
if [ "$file" = "magpie-linux-$arch" ] && ! has_gui_libs; then
|
||||
pkgs=$(gui_packages)
|
||||
gui_packages
|
||||
say ""
|
||||
say "the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed; it opens once they are:"
|
||||
say " ${pkgs:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}"
|
||||
if [ -n "${tried:-}" ]; then say "installing GTK 3 and WebKitGTK 4.1 didn't work (see above); the desktop app opens once they are installed:"
|
||||
else say "the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed; it opens once they are:"; fi
|
||||
say " ${hint:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}"
|
||||
elif [ -n "${nolibs:-}" ]; then
|
||||
pkgs=$(gui_packages)
|
||||
gui_packages
|
||||
say ""
|
||||
say "this computer has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed,"
|
||||
if [ -n "${tried:-}" ]; then say "this computer has a desktop, but installing GTK 3 and WebKitGTK 4.1 for the desktop app didn't work (see above),"
|
||||
else say "this computer has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed,"; fi
|
||||
say "so the terminal build was installed. For the desktop app, install them and run this again:"
|
||||
say " ${pkgs:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}"
|
||||
say " ${hint:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}"
|
||||
say " curl -fsSL $site/install.sh | sh"
|
||||
say "or install the desktop app now and the libraries after: curl -fsSL $site/install.sh | sh -s -- --gui"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user