From 877cf3bae016749330ca4e57564ddc4d778599ba Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 26 Sep 2024 21:49:02 +0200 Subject: [PATCH] Bugfix: firmware switch function was not working correctly --- lib/armbian-configng/config.ng.functions.sh | 34 +++++++++++++++------ lib/armbian-configng/config.ng.system.sh | 13 +++++--- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/armbian-configng/config.ng.functions.sh b/lib/armbian-configng/config.ng.functions.sh index 4b82589d0..03c33e2f6 100644 --- a/lib/armbian-configng/config.ng.functions.sh +++ b/lib/armbian-configng/config.ng.functions.sh @@ -257,7 +257,8 @@ armbian_fw_manipulate() { [[ -n $version ]] && local version="=${version}" # fallback to $BRANCH - [[ -z $branch ]] && branch="${BRANCH}" + [[ -z "${branch}" ]] && branch="${BRANCH}" + [[ -z "${BRANCH}" ]] && branch="current" # fallback in case we switch to very old BSP that have no such info # packages to install local armbian_packages=( @@ -266,6 +267,8 @@ armbian_fw_manipulate() { "linux-dtb-${branch}-${LINUXFAMILY}" "armbian-config" "armbian-zsh" + "armbian-bsp-cli-${BOARD}-${branch}" + "armbian-bsp-desktop-${BOARD}-${branch}" ) # reinstall headers only if they were previously installed @@ -276,26 +279,37 @@ armbian_fw_manipulate() { local packages="" for pkg in "${armbian_packages[@]}"; do if [[ "${function}" == reinstall ]]; then - apt search "$pkg" 2> /dev/null | grep "^$pkg" > /dev/null - if [[ $? -eq 0 ]]; then packages+="$pkg${version} "; fi + local pkg_search=$(apt search "$pkg" 2> /dev/null | grep "^$pkg") + if [[ $? -eq 0 ]]; then + if [[ "${pkg_search}" == *$version* ]] ; then + packages+="$pkg${version} "; + else + packages+="$pkg "; + fi + fi else if check_if_installed $pkg; then packages+="$pkg${version} " fi fi done - +echo "${packages[@]}" for pkg in "${packages[@]}"; do - local pkg_uninstall=${pkg/=*/} # removing numbers case $function in unhold) apt-mark unhold ${pkg} | show_infobox ;; hold) apt-mark hold ${pkg} | show_infobox ;; reinstall) - apt_install_wrapper apt-get -y --download-only --allow-change-held-packages --allow-downgrades install "${pkg}" - apt_install_wrapper apt-get -y purge "${pkg_uninstall/${branch}/*}" # remove all branches - apt_install_wrapper apt-get -y --allow-change-held-packages --allow-downgrades install "${pkg}" - apt_install_wrapper apt-get -y autoremove - apt_install_wrapper apt-get -y clean + apt_install_wrapper apt-get -y --download-only --allow-change-held-packages --allow-downgrades install ${pkg} + if [[ $? == 0 ]]; then + apt_install_wrapper apt-get -y purge "linux-u-boot-*" "linux-image-*" "linux-dtb-*" "linux-headers-*" "armbian-bsp-*" # remove all branches + apt_install_wrapper apt-get -y --allow-change-held-packages --reinstall --allow-downgrades install ${pkg} + apt_install_wrapper apt-get -y autoremove + apt_install_wrapper apt-get -y clean + else + exit 1 + fi + + ;; *) return ;; esac diff --git a/lib/armbian-configng/config.ng.system.sh b/lib/armbian-configng/config.ng.system.sh index 4fffcc4fd..df7f1ac64 100644 --- a/lib/armbian-configng/config.ng.system.sh +++ b/lib/armbian-configng/config.ng.system.sh @@ -12,12 +12,13 @@ module_options+=( # @description Use TUI / GUI for apt install if exists # function apt_install_wrapper() { - if [ -t 0 ]; then - debconf-apt-progress -- "$@" - else + + #if [ -t 0 ]; then + # debconf-apt-progress -- "$@" + #else # Terminal not defined - proceed without TUI - "$@" - fi + DEBIAN_FRONTEND=noninteractive "$@" + #fi } module_options+=( @@ -145,6 +146,7 @@ function set_stable() { if ! grep -q 'apt.armbian.com' /etc/apt/sources.list.d/armbian.list; then sed -i "s/http:\/\/[^ ]*/http:\/\/apt.armbian.com/" /etc/apt/sources.list.d/armbian.list + apt_install_wrapper apt-get update armbian_fw_manipulate "reinstall" fi } @@ -164,6 +166,7 @@ function set_rolling() { if ! grep -q 'beta.armbian.com' /etc/apt/sources.list.d/armbian.list; then sed -i "s/http:\/\/[^ ]*/http:\/\/beta.armbian.com/" /etc/apt/sources.list.d/armbian.list + apt_install_wrapper apt-get update armbian_fw_manipulate "reinstall" fi }