Keep one extras list per device instead of per version

The package lists were stored as config_<version>/packages_<device>_<version>.txt,
but the version dimension was pure duplication: the Linksys MX8500 extras were
byte-identical across 24.10.4, 25.12.0, 25.12.2 and 25.12.4, and the Cudy lists
only ever changed with the device, never with the release.

Your packages now live in packages/<device-id>.txt, one file per device and
independent of the OpenWrt version. The built-in part is fetched per release
anyway, so upgrading needs no file changes at all.

The combined list is a build artefact and moves to .generated/, which is
gitignored, along with the buildinfo saved by --save-buildinfo --offline.

This removes work rather than adding it: because the generated file is now
entirely machine-owned, the sentinel comments, the in-section replacement state
machine and the "line containing base-files and libc is the old generated one"
migration heuristic are all gone. Hand-written content is isolated in the extras
file, generated content in .generated/.

Also fix version detection when a script is run from the helper directory. The
helper checkout is its own git repository inside the OpenWrt worktree, so git
commands there described the helper repo -- a checkout of OpenWrt 25.12.5 was
reported as SNAPSHOT because the helper repo is on main. Version queries are now
anchored to the OpenWrt tree.

The config_* archives are deleted; git history keeps them. That includes
config_24.10.4/apply-dahdi-patches.sh, which only applied to 24.10.4.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-05 21:18:29 -04:00
parent 0255d2f890
commit e668221b4e
26 changed files with 205 additions and 49829 deletions

View File

