Compare commits
10 Commits
018a91e216
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b9f1f2f39 | |||
| c5bfc7907b | |||
| 533b0b5ffc | |||
| eba54804d3 | |||
| 09b62923a8 | |||
| 960755e6a2 | |||
| 0fa9b0d85a | |||
| 4de18e6696 | |||
| 3772d373bb | |||
| b75597946d |
@@ -22,18 +22,16 @@ 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
|
||||||
Allows make config options to be passed in profile
|
Optional CLEAN runs the given clean mode before building
|
||||||
Uses git worktree for multi-profile deduplication
|
(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
|
|
||||||
Cleanup all source and output files
|
|
||||||
--depends
|
--depends
|
||||||
Force dependency installation
|
Force dependency installation
|
||||||
--yes,-y
|
--yes,-y
|
||||||
@@ -127,8 +125,8 @@ parse_input() {
|
|||||||
debug "${FUNCNAME[0]}" "$*"
|
debug "${FUNCNAME[0]}" "$*"
|
||||||
declare -ga PROFILES
|
declare -ga PROFILES
|
||||||
declare -gi RESET=0 FROM_SOURCE=0 YES=0 DEBUG=0 FORCE_DEPENDS=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,depends,yes,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
|
||||||
@@ -138,7 +136,12 @@ 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" ;;
|
||||||
@@ -516,16 +519,12 @@ from_source() {
|
|||||||
local pkg config commit seed_file description
|
local pkg config commit seed_file description
|
||||||
local -a make_opts
|
local -a make_opts
|
||||||
local -a config_opts=(
|
local -a config_opts=(
|
||||||
|
"CONFIG_TARGET_${TARGET%%/*}=y"
|
||||||
"CONFIG_TARGET_${TARGET//\//_}=y"
|
"CONFIG_TARGET_${TARGET//\//_}=y"
|
||||||
"CONFIG_TARGET_${TARGET//\//_}_${TARGET##*/}=y"
|
|
||||||
"CONFIG_TARGET_PROFILE=DEVICE_$DEVICE"
|
"CONFIG_TARGET_PROFILE=DEVICE_$DEVICE"
|
||||||
"CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y"
|
"CONFIG_TARGET_${TARGET//\//_}_DEVICE_$DEVICE=y"
|
||||||
"CONFIG_TARGET_ROOTFS_${FILESYSTEM^^}=y"
|
"CONFIG_TARGET_ROOTFS_${FILESYSTEM^^}=y"
|
||||||
|
|
||||||
# Needed?
|
|
||||||
"CONFIG_TARGET_MULTI_PROFILE=n"
|
"CONFIG_TARGET_MULTI_PROFILE=n"
|
||||||
|
|
||||||
# Not sure if needed yet
|
|
||||||
"CONFIG_BUILDBOT=n"
|
"CONFIG_BUILDBOT=n"
|
||||||
"CONFIG_ALL_KMODS=n"
|
"CONFIG_ALL_KMODS=n"
|
||||||
"CONFIG_ALL_NONSHARED=n"
|
"CONFIG_ALL_NONSHARED=n"
|
||||||
@@ -540,7 +539,7 @@ from_source() {
|
|||||||
|
|
||||||
echo "Building from source is under development"
|
echo "Building from source is under development"
|
||||||
|
|
||||||
# Remove all build directories and worktrees
|
# Remove all build directories and worktrees if --reset
|
||||||
if ((RESET)); then
|
if ((RESET)); then
|
||||||
if [[ -d "$BUILD_DIR" || -d "$worktree_meta" ]]; then
|
if [[ -d "$BUILD_DIR" || -d "$worktree_meta" ]]; then
|
||||||
execute git -C "$SRC_DIR" worktree remove --force --force "$BUILD_DIR"
|
execute git -C "$SRC_DIR" worktree remove --force --force "$BUILD_DIR"
|
||||||
@@ -558,11 +557,11 @@ from_source() {
|
|||||||
execute git clone "$src_url" "$SRC_DIR"
|
execute git clone "$src_url" "$SRC_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d "$BUILD_DIR/.git" ]]; then
|
# Reuse worktree if present; otherwise create it (support branches and tags)
|
||||||
# Keep worktree and reset to desired ref (handles branches and tags)
|
if git -C "$BUILD_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
execute git -C "$BUILD_DIR" fetch origin --tags --prune
|
execute git -C "$BUILD_DIR" fetch origin --tags --prune
|
||||||
execute git -C "$BUILD_DIR" reset --hard "origin/$ref" ||
|
execute git -C "$BUILD_DIR" reset --hard "origin/$ref" || \
|
||||||
execute git -C "$BUILD_DIR" reset --hard "$ref" ||
|
execute git -C "$BUILD_DIR" reset --hard "$ref" || \
|
||||||
execute git -C "$BUILD_DIR" checkout --detach "$ref"
|
execute git -C "$BUILD_DIR" checkout --detach "$ref"
|
||||||
else
|
else
|
||||||
execute git -C "$SRC_DIR" worktree prune --verbose
|
execute git -C "$SRC_DIR" worktree prune --verbose
|
||||||
@@ -599,21 +598,18 @@ from_source() {
|
|||||||
((DEBUG)) && make_opts+=("V=sc")
|
((DEBUG)) && make_opts+=("V=sc")
|
||||||
|
|
||||||
# Cleanup build environment: heavy clean only when --reset was used earlier
|
# Cleanup build environment: heavy clean only when --reset was used earlier
|
||||||
if ((RESET)); then
|
|
||||||
execute make "${make_opts[@]}" "-j1" distclean
|
|
||||||
else
|
|
||||||
debug "Skipping distclean for incremental build"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Advanced build environment cleanup options for debugging and future use
|
|
||||||
# execute make "${make_opts[@]}" "-j1" distclean
|
|
||||||
# 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
|
# Use a custom (faster) mirror
|
||||||
# execute sed -i -E 's;git.openwrt.org/(feed|project);github.com/openwrt;' feeds.conf.default
|
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 -a -f &&
|
./scripts/feeds update -a -f &&
|
||||||
@@ -633,7 +629,8 @@ from_source() {
|
|||||||
config_opts+=("$config")
|
config_opts+=("$config")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Write options to config seed file
|
# Reset and write options to config seed file
|
||||||
|
[[ -f $seed_file ]] && execute rm -f "$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"
|
||||||
@@ -642,11 +639,15 @@ from_source() {
|
|||||||
# Expand seed into full config
|
# Expand seed into full config
|
||||||
execute make "${make_opts[@]}" "-j1" defconfig
|
execute make "${make_opts[@]}" "-j1" defconfig
|
||||||
|
|
||||||
# make_opts+=("-j$(($(nproc)-2))")
|
# Run serial make download for better reliability
|
||||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
execute make "${make_opts[@]}" "-j1" download
|
||||||
|
|
||||||
|
# (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[@]}" BIN_DIR="$BIN_DIR" download 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
|
||||||
|
|||||||
2
profiles
2
profiles
@@ -19,7 +19,7 @@ declare -Ag r4s=(
|
|||||||
[target]="rockchip/armv8"
|
[target]="rockchip/armv8"
|
||||||
[filesystem]="ext4"
|
[filesystem]="ext4"
|
||||||
[packages]="${default_packages[*]} \
|
[packages]="${default_packages[*]} \
|
||||||
luci-app-ddns luci-app-sqm irqbalance \
|
luci-app-ddns luci-app-sqm \
|
||||||
adblock luci-app-adblock \
|
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 \
|
||||||
|
|||||||
Reference in New Issue
Block a user