Add optional build clean arg to --source
This commit is contained in:
@@ -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" ;;
|
||||||
@@ -540,7 +543,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"
|
||||||
@@ -599,18 +602,15 @@ 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
|
||||||
@@ -640,13 +640,14 @@ from_source() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Expand seed into full config
|
# Expand seed into full config
|
||||||
execute make "-j1" defconfig
|
execute make "${make_opts[@]}" "-j1" defconfig
|
||||||
|
|
||||||
# Run serial make download for better reliability
|
# Run serial make download for better reliability
|
||||||
execute make "-j1" download
|
execute make "${make_opts[@]}" "-j1" download
|
||||||
|
|
||||||
# make_opts+=("-j$(($(nproc)-2))")
|
# (Optional) Disable multicore make world
|
||||||
((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
# ((DEBUG)) && make_opts+=("-j1") || make_opts+=("-j$(($(nproc)-2))")
|
||||||
|
make_opts+=("-j$(($(nproc)-2))")
|
||||||
|
|
||||||
# Make image
|
# Make image
|
||||||
if ! execute ionice -c2 -n7 nice -n19 make "${make_opts[@]}" BIN_DIR="$BIN_DIR" world; then
|
if ! execute ionice -c2 -n7 nice -n19 make "${make_opts[@]}" BIN_DIR="$BIN_DIR" world; then
|
||||||
|
|||||||
Reference in New Issue
Block a user