Skip to content

Commit

Permalink
Bugfix: firmware switch function was not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
igorpecovnik committed Sep 29, 2024
1 parent bd256bc commit 877cf3b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
34 changes: 24 additions & 10 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=(
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions lib/armbian-configng/config.ng.system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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+=(
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 877cf3b

Please sign in to comment.