From d342206f0a998a1c67c7fec3093ae95db6a9c65f Mon Sep 17 00:00:00 2001 From: bryan Date: Fri, 13 Jan 2023 11:40:45 -0500 Subject: [PATCH] New directory layout --- openwrtbuilder | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/openwrtbuilder b/openwrtbuilder index 4e09054..c4aa035 100755 --- a/openwrtbuilder +++ b/openwrtbuilder @@ -83,7 +83,7 @@ init() { ID="debian" ;; *) - echo "Autodetecting distro, this may be unreliable and --compat may also be required" + echo "Autodetecting distro, this may be unreliable" if hash dnf &>/dev/null; then ID="fedora" RPM_MGR="dnf" @@ -126,9 +126,12 @@ readInput() { unset RESET declare -ga PROFILES - declare -g PROFILE_INFO + declare -g PROFILE_INFO + declare long_opts + 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 release:,version:,profile:,info:,list-profiles,buildroot:,source,ssh-upgrade:,ssh-backup:,flash:,reset,debug,help -- "$@"); then + if _input=$(getopt -o +r:v:p:i:lb:sf:dh -l $long_opts -- "$@"); then eval set -- "$_input" while true; do case "$1" in @@ -419,7 +422,8 @@ sshBackup() { # Move backup archive locally debug "rsync -avz --remove-source-files $SSH_BACKUP_PATH:/tmp/$_backup_fname $BUILDDIR/" - if ! rsync -avz --remove-source-files "$SSH_BACKUP_PATH":"/tmp/$_backup_fname" "$BUILDDIR/"; then + if ! rsync -avz --remove-source-files \ + "$SSH_BACKUP_PATH":"/tmp/$_backup_fname" "$BUILDDIR/"; then echo "Could not copy SSH backup" exit 1 fi @@ -627,19 +631,21 @@ main() { installDependencies for profile in "${PROFILES[@]}"; do - debug "Starting profile: $profile" - [[ ! ${!profile@a} = A ]] && echo "Profile '$profile' does not exist" && return 1 - # Hold profile settings (from config file) in P_ARR + if [[ ! ${!profile@a} = A ]]; then + echo "Profile '$profile' does not exist" + return 1 + fi + + # Store profile settings in P_ARR declare -gn P_ARR="$profile" - # precedence: user input>profile>env>hardcode + # release precedence: user input>profile>env>hardcode declare -g RELEASE="${USER_RELEASE:=${P_ARR[release]:=$RELEASE}}" declare -g SRCDIR="$BUILDROOT/src" declare -g BINDIR="$BUILDROOT/bin" declare -g BUILDDIR="$SRCDIR/${P_ARR[profile]}-$RELEASE" - declare -g IB_ARCHIVE="$SRCDIR/${P_ARR[profile]}-$RELEASE.tar.xz" declare -g FILESYSTEM="${P_ARR[filesystem]:="squashfs"}" @@ -685,7 +691,7 @@ main() { getImageBuilder || return $? addRepos - #copyFiles && + #copyFiles [[ -v SSH_BACKUP_PATH ]] && sshBackup if makeImage; then [[ -v SSH_UPGRADE_PATH ]] && sshUpgrade