AnyBot/docs/install.md

104 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 從原始碼建置和安裝
## 需要準備
| 平台 | 需要 |
|---|---|
| 全部 | Rust(stable,用 rustup 安裝)、git、make |
| macOS 12 以後 | Xcode Command Line Tools(`xcode-select --install`) |
| Linux | 編譯用:`build-essential pkg-config libasound2-dev`;執行用的系統套件見下面,`make deps` 會一次裝好 |
| Windows | Visual Studio Build Tools(C++)。可以 `cargo build --release`,安裝包還沒做 |
安裝 Rust:
```sh
curl --proto '=https' -sSf https://sh.rustup.rs | sh
```
## 步驟
```sh
git clone git@git.30cm.net:daniel.w/AnyBot.git
cd AnyBot
make deps # Linux:安裝系統套件(會問 sudo 密碼);Mac:檢查 Xcode 工具
make # 建置 AnyBot 和帳號伺服器(第一次約 5–15 分鐘)
make install
```
`make install` 做的事:
- **macOS**:做出 `AnyBot.app`(含圖示),放到 `~/Applications/`。沒有 Apple 開發者簽章,第一次打開請按右鍵 › 打開。想放到別的地方:`make install APPDIR=/Applications`。
- **Linux**:程式放在 `~/.local/bin/anybot`,選單項目和圖示放在 `~/.local/share/`。不需要 root。
不想安裝、只想試:`make run`。
## Linux 的系統套件
`make deps` 依發行版(apt、dnf、pacman)安裝這些,全部都是選用的,缺了 App 會說明少了什麼:
| 套件 | 用途 |
|---|---|
| libasound2、libxkbcommon-x11-0、libgl1、xdg-utils | 視窗和聲音(必要) |
| libnotify-bin | 通知 |
| libsecret-tools | 保險庫存在系統鑰匙圈 |
| espeak-ng | 唸出回覆 |
| zenity | 選檔案的視窗 |
| xclip / wl-clipboard | 貼上圖片;GNOME/KDE Wayland 上打中文 |
| ffmpeg | 影片、語音、示範錄影 |
| docker.io | Bot 自己的電腦 |
| fonts-noto-cjk | 更多中文字形(內建的粉圓體已經夠用) |
沒有螢幕的 Linux(只當手腳或大腦):只需要 `libasound2`。要讓 Bot 看得到畫面,再執行 `make hands`,會裝好虛擬螢幕(Xvfb)、視窗管理員和輔助使用服務。
## 更新
```sh
git pull
make install
```
你的 Bot、聊天和設定不在程式裡,更新不會動到它們。
## 移除
```sh
make uninstall
```
只移除程式。要連資料一起刪,刪掉資料資料夾:
| 平台 | 資料在哪 |
|---|---|
| macOS | `~/Library/Application Support/AnyBot/` |
| Linux | `~/.local/share/AnyBot/` |
| Windows | `%APPDATA%\AnyBot\` |
設成開機自動執行的(`anybot setup` 裝的)也要停掉:Linux 執行 `systemctl --user disable --now anybot`。
## 其他執行方式
| 指令 | 用途 |
|---|---|
| `make serve`(`anybot --serve`) | 不開視窗:Bot、例行任務、訊息管道一直運作,用手機操作 |
| `make setup`(`anybot setup`) | 把這台接到你的 AnyBot(大腦或手腳),見 [multi-device.md](multi-device.md) |
| `make relay-run` | 在這台跑帳號伺服器(測試用,埠 8080) |
| `make server` | 在伺服器上用 Docker 架帳號伺服器、大腦和 HTTPS |
| `ANYBOT_DATA_DIR=/某個資料夾 anybot` | 用另一份資料(測試、同一台跑兩份) |
## 常見問題
**Mac 說「無法打開,因為無法驗證開發者」**
按右鍵 › 打開,再按一次「打開」。只有第一次需要。
**Mac 上 Bot 看不到螢幕、不能點擊**
系統設定 › 隱私權與安全性:「螢幕錄製」和「輔助使用」要打開 AnyBot。App 的 設定 › 電腦 有按鈕直接開到那一頁。
**Linux 啟動時說找不到 libasound.so.2**
`sudo apt-get install libasound2`(Ubuntu 24.04 以後叫 `libasound2t64`)。
**編譯時找不到 alsa 或 pkg-config**
Linux 少了編譯用的套件:`sudo apt-get install build-essential pkg-config libasound2-dev`。
**第一次 `make` 很久**
要下載並編譯所有套件,第一次需要 5–15 分鐘,之後只會重編有改的部分。