Simplify options

This commit is contained in:
2023-01-14 14:46:26 -05:00
parent 5a6c3de113
commit 19e96f38f5

View File

@@ -20,10 +20,11 @@ printHelp() {
OPTIONS OPTIONS
--profile,-p PROFILE --profile,-p PROFILE
--info, -i (print profile info) --release,-r,--version,-v RELEASE ("snapshot", "22.03.3")
--list-profiles, -l
--release, --version, -r, -v RELEASE ("snapshot", "22.03.3")
--buildroot,-b PATH --buildroot,-b PATH
Defaults to location of openwrtbuilder script
--source
Build image from source, not from Image Builder
--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
@@ -46,6 +47,7 @@ init() {
debug || echo "To enable debugging output, use --debug or -d" debug || echo "To enable debugging output, use --debug or -d"
# Save the script directory # Save the script directory
# https://stackoverflow.com/a/4774063
SCRIPTDIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit $? ; pwd -P)" SCRIPTDIR="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit $? ; pwd -P)"
if [[ -e "/etc/os-release" ]]; then if [[ -e "/etc/os-release" ]]; then
@@ -135,12 +137,10 @@ readInput() {
unset RESET unset RESET
declare -ga PROFILES declare -ga PROFILES
declare -g PROFILE_INFO declare long_opts='release:,version:,profile:,buildroot:,source,'
declare long_opts long_opts+='ssh-upgrade:,ssh-backup:,flash:,reset,debug,help'
long_opts='release:,version:,profile:,info:,list-profiles,buildroot:,'
long_opts+='source,ssh-upgrade:,ssh-backup:,flash:,reset,debug,help'
if _input=$(getopt -o +r:v:p:i:lb:sf:dh -l $long_opts -- "$@"); then if _input=$(getopt -o +r:v:p:b:sf:dh -l $long_opts -- "$@"); then
eval set -- "$_input" eval set -- "$_input"
while true; do while true; do
case "$1" in case "$1" in
@@ -150,12 +150,6 @@ readInput() {
--profile|-p) --profile|-p)
shift && PROFILES+=("$1") shift && PROFILES+=("$1")
;; ;;
--info|-i)
PROFILE_INFO=1
;;
--list-profiles|-l)
listProfiles && exit $?
;;
--buildroot|-b) --buildroot|-b)
shift && BUILDROOT="$1" shift && BUILDROOT="$1"
;; ;;
@@ -195,12 +189,6 @@ readInput() {
} }
listProfiles() {
debug "${FUNCNAME[0]}"
grep "declare -Ag" "$PFILE" | cut -d" " -f3
}
installDependencies() { installDependencies() {
debug "${FUNCNAME[0]}" debug "${FUNCNAME[0]}"
@@ -556,6 +544,8 @@ fromSource() {
git checkout "v$RELEASE" git checkout "v$RELEASE"
fi fi
# git pull # TODO, necessary?
# Update package feed # Update package feed
./scripts/feeds update -a && ./scripts/feeds update -a &&
./scripts/feeds install -a ./scripts/feeds install -a
@@ -642,7 +632,6 @@ resetProfile() {
loadProfiles() { loadProfiles() {
debug "${FUNCNAME[0]}" debug "${FUNCNAME[0]}"
declare -g PFILE declare -g PFILE
# https://stackoverflow.com/a/4774063
PFILE="$SCRIPTDIR/profiles" PFILE="$SCRIPTDIR/profiles"
# shellcheck source=./profiles # shellcheck source=./profiles
! source "$PFILE" && echo "profiles file missing!" && return 1 ! source "$PFILE" && echo "profiles file missing!" && return 1
@@ -737,7 +726,7 @@ main() {
declare -g SYSUPGRADEIMGGZ="$img_prefix-sysupgrade.img.gz" declare -g SYSUPGRADEIMGGZ="$img_prefix-sysupgrade.img.gz"
declare -g SYSUPGRADEIMGGZFNAME="${SYSUPGRADEIMGGZ##*/}" declare -g SYSUPGRADEIMGGZFNAME="${SYSUPGRADEIMGGZ##*/}"
if (( DEBUG )) || (( PROFILE_INFO )); then if (( DEBUG )); then
echo "Profile settings:" echo "Profile settings:"
for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done for x in "${!P_ARR[@]}"; do printf "%s=%s\n" "$x" "${P_ARR[$x]}"; done
echo "Build settings:" echo "Build settings:"