Add AGENTS.md and fill the gaps in the README

AGENTS.md describes the project for anyone -- human or agent -- changing a
script: what the repository is, where it sits inside the OpenWrt tree, which
scripts run from where, the shell conventions the existing code follows, and
the bash traps that have already caused bugs here.

README: document the options that were missing (--refresh, --skip-defconfig,
--extras-file/--no-extras-file, --extras, --wrap), distinguish --extras from
--extras-file, and replace the Debian-only Go install line with a
distribution-neutral description of how update-go-path.sh finds a toolchain.
Drop the hedged MIT claim, since no LICENSE file exists.

Both documents stay environment-neutral: no absolute home paths and no
assumption of a distribution, with platform-specific advice kept under an
explicit conditional heading.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-11 10:59:41 -04:00
parent 2abd8aba00
commit 40d3b21e71
2 changed files with 173 additions and 8 deletions

View File

@@ -89,6 +89,9 @@ make -j$(nproc) download world
## Scripts
Every script takes `-h/--help` and prints its full option list; the summaries
below cover the options worth knowing about.
- **prepare-openwrt-env.sh** — installs the build dependencies from the official
build system guide. Dispatches on the package manager rather than guessing from
the distro version, and probes every package against the running release so a
@@ -111,14 +114,21 @@ make -j$(nproc) download world
the selected device and strips the buildbot flags (see below).
`--device <id>`, `--target <t>`, `--version <ver>`, `--snapshot`,
`--with-packages`, `--all-profiles`, `--keep-buildbot-flags`,
`--save-buildinfo`, `--offline`, `--output <file>`, `-y`, `-n`.
`--save-buildinfo`, `--offline`, `--output <file>`, `--refresh`,
`--skip-defconfig`, `-y`, `-n`.
- **gen-package-list.sh** — builds the complete package list: the built-in part
from the target's `profiles.json` (`default_packages` + `device_packages` plus
the two packages the Firmware Selector adds), combined with your
`packages/<device-id>.txt`.
`--device <id>`, `--apply`, `--init-extras`, `--stdout`, `--full-stdout`,
`--out <path>`, `--no-extras`, `-y`, `-n`.
`--device <id>`, `--target <t>`, `--version <ver>`, `--snapshot`,
`--apply`, `--init-extras`, `--extras-file <f>`, `--no-extras-file`,
`--stdout`, `--full-stdout`, `--out <path>`, `--extras "<pkgs>"`,
`--no-extras`, `--wrap <cols>`, `--refresh`, `-y`, `-n`.
`--extras`/`--no-extras` control the two packages the Firmware Selector adds
on top of the target's own set; `--extras-file`/`--no-extras-file` control
your `packages/<device-id>.txt`. They are different things.
- **add-openwrt-packages.sh** — applies a package list to `.config`. Rewrites
existing `CONFIG_PACKAGE_` lines in place, so repeated runs do not grow the
@@ -130,7 +140,7 @@ make -j$(nproc) download world
`--external` clears `CONFIG_GOLANG_BUILD_BOOTSTRAP` so the installed toolchain
builds host Go directly instead of OpenWrt building the whole bootstrap chain
from source.
`--external`, `--go-root <dir>`, `-n`.
`--external`, `--go-root <dir>`, `--skip-defconfig`, `-n`.
- **add-external-repos.sh** — clones extra package repositories into `package/`.
Edit the `REPOS` array to change the list.
@@ -167,13 +177,17 @@ install an arbitrary kmod from your own build output.
### Go packages
Packages such as tailscale, adguardhome, easytier and cloudflared need a host Go.
By default OpenWrt builds the entire bootstrap chain from source, which works but
is slow. To skip it, install a Go matching the version the tree expects and run:
is slow. To skip it, install a Go from your distribution (or from go.dev) at
least as new as the version the tree expects, then run:
```bash
sudo apt install golang-1.24-go
./helper/update-go-path.sh --external
```
The script searches `/usr/lib/go-*`, `/usr/local/go` and `/usr/lib/golang`,
picks the newest, and warns if it is older than the bootstrap version the tree
asks for. Point it elsewhere with `--go-root <dir>`.
### WSL: Windows PATH breaks Go package builds
On WSL, `PATH` includes Windows directories containing spaces and parentheses
(`/mnt/c/Program Files (x86)/...`). OpenWrt's Go build recipe interpolates `PATH`
@@ -239,7 +253,9 @@ git clean -xdf -e /helper
files unless you pass `--force`.
- Scripts write under `package/` and `feeds/` inside your OpenWrt tree.
## License and authorship
## Contributing and authorship
- Scripts authored by Zhe Yuan.
- License: MIT (unless you choose a different license; update this line accordingly).
- No `LICENSE` file is present yet; add one before redistributing.
- [AGENTS.md](AGENTS.md) documents the layout, the shell conventions and the
invariants to preserve — read it before changing a script.