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 30, 2024
1 parent e343f04 commit 5652231
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
33 changes: 22 additions & 11 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ 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=(
"linux-u-boot-${BOARD}-${branch}"
"linux-image-${branch}-${LINUXFAMILY}"
"linux-dtb-${branch}-${LINUXFAMILY}"
"armbian-config"
"armbian-zsh"
"armbian-bsp-cli-${BOARD}-${branch}"
)

# reinstall headers only if they were previously installed
Expand All @@ -276,26 +277,36 @@ 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 && -n "${pkg_search}" ]]; 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

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 --simulate --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-zsh-*" "armbian-bsp-cli-*" # remove all branches
apt_install_wrapper apt-get -y --allow-change-held-packages install ${pkg}
apt_install_wrapper apt-get -y autoremove
apt_install_wrapper apt-get -y clean
else
exit 1
fi


;;
*) return ;;
esac
Expand Down
5 changes: 4 additions & 1 deletion lib/armbian-configng/config.ng.system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ module_options+=(
# @description Use TUI / GUI for apt install if exists
#
function apt_install_wrapper() {

if [ -t 0 ]; then
debconf-apt-progress -- "$@"
else
# Terminal not defined - proceed without TUI
"$@"
DEBIAN_FRONTEND=noninteractive "$@"
fi
}

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 5652231

Please sign in to comment.