@@ -1,7 +1,7 @@
# OpenWrt Build Helper Scripts
## Overview
This repository contains shell scripts that streamline preparing, configuring, and building OpenWrt from source on Debian/Ubuntu systems (x86_64 and ARM64). It also includes convenience utilities to manage package selections, fetch device config.buildinfo, apply a DAHDI driver patch, and add external LuCI packages.
This repository contains shell scripts that streamline preparing, configuring, and building OpenWrt from source on Debian/Ubuntu systems (x86_64 and ARM64). It also includes convenience utilities to manage package selections, fetch a device's official configuration, and add external LuCI packages.
## Whats included
- prepare-openwrt-env.sh
@@ -32,9 +32,9 @@ This repository contains shell scripts that streamline preparing, configuring, a
- Downloads to a temp file and validates it before touching .config, and keeps a .config.download.bak.
- Prints the official sysupgrade/factory URLs (taken from profiles.json, so they are always correct) and a Firmware Selector link.
- gen-package-list.sh
- Generates the `##built-in` package list for a device from the official profiles.json (default_packages + device_packages + the packages the Firmware Selector adds), so it no longer has to be copied by hand for each release.
- Writes config_<version>/packages_<device>_<version>.txt, replacing only the generated block and preserving your own packages and the `##module` section verbatim.
- `--stdout` prints the list, `--apply` applies it straight to .config.
- Builds a device's complete package list: the built-in part from the official profiles.json (default_packages + device_packages + the packages the Firmware Selector adds), combined with your own packages from `packages/<device-id>.txt`.
- The built-in part never has to be copied by hand for a new release, and your packages are version independent — a new release needs no file changes at all.
- Writes the combined list to `.generated/` (not kept in git); `--apply` applies it straight to .config, `--full-stdout` just prints it.
- add-openwrt-packages.sh
- Applies a package list to .config: `##built-in` → =y, `##module` → =m, `##remove` or a `-pkg` prefix → =n.
- Rewrites existing CONFIG_PACKAGE_ lines in place, so repeated runs do not grow .config.
@@ -42,11 +42,7 @@ This repository contains shell scripts that streamline preparing, configuring, a
- After make defconfig it reports any package whose final state differs from what you asked for (a dependency pulling a removed package back in, for example).
- update-go-path.sh
- Detects the latest Go installation under /usr/lib/go-* and sets CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT in .config.
- apply-dahdi-patches.sh
- Writes a DAHDI driver patch into package/feeds/telephony/dahdi-linux/patches/300-fix-dahdi-max-attempts.patch.
- Fixes MAX macro naming collisions in multiple DAHDI modules for OpenWrt 24.10.4 builds.
## System requirements
- OS: Debian/Ubuntu, Fedora/RHEL, Arch, openSUSE or Alpine (the other scripts are developed and tested on Debian/Ubuntu)
- Architectures: x86_64/amd64 and aarch64/arm64
- Tools: git, wget, curl, bash, python3 (used to read the official JSON indexes; jq is not required)
@@ -83,25 +79,43 @@ This repository contains shell scripts that streamline preparing, configuring, a
- Add `--with-packages` to also generate the device's package list in the same run.
- Preview without changing anything: `./helper/download-config.sh --device linksys_mx8500 -n`
5) Enable additional packages from a list (optional)
- Generate the built-in list for your device:
5) Enable additional packages (optional)
- Your own packages live in `helper/packages/<device-id>.txt`, one file per device, independent of the OpenWrt version.
- Apply the built-in list plus your packages in one step:
- ./helper/gen-package-list.sh --device linksys_mx8500 --apply
- Or write the combined list out first and review it before applying:
- ./helper/gen-package-list.sh --device linksys_mx8500
- Edit config_<version>/packages_<device>_<version>.txt and add your own packages below the generated block.
- Apply it from the OpenWrt root:
- ./helper/add-openwrt-packages.sh helper/config_<version>/packages_<device>_<version>.txt
- ./helper/add-openwrt-packages.sh helper/.generated/packages_linksys_mx8500_<version>.txt
### Adding a device
1. `./helper/gen-package-list.sh --device <id> --init-extras` — creates `packages/<id>.txt`
2. Edit `packages/<id>.txt` and list the packages you want on top of the defaults
3. `./helper/gen-package-list.sh --device <id> --apply`
Use `./helper/download-config.sh` without `--device` to search for the id by name.
### Upgrading to a new OpenWrt release
Nothing to edit. Check out the new version, then:
```
./helper/download-config.sh --device <id> -y
./helper/gen-package-list.sh --device <id> --apply -y
```
The built-in list is re-fetched for the new release and your `packages/<id>.txt` is reused as is.
### Files
- `packages/<device-id>.txt` — your packages, one file per device, kept in git and edited by hand.
- `.generated/` — combined package lists and saved buildinfo. Build artefacts, not kept in git.
### Package list format
Used by both `packages/<device-id>.txt` and the generated lists:
```
##built-in packages after this are set to =y (the default)
# >>> generated built-in list - do not edit by hand
... regenerated by gen-package-list.sh; do not edit
# <<< generated built-in list
curl yq luci-app-ttyd your own packages, any number per line
curl yq luci-app-ttyd packages, any number per line, set to =y
-luci-app-wol a leading '-' removes a package (=n)
##module packages after this are set to =m
##remove packages after this are set to =n
##built-in back to =y (the default)
pkg # note text after a single '#' is a comment
```
Text after a single `#` is a comment. Everything outside the generated block is preserved when the list is regenerated.
### Buildbot flags
The official config.buildinfo is the buildbot's own configuration: it enables every
@@ -121,17 +135,14 @@ and `--all-profiles` to build every model in the target.
- This sets CONFIG_GOLANG_EXTERNAL_BOOTSTRAP_ROOT to the latest /usr/lib/go-X.XX/ found.
- You can override it manually in .config if necessary.
7) Apply DAHDI patch (only if you build telephony/dahdi-linux)
- Ensure telephony feed is installed:
- ./scripts/feeds update telephony
- ./scripts/feeds install -a
- Then run:
- ./helper/config_24.10.4/apply-dahdi-patches.sh
- Build the package:
- make package/feeds/telephony/dahdi-linux/{clean,prepare} V=s
- make package/feeds/telephony/dahdi-linux/compile V=s
8) Build OpenWrt
- Build the package:
- Common commands:
- make menuconfig
- make -j$(nproc) download world
@@ -153,8 +164,6 @@ and `--all-profiles` to build every model in the target.
- The script installs cross multilib packages for better compatibility, but not all targets need them. If apt errors on specific multilib packages, remove or adjust as appropriate for your environment.
## Troubleshooting
- Telephony feed not found when applying DAHDI patch:
- Run feeds update/install for telephony as shown above.
- Version detection in download-config.sh:
- It uses, in order: an explicit `--version`/`--snapshot`; the exact tag at HEAD; the branch (`main`/`master` → SNAPSHOT, `openwrt-XX.YY` → the newest matching tag merged into HEAD); otherwise it asks. If HEAD is ahead of the tag it warns that the downloaded config describes the release rather than your tree.
- If the device symbol does not survive `make defconfig`, the script stops and tells you the tree does not match that release, and points at the .config.download.bak it kept.