Compare commits

..

3 Commits

Author SHA1 Message Date
2ce592b693 Document profiles keys 2026-05-11 21:29:53 -04:00
4d70450fe8 Fix files overlay and flash_images() 2026-05-11 21:29:19 -04:00
2245e7feef r4s: add luci-app-sqm 2026-05-11 21:28:15 -04:00
3 changed files with 52 additions and 11 deletions

View File

@@ -41,12 +41,37 @@ See `profiles` for example device profile definitions. Multiple `--profile` can
The default build mode is `imagebuilder` unless `--mode=source` is passed. Default profile modes can be set individually in `profiles`.
`--mode=imagebuilder` inherits `CONFIG_TARGET_ROOTFS_PARTSIZE=`, but all other kconfigs only work in `--mode=source`.
Profile keys:
| Key | Required | Description |
|---|---|---|
| `mode` | No | Build mode for this profile: `imagebuilder` or `source`. CLI `--mode` overrides profile value. |
| `device` | Yes | OpenWrt device/profile id used by build commands (for example `friendlyarm_nanopi-r4s`). |
| `target` | Yes | OpenWrt target/subtarget (for example `rockchip/armv8`, `x86/64`). |
| `filesystem` | No | Root filesystem type (`squashfs`, `ext4`, etc). Defaults to `squashfs`. |
| `packages` | No | Space-separated package list. Prefix with `-` to remove a package in Image Builder or source config generation. |
| `kconfigs` | No | Space-separated Kconfig symbols. In `imagebuilder` mode only `CONFIG_TARGET_ROOTFS_PARTSIZE=<MB>` is used (mapped to `ROOTFS_PARTSIZE`). In `source` mode all entries are written to `.config` seed. |
| `files` | No | Host directory containing custom overlay files. In `imagebuilder` mode this is passed as `FILES=<dir>`. In `source` mode contents are synced into `<build dir>/files/` before build. Defaults to `<buildroot>/src/files`. |
| `cherrypicks` | No | Space-separated entries in `URL@branch:commit` form. Each commit is fetched and cherry-picked in `source` mode. |
| `branches` | No | Space-separated `URL@branch` entries to merge into the source worktree in `source` mode. |
| `release` | No | Default release/ref for the profile (for example `snapshot`, `25.12.3`). CLI `--release` overrides it. |
| `clean` | No | Optional source cleanup step (`clean`, `targetclean`, `dirclean`, `distclean`). CLI `--clean` overrides it. |
| `repo` | No | Extra Image Builder repository line appended to `repositories.conf` before build. |
Notes:
* The profile file uses associative arrays (`declare -Ag name=( [key]="value" ... )`).
* `packages`, `kconfigs`, `cherrypicks`, and `branches` are parsed as scalar whitespace-separated strings.
* If a profile-specific `files` path is configured, it must exist.
## Examples
* `openwrtbuilder -p r4s -p ax6000`
* `openwrtbuilder -p r4s -r snapshot --debug`
* `openwrtbuilder -p ax6000 -r 23.05.5 --mode source --debug`
* `openwrtbuilder -p rpi4 -r 23.05.5 --flash /dev/sdX`
* `openwrtbuilder -p ax6000 -r 25.12.3 --mode source --debug`
* `openwrtbuilder -p rpi4 -r 25.12.3 --flash /dev/sdX`
* `openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1`
## Additional Info

View File

@@ -458,7 +458,8 @@ make_images() {
# Debug manually so we can log output
debug "${make_cmd[*]}"
"${make_cmd[@]}" > "$BUILD_DIR/make.log" 2>&1
"${make_cmd[@]}" 2>&1 | tee "$BUILD_DIR/make.log"
return "${PIPESTATUS[0]}" # bash-specific way to return exit code of piped command
}
flash_images() {
@@ -466,9 +467,8 @@ flash_images() {
local img_gz="$1"
local dev="$2"
local img="${img_gz%.gz}"
local partitions
if [[ ! -e "$dev" ]]; then
if [[ ! -b "$dev" ]]; then
echo "The device specified by --flash could not be found"
return 1
fi
@@ -476,13 +476,13 @@ flash_images() {
[[ -f $img_gz ]] || { echo "$img_gz does not exist"; return 1; }
execute gunzip -qfk "$img_gz"
echo "Unmounting target device $dev partitions"
partitions=("$dev"?*)
execute sudo umount "${partitions[@]}"
[[ -f "$img" ]] || { echo "Extracted image '$img' is missing"; return 1; }
if execute sudo dd if="$img" of="$dev" bs=2M conv=fsync; then
sync
if command -v partprobe &>/dev/null; then
execute sudo partprobe "$dev" || debug "partprobe failed for $dev"
fi
echo "Image flashed successfully!"
else
echo "dd failed!"
@@ -674,6 +674,13 @@ from_source() {
./scripts/feeds update -a -f &&
./scripts/feeds install -a -f
# Apply custom files overlay for source builds.
execute rm -rf "$BUILD_DIR/files"
if [[ -d "$FILES_DIR" ]]; then
execute mkdir -p "$BUILD_DIR/files"
execute rsync -a "$FILES_DIR/" "$BUILD_DIR/files/"
fi
# Add custom packages
for pkg in $PACKAGES; do
if [[ $pkg == -* ]]; then
@@ -774,7 +781,6 @@ main() {
# Fallback to SCRIPT_DIR if BUILD_ROOT has not been set
declare -g BUILD_ROOT="${BUILD_ROOT:=$SCRIPT_DIR}"
declare -g FILES_DIR="${FILES_DIR:=$BUILD_ROOT/src/files}"
declare -g BACKUP_DIR="$SCRIPT_DIR/backups"
# This could be dangerous
@@ -822,6 +828,15 @@ main() {
declare -g CHERRYPICKS="${P_ARR[cherrypicks]:-}" # scalar
declare -g BRANCHES="${P_ARR[branches]:-}" # scalar
declare -g KCONFIGS="${P_ARR[kconfigs]:-}" # scalar
declare -g FILES_DIR="${P_ARR[files]:-$BUILD_ROOT/src/files}"
if [[ ! -d "$FILES_DIR" ]]; then
if [[ -v P_ARR[files] ]]; then
echo "Profile '$PROFILE' files directory does not exist: $FILES_DIR"
return 1
fi
execute mkdir -p "$FILES_DIR"
fi
install_dependencies "$MODE"

View File

@@ -24,6 +24,7 @@ declare -Ag r4s=(
[filesystem]="ext4"
[packages]="${default_packages[*]} \
adblock luci-app-adblock \
luci-app-sqm \
collectd-mod-df usbutils kmod-usb-storage kmod-usb-storage-uas \
kmod-fs-btrfs btrfs-progs block-mount smcroute avahi-daemon \
ethtool ca-bundle tailscale"
@@ -45,7 +46,7 @@ declare -Ag ax6000=(
tailscale"
)
declare -Ag ax6000_uboot=(
declare -Ag ax6000_uboot_ap=(
[mode]="imagebuilder"
[device]="xiaomi_redmi-router-ax6000-ubootmod"
[target]="mediatek/filogic"