diff --git a/debian-config-jobs b/debian-config-jobs index 4f8f84d..36d462d 100644 --- a/debian-config-jobs +++ b/debian-config-jobs @@ -189,10 +189,27 @@ unset selection # "Source_install" ) if ! is_package_manager_running; then - PACKAGE=$(echo "$SOURCE_PKG" | sed "s/-current//" | sed "s/-dev//" | sed "s/-legacy//") - if [[ -n $PACKAGE ]]; then - debconf-apt-progress -- apt-get -y install ${SOURCE_PKG} + if [[ -z $scripted ]]; then + LIST=() + for pkg in $SOURCE_PKG_LIST + do + LIST+=( "$pkg" "" ) + done + + exec 3>&1 + selection=$(dialog --backtitle "$BACKTITLE" --title "Kernel install" --clear --cancel-label "Back" \ + --menu "Choose kernel version" 12 70 ${#LIST[@]} "${LIST[@]}" 2>&1 1>&3) + exit_status=$? + exec 3>&- + [[ $exit_status == 1 || $exit_status == 255 ]] && clear + else + selection=$(echo $SOURCE_PKG_LIST | awk '{ print $NF }') + fi + + PACKAGE=$(echo "$selection" | sed "s/-current//" | sed "s/-dev//" | sed "s/-legacy//") + if [[ -n $PACKAGE ]]; then + debconf-apt-progress -- apt-get -y install ${selection} mkdir -p /usr/src/$PACKAGE (pv -n /usr/src/$PACKAGE".tar.xz" | xz -d -T0 - | tar xf - -C /usr/src/$PACKAGE ) 2>&1 | dialog --colors --backtitle "$BACKTITLE" --title " Please wait! " --gauge "\nDecompressing kernel sources to /usr/src/$PACKAGE" 8 80 xz -d /usr/src/*config.xz --stdout > /usr/src/$PACKAGE/.config @@ -201,9 +218,10 @@ unset selection debconf-apt-progress -- apt-get -y purge linux-source* debconf-apt-progress -- apt -y autoremove if [[ -z $scripted ]]; then - dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Kernel source " --clear --msgbox "\nYou will find pre-configured kernel sources in /usr/src/$PACKAGE" 7 72 + dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Kernel source " --clear --msgbox "\nYou will find pre-configured kernel sources in /usr/src/$PACKAGE" 7 72 fi - + else + dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading software submodule ... " 5 34 fi fi ;; @@ -215,15 +233,38 @@ unset selection # "Source_remove" ) if ! is_package_manager_running; then - PACKAGE=$(echo "$SOURCE_PKG" | sed "s/-current//" | sed "s/-dev//" | sed "s/-legacy//") - if [[ -n $PACKAGE ]]; then - if ls /usr/src/linux-source* 1> /dev/null 2>&1; then - debconf-apt-progress -- apt-get -y purge linux-source* + if [[ -z $scripted ]]; then + LIST=() + for pkg in $SOURCE_PKG_LIST_INSTALLED + do + LIST+=( "$pkg" "" ) + done + + exec 3>&1 + selection=$(dialog --backtitle "$BACKTITLE" --title "Kernel remove" --clear --cancel-label "Back" \ + --menu "Choose kernel version" 12 70 ${#LIST[@]} "${LIST[@]}" 2>&1 1>&3) + exit_status=$? + exec 3>&- + [[ $exit_status == 1 || $exit_status == 255 ]] && clear + else + selection=$(echo $SOURCE_PKG_LIST_INSTALLED | awk '{ print $NF }') + fi + + if [[ -n $selection ]]; then + PACKAGE="linux-source-$(echo $selection | sed 's/[-|(|[:alpha:]|(|[:space:]|(|/]//g')-${BRANCH}-${LINUXFAMILY}" + if ls $selection 1> /dev/null 2>&1; then + debconf-apt-progress -- apt-get -y purge $PACKAGE debconf-apt-progress -- apt -y autoremove apt clean - rm -r /usr/src/linux-source* + dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nRemoving $selection ... " 5 72 + rm -r $selection fi + if [[ -z $scripted ]]; then + dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Kernel source " --clear --msgbox "\n$selection removed" 7 72 + fi + else + dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading software submodule ... " 5 34 fi fi ;; diff --git a/debian-config-submenu b/debian-config-submenu index 587f604..99e0a47 100644 --- a/debian-config-submenu +++ b/debian-config-submenu @@ -364,10 +364,13 @@ while true; do if [[ -n $(dpkg -l | grep linux-headers) ]]; then LIST+=( "Headers_remove" "kernel headers" ); else \ LIST+=( "Headers_install" "kernel headers" ); fi - SOURCE_PKG=$(apt-cache --names-only search ^linux-source-* | awk '{ print $1 }' | grep -w ${BRANCH}-${LINUXFAMILY} | tail -1) - if [[ -n $SOURCE_PKG ]]; then - if ls /usr/src/linux-source* 1> /dev/null 2>&1; then LIST+=( "Source_remove" "kernel source" ); else \ - LIST+=( "Source_install" "kernel source" ); fi + SOURCE_PKG_LIST=$(apt-cache --names-only search ^linux-source-* | awk '{ print $1 }' | grep -w ${BRANCH}-${LINUXFAMILY} | tail -n 5) + if [[ -n $SOURCE_PKG_LIST ]]; then + LIST+=( "Source_install" "kernel source" ) + fi + SOURCE_PKG_LIST_INSTALLED=$(find /usr/src -maxdepth 1 -name "linux-source*") + if [[ -n $SOURCE_PKG_LIST_INSTALLED ]]; then + LIST+=( "Source_remove" "kernel source" ); fi if [[ -f /etc/armbian.txt ]]; then @@ -411,15 +414,15 @@ while true; do LISTLENGTH="$((6+${#LIST[@]}/2))" BOXLENGTH=${#LIST[@]} -if [[ -z $selection ]]; then - exec 3>&1 - selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \ - --cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \ - "${LIST[@]}" 2>&1 1>&3) - exit_status=$? - exec 3>&- - [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break -fi + if [[ -z $selection ]]; then + exec 3>&1 + selection=$(dialog --backtitle "$BACKTITLE" --title "System and 3rd party software" --clear \ + --cancel-label "Back" --menu "$disclaimer" $LISTLENGTH 70 $BOXLENGTH \ + "${LIST[@]}" 2>&1 1>&3) + exit_status=$? + exec 3>&- + [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break + fi # run main function jobs "$selection"