Compare commits
102 Commits
93a962a008
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b9f1f2f39 | |||
| c5bfc7907b | |||
| 533b0b5ffc | |||
| eba54804d3 | |||
| 09b62923a8 | |||
| 960755e6a2 | |||
| 0fa9b0d85a | |||
| 4de18e6696 | |||
| 3772d373bb | |||
| b75597946d | |||
| 018a91e216 | |||
| 0c61a27b06 | |||
| 675ed5eb39 | |||
| 94f60e30b1 | |||
| e8ccb76cc6 | |||
| 4274f876a7 | |||
| 4760c84bff | |||
| 20b3f7f4ec | |||
| f178e39a28 | |||
| c7b954252d | |||
| 18929109a2 | |||
| 8d24cb96a9 | |||
| 9be43af11a | |||
| ce2e85d197 | |||
| aeead798c3 | |||
| 72355bb65a | |||
| 3053b24063 | |||
| 186fe21d73 | |||
| d63a909d54 | |||
| 9128c453f3 | |||
| ffbd193b79 | |||
| 5259c72de4 | |||
| 045f43b51f | |||
| 89cc3cddeb | |||
| cd7449dd7c | |||
| 2b35e1e017 | |||
| 983f9ecb04 | |||
| b5f567ce2b | |||
| a16e713895 | |||
| 70d24d7fae | |||
| d5069d4c40 | |||
| 718b29cfe8 | |||
| e3ce0b6e57 | |||
| 3ba76a4e8d | |||
| 4f1f145a10 | |||
| 2123205ca0 | |||
| e510f8ccb6 | |||
| da398172e8 | |||
| 12067ac09b | |||
| cf2c35b114 | |||
| 5629472aa3 | |||
| a7a85ee67a | |||
| 4890aa192d | |||
| 819ff0add0 | |||
| 149da1be87 | |||
| 6f1bc4dd00 | |||
| 5d434f031d | |||
| 25b5623a65 | |||
| 20477c21ab | |||
| 8ed85fff2b | |||
| ab8f58ca92 | |||
| 20e11b7419 | |||
| 11c28c7ab3 | |||
| 908664b185 | |||
| 40ce9940ae | |||
| 64ffeeca17 | |||
| 0106ac7eff | |||
| 86f5bf7e3f | |||
| a18d467c4f | |||
| 3a659b4798 | |||
| 7f996e7724 | |||
| 3688539a90 | |||
| c28d7683d8 | |||
| a5b559c59c | |||
| d22d21148c | |||
| 2b4dac7ef3 | |||
| 498f8a7333 | |||
| d28f2e8c31 | |||
| ca3f1e82ed | |||
| 4b66de068b | |||
| 1e88f1b912 | |||
| cbe7e0468d | |||
| a664b70cf4 | |||
| b5199d5682 | |||
| 35ec2993cc | |||
| e4838f361e | |||
| f32b8c84b0 | |||
| f34953b3cc | |||
| e91394ee00 | |||
| a40ac543e9 | |||
| 06a3209046 | |||
| 5ef6d2dc0f | |||
| 36c0786255 | |||
| 25e66b3d19 | |||
| aa24a58aae | |||
| 7298fca349 | |||
| 7191e10f91 | |||
| e80dddf9a7 | |||
| 481e2e2277 | |||
| de84a404f0 | |||
| a5d57fdd3d | |||
| 732233df32 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,7 +1,8 @@
|
|||||||
src/
|
src/
|
||||||
bin/
|
bin/
|
||||||
.vscode/
|
.vscode/
|
||||||
.dependencies
|
*.code-workspace
|
||||||
.dependencies_sc
|
backups/
|
||||||
|
.dependencies_source
|
||||||
.dependencies_ib
|
.dependencies_ib
|
||||||
|
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -1,10 +1,10 @@
|
|||||||
# openwrtbuilder
|
# openwrtbuilder
|
||||||
|
|
||||||
Sanely build and deploy OpenWRT images using the Image Builder or from source code.
|
Build and deploy OpenWRT images using shell-style device profiles, via source code or the official Image Builder.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
`openwrtbuilder [--option [VALUE]]... -p PROFILE [-p PROFILE]...`
|
`openwrtbuilder [OPTION [VALUE]]... -p PROFILE [-p PROFILE]...`
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
@@ -13,8 +13,9 @@ Sanely build and deploy OpenWRT images using the Image Builder or from source co
|
|||||||
--release,-r,--version,-v RELEASE ("snapshot", "22.03.3")
|
--release,-r,--version,-v RELEASE ("snapshot", "22.03.3")
|
||||||
--buildroot,-b PATH (Default: script directory)
|
--buildroot,-b PATH (Default: script directory)
|
||||||
--source
|
--source
|
||||||
Build image from source, not from Image Builder
|
Build image from source code, not from Image Builder.
|
||||||
Allows make config options to be passed in profile
|
Allows make config options to be passed in profile.
|
||||||
|
Uses git worktree for multi-profile deduplication.
|
||||||
--ssh-upgrade HOST
|
--ssh-upgrade HOST
|
||||||
Example: root@192.168.1.1
|
Example: root@192.168.1.1
|
||||||
--ssh-backup SSH_PATH
|
--ssh-backup SSH_PATH
|
||||||
@@ -24,6 +25,8 @@ Sanely build and deploy OpenWRT images using the Image Builder or from source co
|
|||||||
--reset
|
--reset
|
||||||
Cleanup all source and output files
|
Cleanup all source and output files
|
||||||
Can be combined with -p to reset a specific profile
|
Can be combined with -p to reset a specific profile
|
||||||
|
--depends
|
||||||
|
Force dependency installation
|
||||||
--yes,-y
|
--yes,-y
|
||||||
Assume yes for all questions (automatic mode)
|
Assume yes for all questions (automatic mode)
|
||||||
--debug,-d
|
--debug,-d
|
||||||
@@ -32,15 +35,22 @@ Sanely build and deploy OpenWRT images using the Image Builder or from source co
|
|||||||
|
|
||||||
## Profiles
|
## Profiles
|
||||||
|
|
||||||
See `./profiles` for example device profile definitions.
|
See `profiles` for example device profile definitions. Multiple `--profile` can be passed at once.
|
||||||
|
|
||||||
|
The default build mode is `imagebuilder` unless `--source` is passed. Default profile modes can be set individually in `profiles`.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
* `./openwrtbuilder -p r4s -r snapshot --debug`
|
* `openwrtbuilder -p r4s -p ax6000`
|
||||||
* `./openwrtbuilder -p ax6000 -r 23.05.5 --source --debug`
|
* `openwrtbuilder -p r4s -r snapshot --debug`
|
||||||
* `./openwrtbuilder -p rpi4 -r 23.05.5 --flash /dev/sdX`
|
* `openwrtbuilder -p ax6000 -r 23.05.5 --source --debug`
|
||||||
* `./openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1`
|
* `openwrtbuilder -p rpi4 -r 23.05.5 --flash /dev/sdX`
|
||||||
|
* `openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1`
|
||||||
|
|
||||||
## Additional Info
|
## Additional Info
|
||||||
|
|
||||||
Did you find `openwrtbuilder` useful? [Buy me a coffee!](https://paypal.me/bryanroessler)
|
Find `openwrtbuilder` useful? [Paypal me a coffee!](https://paypal.me/bryanroessler)
|
||||||
|
|
||||||
|
[↓ ↓ ↓ Bitcoin ↓ ↓ ↓](bitcoin:bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a)
|
||||||
|
|
||||||
|
[](bitcoin:bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a)
|
||||||
|
|||||||
670
openwrtbuilder
670
openwrtbuilder
@@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Builds and deploys OpenWRT images
|
# Build and deploy OpenWRT images using shell-style device profiles, via source code or the official Image Builder.
|
||||||
# Copyright 2022-24 Bryan C. Roessler
|
# Copyright 2022-25 Bryan C. Roessler
|
||||||
# Apache 2.0 License
|
# Apache 2.0 License
|
||||||
# See README.md and ./profiles for device configuration
|
# See README and ./profiles for device configuration
|
||||||
|
|
||||||
# Set default release
|
# Set default release
|
||||||
: "${RELEASE:="23.05.5"}"
|
: "${RELEASE:="24.10.4"}"
|
||||||
|
|
||||||
# @internal
|
# @internal
|
||||||
print_help() {
|
print_help() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
|
||||||
cat <<-'EOF'
|
cat <<-'EOF'
|
||||||
Build and deploy OpenWRT images
|
Build and deploy OpenWRT images using convenient profiles.
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
openwrtbuilder [OPTION [VALUE]]... -p PROFILE [-p PROFILE]...
|
openwrtbuilder [OPTION [VALUE]]... -p PROFILE [-p PROFILE]...
|
||||||
@@ -22,28 +22,28 @@ print_help() {
|
|||||||
--release,-r,--version,-v RELEASE ("snapshot", "22.03.5")
|
--release,-r,--version,-v RELEASE ("snapshot", "22.03.5")
|
||||||
--buildroot,-b PATH
|
--buildroot,-b PATH
|
||||||
Default: location of openwrtbuilder script
|
Default: location of openwrtbuilder script
|
||||||
--source
|
--source[=CLEAN]
|
||||||
Build image from source, not from Image Builder
|
Build image from source, not from Image Builder
|
||||||
|
Optional CLEAN runs the given clean mode before building
|
||||||
|
(clean|targetclean|dirclean|distclean)
|
||||||
--ssh-upgrade HOST
|
--ssh-upgrade HOST
|
||||||
Examples: root@192.168.1.1, root@router.lan
|
Examples: root@192.168.1.1, root@router.lan
|
||||||
--ssh-backup SSH_PATH
|
--ssh-backup SSH_PATH
|
||||||
Enabled by default for --ssh-upgrade
|
Enabled by default for --ssh-upgrade
|
||||||
--flash,-f DEVICE
|
--flash,-f DEVICE
|
||||||
Example: /dev/sdX
|
Example: /dev/sdX
|
||||||
--reset
|
--depends
|
||||||
Cleanup all source and output files
|
Force dependency installation
|
||||||
--yes,-y
|
--yes,-y
|
||||||
Assume yes for all questions (automatic mode)
|
Assume yes for all questions (automatic mode)
|
||||||
--verbose
|
|
||||||
Make make or imagebuilder noisier
|
|
||||||
--debug,-d
|
--debug,-d
|
||||||
--help,-h
|
--help,-h
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
./openwrtbuilder -p r4s -r snapshot
|
openwrtbuilder -p r4s -r snapshot
|
||||||
./openwrtbuilder -p ax6000 -r 23.05.0-rc3 --source --debug
|
openwrtbuilder -p ax6000 -r 23.05.0-rc3 --source --debug
|
||||||
./openwrtbuilder -p rpi4 -r 22.03.3 --flash /dev/sdX
|
openwrtbuilder -p rpi4 -r 24.10.0 --flash /dev/sdX
|
||||||
./openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1
|
openwrtbuilder -p linksys -r snapshot --ssh-upgrade root@192.168.1.1
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ init() {
|
|||||||
|
|
||||||
# Save the script directory
|
# Save the script directory
|
||||||
# https://stackoverflow.com/a/4774063
|
# https://stackoverflow.com/a/4774063
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit $? ; pwd -P)"
|
SCRIPT_DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
|
||||||
|
|
||||||
if [[ -e "/etc/os-release" ]]; then
|
if [[ -e "/etc/os-release" ]]; then
|
||||||
source "/etc/os-release"
|
source "/etc/os-release"
|
||||||
@@ -124,10 +124,10 @@ init() {
|
|||||||
parse_input() {
|
parse_input() {
|
||||||
debug "${FUNCNAME[0]}" "$*"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
declare -ga PROFILES
|
declare -ga PROFILES
|
||||||
declare -g RESET=0 FROM_SOURCE=0 YES=0 VERBOSE=0 DEBUG=0
|
declare -gi RESET=0 FROM_SOURCE=0 YES=0 DEBUG=0 FORCE_DEPENDS=0
|
||||||
declare -g USER_RELEASE SSH_UPGRADE_PATH SSH_BACKUP_PATH FLASH_DEV
|
declare -g USER_RELEASE SSH_UPGRADE_PATH SSH_BACKUP_PATH FLASH_DEV SOURCE_CLEAN
|
||||||
local long_opts='release:,version:,profile:,buildroot:,source,'
|
local long_opts='release:,version:,profile:,buildroot:,source::,'
|
||||||
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,yes,verbose,debug,help'
|
long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,depends,yes,debug,help'
|
||||||
|
|
||||||
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
if _input=$(getopt -o +r:v:p:b:sf:ydh -l $long_opts -- "$@"); then
|
||||||
eval set -- "$_input"
|
eval set -- "$_input"
|
||||||
@@ -136,13 +136,18 @@ parse_input() {
|
|||||||
--release|-r|--version|-v) shift; USER_RELEASE="$1" ;;
|
--release|-r|--version|-v) shift; USER_RELEASE="$1" ;;
|
||||||
--profile|-p) shift; PROFILES+=("$1") ;;
|
--profile|-p) shift; PROFILES+=("$1") ;;
|
||||||
--buildroot|-b) shift; BUILD_ROOT="$1" ;;
|
--buildroot|-b) shift; BUILD_ROOT="$1" ;;
|
||||||
--source|-s) FROM_SOURCE=1 ;;
|
--source|-s) FROM_SOURCE=1
|
||||||
|
case "$1" in
|
||||||
|
-*|"") ;; # if empty
|
||||||
|
*) SOURCE_CLEAN="$1"; shift ;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
--ssh-upgrade) shift; SSH_UPGRADE_PATH="$1" ;;
|
--ssh-upgrade) shift; SSH_UPGRADE_PATH="$1" ;;
|
||||||
--ssh-backup) shift; SSH_BACKUP_PATH="$1" ;;
|
--ssh-backup) shift; SSH_BACKUP_PATH="$1" ;;
|
||||||
--flash|-f) shift; FLASH_DEV="$1" ;;
|
--flash|-f) shift; FLASH_DEV="$1" ;;
|
||||||
--reset) RESET=1 ;;
|
--reset) RESET=1 ;;
|
||||||
|
--depends) FORCE_DEPENDS=1 ;;
|
||||||
--yes|-y) YES=1 ;;
|
--yes|-y) YES=1 ;;
|
||||||
--verbose) VERBOSE=1 ;;
|
|
||||||
--debug|-d) echo "Debugging on"; DEBUG=1 ;;
|
--debug|-d) echo "Debugging on"; DEBUG=1 ;;
|
||||||
--help|-h) print_help; exit 0 ;;
|
--help|-h) print_help; exit 0 ;;
|
||||||
--) shift; break ;;
|
--) shift; break ;;
|
||||||
@@ -156,163 +161,214 @@ parse_input() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# @description Install build dependencies on major distros
|
# @description Install build dependencies on major distros
|
||||||
|
# @arg $1 string Build mode ("source" or "imagebuilder")
|
||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
|
local mode="$1"
|
||||||
local -a pkg_list
|
local -a pkg_list
|
||||||
local lock_file
|
local lock_file
|
||||||
if ((FROM_SOURCE)); then
|
|
||||||
lock_file="$BUILD_ROOT/.dependencies_source"
|
# Set appropriate lock file based on mode
|
||||||
else
|
if [[ "$mode" == "source" ]]; then
|
||||||
lock_file="$BUILD_ROOT/.dependencies_ib"
|
lock_file="$BUILD_ROOT/.dependencies_source.lock"
|
||||||
|
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||||
|
lock_file="$BUILD_ROOT/.dependencies_ib.lock"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f $lock_file ]]; then
|
[[ -f $lock_file ]] && debug "$lock_file lock file exists but skipping for --debug" && return 0
|
||||||
if ((FROM_SOURCE)); then
|
|
||||||
# For building from source code
|
|
||||||
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
|
||||||
case "$ID" in
|
|
||||||
fedora|centos)
|
|
||||||
pkg_list+=(
|
|
||||||
bash-completion
|
|
||||||
bzip2
|
|
||||||
gcc
|
|
||||||
gcc-c++
|
|
||||||
git
|
|
||||||
make
|
|
||||||
ncurses-devel
|
|
||||||
patch
|
|
||||||
rsync
|
|
||||||
tar
|
|
||||||
unzip
|
|
||||||
wget
|
|
||||||
which
|
|
||||||
diffutils
|
|
||||||
python3
|
|
||||||
python3-devel
|
|
||||||
python3-setuptools
|
|
||||||
python3-pyelftools
|
|
||||||
perl-base
|
|
||||||
perl-Data-Dumper
|
|
||||||
perl-File-Compare
|
|
||||||
perl-File-Copy
|
|
||||||
perl-FindBin
|
|
||||||
perl-IPC-Cmd
|
|
||||||
perl-Thread-Queue
|
|
||||||
perl-Time-Piece
|
|
||||||
perl-JSON-PP
|
|
||||||
swig
|
|
||||||
clang # for qosify
|
|
||||||
llvm15-libs
|
|
||||||
patch)
|
|
||||||
;;
|
|
||||||
debian|ubuntu)
|
|
||||||
pkg_list+=(
|
|
||||||
build-essential
|
|
||||||
clang
|
|
||||||
flex
|
|
||||||
g++
|
|
||||||
gawk
|
|
||||||
gcc-multilib
|
|
||||||
gettext
|
|
||||||
git
|
|
||||||
libncurses5-dev
|
|
||||||
libssl-dev
|
|
||||||
python3-distutils
|
|
||||||
rsync
|
|
||||||
unzip
|
|
||||||
zlib1g-dev
|
|
||||||
file
|
|
||||||
wget
|
|
||||||
patch)
|
|
||||||
;;
|
|
||||||
arch)
|
|
||||||
pkg_list+=(
|
|
||||||
base-devel
|
|
||||||
autoconf
|
|
||||||
automake
|
|
||||||
bash
|
|
||||||
binutils
|
|
||||||
bison
|
|
||||||
bzip2
|
|
||||||
clang
|
|
||||||
fakeroot
|
|
||||||
file
|
|
||||||
findutils
|
|
||||||
flex
|
|
||||||
gawk
|
|
||||||
gcc
|
|
||||||
gettext
|
|
||||||
git
|
|
||||||
grep
|
|
||||||
groff
|
|
||||||
gzip
|
|
||||||
libelf
|
|
||||||
libtool
|
|
||||||
libxslt
|
|
||||||
m4
|
|
||||||
make
|
|
||||||
ncurses
|
|
||||||
openssl
|
|
||||||
patch
|
|
||||||
pkgconf
|
|
||||||
python
|
|
||||||
rsync
|
|
||||||
sed
|
|
||||||
texinfo
|
|
||||||
time
|
|
||||||
unzip
|
|
||||||
util-linux
|
|
||||||
wget
|
|
||||||
which
|
|
||||||
zlib
|
|
||||||
patch)
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
debug "Skipping dependency install, your OS is unsupported"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
# For Imagebuilder
|
|
||||||
case "$ID" in
|
|
||||||
fedora|centos)
|
|
||||||
pkg_list+=(
|
|
||||||
@c-development
|
|
||||||
@development-tools
|
|
||||||
@development-libs
|
|
||||||
perl-FindBin
|
|
||||||
zlib-static
|
|
||||||
elfutils-libelf-devel
|
|
||||||
gawk
|
|
||||||
unzip
|
|
||||||
file
|
|
||||||
wget
|
|
||||||
python3
|
|
||||||
axel
|
|
||||||
perl-IPC-Cmd
|
|
||||||
zstd) ;;
|
|
||||||
debian|ubuntu)
|
|
||||||
pkg_list+=(
|
|
||||||
build-essential
|
|
||||||
libncurses5-dev
|
|
||||||
libncursesw5-dev
|
|
||||||
zlib1g-dev
|
|
||||||
gawk
|
|
||||||
git
|
|
||||||
gettext
|
|
||||||
libssl-dev
|
|
||||||
xsltproc
|
|
||||||
wget
|
|
||||||
unzip
|
|
||||||
python
|
|
||||||
axel
|
|
||||||
zstd) ;;
|
|
||||||
*) debug "Unsupported OS for automatic dependency install"; return 1 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
if [[ "$mode" == "source" ]]; then
|
||||||
|
# For building from source code see:
|
||||||
|
# https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
|
||||||
|
case "$ID" in
|
||||||
|
fedora|centos)
|
||||||
|
pkg_list+=(
|
||||||
|
bzip2
|
||||||
|
clang # for qosify
|
||||||
|
diffutils
|
||||||
|
gcc
|
||||||
|
gcc-c++
|
||||||
|
git
|
||||||
|
golang
|
||||||
|
llvm15-libs # for qosify
|
||||||
|
make
|
||||||
|
ncurses-devel
|
||||||
|
patch
|
||||||
|
perl
|
||||||
|
perl-Data-Dumper
|
||||||
|
perl-File-Compare
|
||||||
|
perl-File-Copy
|
||||||
|
perl-FindBin
|
||||||
|
perl-IPC-Cmd
|
||||||
|
perl-JSON-PP
|
||||||
|
perl-Thread-Queue
|
||||||
|
perl-Time-Piece
|
||||||
|
perl-base
|
||||||
|
python3
|
||||||
|
python3-devel
|
||||||
|
python3-pyelftools
|
||||||
|
python3-setuptools
|
||||||
|
quilt
|
||||||
|
rsync
|
||||||
|
swig
|
||||||
|
tar
|
||||||
|
unzip
|
||||||
|
wget
|
||||||
|
which
|
||||||
|
) ;;
|
||||||
|
debian|ubuntu)
|
||||||
|
pkg_list+=(
|
||||||
|
build-essential
|
||||||
|
clang
|
||||||
|
file
|
||||||
|
flex
|
||||||
|
g++
|
||||||
|
gawk
|
||||||
|
gcc-multilib
|
||||||
|
gettext
|
||||||
|
git
|
||||||
|
golang
|
||||||
|
liblzma-dev
|
||||||
|
libncurses5-dev
|
||||||
|
libssl-dev
|
||||||
|
python3-distutils
|
||||||
|
quilt
|
||||||
|
rsync
|
||||||
|
patch
|
||||||
|
unzip
|
||||||
|
wget
|
||||||
|
zlib1g-dev
|
||||||
|
) ;;
|
||||||
|
arch)
|
||||||
|
pkg_list+=(
|
||||||
|
autoconf
|
||||||
|
automake
|
||||||
|
base-devel
|
||||||
|
bash
|
||||||
|
binutils
|
||||||
|
bison
|
||||||
|
bzip2
|
||||||
|
clang
|
||||||
|
fakeroot
|
||||||
|
file
|
||||||
|
findutils
|
||||||
|
flex
|
||||||
|
gawk
|
||||||
|
gcc
|
||||||
|
gettext
|
||||||
|
git
|
||||||
|
golang
|
||||||
|
grep
|
||||||
|
groff
|
||||||
|
gzip
|
||||||
|
libelf
|
||||||
|
libtool
|
||||||
|
libxslt
|
||||||
|
m4
|
||||||
|
make
|
||||||
|
ncurses
|
||||||
|
net-snmp
|
||||||
|
openssl
|
||||||
|
patch
|
||||||
|
pkgconf
|
||||||
|
python
|
||||||
|
quilt
|
||||||
|
rsync
|
||||||
|
sed
|
||||||
|
texinfo
|
||||||
|
time
|
||||||
|
unzip
|
||||||
|
util-linux
|
||||||
|
wget
|
||||||
|
which
|
||||||
|
xz
|
||||||
|
zlib
|
||||||
|
) ;;
|
||||||
|
*) debug "Unsupported OS, skipping dependency install"; return 1 ;;
|
||||||
|
esac
|
||||||
|
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||||
|
# For Imagebuilder
|
||||||
|
case "$ID" in
|
||||||
|
fedora|centos)
|
||||||
|
pkg_list+=(
|
||||||
|
@c-development
|
||||||
|
@development-tools
|
||||||
|
@development-libs
|
||||||
|
perl-FindBin
|
||||||
|
zlib-static
|
||||||
|
elfutils-libelf-devel
|
||||||
|
gawk
|
||||||
|
unzip
|
||||||
|
file
|
||||||
|
wget
|
||||||
|
python3
|
||||||
|
axel
|
||||||
|
perl-IPC-Cmd
|
||||||
|
zstd) ;;
|
||||||
|
debian|ubuntu)
|
||||||
|
pkg_list+=(
|
||||||
|
build-essential
|
||||||
|
libncurses5-dev
|
||||||
|
libncursesw5-dev
|
||||||
|
zlib1g-dev
|
||||||
|
gawk
|
||||||
|
git
|
||||||
|
gettext
|
||||||
|
libssl-dev
|
||||||
|
xsltproc
|
||||||
|
wget
|
||||||
|
unzip
|
||||||
|
python
|
||||||
|
axel
|
||||||
|
zstd) ;;
|
||||||
|
*) debug "Unsupported OS, skipping dependency install"; return 1 ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pkg_install "${pkg_list[@]}" && echo "${pkg_list[@]}" > "$lock_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# @description Normalize release and set worktree reference
|
||||||
|
# @arg $1 string Raw release input
|
||||||
|
# @arg $2 string Build mode ("source" or "imagebuilder")
|
||||||
|
# @returns string Normalized release and reference
|
||||||
|
normalize_and_ref() {
|
||||||
|
local input="$1" mode="$2"
|
||||||
|
local rel ref branch tag
|
||||||
|
|
||||||
|
case "$input" in
|
||||||
|
snapshot|latest|main|master)
|
||||||
|
rel="snapshot"
|
||||||
|
ref="main"
|
||||||
|
;;
|
||||||
|
v[0-9][0-9].[0-9][0-9].*|[0-9][0-9].[0-9][0-9].*)
|
||||||
|
# strip optional leading “v”
|
||||||
|
rel="${input#v}"
|
||||||
|
if [[ "$mode" == "source" ]]; then
|
||||||
|
branch="openwrt-${rel%.*}"
|
||||||
|
tag="v$rel"
|
||||||
|
if ask_ok "Use branch $branch HEAD (y) or tag $tag (n)?"; then
|
||||||
|
ref="$branch"
|
||||||
|
else
|
||||||
|
ref="$tag"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
ref="$rel"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ "$mode" == "source" ]]; then
|
||||||
|
# arbitrary commit-ish allowed
|
||||||
|
rel="$input"
|
||||||
|
ref="$input"
|
||||||
|
else
|
||||||
|
echo "Error: invalid release '$input'" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf '%s %s' "$rel" "$ref"
|
||||||
}
|
}
|
||||||
|
|
||||||
# @description Acquires the OpenWRT Image Builder
|
# @description Acquires the OpenWRT Image Builder
|
||||||
@@ -337,17 +393,6 @@ get_imagebuilder() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
add_repos() {
|
|
||||||
debug "${FUNCNAME[0]}"
|
|
||||||
|
|
||||||
if [[ -v P_ARR[repo] ]]; then
|
|
||||||
if ! grep -q "${P_ARR[repo]}" "$BUILD_DIR/repositories.conf"; then
|
|
||||||
echo "${P_ARR[repo]}" >> "$BUILD_DIR/repositories.conf"
|
|
||||||
fi
|
|
||||||
sed -i '/option check_signature/d' "$BUILD_DIR/repositories.conf"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ssh_backup() {
|
ssh_backup() {
|
||||||
debug "${FUNCNAME[0]}"
|
debug "${FUNCNAME[0]}"
|
||||||
local date hostname backup_fname
|
local date hostname backup_fname
|
||||||
@@ -391,7 +436,7 @@ make_images() {
|
|||||||
# fi
|
# fi
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
((VERBOSE)) && make_opts+=("V=s")
|
((DEBUG)) && make_opts+=("V=sc")
|
||||||
|
|
||||||
debug make "${make_opts[@]}" image BIN_DIR="$BIN_DIR" \
|
debug make "${make_opts[@]}" image BIN_DIR="$BIN_DIR" \
|
||||||
PROFILE="$DEVICE" PACKAGES="$PACKAGES" \
|
PROFILE="$DEVICE" PACKAGES="$PACKAGES" \
|
||||||
@@ -461,87 +506,115 @@ ssh_upgrade() {
|
|||||||
# @description Builds OpenWRT from source code using the the default buildbot as base
|
# @description Builds OpenWRT from source code using the the default buildbot as base
|
||||||
# This enables the use of kernel config options in profiles
|
# This enables the use of kernel config options in profiles
|
||||||
# @arg $1 string .config seed URL
|
# @arg $1 string .config seed URL
|
||||||
|
# @arg $2 string Profile name
|
||||||
|
# @arg $3 string Worktree ref (commit-ish or branch name)
|
||||||
from_source() {
|
from_source() {
|
||||||
debug "${FUNCNAME[0]}" "$*"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
local seed_url="$1"
|
local seed_url="$1"
|
||||||
|
local profile="$2"
|
||||||
|
local ref="$3"
|
||||||
local src_url="https://github.com/openwrt/openwrt.git"
|
local src_url="https://github.com/openwrt/openwrt.git"
|
||||||
local seed_file="$WORKTREE_DIR/.config"
|
local seed_file="$BUILD_DIR/.config"
|
||||||
local pkg config commit seed_file wt_commit description
|
local worktree_meta="$SRC_DIR/.git/worktrees/source-$ref"
|
||||||
local -a make_opts config_opts
|
local pkg config commit seed_file description
|
||||||
|
local -a make_opts
|
||||||
|
local -a config_opts=(
|
||||||
|
"CONFIG_TARGET_${TARGET%%/*}=y"
|
||||||
|
"CONFIG_TARGET_${TARGET//\//_}=y"
|
||||||
|
"CONFIG_TARGET_PROFILE=DEVICE_$DEVICE"
|
||||||
|
"CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y"
|
||||||
|
"CONFIG_TARGET_ROOTFS_${FILESYSTEM^^}=y"
|
||||||
|
"CONFIG_TARGET_MULTI_PROFILE=n"
|
||||||
|
"CONFIG_BUILDBOT=n"
|
||||||
|
"CONFIG_ALL_KMODS=n"
|
||||||
|
"CONFIG_ALL_NONSHARED=n"
|
||||||
|
"CONFIG_DEVEL=n"
|
||||||
|
"CONFIG_COLLECT_KERNEL_DEBUG=n"
|
||||||
|
"CONFIG_SDK=n"
|
||||||
|
"CONFIG_SDK_LLVM_BPF=n"
|
||||||
|
"CONFIG_IB=n"
|
||||||
|
"CONFIG_MAKE_TOOLCHAIN=n"
|
||||||
|
"CONFIG_TARGET_PER_DEVICE_ROOTFS=n"
|
||||||
|
)
|
||||||
|
|
||||||
echo "Building from source is under development"
|
echo "Building from source is under development"
|
||||||
|
|
||||||
# Update source code
|
# Remove all build directories and worktrees if --reset
|
||||||
if [[ ! -d "$SRC_DIR" ]]; then
|
if ((RESET)); then
|
||||||
|
if [[ -d "$BUILD_DIR" || -d "$worktree_meta" ]]; then
|
||||||
|
execute git -C "$SRC_DIR" worktree remove --force --force "$BUILD_DIR"
|
||||||
|
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
||||||
|
[[ -d "$worktree_meta" ]] && execute rm -rf "$worktree_meta"
|
||||||
|
fi
|
||||||
|
[[ -d "$BUILD_DIR" ]] && execute rm -rf "$BUILD_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fetch or clone source repo (no local merges)
|
||||||
|
if [[ -d "$SRC_DIR" ]]; then
|
||||||
|
execute git -C "$SRC_DIR" fetch origin --tags --prune
|
||||||
|
else
|
||||||
execute mkdir -p "$SRC_DIR"
|
execute mkdir -p "$SRC_DIR"
|
||||||
execute git clone "$src_url" "$SRC_DIR"
|
execute git clone "$src_url" "$SRC_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git -C "$SRC_DIR" pull
|
# Reuse worktree if present; otherwise create it (support branches and tags)
|
||||||
|
if git -C "$BUILD_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
# Generate commitish for git worktree
|
execute git -C "$BUILD_DIR" fetch origin --tags --prune
|
||||||
case "$RELEASE" in
|
execute git -C "$BUILD_DIR" reset --hard "origin/$ref" || \
|
||||||
snapshot) wt_commit="origin/main" ;;
|
execute git -C "$BUILD_DIR" reset --hard "$ref" || \
|
||||||
[0-9][0-9].[0-9][0-9].*)
|
execute git -C "$BUILD_DIR" checkout --detach "$ref"
|
||||||
local branch="openwrt-${RELEASE%.*}"
|
|
||||||
local tag="v$RELEASE"
|
|
||||||
if ask_ok "Use $branch branch HEAD (y, recommended) or $tag tag (N)?"; then
|
|
||||||
wt_commit="origin/$branch"
|
|
||||||
else
|
|
||||||
wt_commit="$tag"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
debug "Passing '$RELEASE' commit-ish to git worktree"
|
|
||||||
wt_commit="$RELEASE"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# TODO There's a bug in the make clean functions that seem to invoke a full make
|
|
||||||
if [[ -d "$WORKTREE_DIR" ]]; then
|
|
||||||
execute git -C "$WORKTREE_DIR" checkout "$wt_commit"
|
|
||||||
execute git -C "$WORKTREE_DIR" pull
|
|
||||||
else
|
else
|
||||||
execute git -C "$SRC_DIR" worktree add --force --detach "$WORKTREE_DIR" "$wt_commit"
|
execute git -C "$SRC_DIR" worktree prune --verbose
|
||||||
|
# Prefer local tag/branch if present, otherwise use remote-tracking branch
|
||||||
|
if ! execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "$ref"; then
|
||||||
|
execute git -C "$SRC_DIR" worktree add --detach "$BUILD_DIR" "origin/$ref"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# To workaround bug, don't use make *clean, blow it away and start fresh
|
# Add cherrypick commits if specified in profile (skip if already included)
|
||||||
# [[ -d "$WORKTREE_DIR" ]] && execute rm -rf "$WORKTREE_DIR"
|
for entry in ${P_ARR[cherrypicks]}; do
|
||||||
# execute git -C "$SRC_DIR" worktree add --force --detach "$WORKTREE_DIR" "$wt_commit"
|
remote="${entry%%:*}"
|
||||||
|
commit="${entry##*:}"
|
||||||
# Print commit information
|
if ! git -C "$BUILD_DIR" remote | grep -q "^$remote$"; then
|
||||||
commit=$(git -C "$WORKTREE_DIR" rev-parse HEAD)
|
execute git -C "$BUILD_DIR" remote add "$remote" "https://github.com/$remote/openwrt.git"
|
||||||
description=$(git -C "$WORKTREE_DIR" describe)
|
fi
|
||||||
|
execute git -C "$BUILD_DIR" fetch "$remote"
|
||||||
|
execute git -C "$BUILD_DIR" merge-base --is-ancestor "$commit" HEAD ||
|
||||||
|
execute git -C "$BUILD_DIR" cherry-pick "$commit"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Print commit info
|
||||||
|
commit=$(git -C "$BUILD_DIR" rev-parse HEAD)
|
||||||
|
description=$(git -C "$BUILD_DIR" describe --always --dirty)
|
||||||
echo "Current commit hash: $commit"
|
echo "Current commit hash: $commit"
|
||||||
echo "Git worktree description: $description"
|
echo "Git worktree description: $description"
|
||||||
|
|
||||||
((DEBUG)) && git --no-pager -C "$WORKTREE_DIR" log -1
|
((DEBUG)) && git --no-pager -C "$BUILD_DIR" log -1
|
||||||
|
|
||||||
# Enter worktree
|
# Enter worktree
|
||||||
execute pushd "$WORKTREE_DIR" || return 1
|
execute pushd "$BUILD_DIR" || return 1
|
||||||
|
|
||||||
# Cleanup build environment
|
# Begin OpenWRT build process
|
||||||
((VERBOSE)) && make_opts+=("V=s")
|
((DEBUG)) && make_opts+=("V=sc")
|
||||||
execute make "${make_opts[@]}" "-j1" dirclean
|
|
||||||
|
# Cleanup build environment: heavy clean only when --reset was used earlier
|
||||||
# make clean # compiled output
|
# make clean # compiled output
|
||||||
# make targetclean # compiled output, toolchain
|
# make targetclean # compiled output, toolchain
|
||||||
# make dirclean # compiled output, toolchain, build tools
|
# make dirclean # compiled output, toolchain, build tools
|
||||||
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
# make distclean # compiled output, toolchain, build tools, .config, feeds, .ccache
|
||||||
|
if [[ -n $SOURCE_CLEAN ]]; then
|
||||||
|
execute make "${make_opts[@]}" "-j1" "$SOURCE_CLEAN"
|
||||||
|
else
|
||||||
|
debug "Skipping cleanup step"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use a custom (faster) mirror
|
||||||
|
execute sed -i -E 's;git.openwrt.org/(feed|project);github.com/openwrt;' feeds.conf.default
|
||||||
|
|
||||||
# Update package feed
|
# Update package feed
|
||||||
./scripts/feeds update -i -f &&
|
|
||||||
./scripts/feeds update -a -f &&
|
./scripts/feeds update -a -f &&
|
||||||
./scripts/feeds install -a -f
|
./scripts/feeds install -a -f
|
||||||
|
|
||||||
# Grab the release seed config
|
|
||||||
if ! execute "$DL_TOOL" "-o" "$seed_file" "$seed_url"; then
|
|
||||||
echo "Could not obtain $seed_file from $seed_url"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set compilation output dir
|
|
||||||
config_opts+=("CONFIG_BINARY_FOLDER=\"$BIN_DIR\"")
|
|
||||||
|
|
||||||
# Add custom packages
|
# Add custom packages
|
||||||
for pkg in $PACKAGES; do
|
for pkg in $PACKAGES; do
|
||||||
if [[ $pkg == -* ]]; then
|
if [[ $pkg == -* ]]; then
|
||||||
@@ -551,53 +624,37 @@ from_source() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add config options from profile
|
# Add profile config options
|
||||||
for config in ${P_ARR[config]}; do
|
for config in ${P_ARR[config]}; do
|
||||||
config_opts+=("$config")
|
config_opts+=("$config")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Only compile selected fs
|
# Reset and write options to config seed file
|
||||||
execute sed -i '/CONFIG_TARGET_ROOTFS_/d' "$seed_file"
|
[[ -f $seed_file ]] && execute rm -f "$seed_file"
|
||||||
config_opts+=("CONFIG_TARGET_PER_DEVICE_ROOTFS=n")
|
|
||||||
if [[ $FILESYSTEM == "squashfs" ]]; then
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=y")
|
|
||||||
elif [[ $FILESYSTEM == "ext4" ]]; then
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_SQUASHFS=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_ROOTFS_EXT4FS=y")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only compile selected target image
|
|
||||||
execute sed -i '/CONFIG_TARGET_DEVICE_/d' "$seed_file"
|
|
||||||
config_opts+=("CONFIG_TARGET_MULTI_PROFILE=n")
|
|
||||||
config_opts+=("CONFIG_TARGET_PROFILE=DEVICE_$DEVICE")
|
|
||||||
config_opts+=("CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y")
|
|
||||||
config_opts+=("CONFIG_SDK=n")
|
|
||||||
config_opts+=("CONFIG_SDK_LLVM_BPF=n")
|
|
||||||
config_opts+=("CONFIG_IB=n")
|
|
||||||
config_opts+=("CONFIG_MAKE_TOOLCHAIN=n")
|
|
||||||
|
|
||||||
# Write options to config seed file
|
|
||||||
for config in "${config_opts[@]}"; do
|
for config in "${config_opts[@]}"; do
|
||||||
debug "Writing $config to $seed_file"
|
debug "Writing $config to $seed_file"
|
||||||
echo "$config" >> "$seed_file"
|
echo "$config" >> "$seed_file"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make prep
|
# Expand seed into full config
|
||||||
execute make "${make_opts[@]}" "-j1" defconfig
|
execute make "${make_opts[@]}" "-j1" defconfig
|
||||||
|
|
||||||
|
# Run serial make download for better reliability
|
||||||
execute make "${make_opts[@]}" "-j1" download
|
execute make "${make_opts[@]}" "-j1" download
|
||||||
# ((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)+1))")
|
|
||||||
make_opts+=("-j$(($(nproc)+1))")
|
# (Optional) Disable multicore make world
|
||||||
|
# ((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
||||||
|
make_opts+=("-j$(($(nproc)-2))")
|
||||||
|
|
||||||
# Make image
|
# Make image
|
||||||
if ! execute ionice -c 3 chrt --idle 0 nice -n19 make "${make_opts[@]}" world; then
|
if ! execute ionice -c2 -n7 nice -n19 make "${make_opts[@]}" BIN_DIR="$BIN_DIR" world; then
|
||||||
echo "Error: make failed"
|
echo "Error: make failed"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
execute popd || return 1
|
execute popd || return 1
|
||||||
|
|
||||||
# Symlink output images to root of BIN_DIR (match Image Builder)
|
# Symlink output images to root of BIN_DIR (match Image Builder behavior)
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
for image in "$BIN_DIR/targets/${TARGET}/"*.{img,img.gz,ubi}; do
|
||||||
execute ln -fs "$image" "$BIN_DIR/${image##*/}"
|
execute ln -fs "$image" "$BIN_DIR/${image##*/}"
|
||||||
@@ -615,7 +672,7 @@ backup() {
|
|||||||
local file="$1" dir="$2"
|
local file="$1" dir="$2"
|
||||||
local creation_date base_name backup_file
|
local creation_date base_name backup_file
|
||||||
|
|
||||||
[[ -f $file ]] || { debug "File not found: $file"; return 1; }
|
[[ -f $file ]] || return 1
|
||||||
[[ -d $dir ]] || execute mkdir -p "$dir" || { debug "Failed to create directory: $dir"; return 1; }
|
[[ -d $dir ]] || execute mkdir -p "$dir" || { debug "Failed to create directory: $dir"; return 1; }
|
||||||
|
|
||||||
if creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" 2>/dev/null) && \
|
if creation_date=$(stat -c %w "$file" 2>/dev/null || stat -c %y "$file" 2>/dev/null) && \
|
||||||
@@ -704,8 +761,13 @@ main() {
|
|||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_dependencies
|
# Remove dependency lock files for --depends
|
||||||
|
if ((FORCE_DEPENDS)); then
|
||||||
|
[[ -f "$BUILD_ROOT/.dependencies_source.lock" ]] && rm -f "$BUILD_ROOT/.dependencies_source.lock"
|
||||||
|
[[ -f "$BUILD_ROOT/.dependencies_ib.lock" ]] && rm -f "$BUILD_ROOT/.dependencies_ib.lock"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run selected profiles
|
||||||
for profile in "${PROFILES[@]}"; do
|
for profile in "${PROFILES[@]}"; do
|
||||||
debug "Running profile: $profile"
|
debug "Running profile: $profile"
|
||||||
|
|
||||||
@@ -715,40 +777,34 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Store profile in P_ARR nameref
|
# Store profile in P_ARR nameref
|
||||||
declare -gn P_ARR="$profile"
|
local -n P_ARR="$profile"
|
||||||
|
local mode="${P_ARR[mode]:-"imagebuilder"}"
|
||||||
|
((FROM_SOURCE)) && mode="source" # allow cli override
|
||||||
|
install_dependencies "$mode"
|
||||||
|
local repo="${P_ARR[repo]:-}"
|
||||||
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}"
|
||||||
declare -g TARGET="${P_ARR[target]}"
|
declare -g TARGET="${P_ARR[target]}"
|
||||||
declare -g DEVICE="${P_ARR[device]}"
|
declare -g DEVICE="${P_ARR[device]}"
|
||||||
declare -g PACKAGES="${P_ARR[packages]:-}"
|
declare -g PACKAGES="${P_ARR[packages]:-}"
|
||||||
declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
|
||||||
|
|
||||||
# normalize RELEASE
|
# pull in USER_RELEASE from args or profile default
|
||||||
case "$RELEASE" in
|
local raw_release="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}"
|
||||||
snapshot|latest|main|master) RELEASE="snapshot" ;;
|
|
||||||
v[0-9][0-9].[0-9][0-9].*) RELEASE="${RELEASE#v}" ;;
|
|
||||||
[0-9][0-9].[0-9][0-9].*) ;;
|
|
||||||
*)
|
|
||||||
if ! ((FROM_SOURCE)); then
|
|
||||||
echo "Error: Invalid release version format"
|
|
||||||
echo "Use semantic version, tag, or 'snapshot'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
declare -g SRC_DIR="$BUILD_ROOT/src/openwrt"
|
# single call to normalize+ref
|
||||||
declare -g WORKTREE_DIR="$BUILD_ROOT/src/$profile/$RELEASE-src"
|
read -r release ref < <(normalize_and_ref "$raw_release" "$mode")
|
||||||
declare -g BUILD_DIR="$BUILD_ROOT/src/$profile/$RELEASE"
|
|
||||||
declare -g BIN_DIR="$BUILD_ROOT/bin/$profile/$RELEASE"
|
|
||||||
|
|
||||||
if [[ "$RELEASE" == "snapshot" ]]; then
|
declare -g SRC_DIR="$BUILD_ROOT/src/.openwrt"
|
||||||
|
declare -g BUILD_DIR="$BUILD_ROOT/src/$profile/$ref-$mode"
|
||||||
|
declare -g BIN_DIR="$BUILD_ROOT/bin/$profile/$ref-$mode"
|
||||||
|
|
||||||
|
if [[ "$release" == "snapshot" ]]; then
|
||||||
local url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
local url_prefix="https://downloads.openwrt.org/snapshots/targets/$TARGET"
|
||||||
local url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
local url_filename="openwrt-imagebuilder-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
||||||
local img_fname="openwrt-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
local img_fname="openwrt-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||||
else
|
else
|
||||||
local url_prefix="https://downloads.openwrt.org/releases/$RELEASE/targets/$TARGET"
|
local url_prefix="https://downloads.openwrt.org/releases/$release/targets/$TARGET"
|
||||||
local url_filename="openwrt-imagebuilder-$RELEASE-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
local url_filename="openwrt-imagebuilder-$release-${TARGET//\//-}.Linux-x86_64.tar.zst"
|
||||||
local img_fname="openwrt-$RELEASE-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
local img_fname="openwrt-$release-${TARGET//\//-}-$DEVICE-$FILESYSTEM"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local ib_url="$url_prefix/$url_filename"
|
local ib_url="$url_prefix/$url_filename"
|
||||||
@@ -757,39 +813,27 @@ main() {
|
|||||||
local ib_sha256_file="$BUILD_DIR/sha256sums"
|
local ib_sha256_file="$BUILD_DIR/sha256sums"
|
||||||
local seed_url="$url_prefix/config.buildinfo"
|
local seed_url="$url_prefix/config.buildinfo"
|
||||||
|
|
||||||
if ((FROM_SOURCE)); then
|
if [[ "$mode" == "source" ]]; then
|
||||||
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$TARGET/$img_fname-sysupgrade.img.gz"
|
declare -g SYSUPGRADEIMGGZ="$BIN_DIR/targets/$TARGET/$img_fname-sysupgrade.img.gz"
|
||||||
else
|
else
|
||||||
declare -g SYSUPGRADEIMGGZ="$BUILD_DIR/$img_fname-sysupgrade.img.gz"
|
declare -g SYSUPGRADEIMGGZ="$BUILD_DIR/$img_fname-sysupgrade.img.gz"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
backup "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$RELEASE"
|
backup "$SYSUPGRADEIMGGZ" "$BACKUP_DIR/$profile/$ref-$mode"
|
||||||
|
|
||||||
if ((RESET)); then
|
if [[ "$mode" == "source" ]]; then
|
||||||
if ((FROM_SOURCE)); then
|
from_source "$seed_url" "$profile" "$ref" || return $?
|
||||||
[[ -d $WORKTREE_DIR ]] && ask_ok "Remove $WORKTREE_DIR?"
|
elif [[ "$mode" == "imagebuilder" ]]; then
|
||||||
execute git worktree remove --force "$WORKTREE_DIR"
|
|
||||||
execute rm -rf "$WORKTREE_DIR"
|
|
||||||
elif [[ -d $BUILD_DIR ]] && ask_ok "Remove $BUILD_DIR?"; then
|
|
||||||
execute rm -rf "$BUILD_DIR"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ((DEBUG)); then
|
|
||||||
echo "Profile settings:"
|
|
||||||
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
|
|
||||||
echo "Environment variables:"
|
|
||||||
declare -p
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ((FROM_SOURCE)); then
|
|
||||||
from_source "$seed_url" || return $?
|
|
||||||
else
|
|
||||||
[[ -d $BUILD_DIR ]] || mkdir -p "$BUILD_DIR"
|
[[ -d $BUILD_DIR ]] || mkdir -p "$BUILD_DIR"
|
||||||
get_imagebuilder "$ib_url" "$ib_file" "$ib_sha256_url" "$ib_sha256_file" &&
|
get_imagebuilder "$ib_url" "$ib_file" "$ib_sha256_url" "$ib_sha256_file" &&
|
||||||
verify "$ib_file" "$ib_sha256_file" &&
|
verify "$ib_file" "$ib_sha256_file" &&
|
||||||
extract "$ib_file" "$BUILD_DIR" || return $?
|
extract "$ib_file" "$BUILD_DIR" || return $?
|
||||||
add_repos
|
if [[ -v $repo ]]; then
|
||||||
|
if ! grep -q "$repo" "$BUILD_DIR/repositories.conf"; then
|
||||||
|
echo "$repo" >> "$BUILD_DIR/repositories.conf"
|
||||||
|
fi
|
||||||
|
sed -i '/option check_signature/d' "$BUILD_DIR/repositories.conf"
|
||||||
|
fi
|
||||||
make_images
|
make_images
|
||||||
# Verify output image for stock builds (in testing)
|
# Verify output image for stock builds (in testing)
|
||||||
if [[ ! -v P_ARR[packages] || -z ${P_ARR[packages]} ]]; then
|
if [[ ! -v P_ARR[packages] || -z ${P_ARR[packages]} ]]; then
|
||||||
@@ -809,5 +853,9 @@ main() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Roughly turn debugging on for pre-init
|
||||||
|
# Reset and reparse in parse_input() with getopt
|
||||||
|
[[ " $* " =~ ( --debug | -d ) ]] && DEBUG=1
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
exit
|
exit
|
||||||
|
|||||||
66
profiles
66
profiles
@@ -1,64 +1,80 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck disable=SC2034
|
|
||||||
# Device profiles for openwrtbuilder
|
# Device profiles for openwrtbuilder
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
# Default packages
|
# Default (but optional) packages (precede with "-" to exclude)
|
||||||
default_packages="luci luci-ssl luci-proto-wireguard luci-app-statistics \
|
default_packages=(nano htop diffutils tar iperf3 zsh rsync curl tcpdump
|
||||||
collectd-mod-sensors collectd-mod-thermal collectd-mod-conntrack \
|
openssh-sftp-server luci luci-ssl luci-proto-wireguard luci-app-statistics
|
||||||
collectd-mod-cpu nano htop diffutils tar iperf3 zsh rsync \
|
collectd-mod-sensors collectd-mod-thermal collectd-mod-conntrack collectd-mod-cpu
|
||||||
openssh-sftp-server"
|
)
|
||||||
|
|
||||||
|
# Default (but optional) kernel configs
|
||||||
|
default_configs=(
|
||||||
|
)
|
||||||
|
|
||||||
# Current devices
|
# Current devices
|
||||||
declare -Ag r4s=(
|
declare -Ag r4s=(
|
||||||
|
[mode]="source"
|
||||||
[device]="friendlyarm_nanopi-r4s"
|
[device]="friendlyarm_nanopi-r4s"
|
||||||
[target]="rockchip/armv8"
|
[target]="rockchip/armv8"
|
||||||
[filesystem]="ext4"
|
[filesystem]="ext4"
|
||||||
[packages]="$default_packages luci-app-ddns luci-app-sqm irqbalance \
|
[packages]="${default_packages[*]} \
|
||||||
|
luci-app-ddns luci-app-sqm \
|
||||||
|
adblock luci-app-adblock \
|
||||||
collectd-mod-df usbutils kmod-usb-storage kmod-usb-storage-uas \
|
collectd-mod-df usbutils kmod-usb-storage kmod-usb-storage-uas \
|
||||||
kmod-fs-btrfs btrfs-progs block-mount smcroute avahi-daemon \
|
kmod-fs-btrfs btrfs-progs block-mount smcroute avahi-daemon \
|
||||||
curl ethtool ca-bundle"
|
ethtool ca-bundle tailscale"
|
||||||
[config]="CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
[config]="${default_configs[*]} \
|
||||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32 \
|
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||||
CONFIG_BUILDBOT=n"
|
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
||||||
[files]="/mnt/backup"
|
[files]="/mnt/backup"
|
||||||
|
# For 24.10 branch (Linux 6.6)
|
||||||
|
# [cherrypicks]="wurzerj:59d6e31 wurzerj:bb251b8" # fix inconsistent reboot
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag ax6000=(
|
declare -Ag ax6000=(
|
||||||
|
[mode]="imagebuilder"
|
||||||
[device]="xiaomi_redmi-router-ax6000-stock"
|
[device]="xiaomi_redmi-router-ax6000-stock"
|
||||||
[target]="mediatek/filogic"
|
[target]="mediatek/filogic"
|
||||||
[release]="snapshot"
|
[release]="snapshot"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4"
|
[packages]="${default_packages[*]} \
|
||||||
|
-dnsmasq -odhcpd-ipv6only -nftables -firewall4 tailscale"
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag ax6000_uboot=(
|
declare -Ag ax6000_uboot=(
|
||||||
|
[mode]="imagebuilder"
|
||||||
[device]="xiaomi_redmi-router-ax6000-ubootmod"
|
[device]="xiaomi_redmi-router-ax6000-ubootmod"
|
||||||
[target]="mediatek/filogic"
|
[target]="mediatek/filogic"
|
||||||
[release]="snapshot"
|
[release]="snapshot"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4"
|
[packages]="${default_packages[*]} \
|
||||||
|
-dnsmasq -odhcpd-ipv6only -nftables -firewall4"
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag n5100=(
|
declare -Ag n5100=(
|
||||||
[device]="generic"
|
[device]="generic"
|
||||||
[target]="x86/64"
|
[target]="x86/64"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages luci-app-ddns irqbalance collectd-mod-df \
|
[packages]="${default_packages[*]} \
|
||||||
|
luci-app-ddns irqbalance collectd-mod-df \
|
||||||
usbutils kmod-usb-storage kmod-usb-storage-uas kmod-fs-btrfs \
|
usbutils kmod-usb-storage kmod-usb-storage-uas kmod-fs-btrfs \
|
||||||
btrfs-progs block-mount cryptsetup kmod-crypto-xts smcroute \
|
btrfs-progs block-mount cryptsetup kmod-crypto-xts smcroute \
|
||||||
avahi-daemon curl ethtool ca-bundle smartmontools intel-microcode \
|
avahi-daemon curl ethtool ca-bundle smartmontools intel-microcode \
|
||||||
lm-sensors samba4-server luci-app-samba4 tailscale shadow-useradd"
|
lm-sensors samba4-server luci-app-samba4 tailscale shadow-useradd"
|
||||||
[config]="CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
[config]="${default_configs[*]} \
|
||||||
|
CONFIG_KERNEL_BTRFS_FS_POSIX_ACL=y CONFIG_BTRFS_PROGS_ZSTD=y \
|
||||||
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
CONFIG_TARGET_ROOTFS_PARTSIZE=512 CONFIG_TARGET_KERNEL_PARTSIZE=32"
|
||||||
[files]="/mnt/backup"
|
# [files]="/mnt/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag rpi4=(
|
declare -Ag rpi4=(
|
||||||
[device]="rpi-4"
|
[device]="rpi-4"
|
||||||
[target]="bcm27xx/bcm2711"
|
[target]="bcm27xx/bcm2711"
|
||||||
[filesystem]="ext4"
|
[filesystem]="ext4"
|
||||||
[packages]="$default_packages kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8152 \
|
[packages]="${default_packages[*]} \
|
||||||
luci-app-upnp luci-app-pbr -dnsmasq dnsmasq-full luci-app-ddns luci-app-sqm"
|
luci-app-upnp luci-app-pbr -dnsmasq dnsmasq-full luci-app-ddns luci-app-sqm \
|
||||||
|
kmod-usb-net-asix-ax88179 kmod-usb-net-rtl8152"
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag r4s_stock=(
|
declare -Ag r4s_stock=(
|
||||||
@@ -72,7 +88,8 @@ declare -Ag totolink=(
|
|||||||
[device]="totolink_x5000r"
|
[device]="totolink_x5000r"
|
||||||
[target]="ramips/mt7621"
|
[target]="ramips/mt7621"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages -dnsmasq -odhcpd-ipv6only -nftables -firewall4 \
|
[packages]="${default_packages[*]} \
|
||||||
|
-dnsmasq -odhcpd-ipv6only -nftables -firewall4 \
|
||||||
-kmod-nft-offload collectd-mod-iwinfo"
|
-kmod-nft-offload collectd-mod-iwinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -80,7 +97,7 @@ declare -Ag archer=(
|
|||||||
[device]="tplink_archer-c7-v2"
|
[device]="tplink_archer-c7-v2"
|
||||||
[target]="ath79/generic"
|
[target]="ath79/generic"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages -dnsmasq -odhcpd -iptables \
|
[packages]="${default_packages[*]} -dnsmasq -odhcpd -iptables \
|
||||||
-ath10k-firmware-qca988x-ct ath10k-firmware-qca988x-ct-full-htt"
|
-ath10k-firmware-qca988x-ct ath10k-firmware-qca988x-ct-full-htt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -88,14 +105,16 @@ declare -Ag linksys=(
|
|||||||
[device]="linksys_ea8300"
|
[device]="linksys_ea8300"
|
||||||
[target]="ipq40xx/generic"
|
[target]="ipq40xx/generic"
|
||||||
[filesystem]="squashfs"
|
[filesystem]="squashfs"
|
||||||
[packages]="$default_packages -dnsmasq -odhcpd -iptables"
|
[packages]="${default_packages[*]} \
|
||||||
|
-dnsmasq -odhcpd -iptables"
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -Ag r2s=(
|
declare -Ag r2s=(
|
||||||
[device]="friendlyarm_nanopi-r2s"
|
[device]="friendlyarm_nanopi-r2s"
|
||||||
[target]="rockchip/armv8"
|
[target]="rockchip/armv8"
|
||||||
[filesystem]="ext4"
|
[filesystem]="ext4"
|
||||||
[packages]="$default_packages luci-app-upnp luci-app-pbr -dnsmasq dnsmasq-full \
|
[packages]="${default_packages[*]} \
|
||||||
|
luci-app-upnp luci-app-pbr -dnsmasq dnsmasq-full \
|
||||||
luci-app-ddns luci-app-sqm luci-app-statistics collectd-mod-sensors \
|
luci-app-ddns luci-app-sqm luci-app-statistics collectd-mod-sensors \
|
||||||
collectd-mod-thermal collectd-mod-conntrack smcroute curl ethtool"
|
collectd-mod-thermal collectd-mod-conntrack smcroute curl ethtool"
|
||||||
)
|
)
|
||||||
@@ -104,7 +123,8 @@ declare -Ag r2s_tr=(
|
|||||||
[device]="friendlyarm_nanopi-r2s"
|
[device]="friendlyarm_nanopi-r2s"
|
||||||
[target]="rockchip/armv8"
|
[target]="rockchip/armv8"
|
||||||
[filesystem]="ext4"
|
[filesystem]="ext4"
|
||||||
[packages]="$default_packages luci-app-upnp luci-app-pbr luci-app-ddns \
|
[packages]="${default_packages[*]} \
|
||||||
|
luci-app-upnp luci-app-pbr luci-app-ddns \
|
||||||
luci-app-statistics collectd-mod-sensors collectd-mod-thermal \
|
luci-app-statistics collectd-mod-sensors collectd-mod-thermal \
|
||||||
collectd-mod-conntrack curl ethtool travelmate"
|
collectd-mod-conntrack curl ethtool travelmate"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user