Simplify options
This commit is contained in:
@@ -19,21 +19,22 @@ printHelp() {
|
|||||||
openwrtbuilder [OPTION [VALUE]] -p PROFILE [-p PROFILE2]...
|
openwrtbuilder [OPTION [VALUE]] -p PROFILE [-p PROFILE2]...
|
||||||
|
|
||||||
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
|
--buildroot,-b PATH
|
||||||
--release, --version, -r, -v RELEASE ("snapshot", "22.03.3")
|
Defaults to location of openwrtbuilder script
|
||||||
--buildroot, -b PATH
|
--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
|
||||||
(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
|
--reset
|
||||||
Cleanup all source and output files
|
Cleanup all source and output files
|
||||||
--debug, -d
|
--debug,-d
|
||||||
--help, -h
|
--help,-h
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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:"
|
||||||
|
|||||||
Reference in New Issue
Block a user