bots-garden/mini-mepublic Fork
⑂ bc407a6
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

✨ install-mm.sh: install or upgrade mm with curl | bash (ticket 276)

curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash

- install-mm.sh, razorbill's shape: --version (latest by default, from
  the /releases/latest redirect), --prefix, --uninstall, --dry-run,
  --no-verify, -h; macOS arm64 and Linux amd64/arm64; checksum from the
  release's SHA256SUMS, Developer ID signature on macOS, the downloaded
  mm must report the version; never replaces an mm that is not mini-me;
  sudo only when needed. install.sh (build from source) untouched.
- tests/installer/test-install-mm.sh: 27 checks against fake releases
  on 127.0.0.1; run by local-ci-01-check.sh.
- README, INSTALL.LINUX.md, INSTALL.MACOS.md: the one line first, the
  manual steps kept; docs/{en,fr}/reference/cli.md: options, checks,
  errors.

Checked live against rickub.com on Linux arm64 (latest 2.1.1, 2.1.0,
uninstall; dry runs of 2.0.0 down to 1.0.0). The macOS signature path is
not tested here (no Mac): the test script covers it on an Apple Silicon
Mac.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
agent committed 2026-11-28T13:29:35+01:00 Browse files
bc407a6 parent: bdafb16
modified .tickets/issues/0276-install-mm-sh-install-or-upgrade-mm-with-curl-bash.yaml +28 -6
@@ -6,7 +6,7 @@ author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-11-28T06:06:32.000Z
9-updatedAt: 2026-11-28T06:06:32.000Z
9+updatedAt: 2026-11-28T12:29:22.000Z
1010 labels:
1111 - enhancement
1212 - kind::feature
@@ -44,34 +44,56 @@ body: |
4444 tasks:
4545 - id: 1
4646 title: install-mm.sh (options, platform, latest version, download, checksum, codesign on macOS, version check, install / uninstall / dry-run)
47- state: open
47+ state: closed
4848 priority: high
4949 author:
5050 name: k33g
5151 email: ph.charriere@gmail.com
5252 createdAt: 2026-11-28T06:06:32.000Z
53+ updatedAt: 2026-11-28T12:29:22.000Z
54+ closedAt: 2026-11-28T12:29:22.000Z
5355 - id: 2
5456 title: "Installer tests against fake releases on 127.0.0.1 (latest, --version, bad checksum, unsigned on macOS, --prefix, --uninstall, --dry-run, foreign mm refused)"
55- state: open
57+ state: closed
5658 priority: high
5759 author:
5860 name: k33g
5961 email: ph.charriere@gmail.com
6062 createdAt: 2026-11-28T06:06:32.000Z
63+ updatedAt: 2026-11-28T12:29:22.000Z
64+ closedAt: 2026-11-28T12:29:22.000Z
6165 - id: 3
6266 title: INSTALL.LINUX.md / INSTALL.MACOS.md (EN + FR) and README — the one-line install first, the manual steps kept
63- state: open
67+ state: closed
6468 priority: medium
6569 author:
6670 name: k33g
6771 email: ph.charriere@gmail.com
6872 createdAt: 2026-11-28T06:06:32.000Z
73+ updatedAt: 2026-11-28T12:29:22.000Z
74+ closedAt: 2026-11-28T12:29:22.000Z
6975 - id: 4
7076 title: "Release skill and local-ci: the installer's version needs no bump (latest by default); check the asset names it expects"
71- state: open
77+ state: closed
7278 priority: low
7379 author:
7480 name: k33g
7581 email: ph.charriere@gmail.com
7682 createdAt: 2026-11-28T06:06:32.000Z
77-comments: []
83+ updatedAt: 2026-11-28T12:29:22.000Z
84+ closedAt: 2026-11-28T12:29:22.000Z
85+comments:
86+ - id: 1
87+ author:
88+ name: k33g
89+ email: ph.charriere@gmail.com
90+ createdAt: 2026-11-28T12:29:22.000Z
91+ body: |
92+ Done on branch feature/install-mm:
93+ - install-mm.sh at the root (razorbill's shape): --version (latest by default, from the /releases/latest redirect), --prefix, --uninstall, --dry-run, --no-verify, -h; macOS arm64 and Linux amd64/arm64 (Windows refers to INSTALL.WINDOWS.md); SHA256SUMS line of the binary; on macOS codesign --verify --strict + TeamIdentifier SNLLBZP9V9 + Identifier com.bots-garden.mm; the downloaded mm must answer "mm v<version> (…"; an existing bin/mm is replaced or removed only when its --version starts with "mm <version> (go" (a release or a build from source); sudo only when the prefix is not writable; everything in main(). install.sh untouched.
94+ - tests/installer/test-install-mm.sh: 27 checks against fake releases on 127.0.0.1 (latest, --version with v, piped like curl | bash, checksum mismatch, a binary reporting another version, unpublished version, bad version, --dry-run, replacing a source build, refusing a foreign mm for install and uninstall, unknown option, --help piped, this Linux machine's own asset, --uninstall twice); 27 passed. Run by local-ci-01-check.sh.
95+ - Live against rickub.com from the sandbox (Linux arm64): latest = 2.1.1 installed, 2.1.0 over it, --uninstall; --dry-run of 2.0.0, 1.1.1, 1.0.9, 1.0.4, 1.0.0 — every release prints "mm v<version> (…)".
96+ - NOT tested here: the macOS path (codesign) — no Mac in the sandbox; the test script checks it when run on an Apple Silicon Mac.
97+ - Docs: README (one line first), INSTALL.LINUX.md and INSTALL.MACOS.md (one line first, "By hand" kept; these guides exist in English only), docs/{en,fr}/reference/cli.md (row + "install-mm.sh" options, checks, errors). The release skill notes the installer needs no version bump; asset names and SHA256SUMS format checked against local-ci-02-build.sh.
98+ - Quality run #17: PASS 0/0/0; shellcheck clean on the scripts.
99+ The one-line URL (raw/main/install-mm.sh) works once the branch is merged and pushed.
@@ -6,7 +6,7 @@ author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-11-28T06:06:32.000Z8 createdAt: 2026-11-28T06:06:32.000Z
9-updatedAt: 2026-11-28T06:06:32.000Z9+updatedAt: 2026-11-28T12:29:22.000Z
10 labels:10 labels:
11 - enhancement11 - enhancement
12 - kind::feature12 - kind::feature
@@ -44,34 +44,56 @@ body: |
44 tasks:44 tasks:
45 - id: 145 - id: 1
46 title: install-mm.sh (options, platform, latest version, download, checksum, codesign on macOS, version check, install / uninstall / dry-run)46 title: install-mm.sh (options, platform, latest version, download, checksum, codesign on macOS, version check, install / uninstall / dry-run)
47- state: open47+ state: closed
48 priority: high48 priority: high
49 author:49 author:
50 name: k33g50 name: k33g
51 email: ph.charriere@gmail.com51 email: ph.charriere@gmail.com
52 createdAt: 2026-11-28T06:06:32.000Z52 createdAt: 2026-11-28T06:06:32.000Z
53+ updatedAt: 2026-11-28T12:29:22.000Z
54+ closedAt: 2026-11-28T12:29:22.000Z
53 - id: 255 - id: 2
54 title: "Installer tests against fake releases on 127.0.0.1 (latest, --version, bad checksum, unsigned on macOS, --prefix, --uninstall, --dry-run, foreign mm refused)"56 title: "Installer tests against fake releases on 127.0.0.1 (latest, --version, bad checksum, unsigned on macOS, --prefix, --uninstall, --dry-run, foreign mm refused)"
55- state: open57+ state: closed
56 priority: high58 priority: high
57 author:59 author:
58 name: k33g60 name: k33g
59 email: ph.charriere@gmail.com61 email: ph.charriere@gmail.com
60 createdAt: 2026-11-28T06:06:32.000Z62 createdAt: 2026-11-28T06:06:32.000Z
63+ updatedAt: 2026-11-28T12:29:22.000Z
64+ closedAt: 2026-11-28T12:29:22.000Z
61 - id: 365 - id: 3
62 title: INSTALL.LINUX.md / INSTALL.MACOS.md (EN + FR) and README — the one-line install first, the manual steps kept66 title: INSTALL.LINUX.md / INSTALL.MACOS.md (EN + FR) and README — the one-line install first, the manual steps kept
63- state: open67+ state: closed
64 priority: medium68 priority: medium
65 author:69 author:
66 name: k33g70 name: k33g
67 email: ph.charriere@gmail.com71 email: ph.charriere@gmail.com
68 createdAt: 2026-11-28T06:06:32.000Z72 createdAt: 2026-11-28T06:06:32.000Z
73+ updatedAt: 2026-11-28T12:29:22.000Z
74+ closedAt: 2026-11-28T12:29:22.000Z
69 - id: 475 - id: 4
70 title: "Release skill and local-ci: the installer's version needs no bump (latest by default); check the asset names it expects"76 title: "Release skill and local-ci: the installer's version needs no bump (latest by default); check the asset names it expects"
71- state: open77+ state: closed
72 priority: low78 priority: low
73 author:79 author:
74 name: k33g80 name: k33g
75 email: ph.charriere@gmail.com81 email: ph.charriere@gmail.com
76 createdAt: 2026-11-28T06:06:32.000Z82 createdAt: 2026-11-28T06:06:32.000Z
77-comments: []83+ updatedAt: 2026-11-28T12:29:22.000Z
84+ closedAt: 2026-11-28T12:29:22.000Z
85+comments:
86+ - id: 1
87+ author:
88+ name: k33g
89+ email: ph.charriere@gmail.com
90+ createdAt: 2026-11-28T12:29:22.000Z
91+ body: |
92+ Done on branch feature/install-mm:
93+ - install-mm.sh at the root (razorbill's shape): --version (latest by default, from the /releases/latest redirect), --prefix, --uninstall, --dry-run, --no-verify, -h; macOS arm64 and Linux amd64/arm64 (Windows refers to INSTALL.WINDOWS.md); SHA256SUMS line of the binary; on macOS codesign --verify --strict + TeamIdentifier SNLLBZP9V9 + Identifier com.bots-garden.mm; the downloaded mm must answer "mm v<version> (…"; an existing bin/mm is replaced or removed only when its --version starts with "mm <version> (go" (a release or a build from source); sudo only when the prefix is not writable; everything in main(). install.sh untouched.
94+ - tests/installer/test-install-mm.sh: 27 checks against fake releases on 127.0.0.1 (latest, --version with v, piped like curl | bash, checksum mismatch, a binary reporting another version, unpublished version, bad version, --dry-run, replacing a source build, refusing a foreign mm for install and uninstall, unknown option, --help piped, this Linux machine's own asset, --uninstall twice); 27 passed. Run by local-ci-01-check.sh.
95+ - Live against rickub.com from the sandbox (Linux arm64): latest = 2.1.1 installed, 2.1.0 over it, --uninstall; --dry-run of 2.0.0, 1.1.1, 1.0.9, 1.0.4, 1.0.0 — every release prints "mm v<version> (…)".
96+ - NOT tested here: the macOS path (codesign) — no Mac in the sandbox; the test script checks it when run on an Apple Silicon Mac.
97+ - Docs: README (one line first), INSTALL.LINUX.md and INSTALL.MACOS.md (one line first, "By hand" kept; these guides exist in English only), docs/{en,fr}/reference/cli.md (row + "install-mm.sh" options, checks, errors). The release skill notes the installer needs no version bump; asset names and SHA256SUMS format checked against local-ci-02-build.sh.
98+ - Quality run #17: PASS 0/0/0; shellcheck clean on the scripts.
99+ The one-line URL (raw/main/install-mm.sh) works once the branch is merged and pushed.
modified INSTALL.LINUX.md +12 -0
@@ -1,5 +1,17 @@
11 # Install `mm` on Linux
22
3+In one line (amd64 or arm64; the latest release, checked against its `SHA256SUMS`, installed as `/usr/local/bin/mm` — `sudo` only when needed):
4+
5+```bash
6+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
7+# a given version, without sudo, into ~/.local/bin:
8+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash -s -- --version 2.1.1 --prefix ~/.local
9+```
10+
11+`--uninstall` removes it, `--dry-run` downloads and checks without installing, `--help` lists the options. The steps below do the same by hand.
12+
13+## By hand
14+
315 ```bash
416 # download the binary release in https://rickub.com/bots-garden/mini-me/releases
517 VERSION=2.1.1
@@ -1,5 +1,17 @@
1 # Install `mm` on Linux1 # Install `mm` on Linux
2 2
3+In one line (amd64 or arm64; the latest release, checked against its `SHA256SUMS`, installed as `/usr/local/bin/mm` — `sudo` only when needed):
4+
5+```bash
6+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
7+# a given version, without sudo, into ~/.local/bin:
8+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash -s -- --version 2.1.1 --prefix ~/.local
9+```
10+
11+`--uninstall` removes it, `--dry-run` downloads and checks without installing, `--help` lists the options. The steps below do the same by hand.
12+
13+## By hand
14+
3 ```bash15 ```bash
4 # download the binary release in https://rickub.com/bots-garden/mini-me/releases16 # download the binary release in https://rickub.com/bots-garden/mini-me/releases
5 VERSION=2.1.117 VERSION=2.1.1
modified INSTALL.MACOS.md +12 -0
@@ -1,5 +1,17 @@
11 # Install `mm` on macOS
22
3+In one line (Apple Silicon; the latest release, checked against its `SHA256SUMS` and its Developer ID signature, installed as `/usr/local/bin/mm` — `sudo` only when needed):
4+
5+```bash
6+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
7+# a given version, without sudo, into ~/.local/bin:
8+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash -s -- --version 2.1.1 --prefix ~/.local
9+```
10+
11+`--uninstall` removes it, `--dry-run` downloads and checks without installing, `--help` lists the options; versions before 2.1.1 are not signed and need `--no-verify`. The steps below do the same by hand.
12+
13+## By hand
14+
315 Short version:
416 ```bash
517 VERSION=2.1.1
@@ -1,5 +1,17 @@
1 # Install `mm` on macOS1 # Install `mm` on macOS
2 2
3+In one line (Apple Silicon; the latest release, checked against its `SHA256SUMS` and its Developer ID signature, installed as `/usr/local/bin/mm` — `sudo` only when needed):
4+
5+```bash
6+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
7+# a given version, without sudo, into ~/.local/bin:
8+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash -s -- --version 2.1.1 --prefix ~/.local
9+```
10+
11+`--uninstall` removes it, `--dry-run` downloads and checks without installing, `--help` lists the options; versions before 2.1.1 are not signed and need `--no-verify`. The steps below do the same by hand.
12+
13+## By hand
14+
3 Short version:15 Short version:
4 ```bash16 ```bash
5 VERSION=2.1.117 VERSION=2.1.1
modified README.md +10 -2
@@ -20,7 +20,15 @@ What makes Mini Me a bit special is that it was designed from the start to be us
2020
2121 ## Install
2222
23-You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
23+On macOS (Apple Silicon) or Linux (amd64, arm64), install the latest release in one line:
24+
25+```bash
26+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
27+```
28+
29+It downloads the binary, checks it against the release's `SHA256SUMS` (and on macOS its Developer ID signature), and installs it as `/usr/local/bin/mm` — `sudo` only when needed. `bash -s -- --version 2.1.1` picks a version, `--prefix ~/.local` installs as `~/.local/bin/mm` without `sudo`, `--uninstall` removes it, `--help` lists the rest. It never replaces an `mm` that is not mini-me, and touches no agent file or session.
30+
31+To build from source instead, you need Go 1.27+. Either way, you need a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
2432
2533 ```bash
2634 git clone https://git.rickub.com/bots-garden/mini-me.git
@@ -32,7 +40,7 @@ mm --about # what it is, in one screen
3240 ```
3341 > `install.sh` works only on macOS and Linux
3442
35-Or download a binary from the [releases page](https://rickub.com/bots-garden/mini-me/releases) and put it on your `PATH` — step by step for [macOS](INSTALL.MACOS.md), [Linux](INSTALL.LINUX.md) and [Windows](INSTALL.WINDOWS.md). From v1.0.5, the macOS binary is signed with a Developer ID and notarized by Apple: downloaded with a browser, it runs without a quarantine step.
43+Or download a binary yourself from the [releases page](https://rickub.com/bots-garden/mini-me/releases) and put it on your `PATH` — step by step for [macOS](INSTALL.MACOS.md), [Linux](INSTALL.LINUX.md) and [Windows](INSTALL.WINDOWS.md). From v1.0.5, the macOS binary is signed with a Developer ID and notarized by Apple: downloaded with a browser, it runs without a quarantine step.
3644
3745 Then pick a configuration file. Copy one to `agent.yaml` in your project and adjust the `model:` and `system:` keys to taste:
3846
@@ -20,7 +20,15 @@ What makes Mini Me a bit special is that it was designed from the start to be us
20 20
21 ## Install21 ## Install
22 22
23-You need Go 1.27+ and a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).23+On macOS (Apple Silicon) or Linux (amd64, arm64), install the latest release in one line:
24+
25+```bash
26+curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
27+```
28+
29+It downloads the binary, checks it against the release's `SHA256SUMS` (and on macOS its Developer ID signature), and installs it as `/usr/local/bin/mm` — `sudo` only when needed. `bash -s -- --version 2.1.1` picks a version, `--prefix ~/.local` installs as `~/.local/bin/mm` without `sudo`, `--uninstall` removes it, `--help` lists the rest. It never replaces an `mm` that is not mini-me, and touches no agent file or session.
30+
31+To build from source instead, you need Go 1.27+. Either way, you need a model server that can emit tool calls, through its OpenAI-compatible API: Docker Model Runner (`provider: dmr`, the default), llama.cpp's `llama-server` (`llamacpp`), [llmman](https://github.com/llmmanorg/llmman) (`llmman`), Ollama (`ollama`) or [Kronk](https://www.kronkai.com), the Go inference server of Ardan Labs (`kronk`), [MLX-Serve](https://github.com/ddalcu/mlx-serve) on Apple Silicon (`mlxserve`), or razorbill (`rzb`, MLX on the Mac: `razorbill`) — or any other OpenAI-compatible server or service with `provider: openai` (the OpenAI API by default, Mistral AI, Cerebras, Hugging Face, vLLM, LM Studio…: `mm init` asks its endpoint and the variable that holds its API key).
24 32
25 ```bash33 ```bash
26 git clone https://git.rickub.com/bots-garden/mini-me.git34 git clone https://git.rickub.com/bots-garden/mini-me.git
@@ -32,7 +40,7 @@ mm --about # what it is, in one screen
32 ```40 ```
33 > `install.sh` works only on macOS and Linux41 > `install.sh` works only on macOS and Linux
34 42
35-Or download a binary from the [releases page](https://rickub.com/bots-garden/mini-me/releases) and put it on your `PATH` — step by step for [macOS](INSTALL.MACOS.md), [Linux](INSTALL.LINUX.md) and [Windows](INSTALL.WINDOWS.md). From v1.0.5, the macOS binary is signed with a Developer ID and notarized by Apple: downloaded with a browser, it runs without a quarantine step.43+Or download a binary yourself from the [releases page](https://rickub.com/bots-garden/mini-me/releases) and put it on your `PATH` — step by step for [macOS](INSTALL.MACOS.md), [Linux](INSTALL.LINUX.md) and [Windows](INSTALL.WINDOWS.md). From v1.0.5, the macOS binary is signed with a Developer ID and notarized by Apple: downloaded with a browser, it runs without a quarantine step.
36 44
37 Then pick a configuration file. Copy one to `agent.yaml` in your project and adjust the `model:` and `system:` keys to taste:45 Then pick a configuration file. Copy one to `agent.yaml` in your project and adjust the `model:` and `system:` keys to taste:
38 46
modified docs/en/reference/cli.md +31 -0
@@ -361,4 +361,35 @@ Sends one message to an A2A agent (another `mm a2a`, or any agent speaking A2A o
361361 |---------|--------|
362362 | `go build -o mm .` | Builds the binary in the current directory. |
363363 | `./install.sh` | Builds `mm` and copies it to `/usr/local/bin`, with `sudo` when the directory is not writable. |
364+| `curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh \| bash` | Installs or upgrades `mm` from a published release (macOS arm64, Linux amd64 / arm64), without building it. Options below. |
365+| `tests/installer/test-install-mm.sh` | Runs the installer's tests against fake releases served on `127.0.0.1` (bash, curl, python3). |
364366 | `go test ./...` | Runs the unit tests. |
367+
368+### install-mm.sh
369+
370+Options, after `bash -s --` when the script is piped from `curl`:
371+
372+| Option | Effect |
373+|--------|--------|
374+| `--version X.Y.Z` | Installs this version (a leading `v` is accepted). Default: the latest release, read from the `/releases/latest` redirect. |
375+| `--prefix DIR` | Installs the binary as `DIR/bin/mm`. Default: `/usr/local`. `sudo` is used only when `DIR/bin` is not writable. |
376+| `--uninstall` | Removes `DIR/bin/mm`. |
377+| `--dry-run` | Downloads and checks everything, installs (or removes) nothing. |
378+| `--no-verify` | Skips the signature check on macOS. Releases before 2.1.1 are not signed. |
379+| `-h`, `--help` | Prints the usage. |
380+
381+What it checks before installing: the platform (`darwin-arm64`, `linux-amd64`, `linux-arm64`; on Windows it refers to `INSTALL.WINDOWS.md`), the binary's line in the release's `SHA256SUMS`, on macOS the signature (`codesign --verify --strict`, `TeamIdentifier=SNLLBZP9V9`, `Identifier=com.bots-garden.mm`), and that the downloaded binary answers `mm --version` with `mm v<version> (…)`. An existing `DIR/bin/mm` is replaced or removed only when its `--version` starts with `mm <version> (go`: a release or a build from source.
382+
383+Errors (stderr, `install-mm: …`, exit 1):
384+
385+| Message | Cause |
386+|---------|-------|
387+| `not a version: …` | `--version` is not `X.Y.Z`. |
388+| `cannot download …/mm-<version>-<os>-<arch> (is <version> published?)` | No such release or asset, or the site is unreachable. |
389+| `SHA256SUMS has no line for …` / `checksum mismatch for …` | The download does not match the release's checksums. |
390+| `mm is not validly signed …` / `mm is not signed by the bots-garden team …` / `mm does not carry the identifier …` | macOS: the signature check failed. |
391+| `the downloaded mm reports "…", expected mm v<version>` | The binary is not the version asked for. |
392+| `… exists and is not mini-me …: remove it first` | `DIR/bin/mm` is another program. |
393+| `no mm binary for …` / `on Windows, follow INSTALL.WINDOWS.md …` | Unsupported platform. |
394+
395+Environment, for the installer's tests: `MM_INSTALL_BASE_URL` replaces the release site; `MM_INSTALL_ANY_PLATFORM=1` installs the `linux-amd64` binary on any machine.
@@ -361,4 +361,35 @@ Sends one message to an A2A agent (another `mm a2a`, or any agent speaking A2A o
361 |---------|--------|361 |---------|--------|
362 | `go build -o mm .` | Builds the binary in the current directory. |362 | `go build -o mm .` | Builds the binary in the current directory. |
363 | `./install.sh` | Builds `mm` and copies it to `/usr/local/bin`, with `sudo` when the directory is not writable. |363 | `./install.sh` | Builds `mm` and copies it to `/usr/local/bin`, with `sudo` when the directory is not writable. |
364+| `curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh \| bash` | Installs or upgrades `mm` from a published release (macOS arm64, Linux amd64 / arm64), without building it. Options below. |
365+| `tests/installer/test-install-mm.sh` | Runs the installer's tests against fake releases served on `127.0.0.1` (bash, curl, python3). |
364 | `go test ./...` | Runs the unit tests. |366 | `go test ./...` | Runs the unit tests. |
367+
368+### install-mm.sh
369+
370+Options, after `bash -s --` when the script is piped from `curl`:
371+
372+| Option | Effect |
373+|--------|--------|
374+| `--version X.Y.Z` | Installs this version (a leading `v` is accepted). Default: the latest release, read from the `/releases/latest` redirect. |
375+| `--prefix DIR` | Installs the binary as `DIR/bin/mm`. Default: `/usr/local`. `sudo` is used only when `DIR/bin` is not writable. |
376+| `--uninstall` | Removes `DIR/bin/mm`. |
377+| `--dry-run` | Downloads and checks everything, installs (or removes) nothing. |
378+| `--no-verify` | Skips the signature check on macOS. Releases before 2.1.1 are not signed. |
379+| `-h`, `--help` | Prints the usage. |
380+
381+What it checks before installing: the platform (`darwin-arm64`, `linux-amd64`, `linux-arm64`; on Windows it refers to `INSTALL.WINDOWS.md`), the binary's line in the release's `SHA256SUMS`, on macOS the signature (`codesign --verify --strict`, `TeamIdentifier=SNLLBZP9V9`, `Identifier=com.bots-garden.mm`), and that the downloaded binary answers `mm --version` with `mm v<version> (…)`. An existing `DIR/bin/mm` is replaced or removed only when its `--version` starts with `mm <version> (go`: a release or a build from source.
382+
383+Errors (stderr, `install-mm: …`, exit 1):
384+
385+| Message | Cause |
386+|---------|-------|
387+| `not a version: …` | `--version` is not `X.Y.Z`. |
388+| `cannot download …/mm-<version>-<os>-<arch> (is <version> published?)` | No such release or asset, or the site is unreachable. |
389+| `SHA256SUMS has no line for …` / `checksum mismatch for …` | The download does not match the release's checksums. |
390+| `mm is not validly signed …` / `mm is not signed by the bots-garden team …` / `mm does not carry the identifier …` | macOS: the signature check failed. |
391+| `the downloaded mm reports "…", expected mm v<version>` | The binary is not the version asked for. |
392+| `… exists and is not mini-me …: remove it first` | `DIR/bin/mm` is another program. |
393+| `no mm binary for …` / `on Windows, follow INSTALL.WINDOWS.md …` | Unsupported platform. |
394+
395+Environment, for the installer's tests: `MM_INSTALL_BASE_URL` replaces the release site; `MM_INSTALL_ANY_PLATFORM=1` installs the `linux-amd64` binary on any machine.
modified docs/fr/reference/cli.md +31 -0
@@ -361,4 +361,35 @@ Envoie un message à un agent A2A (un autre `mm a2a`, ou tout agent qui parle A2
361361 |----------|-------|
362362 | `go build -o mm .` | Compile le binaire dans le répertoire courant. |
363363 | `./install.sh` | Compile `mm` et le copie dans `/usr/local/bin`, avec `sudo` si le répertoire n'est pas accessible en écriture. |
364+| `curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh \| bash` | Installe ou met à jour `mm` depuis une release publiée (macOS arm64, Linux amd64 / arm64), sans le compiler. Options plus bas. |
365+| `tests/installer/test-install-mm.sh` | Lance les tests de l'installeur contre de fausses releases servies sur `127.0.0.1` (bash, curl, python3). |
364366 | `go test ./...` | Lance les tests unitaires. |
367+
368+### install-mm.sh
369+
370+Options, après `bash -s --` quand le script arrive de `curl` par un tube :
371+
372+| Option | Effet |
373+|--------|-------|
374+| `--version X.Y.Z` | Installe cette version (un `v` en tête est accepté). Par défaut : la dernière release, lue dans la redirection de `/releases/latest`. |
375+| `--prefix DIR` | Installe le binaire sous `DIR/bin/mm`. Par défaut : `/usr/local`. `sudo` n'est utilisé que si `DIR/bin` n'est pas accessible en écriture. |
376+| `--uninstall` | Supprime `DIR/bin/mm`. |
377+| `--dry-run` | Télécharge et vérifie tout, n'installe (ni ne supprime) rien. |
378+| `--no-verify` | Ne vérifie pas la signature sur macOS. Les releases antérieures à 2.1.1 ne sont pas signées. |
379+| `-h`, `--help` | Affiche l'aide. |
380+
381+Ce qu'il vérifie avant d'installer : la plateforme (`darwin-arm64`, `linux-amd64`, `linux-arm64` ; sur Windows il renvoie à `INSTALL.WINDOWS.md`), la ligne du binaire dans le `SHA256SUMS` de la release, sur macOS la signature (`codesign --verify --strict`, `TeamIdentifier=SNLLBZP9V9`, `Identifier=com.bots-garden.mm`), et que le binaire téléchargé répond à `mm --version` par `mm v<version> (…)`. Un `DIR/bin/mm` existant n'est remplacé ou supprimé que si son `--version` commence par `mm <version> (go` : une release ou une compilation depuis les sources.
382+
383+Erreurs (sur stderr, `install-mm: …`, code de sortie 1) :
384+
385+| Message | Cause |
386+|---------|-------|
387+| `not a version: …` | `--version` n'est pas de la forme `X.Y.Z`. |
388+| `cannot download …/mm-<version>-<os>-<arch> (is <version> published?)` | Pas de telle release ou de tel fichier, ou site injoignable. |
389+| `SHA256SUMS has no line for …` / `checksum mismatch for …` | Le téléchargement ne correspond pas aux sommes de contrôle de la release. |
390+| `mm is not validly signed …` / `mm is not signed by the bots-garden team …` / `mm does not carry the identifier …` | macOS : la vérification de la signature a échoué. |
391+| `the downloaded mm reports "…", expected mm v<version>` | Le binaire n'est pas la version demandée. |
392+| `… exists and is not mini-me …: remove it first` | `DIR/bin/mm` est un autre programme. |
393+| `no mm binary for …` / `on Windows, follow INSTALL.WINDOWS.md …` | Plateforme non prise en charge. |
394+
395+Environnement, pour les tests de l'installeur : `MM_INSTALL_BASE_URL` remplace le site des releases ; `MM_INSTALL_ANY_PLATFORM=1` installe le binaire `linux-amd64` sur n'importe quelle machine.
@@ -361,4 +361,35 @@ Envoie un message à un agent A2A (un autre `mm a2a`, ou tout agent qui parle A2
361 |----------|-------|361 |----------|-------|
362 | `go build -o mm .` | Compile le binaire dans le répertoire courant. |362 | `go build -o mm .` | Compile le binaire dans le répertoire courant. |
363 | `./install.sh` | Compile `mm` et le copie dans `/usr/local/bin`, avec `sudo` si le répertoire n'est pas accessible en écriture. |363 | `./install.sh` | Compile `mm` et le copie dans `/usr/local/bin`, avec `sudo` si le répertoire n'est pas accessible en écriture. |
364+| `curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh \| bash` | Installe ou met à jour `mm` depuis une release publiée (macOS arm64, Linux amd64 / arm64), sans le compiler. Options plus bas. |
365+| `tests/installer/test-install-mm.sh` | Lance les tests de l'installeur contre de fausses releases servies sur `127.0.0.1` (bash, curl, python3). |
364 | `go test ./...` | Lance les tests unitaires. |366 | `go test ./...` | Lance les tests unitaires. |
367+
368+### install-mm.sh
369+
370+Options, après `bash -s --` quand le script arrive de `curl` par un tube :
371+
372+| Option | Effet |
373+|--------|-------|
374+| `--version X.Y.Z` | Installe cette version (un `v` en tête est accepté). Par défaut : la dernière release, lue dans la redirection de `/releases/latest`. |
375+| `--prefix DIR` | Installe le binaire sous `DIR/bin/mm`. Par défaut : `/usr/local`. `sudo` n'est utilisé que si `DIR/bin` n'est pas accessible en écriture. |
376+| `--uninstall` | Supprime `DIR/bin/mm`. |
377+| `--dry-run` | Télécharge et vérifie tout, n'installe (ni ne supprime) rien. |
378+| `--no-verify` | Ne vérifie pas la signature sur macOS. Les releases antérieures à 2.1.1 ne sont pas signées. |
379+| `-h`, `--help` | Affiche l'aide. |
380+
381+Ce qu'il vérifie avant d'installer : la plateforme (`darwin-arm64`, `linux-amd64`, `linux-arm64` ; sur Windows il renvoie à `INSTALL.WINDOWS.md`), la ligne du binaire dans le `SHA256SUMS` de la release, sur macOS la signature (`codesign --verify --strict`, `TeamIdentifier=SNLLBZP9V9`, `Identifier=com.bots-garden.mm`), et que le binaire téléchargé répond à `mm --version` par `mm v<version> (…)`. Un `DIR/bin/mm` existant n'est remplacé ou supprimé que si son `--version` commence par `mm <version> (go` : une release ou une compilation depuis les sources.
382+
383+Erreurs (sur stderr, `install-mm: …`, code de sortie 1) :
384+
385+| Message | Cause |
386+|---------|-------|
387+| `not a version: …` | `--version` n'est pas de la forme `X.Y.Z`. |
388+| `cannot download …/mm-<version>-<os>-<arch> (is <version> published?)` | Pas de telle release ou de tel fichier, ou site injoignable. |
389+| `SHA256SUMS has no line for …` / `checksum mismatch for …` | Le téléchargement ne correspond pas aux sommes de contrôle de la release. |
390+| `mm is not validly signed …` / `mm is not signed by the bots-garden team …` / `mm does not carry the identifier …` | macOS : la vérification de la signature a échoué. |
391+| `the downloaded mm reports "…", expected mm v<version>` | Le binaire n'est pas la version demandée. |
392+| `… exists and is not mini-me …: remove it first` | `DIR/bin/mm` est un autre programme. |
393+| `no mm binary for …` / `on Windows, follow INSTALL.WINDOWS.md …` | Plateforme non prise en charge. |
394+
395+Environnement, pour les tests de l'installeur : `MM_INSTALL_BASE_URL` remplace le site des releases ; `MM_INSTALL_ANY_PLATFORM=1` installe le binaire `linux-amd64` sur n'importe quelle machine.
added install-mm.sh +245 -0
new file mode 100755
@@ -0,0 +1,245 @@
1+#!/usr/bin/env bash
2+# install-mm.sh — install or upgrade mini-me (mm) from its published release. Ticket #276.
3+#
4+# curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
5+# curl -fsSL …/install-mm.sh | bash -s -- --version 2.2.0 --prefix ~/.local
6+#
7+# Options:
8+# --version X.Y.Z install this version (default: the latest release)
9+# --prefix DIR install the binary as DIR/bin/mm (default /usr/local)
10+# --uninstall remove DIR/bin/mm, when it is mini-me
11+# --dry-run download and check everything, install nothing
12+# --no-verify skip the signature check on macOS (binaries before 2.1.1 are not signed)
13+# -h, --help this help
14+#
15+# What it does: finds the version, downloads mm-<version>-<os>-<arch> and SHA256SUMS into a
16+# temporary folder, checks the checksum, on macOS checks that the binary is signed by the
17+# bots-garden Developer ID, runs the downloaded `mm --version`, then installs it as
18+# <prefix>/bin/mm. sudo is used only when the prefix is not writable. An existing <prefix>/bin/mm
19+# is replaced only when it is mini-me (its --version says so). Agent files, sessions and
20+# ~/.cache/mm are never touched. Platforms: macOS on Apple Silicon, Linux amd64 / arm64; on
21+# Windows, follow INSTALL.WINDOWS.md. The existing install.sh (build from source) is another tool.
22+#
23+# Everything runs from main(), called on the last line: a download cut halfway runs nothing.
24+set -euo pipefail
25+
26+BASE_URL="${MM_INSTALL_BASE_URL:-https://rickub.com/bots-garden/mini-me}"
27+# The team that signs mm (Developer ID Application: … (SNLLBZP9V9)), see release/*/macos-signature.txt.
28+TEAM_ID="SNLLBZP9V9"
29+IDENTIFIER="com.bots-garden.mm"
30+
31+say() { printf '%s\n' "$*"; }
32+fail() { printf 'install-mm: %s\n' "$*" >&2; exit 1; }
33+
34+# The help is a heredoc, not read from this file: under `curl | bash` there is no file.
35+usage() {
36+ cat <<'HELP'
37+install-mm.sh — install or upgrade mini-me (mm) from its published release.
38+
39+ curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
40+ curl -fsSL …/install-mm.sh | bash -s -- --version 2.2.0 --prefix ~/.local
41+
42+ --version X.Y.Z install this version (default: the latest release)
43+ --prefix DIR install the binary as DIR/bin/mm (default /usr/local)
44+ --uninstall remove DIR/bin/mm, when it is mini-me
45+ --dry-run download and check everything, install nothing
46+ --no-verify skip the signature check on macOS (binaries before 2.1.1 are not signed)
47+ -h, --help this help
48+
49+macOS on Apple Silicon, Linux amd64 / arm64. On Windows, follow INSTALL.WINDOWS.md.
50+HELP
51+}
52+
53+# platform prints the <os>-<arch> part of the asset names (local-ci-02-build.sh), or refuses.
54+# MM_INSTALL_ANY_PLATFORM=1 makes any machine install the linux-amd64 binary — for the
55+# installer's own tests only, which run a fake mm.
56+platform() {
57+ if [[ "${MM_INSTALL_ANY_PLATFORM:-}" == 1 ]]; then
58+ printf 'linux-amd64\n'
59+ return 0
60+ fi
61+ local os arch
62+ case "$(uname -s)" in
63+ Darwin) os=darwin ;;
64+ Linux) os=linux ;;
65+ MINGW* | MSYS* | CYGWIN*) fail "on Windows, follow INSTALL.WINDOWS.md (this script installs on macOS and Linux)" ;;
66+ *) fail "no mm binary for $(uname -s): macOS arm64, Linux amd64 / arm64 (or build it: install.sh)" ;;
67+ esac
68+ case "$(uname -m)" in
69+ x86_64 | amd64) arch=amd64 ;;
70+ aarch64 | arm64) arch=arm64 ;;
71+ *) fail "no mm binary for $(uname -m): macOS arm64, Linux amd64 / arm64 (or build it: install.sh)" ;;
72+ esac
73+ if [[ "${os}" == darwin && "${arch}" != arm64 ]]; then
74+ fail "no mm binary for Intel Macs: macOS arm64, Linux amd64 / arm64 (or build it: install.sh)"
75+ fi
76+ printf '%s-%s\n' "${os}" "${arch}"
77+}
78+
79+# latest_version prints the version of the latest release, read from the /releases/latest
80+# redirect (the API needs a token; the redirect does not).
81+latest_version() {
82+ local location
83+ location="$(curl -fsSI -m 30 "${BASE_URL}/releases/latest" | tr -d '\r' \
84+ | awk 'tolower($1) == "location:" {print $2}' | tail -1)" \
85+ || fail "cannot reach ${BASE_URL}/releases/latest"
86+ [[ -n "${location}" ]] || fail "no release found at ${BASE_URL}/releases/latest"
87+ local tag="${location##*/}"
88+ printf '%s\n' "${tag#v}"
89+}
90+
91+checksum() {
92+ if command -v shasum >/dev/null 2>&1; then shasum -a 256 "$@"; else sha256sum "$@"; fi
93+}
94+
95+# is_mm is true when the binary at $1 is mini-me: `mm --version` prints
96+# "mm <version> (<go version>, <os>/<arch>)", a release ("mm v2.2.0 (go1.27.4, darwin/arm64)")
97+# as well as a build from source ("mm f062af9+dirty (…)").
98+is_mm() {
99+ local out
100+ out="$("$1" --version 2>/dev/null)" || return 1
101+ [[ "${out}" =~ ^mm\ [^\ ]+\ \(go ]]
102+}
103+
104+# check_existing refuses to replace or remove a <prefix>/bin/mm that is not mini-me.
105+check_existing() {
106+ if [[ -e "${TARGET}" ]] && ! is_mm "${TARGET}"; then
107+ fail "${TARGET} exists and is not mini-me (its --version does not say so): remove it first"
108+ fi
109+}
110+
111+# writable_as_user is true when the current user can create or replace <prefix>/bin/mm.
112+writable_as_user() {
113+ local path
114+ for path in "${PREFIX}/bin" "${TARGET}"; do
115+ while [[ ! -e "${path}" ]]; do path="$(dirname "${path}")"; done
116+ [[ -w "${path}" ]] || return 1
117+ done
118+}
119+
120+as_owner() {
121+ if writable_as_user; then "$@"; else sudo "$@"; fi
122+}
123+
124+# verify_signature checks that mm is validly signed, by our team, with our identifier. Whole
125+# outputs first: with pipefail, `codesign | grep -q` can fail on SIGPIPE.
126+verify_signature() {
127+ local binary=$1
128+ command -v codesign >/dev/null 2>&1 || fail "codesign not found: cannot check the signature"
129+ codesign --verify --strict "${binary}" 2>/dev/null \
130+ || fail "mm is not validly signed (binaries before 2.1.1 are not: pass --no-verify)"
131+ local details
132+ details="$(codesign -dv --verbose=4 "${binary}" 2>&1)"
133+ grep -qx "TeamIdentifier=${TEAM_ID}" <<<"${details}" \
134+ || fail "mm is not signed by the bots-garden team (${TEAM_ID})"
135+ grep -qx "Identifier=${IDENTIFIER}" <<<"${details}" \
136+ || fail "mm does not carry the identifier ${IDENTIFIER}"
137+ say "✅ signed by the bots-garden Developer ID (${TEAM_ID})"
138+}
139+
140+# Not named `uninstall` / `install`: `install` would shadow /usr/bin/install, used below.
141+remove_mm() {
142+ check_existing
143+ if [[ ! -e "${TARGET}" ]]; then
144+ say "nothing to remove under ${PREFIX}"
145+ return 0
146+ fi
147+ if [[ "${DRY_RUN}" == true ]]; then
148+ say "would remove ${TARGET}"
149+ return 0
150+ fi
151+ as_owner rm -f "${TARGET}"
152+ say "removed ${TARGET} (agent files, sessions and ~/.cache/mm kept)"
153+}
154+
155+# download fetches the binary and SHA256SUMS into WORK and checks the binary's checksum.
156+download() {
157+ local name=$1 version=$2
158+ local url="${BASE_URL}/releases/download/v${version}"
159+ curl -fsSL -m 600 -o "${WORK}/${name}" "${url}/${name}" \
160+ || fail "cannot download ${url}/${name} (is ${version} published?)"
161+ curl -fsSL -m 60 -o "${WORK}/SHA256SUMS" "${url}/SHA256SUMS" \
162+ || fail "cannot download ${url}/SHA256SUMS"
163+ # Only the binary's line: the release lists every platform.
164+ grep -E "^[0-9a-f]{64} ${name}$" "${WORK}/SHA256SUMS" >"${WORK}/expected" \
165+ || fail "SHA256SUMS has no line for ${name}"
166+ (cd "${WORK}" && checksum -c expected >/dev/null 2>&1) || fail "checksum mismatch for ${name}"
167+ say "✅ checksum"
168+}
169+
170+install_mm() {
171+ local version="${VERSION}"
172+ if [[ -z "${version}" ]]; then
173+ version="$(latest_version)"
174+ fi
175+ version="${version#v}"
176+ [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || fail "not a version: ${version}"
177+ check_existing
178+
179+ local name
180+ name="mm-${version}-$(platform)"
181+ say "==> mini-me ${version} (${name})"
182+
183+ WORK="$(mktemp -d)"
184+ trap 'rm -rf "${WORK}"' EXIT
185+ download "${name}" "${version}"
186+ local binary="${WORK}/${name}"
187+ chmod 755 "${binary}"
188+
189+ if [[ "${name}" == *-darwin-* ]]; then
190+ if [[ "${NO_VERIFY}" == true ]]; then
191+ say "⚠️ signature not checked (--no-verify)"
192+ else
193+ verify_signature "${binary}"
194+ fi
195+ fi
196+
197+ # A release prints "mm v<version> (…)": the version stamped at build time is the tag.
198+ local reported
199+ reported="$("${binary}" --version 2>/dev/null)" || fail "the downloaded mm does not start"
200+ [[ "${reported}" == "mm v${version} ("* ]] || fail "the downloaded mm reports \"${reported}\", expected mm v${version}"
201+ say "✅ ${reported}"
202+
203+ if [[ "${DRY_RUN}" == true ]]; then
204+ say "dry run: would install ${TARGET}"
205+ return 0
206+ fi
207+
208+ as_owner mkdir -p "${PREFIX}/bin"
209+ as_owner install -m 755 "${binary}" "${TARGET}"
210+ say "✅ installed ${TARGET}"
211+
212+ if [[ "$(command -v mm || true)" != "${TARGET}" ]]; then
213+ say "note: \`mm\` does not resolve to ${TARGET}: put ${PREFIX}/bin first in PATH"
214+ fi
215+ say "next: mm init (writes an agent.yaml), then mm"
216+}
217+
218+main() {
219+ VERSION=""
220+ PREFIX="/usr/local"
221+ ACTION=install
222+ DRY_RUN=false
223+ NO_VERIFY=false
224+ while [[ $# -gt 0 ]]; do
225+ case "$1" in
226+ --version) VERSION="${2:?--version needs a version}"; shift 2 ;;
227+ --prefix) PREFIX="${2:?--prefix needs a directory}"; shift 2 ;;
228+ --uninstall) ACTION=uninstall; shift ;;
229+ --dry-run) DRY_RUN=true; shift ;;
230+ --no-verify) NO_VERIFY=true; shift ;;
231+ -h | --help) usage; exit 0 ;;
232+ *) fail "unknown option $1 (see --help)" ;;
233+ esac
234+ done
235+ PREFIX="${PREFIX%/}"
236+ TARGET="${PREFIX}/bin/mm"
237+
238+ if [[ "${ACTION}" == uninstall ]]; then
239+ remove_mm
240+ else
241+ install_mm
242+ fi
243+}
244+
245+main "$@"
new file mode 100755
@@ -0,0 +1,245 @@
1+#!/usr/bin/env bash
2+# install-mm.sh — install or upgrade mini-me (mm) from its published release. Ticket #276.
3+#
4+# curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
5+# curl -fsSL …/install-mm.sh | bash -s -- --version 2.2.0 --prefix ~/.local
6+#
7+# Options:
8+# --version X.Y.Z install this version (default: the latest release)
9+# --prefix DIR install the binary as DIR/bin/mm (default /usr/local)
10+# --uninstall remove DIR/bin/mm, when it is mini-me
11+# --dry-run download and check everything, install nothing
12+# --no-verify skip the signature check on macOS (binaries before 2.1.1 are not signed)
13+# -h, --help this help
14+#
15+# What it does: finds the version, downloads mm-<version>-<os>-<arch> and SHA256SUMS into a
16+# temporary folder, checks the checksum, on macOS checks that the binary is signed by the
17+# bots-garden Developer ID, runs the downloaded `mm --version`, then installs it as
18+# <prefix>/bin/mm. sudo is used only when the prefix is not writable. An existing <prefix>/bin/mm
19+# is replaced only when it is mini-me (its --version says so). Agent files, sessions and
20+# ~/.cache/mm are never touched. Platforms: macOS on Apple Silicon, Linux amd64 / arm64; on
21+# Windows, follow INSTALL.WINDOWS.md. The existing install.sh (build from source) is another tool.
22+#
23+# Everything runs from main(), called on the last line: a download cut halfway runs nothing.
24+set -euo pipefail
25+
26+BASE_URL="${MM_INSTALL_BASE_URL:-https://rickub.com/bots-garden/mini-me}"
27+# The team that signs mm (Developer ID Application: … (SNLLBZP9V9)), see release/*/macos-signature.txt.
28+TEAM_ID="SNLLBZP9V9"
29+IDENTIFIER="com.bots-garden.mm"
30+
31+say() { printf '%s\n' "$*"; }
32+fail() { printf 'install-mm: %s\n' "$*" >&2; exit 1; }
33+
34+# The help is a heredoc, not read from this file: under `curl | bash` there is no file.
35+usage() {
36+ cat <<'HELP'
37+install-mm.sh — install or upgrade mini-me (mm) from its published release.
38+
39+ curl -fsSL https://rickub.com/bots-garden/mini-me/raw/main/install-mm.sh | bash
40+ curl -fsSL …/install-mm.sh | bash -s -- --version 2.2.0 --prefix ~/.local
41+
42+ --version X.Y.Z install this version (default: the latest release)
43+ --prefix DIR install the binary as DIR/bin/mm (default /usr/local)
44+ --uninstall remove DIR/bin/mm, when it is mini-me
45+ --dry-run download and check everything, install nothing
46+ --no-verify skip the signature check on macOS (binaries before 2.1.1 are not signed)
47+ -h, --help this help
48+
49+macOS on Apple Silicon, Linux amd64 / arm64. On Windows, follow INSTALL.WINDOWS.md.
50+HELP
51+}
52+
53+# platform prints the <os>-<arch> part of the asset names (local-ci-02-build.sh), or refuses.
54+# MM_INSTALL_ANY_PLATFORM=1 makes any machine install the linux-amd64 binary — for the
55+# installer's own tests only, which run a fake mm.
56+platform() {
57+ if [[ "${MM_INSTALL_ANY_PLATFORM:-}" == 1 ]]; then
58+ printf 'linux-amd64\n'
59+ return 0
60+ fi
61+ local os arch
62+ case "$(uname -s)" in
63+ Darwin) os=darwin ;;
64+ Linux) os=linux ;;
65+ MINGW* | MSYS* | CYGWIN*) fail "on Windows, follow INSTALL.WINDOWS.md (this script installs on macOS and Linux)" ;;
66+ *) fail "no mm binary for $(uname -s): macOS arm64, Linux amd64 / arm64 (or build it: install.sh)" ;;
67+ esac
68+ case "$(uname -m)" in
69+ x86_64 | amd64) arch=amd64 ;;
70+ aarch64 | arm64) arch=arm64 ;;
71+ *) fail "no mm binary for $(uname -m): macOS arm64, Linux amd64 / arm64 (or build it: install.sh)" ;;
72+ esac
73+ if [[ "${os}" == darwin && "${arch}" != arm64 ]]; then
74+ fail "no mm binary for Intel Macs: macOS arm64, Linux amd64 / arm64 (or build it: install.sh)"
75+ fi
76+ printf '%s-%s\n' "${os}" "${arch}"
77+}
78+
79+# latest_version prints the version of the latest release, read from the /releases/latest
80+# redirect (the API needs a token; the redirect does not).
81+latest_version() {
82+ local location
83+ location="$(curl -fsSI -m 30 "${BASE_URL}/releases/latest" | tr -d '\r' \
84+ | awk 'tolower($1) == "location:" {print $2}' | tail -1)" \
85+ || fail "cannot reach ${BASE_URL}/releases/latest"
86+ [[ -n "${location}" ]] || fail "no release found at ${BASE_URL}/releases/latest"
87+ local tag="${location##*/}"
88+ printf '%s\n' "${tag#v}"
89+}
90+
91+checksum() {
92+ if command -v shasum >/dev/null 2>&1; then shasum -a 256 "$@"; else sha256sum "$@"; fi
93+}
94+
95+# is_mm is true when the binary at $1 is mini-me: `mm --version` prints
96+# "mm <version> (<go version>, <os>/<arch>)", a release ("mm v2.2.0 (go1.27.4, darwin/arm64)")
97+# as well as a build from source ("mm f062af9+dirty (…)").
98+is_mm() {
99+ local out
100+ out="$("$1" --version 2>/dev/null)" || return 1
101+ [[ "${out}" =~ ^mm\ [^\ ]+\ \(go ]]
102+}
103+
104+# check_existing refuses to replace or remove a <prefix>/bin/mm that is not mini-me.
105+check_existing() {
106+ if [[ -e "${TARGET}" ]] && ! is_mm "${TARGET}"; then
107+ fail "${TARGET} exists and is not mini-me (its --version does not say so): remove it first"
108+ fi
109+}
110+
111+# writable_as_user is true when the current user can create or replace <prefix>/bin/mm.
112+writable_as_user() {
113+ local path
114+ for path in "${PREFIX}/bin" "${TARGET}"; do
115+ while [[ ! -e "${path}" ]]; do path="$(dirname "${path}")"; done
116+ [[ -w "${path}" ]] || return 1
117+ done
118+}
119+
120+as_owner() {
121+ if writable_as_user; then "$@"; else sudo "$@"; fi
122+}
123+
124+# verify_signature checks that mm is validly signed, by our team, with our identifier. Whole
125+# outputs first: with pipefail, `codesign | grep -q` can fail on SIGPIPE.
126+verify_signature() {
127+ local binary=$1
128+ command -v codesign >/dev/null 2>&1 || fail "codesign not found: cannot check the signature"
129+ codesign --verify --strict "${binary}" 2>/dev/null \
130+ || fail "mm is not validly signed (binaries before 2.1.1 are not: pass --no-verify)"
131+ local details
132+ details="$(codesign -dv --verbose=4 "${binary}" 2>&1)"
133+ grep -qx "TeamIdentifier=${TEAM_ID}" <<<"${details}" \
134+ || fail "mm is not signed by the bots-garden team (${TEAM_ID})"
135+ grep -qx "Identifier=${IDENTIFIER}" <<<"${details}" \
136+ || fail "mm does not carry the identifier ${IDENTIFIER}"
137+ say "✅ signed by the bots-garden Developer ID (${TEAM_ID})"
138+}
139+
140+# Not named `uninstall` / `install`: `install` would shadow /usr/bin/install, used below.
141+remove_mm() {
142+ check_existing
143+ if [[ ! -e "${TARGET}" ]]; then
144+ say "nothing to remove under ${PREFIX}"
145+ return 0
146+ fi
147+ if [[ "${DRY_RUN}" == true ]]; then
148+ say "would remove ${TARGET}"
149+ return 0
150+ fi
151+ as_owner rm -f "${TARGET}"
152+ say "removed ${TARGET} (agent files, sessions and ~/.cache/mm kept)"
153+}
154+
155+# download fetches the binary and SHA256SUMS into WORK and checks the binary's checksum.
156+download() {
157+ local name=$1 version=$2
158+ local url="${BASE_URL}/releases/download/v${version}"
159+ curl -fsSL -m 600 -o "${WORK}/${name}" "${url}/${name}" \
160+ || fail "cannot download ${url}/${name} (is ${version} published?)"
161+ curl -fsSL -m 60 -o "${WORK}/SHA256SUMS" "${url}/SHA256SUMS" \
162+ || fail "cannot download ${url}/SHA256SUMS"
163+ # Only the binary's line: the release lists every platform.
164+ grep -E "^[0-9a-f]{64} ${name}$" "${WORK}/SHA256SUMS" >"${WORK}/expected" \
165+ || fail "SHA256SUMS has no line for ${name}"
166+ (cd "${WORK}" && checksum -c expected >/dev/null 2>&1) || fail "checksum mismatch for ${name}"
167+ say "✅ checksum"
168+}
169+
170+install_mm() {
171+ local version="${VERSION}"
172+ if [[ -z "${version}" ]]; then
173+ version="$(latest_version)"
174+ fi
175+ version="${version#v}"
176+ [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || fail "not a version: ${version}"
177+ check_existing
178+
179+ local name
180+ name="mm-${version}-$(platform)"
181+ say "==> mini-me ${version} (${name})"
182+
183+ WORK="$(mktemp -d)"
184+ trap 'rm -rf "${WORK}"' EXIT
185+ download "${name}" "${version}"
186+ local binary="${WORK}/${name}"
187+ chmod 755 "${binary}"
188+
189+ if [[ "${name}" == *-darwin-* ]]; then
190+ if [[ "${NO_VERIFY}" == true ]]; then
191+ say "⚠️ signature not checked (--no-verify)"
192+ else
193+ verify_signature "${binary}"
194+ fi
195+ fi
196+
197+ # A release prints "mm v<version> (…)": the version stamped at build time is the tag.
198+ local reported
199+ reported="$("${binary}" --version 2>/dev/null)" || fail "the downloaded mm does not start"
200+ [[ "${reported}" == "mm v${version} ("* ]] || fail "the downloaded mm reports \"${reported}\", expected mm v${version}"
201+ say "✅ ${reported}"
202+
203+ if [[ "${DRY_RUN}" == true ]]; then
204+ say "dry run: would install ${TARGET}"
205+ return 0
206+ fi
207+
208+ as_owner mkdir -p "${PREFIX}/bin"
209+ as_owner install -m 755 "${binary}" "${TARGET}"
210+ say "✅ installed ${TARGET}"
211+
212+ if [[ "$(command -v mm || true)" != "${TARGET}" ]]; then
213+ say "note: \`mm\` does not resolve to ${TARGET}: put ${PREFIX}/bin first in PATH"
214+ fi
215+ say "next: mm init (writes an agent.yaml), then mm"
216+}
217+
218+main() {
219+ VERSION=""
220+ PREFIX="/usr/local"
221+ ACTION=install
222+ DRY_RUN=false
223+ NO_VERIFY=false
224+ while [[ $# -gt 0 ]]; do
225+ case "$1" in
226+ --version) VERSION="${2:?--version needs a version}"; shift 2 ;;
227+ --prefix) PREFIX="${2:?--prefix needs a directory}"; shift 2 ;;
228+ --uninstall) ACTION=uninstall; shift ;;
229+ --dry-run) DRY_RUN=true; shift ;;
230+ --no-verify) NO_VERIFY=true; shift ;;
231+ -h | --help) usage; exit 0 ;;
232+ *) fail "unknown option $1 (see --help)" ;;
233+ esac
234+ done
235+ PREFIX="${PREFIX%/}"
236+ TARGET="${PREFIX}/bin/mm"
237+
238+ if [[ "${ACTION}" == uninstall ]]; then
239+ remove_mm
240+ else
241+ install_mm
242+ fi
243+}
244+
245+main "$@"
modified local-ci-01-check.sh +5 -0
@@ -20,4 +20,9 @@ go vet ./...
2020 echo "==> go test"
2121 go test ./... -count=1
2222
23+# install-mm.sh (ticket #276) against fake releases on 127.0.0.1: what
24+# `curl … | bash` will do with the release this script prepares.
25+echo "==> install-mm.sh"
26+tests/installer/test-install-mm.sh
27+
2328 echo "✅ checks passed"
@@ -20,4 +20,9 @@ go vet ./...
20 echo "==> go test"20 echo "==> go test"
21 go test ./... -count=121 go test ./... -count=1
22 22
23+# install-mm.sh (ticket #276) against fake releases on 127.0.0.1: what
24+# `curl … | bash` will do with the release this script prepares.
25+echo "==> install-mm.sh"
26+tests/installer/test-install-mm.sh
27+
23 echo "✅ checks passed"28 echo "✅ checks passed"
added tests/installer/test-install-mm.sh +173 -0
new file mode 100755
@@ -0,0 +1,173 @@
1+#!/usr/bin/env bash
2+# Tests of install-mm.sh (ticket #276) against fake releases served on 127.0.0.1.
3+#
4+# tests/installer/test-install-mm.sh
5+#
6+# Needs bash, curl, python3; runs on Linux and on the Mac. The fake mm is a shell script that
7+# prints what a release prints for --version, laid out the way local-ci-02-build.sh lays out a
8+# release (one binary per platform, one SHA256SUMS). MM_INSTALL_ANY_PLATFORM=1 makes the
9+# installer take the linux-amd64 binary on any machine, except in the platform tests. The fake
10+# binaries are not signed: the signature is only checked for a darwin binary, and the macOS test
11+# (run on a Mac only) checks that an unsigned one is refused. Writes only into a temporary folder.
12+set -euo pipefail
13+cd "$(dirname "$0")/../.."
14+installer="$PWD/install-mm.sh"
15+
16+work="$(mktemp -d)"
17+server_pid=""
18+cleanup() {
19+ if [[ -n "${server_pid}" ]]; then kill "${server_pid}" 2>/dev/null || true; fi
20+ rm -rf "${work}"
21+}
22+trap cleanup EXIT
23+
24+passed=0
25+failed=0
26+ok() { passed=$((passed + 1)); printf ' ✅ %s\n' "$1"; }
27+ko() { failed=$((failed + 1)); printf ' ❌ %s\n' "$1"; }
28+check() { # check "description" command…
29+ local what=$1
30+ shift
31+ if "$@" >"${work}/out" 2>&1; then ok "${what}"; else ko "${what}"; sed 's/^/ /' "${work}/out"; fi
32+}
33+refuses() { # refuses "description" "expected message" command…
34+ local what=$1 message=$2
35+ shift 2
36+ if "$@" >"${work}/out" 2>&1; then
37+ ko "${what} (it succeeded)"
38+ elif grep -qF -- "${message}" "${work}/out"; then
39+ ok "${what}"
40+ else
41+ ko "${what} (message: $(tr '\n' ' ' <"${work}/out"))"
42+ fi
43+}
44+
45+checksum() { if command -v shasum >/dev/null 2>&1; then shasum -a 256 "$@"; else sha256sum "$@"; fi; }
46+
47+# publish VERSION [corrupt|liar]: a release laid out like local-ci-02-build.sh's, every platform.
48+# corrupt: SHA256SUMS does not match; liar: the binary reports another version.
49+site="${work}/site"
50+publish() {
51+ local version=$1 how=${2:-}
52+ local dir="${site}/releases/download/v${version}"
53+ local reported="v${version}"
54+ [[ "${how}" == liar ]] && reported="v0.0.1"
55+ mkdir -p "${dir}"
56+ local platform
57+ for platform in darwin-arm64 linux-amd64 linux-arm64; do
58+ printf '#!/bin/sh\necho "mm %s (go1.27.4, %s)"\n' "${reported}" "${platform/-//}" >"${dir}/mm-${version}-${platform}"
59+ done
60+ printf 'windows\n' >"${dir}/mm-${version}-windows-amd64.exe"
61+ (cd "${dir}" && checksum mm-"${version}"-* >SHA256SUMS)
62+ if [[ "${how}" == corrupt ]]; then
63+ sed -i.bak "s/^[0-9a-f]\{64\}/$(printf '%064d' 0)/" "${dir}/SHA256SUMS"
64+ fi
65+}
66+publish 2.1.1
67+publish 2.2.0
68+publish 9.9.9 corrupt
69+publish 8.8.8 liar
70+latest=2.2.0
71+
72+# A file server that also answers /releases/latest with a redirect, like Rickub.
73+port="$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])')"
74+cat >"${work}/server.py" <<'PY'
75+import http.server, sys, functools
76+root, port, latest = sys.argv[1], int(sys.argv[2]), sys.argv[3]
77+class Handler(http.server.SimpleHTTPRequestHandler):
78+ def do_HEAD(self):
79+ if self.path == "/releases/latest":
80+ self.send_response(302)
81+ self.send_header("Location", f"/bots-garden/mini-me/releases/v{latest}")
82+ self.end_headers()
83+ return
84+ super().do_HEAD()
85+ def do_GET(self):
86+ if self.path == "/releases/latest":
87+ return self.do_HEAD()
88+ super().do_GET()
89+ def log_message(self, *args):
90+ pass
91+http.server.ThreadingHTTPServer(("127.0.0.1", port), functools.partial(Handler, directory=root)).serve_forever()
92+PY
93+python3 "${work}/server.py" "${site}" "${port}" "${latest}" &
94+server_pid=$!
95+export MM_INSTALL_BASE_URL="http://127.0.0.1:${port}"
96+export MM_INSTALL_ANY_PLATFORM=1
97+# The sandbox proxy must not see 127.0.0.1.
98+export NO_PROXY="127.0.0.1${NO_PROXY:+,${NO_PROXY}}" no_proxy="127.0.0.1${no_proxy:+,${no_proxy}}"
99+for _ in $(seq 50); do
100+ curl -fsS -o /dev/null "${MM_INSTALL_BASE_URL}/releases/download/v2.1.1/SHA256SUMS" 2>/dev/null && break
101+ sleep 0.1
102+done
103+
104+prefix="${work}/prefix"
105+reports() { [[ "$("${prefix}/bin/mm" --version)" == "mm v$1 ("* ]]; }
106+
107+echo "install-mm.sh"
108+
109+check "installs the latest release" bash "${installer}" --prefix "${prefix}"
110+check " the installed mm reports it" reports "${latest}"
111+check " installed executable" test -x "${prefix}/bin/mm"
112+
113+check "installs a given version (v prefix accepted), over a mini-me" bash "${installer}" --prefix "${prefix}" --version v2.1.1
114+check " the installed mm reports it" reports 2.1.1
115+
116+check "works piped, as curl | bash runs it" bash -c "cat '${installer}' | bash -s -- --prefix '${prefix}' --version ${latest}"
117+check " the installed mm reports it" reports "${latest}"
118+
119+refuses "refuses a checksum mismatch" "checksum mismatch" \
120+ bash "${installer}" --prefix "${prefix}" --version 9.9.9
121+check " the installed version is untouched" reports "${latest}"
122+
123+refuses "refuses a binary that reports another version" "expected mm v8.8.8" \
124+ bash "${installer}" --prefix "${prefix}" --version 8.8.8
125+check " the installed version is untouched" reports "${latest}"
126+
127+refuses "refuses a version that is not published" "cannot download" \
128+ bash "${installer}" --prefix "${prefix}" --version 7.7.7
129+refuses "refuses something that is not a version" "not a version" \
130+ bash "${installer}" --prefix "${prefix}" --version latest
131+
132+check "--dry-run installs nothing" bash "${installer}" --prefix "${work}/dry" --dry-run
133+check " no folder, no binary" test ! -e "${work}/dry"
134+
135+source_build="${work}/source"
136+mkdir -p "${source_build}/bin"
137+printf '#!/bin/sh\necho "mm f062af9+dirty (go1.27.4, linux/arm64)"\n' >"${source_build}/bin/mm"
138+chmod 755 "${source_build}/bin/mm"
139+check "replaces an mm built from source (install.sh)" bash "${installer}" --prefix "${source_build}"
140+check " the installed mm reports the release" bash -c "'${source_build}/bin/mm' --version | grep -q 'mm v${latest} '"
141+
142+foreign="${work}/foreign"
143+mkdir -p "${foreign}/bin"
144+printf '#!/bin/sh\necho "someone else 1.0"\n' >"${foreign}/bin/mm"
145+chmod 755 "${foreign}/bin/mm"
146+refuses "never overwrites an mm that is not mini-me" "is not mini-me" \
147+ bash "${installer}" --prefix "${foreign}"
148+refuses "never removes an mm that is not mini-me" "is not mini-me" \
149+ bash "${installer}" --prefix "${foreign}" --uninstall
150+check " the foreign mm is untouched" grep -q "someone else" "${foreign}/bin/mm"
151+
152+refuses "refuses an unknown option" "unknown option" bash "${installer}" --frobnicate
153+check "--help prints the usage, piped too" bash -c "cat '${installer}' | bash -s -- --help | grep -q -- --uninstall"
154+
155+case "$(uname -s)-$(uname -m)" in
156+ Darwin-arm64)
157+ refuses "refuses an unsigned macOS binary without --no-verify" "not validly signed" \
158+ env MM_INSTALL_ANY_PLATFORM= bash "${installer}" --prefix "${work}/mac" --version 2.1.1
159+ check " installs it with --no-verify" env MM_INSTALL_ANY_PLATFORM= bash "${installer}" --prefix "${work}/mac" --version 2.1.1 --no-verify
160+ ;;
161+ Linux-x86_64 | Linux-aarch64 | Linux-arm64 | Linux-amd64)
162+ check "takes this Linux machine's own binary" bash -c "MM_INSTALL_ANY_PLATFORM= bash '${installer}' --prefix '${work}/native' --dry-run >'${work}/native.out' 2>&1"
163+ check " named after its architecture" grep -q "mm-${latest}-linux-$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" "${work}/native.out"
164+ ;;
165+esac
166+
167+check "--uninstall removes the binary" bash "${installer}" --prefix "${prefix}" --uninstall
168+check " it is gone" test ! -e "${prefix}/bin/mm"
169+check "--uninstall again has nothing to remove" bash "${installer}" --prefix "${prefix}" --uninstall
170+
171+echo ""
172+echo "${passed} passed, ${failed} failed"
173+[[ "${failed}" == 0 ]]
new file mode 100755
@@ -0,0 +1,173 @@
1+#!/usr/bin/env bash
2+# Tests of install-mm.sh (ticket #276) against fake releases served on 127.0.0.1.
3+#
4+# tests/installer/test-install-mm.sh
5+#
6+# Needs bash, curl, python3; runs on Linux and on the Mac. The fake mm is a shell script that
7+# prints what a release prints for --version, laid out the way local-ci-02-build.sh lays out a
8+# release (one binary per platform, one SHA256SUMS). MM_INSTALL_ANY_PLATFORM=1 makes the
9+# installer take the linux-amd64 binary on any machine, except in the platform tests. The fake
10+# binaries are not signed: the signature is only checked for a darwin binary, and the macOS test
11+# (run on a Mac only) checks that an unsigned one is refused. Writes only into a temporary folder.
12+set -euo pipefail
13+cd "$(dirname "$0")/../.."
14+installer="$PWD/install-mm.sh"
15+
16+work="$(mktemp -d)"
17+server_pid=""
18+cleanup() {
19+ if [[ -n "${server_pid}" ]]; then kill "${server_pid}" 2>/dev/null || true; fi
20+ rm -rf "${work}"
21+}
22+trap cleanup EXIT
23+
24+passed=0
25+failed=0
26+ok() { passed=$((passed + 1)); printf ' ✅ %s\n' "$1"; }
27+ko() { failed=$((failed + 1)); printf ' ❌ %s\n' "$1"; }
28+check() { # check "description" command…
29+ local what=$1
30+ shift
31+ if "$@" >"${work}/out" 2>&1; then ok "${what}"; else ko "${what}"; sed 's/^/ /' "${work}/out"; fi
32+}
33+refuses() { # refuses "description" "expected message" command…
34+ local what=$1 message=$2
35+ shift 2
36+ if "$@" >"${work}/out" 2>&1; then
37+ ko "${what} (it succeeded)"
38+ elif grep -qF -- "${message}" "${work}/out"; then
39+ ok "${what}"
40+ else
41+ ko "${what} (message: $(tr '\n' ' ' <"${work}/out"))"
42+ fi
43+}
44+
45+checksum() { if command -v shasum >/dev/null 2>&1; then shasum -a 256 "$@"; else sha256sum "$@"; fi; }
46+
47+# publish VERSION [corrupt|liar]: a release laid out like local-ci-02-build.sh's, every platform.
48+# corrupt: SHA256SUMS does not match; liar: the binary reports another version.
49+site="${work}/site"
50+publish() {
51+ local version=$1 how=${2:-}
52+ local dir="${site}/releases/download/v${version}"
53+ local reported="v${version}"
54+ [[ "${how}" == liar ]] && reported="v0.0.1"
55+ mkdir -p "${dir}"
56+ local platform
57+ for platform in darwin-arm64 linux-amd64 linux-arm64; do
58+ printf '#!/bin/sh\necho "mm %s (go1.27.4, %s)"\n' "${reported}" "${platform/-//}" >"${dir}/mm-${version}-${platform}"
59+ done
60+ printf 'windows\n' >"${dir}/mm-${version}-windows-amd64.exe"
61+ (cd "${dir}" && checksum mm-"${version}"-* >SHA256SUMS)
62+ if [[ "${how}" == corrupt ]]; then
63+ sed -i.bak "s/^[0-9a-f]\{64\}/$(printf '%064d' 0)/" "${dir}/SHA256SUMS"
64+ fi
65+}
66+publish 2.1.1
67+publish 2.2.0
68+publish 9.9.9 corrupt
69+publish 8.8.8 liar
70+latest=2.2.0
71+
72+# A file server that also answers /releases/latest with a redirect, like Rickub.
73+port="$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1])')"
74+cat >"${work}/server.py" <<'PY'
75+import http.server, sys, functools
76+root, port, latest = sys.argv[1], int(sys.argv[2]), sys.argv[3]
77+class Handler(http.server.SimpleHTTPRequestHandler):
78+ def do_HEAD(self):
79+ if self.path == "/releases/latest":
80+ self.send_response(302)
81+ self.send_header("Location", f"/bots-garden/mini-me/releases/v{latest}")
82+ self.end_headers()
83+ return
84+ super().do_HEAD()
85+ def do_GET(self):
86+ if self.path == "/releases/latest":
87+ return self.do_HEAD()
88+ super().do_GET()
89+ def log_message(self, *args):
90+ pass
91+http.server.ThreadingHTTPServer(("127.0.0.1", port), functools.partial(Handler, directory=root)).serve_forever()
92+PY
93+python3 "${work}/server.py" "${site}" "${port}" "${latest}" &
94+server_pid=$!
95+export MM_INSTALL_BASE_URL="http://127.0.0.1:${port}"
96+export MM_INSTALL_ANY_PLATFORM=1
97+# The sandbox proxy must not see 127.0.0.1.
98+export NO_PROXY="127.0.0.1${NO_PROXY:+,${NO_PROXY}}" no_proxy="127.0.0.1${no_proxy:+,${no_proxy}}"
99+for _ in $(seq 50); do
100+ curl -fsS -o /dev/null "${MM_INSTALL_BASE_URL}/releases/download/v2.1.1/SHA256SUMS" 2>/dev/null && break
101+ sleep 0.1
102+done
103+
104+prefix="${work}/prefix"
105+reports() { [[ "$("${prefix}/bin/mm" --version)" == "mm v$1 ("* ]]; }
106+
107+echo "install-mm.sh"
108+
109+check "installs the latest release" bash "${installer}" --prefix "${prefix}"
110+check " the installed mm reports it" reports "${latest}"
111+check " installed executable" test -x "${prefix}/bin/mm"
112+
113+check "installs a given version (v prefix accepted), over a mini-me" bash "${installer}" --prefix "${prefix}" --version v2.1.1
114+check " the installed mm reports it" reports 2.1.1
115+
116+check "works piped, as curl | bash runs it" bash -c "cat '${installer}' | bash -s -- --prefix '${prefix}' --version ${latest}"
117+check " the installed mm reports it" reports "${latest}"
118+
119+refuses "refuses a checksum mismatch" "checksum mismatch" \
120+ bash "${installer}" --prefix "${prefix}" --version 9.9.9
121+check " the installed version is untouched" reports "${latest}"
122+
123+refuses "refuses a binary that reports another version" "expected mm v8.8.8" \
124+ bash "${installer}" --prefix "${prefix}" --version 8.8.8
125+check " the installed version is untouched" reports "${latest}"
126+
127+refuses "refuses a version that is not published" "cannot download" \
128+ bash "${installer}" --prefix "${prefix}" --version 7.7.7
129+refuses "refuses something that is not a version" "not a version" \
130+ bash "${installer}" --prefix "${prefix}" --version latest
131+
132+check "--dry-run installs nothing" bash "${installer}" --prefix "${work}/dry" --dry-run
133+check " no folder, no binary" test ! -e "${work}/dry"
134+
135+source_build="${work}/source"
136+mkdir -p "${source_build}/bin"
137+printf '#!/bin/sh\necho "mm f062af9+dirty (go1.27.4, linux/arm64)"\n' >"${source_build}/bin/mm"
138+chmod 755 "${source_build}/bin/mm"
139+check "replaces an mm built from source (install.sh)" bash "${installer}" --prefix "${source_build}"
140+check " the installed mm reports the release" bash -c "'${source_build}/bin/mm' --version | grep -q 'mm v${latest} '"
141+
142+foreign="${work}/foreign"
143+mkdir -p "${foreign}/bin"
144+printf '#!/bin/sh\necho "someone else 1.0"\n' >"${foreign}/bin/mm"
145+chmod 755 "${foreign}/bin/mm"
146+refuses "never overwrites an mm that is not mini-me" "is not mini-me" \
147+ bash "${installer}" --prefix "${foreign}"
148+refuses "never removes an mm that is not mini-me" "is not mini-me" \
149+ bash "${installer}" --prefix "${foreign}" --uninstall
150+check " the foreign mm is untouched" grep -q "someone else" "${foreign}/bin/mm"
151+
152+refuses "refuses an unknown option" "unknown option" bash "${installer}" --frobnicate
153+check "--help prints the usage, piped too" bash -c "cat '${installer}' | bash -s -- --help | grep -q -- --uninstall"
154+
155+case "$(uname -s)-$(uname -m)" in
156+ Darwin-arm64)
157+ refuses "refuses an unsigned macOS binary without --no-verify" "not validly signed" \
158+ env MM_INSTALL_ANY_PLATFORM= bash "${installer}" --prefix "${work}/mac" --version 2.1.1
159+ check " installs it with --no-verify" env MM_INSTALL_ANY_PLATFORM= bash "${installer}" --prefix "${work}/mac" --version 2.1.1 --no-verify
160+ ;;
161+ Linux-x86_64 | Linux-aarch64 | Linux-arm64 | Linux-amd64)
162+ check "takes this Linux machine's own binary" bash -c "MM_INSTALL_ANY_PLATFORM= bash '${installer}' --prefix '${work}/native' --dry-run >'${work}/native.out' 2>&1"
163+ check " named after its architecture" grep -q "mm-${latest}-linux-$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" "${work}/native.out"
164+ ;;
165+esac
166+
167+check "--uninstall removes the binary" bash "${installer}" --prefix "${prefix}" --uninstall
168+check " it is gone" test ! -e "${prefix}/bin/mm"
169+check "--uninstall again has nothing to remove" bash "${installer}" --prefix "${prefix}" --uninstall
170+
171+echo ""
172+echo "${passed} passed, ${failed} failed"
173+[[ "${failed}" == 0 ]]