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

@@ -71,6 +71,21 @@ require_python3() {
fi
}
# The helper checkout is itself a git repository living inside the OpenWrt
# worktree, so plain git commands run from here describe the HELPER repo.
# Every version query must be anchored to the OpenWrt tree instead.
find_openwrt_root() {
local d
for d in "$PWD" "$(dirname -- "${LIB_SCRIPT_DIR:-$PWD}")"; do
[ -n "$d" ] || continue
if [ -f "$d/feeds.conf.default" ] && [ -f "$d/Makefile" ] && [ -d "$d/scripts" ]; then
( cd -- "$d" && pwd -P )
return 0
fi
done
return 1
}
require_openwrt_root() {
if [ ! -f feeds.conf.default ] || [ ! -f Makefile ] || [ ! -d scripts ]; then
err "Must run inside the OpenWrt root directory."
@@ -155,19 +170,24 @@ detect_version() {
return 0
fi
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
err "Not inside a Git repository and no --version given."
local root=""
if ! root="$(find_openwrt_root)"; then
err "Cannot locate the OpenWrt source tree; pass --version <ver> explicitly."
exit 1
fi
if ! git -C "$root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
err "'$root' is not a Git repository and no --version was given."
exit 1
fi
if tag="$(git describe --tags --exact-match HEAD 2>/dev/null)"; then
if tag="$(git -C "$root" describe --tags --exact-match HEAD 2>/dev/null)"; then
ver="${tag#v}"
info "HEAD is exactly at tag $tag; using version $ver."
echo "$ver"
return 0
fi
if branch="$(git symbolic-ref --quiet --short HEAD 2>/dev/null)"; then
if branch="$(git -C "$root" symbolic-ref --quiet --short HEAD 2>/dev/null)"; then
case "$branch" in
main | master)
info "On branch '$branch'; using SNAPSHOT."
@@ -177,10 +197,10 @@ detect_version() {
openwrt-* | [0-9]*)
local series="${branch#openwrt-}"
# --merged HEAD keeps tags from unrelated branches out of the picture.
tag="$(git tag --merged HEAD -l "v${series}.*" 2>/dev/null |
tag="$(git -C "$root" tag --merged HEAD -l "v${series}.*" 2>/dev/null |
grep -v -- '-rc' | sort -V | tail -n 1)"
if [ -n "$tag" ]; then
drift="$(git rev-list --count "$tag..HEAD" 2>/dev/null || echo 0)"
drift="$(git -C "$root" rev-list --count "$tag..HEAD" 2>/dev/null || echo 0)"
if [ "$drift" -gt 0 ]; then
warn "HEAD is $drift commit(s) past $tag."
warn "The downloaded config describes the release, not your tree."
@@ -194,9 +214,9 @@ detect_version() {
esac
fi
if tag="$(git describe --tags --long 2>/dev/null)"; then
if tag="$(git -C "$root" describe --tags --long 2>/dev/null)"; then
tag="${tag%-*-g*}"
drift="$(git rev-list --count "$tag..HEAD" 2>/dev/null || echo 0)"
drift="$(git -C "$root" rev-list --count "$tag..HEAD" 2>/dev/null || echo 0)"
warn "HEAD is not at a tag; nearest is $tag ($drift commit(s) behind HEAD)."
if [ "$ASSUME_YES" != true ] &&
! confirm "Use version ${tag#v}?" no; then