Commit 70f495c7 authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

[feature] Switching between available kernel versions which are in repository

parent ddea9151
...@@ -333,6 +333,56 @@ function reload_bsp(){ ...@@ -333,6 +333,56 @@ function reload_bsp(){
} }
function other_kernel_version ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
TARGET_BRANCH="-"${BRANCH}
[[ $BRANCH == "default" ]] && TARGET_BRANCH=""
CURRENT_VERSION=$(apt-cache policy linux-image${TARGET_BRANCH}-${LINUXFAMILY} | grep Installed| sed -n -e 's/^.*Installed: //p')
LIST=($(apt-cache show linux-image${TARGET_BRANCH}-${LINUXFAMILY} | grep -E "version: |Version:" | sed -n -e 's/^.*ersion: //p' | sed 's/\.$//g' | head -20))
# make a temporally array
new_list=()
for ((n=0;n<$((${#LIST[@]}));n++));
do
# skip currently installed package
if [[ ${LIST[$n]} == $CURRENT_VERSION ]]; then
n=$(( $n + 1 ))
else
echo ${LIST[$n]}
new_list+=( "${LIST[$n]}" )
fi
done
# copy back to main array
LIST=("${new_list[@]}")
LIST_LENGHT=$((${#LIST[@]}/2));
if [ "$LIST_LENGHT" -eq 0 ]; then
dialog --backtitle "$BACKTITLE" --title " linux-image${TARGET_BRANCH}-${LINUXFAMILY} " --msgbox "\nOther versions are not available!" 7 38
else
beta_disclaimer "Switching between kernels might change functionality of your board or it might fail to boot."
if [[ -n $ACKNOWLEDGEMENT ]]; then
exec 3>&1
TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Switch to other kernel versions" --clear --menu "\nSwitch from package (${CURRENT_VERSION}) to:\n \n" $((9+${LIST_LENGHT})) 60 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?;
exec 3>&-
if [[ $? = 0 ]]; then
# install packages
INSTALL_DTB=""
[[ -n $(apt-cache search --names-only "^linux-dtb$TARGET_BRANCH-$LINUXFAMILY") ]] && INSTALL_DTB="linux-dtb$TARGET_BRANCH-$LINUXFAMILY=$TARGET_VERSION"
debconf-apt-progress -- apt-get -y -qq --allow-downgrades --no-install-recommends install linux-image${TARGET_BRANCH}-${LINUXFAMILY}=$TARGET_VERSION $INSTALL_DTB
dialog --title "Switching to $TARGET_VERSION" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno "\nReboot to apply new settings?" 7 34
if [[ $? = 0 ]]; then reboot; fi
fi
fi
fi
}
# #
......
...@@ -870,6 +870,15 @@ function jobs () ...@@ -870,6 +870,15 @@ function jobs ()
;; ;;
# Switch to other kernel versions
"Other")
if ! is_package_manager_running; then
other_kernel_version
fi
;;
# Enable or disable desktop # Enable or disable desktop
# #
"Desktop" ) "Desktop" )
......
...@@ -67,8 +67,12 @@ while true; do ...@@ -67,8 +67,12 @@ while true; do
testvercomp "$(uname -r | sed 's/-.*//')" "4.10.0" ">" testvercomp "$(uname -r | sed 's/-.*//')" "4.10.0" ">"
[[ "$LINUXFAMILY" = odroidxu4 && $? == 0 ]] && LIST+=( "DTB" "Select optimised board configuration" ) [[ "$LINUXFAMILY" = odroidxu4 && $? == 0 ]] && LIST+=( "DTB" "Select optimised board configuration" )
[[ -f /usr/bin/bin2fex && "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" ]] && LIST+=( "Fexedit" "Board (fex) settings editor" ) [[ -f /usr/bin/bin2fex && "$LINUXFAMILY" = sun*i && "$BRANCH" = "default" ]] && LIST+=( "Fexedit" "Board (fex) settings editor" )
[[ -z ${mark} ]] && [[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \
&& LIST+=( "Other" "Switch to other kernel versions" )
[[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \ [[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \
| wc -l) -gt 1 && -z "${mark}" ]] && LIST+=( "Switch" "Switch to alternative kernels" ) | wc -l) -gt 1 && -z "${mark}" ]] && LIST+=( "Switch" "Switch to alternative kernel branches" )
LIST+=( "SSH" "Reconfigure SSH daemon" ) LIST+=( "SSH" "Reconfigure SSH daemon" )
LIST+=( "Firmware" "Run apt update & apt upgrade" ) LIST+=( "Firmware" "Run apt update & apt upgrade" )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment