Support Fedora and derivatives (#56)

* linux57: install.sh: Add install for Fedora

* linux57: install.sh: use dnf to install and save it for uninstall

* linux57: install.sh: enable Fedora compilation

* linux57: use single equal sign for conditions

* linux57: Add uninstall step

* linux57: remove unwated changes

* linux57: install.sh: code cleanup

* linux57: install.sh: remove redundant condition

* linux57: install.sh: Fedora: update dependency install

* linux57: install.sh: uninstall only kernel and keep dependencies

* linux57: install.sh: make script executable

* linux57: install.sh: remove header uninstall in Ubuntu

* Linux57: Initial Suse support

* linux57: install.sh: Add Suse to the distro error message

* linux57: install.sh: Additionnal Suse dependency packages

* linux57: install.sh: disable gpg check for Suse kernel install

* linux57: install.sh: Fedora & derivative: produce dev files

* Linux57: install.sh: make Suse use ccache

* Linux57: install.sh: Fedora & derivatives: add install/uninstall of kernel-devel

* linux57: install.sh: Fix: disable sign check for Suse kernel install

* linux57: install.sh: Fedora & derivatives: enable confirm prompt for kernel install

* linux57: install.sh: suse add flag to replace files from default kernel-headers

* linux57: install.sh: make uninstall manual

* linux57: install.sh: add uninstall help for Suse

* linux57: install.sh: correct uninstall message for suse

* linux57: install.sh: move made RPMS into working folder and cleanup

* linux57: install.sh: add uninstall help for Fedora

* linux57: install.sh: Move deb files into DEBs folder

* linux57: install.sh: Ubuntu: install dev deb package

* linux57: install.sh: add Ubuntu uninstall help.

* linux57: install.sh: improve Ubuntu uninstall help

* linux57: Add Debian distro and related fix

* linux57: install.sh: prompt for distro

* linux57: install.sh: use _basekernel instead of 5.7

* linux57: install.sh: fix for using _basekernel everywhere

* linux57: add ubuntu/debian dependency install

* linux58: copy install.sh from 5.7 as-is, add distro prompt

* linux59: copy install.sh from 5.7 as-is, add distro prompt

* Fix PKGBUILD after adding the distro prompt

* Revert "Fix PKGBUILD after adding the distro prompt"

This reverts commit 9c3c155b3ed07a4aa04ec10d6fc0e8b5710a2f07.

* Fix PKGBUILD because of the distro prompt

* linux57: install.sh: improve `config` script path

* linux57: install.sh: loop if wrong answer in distro prompt

* linux57: install.sh: code cleanup

* Copy linux57 install.sh to linux58 and linux59

* install.sh: change "uninstall" argument to "uninstall-help"

* Update READMEs
This commit is contained in:
Adel Kara Slimane 2020-09-01 17:57:21 +02:00 committed by GitHub
parent cdbf5273ad
commit ee80080260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 454 additions and 227 deletions

View File

@ -30,6 +30,8 @@ source "$_where"/linux*-tkg-config/prepare
_tkg_initscript _tkg_initscript
_distro="Arch"
if [ -n "$_custom_pkgbase" ]; then if [ -n "$_custom_pkgbase" ]; then
pkgbase="${_custom_pkgbase}" pkgbase="${_custom_pkgbase}"
else else

View File

@ -39,27 +39,27 @@ You can enable support for it at the beginning of the PKGBUILD file. Make sure t
``` ```
git clone https://github.com/Frogging-Family/linux-tkg.git git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux57-tkg cd linux-tkg/linux57-tkg
# Edit customization.cfg file # Optional: edit customization.cfg file
makepkg -si makepkg -si
``` ```
### Ubuntu & derivatives ### Fedora, Ubuntu and derivatives
``` ```
git clone https://github.com/Frogging-Family/linux-tkg.git git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux57-tkg cd linux-tkg/linux57-tkg
# Edit customization.cfg file to at least set _distro to "Ubuntu" # Optional: edit customization.cfg file
./install.sh install ./install.sh install
``` ```
To uninstall custom kernels installed through the script: Uninstalling custom kernels installed through the script has to be done
manually, the script can can help out with some useful information:
``` ```
cd path/to/linux-tkg/linux57-tkg cd path/to/linux-tkg/linux57-tkg
./install.sh uninstall ./install.sh uninstall-help
``` ```
### Other linux distributions ### Other linux distributions
Other distros are not supported, Debian may work with the `install.sh` script. Otherwise, If your distro is not DEB or RPM based, `install.sh` script can clone the kernel tree, patch and edit a `.config` file from your current distro's
that same `install.sh` script can clone, patch and edit a `.config` file from your current distro's that is expected at ``/boot/config-`uname -r`.config`` (otherwise it won't work as-is)
that is expected at ``/boot/config-`uname -r`.config``. Otherwise it won't work as-is.
The command to do for that is: The command to do for that is:
``` ```

View File

@ -1,7 +1,9 @@
# linux57-TkG config file # linux57-TkG config file
# Linux distribution you are using, options are "Arch" (default), "Ubuntu" # Linux distribution you are using, options are "Arch", "Ubuntu", "Debian", "Fedora" or "Suse".
_distro="Arch" # It is automatically set to "Arch" when using PKGBUILD.
# If left empty, the script will prompt
_distro=""
#### MISC OPTIONS #### #### MISC OPTIONS ####
@ -155,7 +157,7 @@ _custom_commandline="intel_pstate=passive"
# !!! It will also change pkgname - If you don't explicitely need this, don't use it !!! # !!! It will also change pkgname - If you don't explicitely need this, don't use it !!!
_custom_pkgbase="" _custom_pkgbase=""
# [non-Arch specific] Kernel localversion. Putting it to "Mario" will make for example the kernel version be 5.7.0-Mario (given by uname -r) # [non-Arch specific] Kernel localversion. Putting it to "Mario" will make for example the kernel version be 5.7.0-tkg-Mario (given by uname -r)
# If left empty, it will use -tkg-"${_cpusched}" where "${_cpusched}" will be replaced by the user chosen scheduler # If left empty, it will use -tkg-"${_cpusched}" where "${_cpusched}" will be replaced by the user chosen scheduler
_kernel_localversion="" _kernel_localversion=""

View File

@ -16,21 +16,24 @@ plain() {
echo "$1" >&2 echo "$1" >&2
} }
# alias plain=echo # Stop the script at any ecountered error
set -e set -e
_where=`pwd` _where=`pwd`
srcdir="$_where" srcdir="$_where"
_cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.7%2B.patch" source linux*-tkg-config/prepare
_cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v${_basekernel}%2B.patch"
source customization.cfg source customization.cfg
if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall" ]; then if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ]; then
echo "Command not recognised, options are: msg2 "Argument not recognised, options are:
- config : shallow clones the linux 5.7.x git tree into the folder linux-5.7, then applies on it the extra patches and prepares the .config file by copying the one from the current linux system in /boot/config-`uname -r` and updates it. - config : shallow clones the linux ${_basekernel}.x git tree into the folder linux-${_basekernel}, then applies on it the extra patches and prepares the .config file
- install : [Debian-like only (Debian, Ubuntu, Pop_os!...)], does the config step, proceeds to compile, then prompts to install by copying the one from the current linux system in /boot/config-`uname -r` and updates it.
- uninstall : [Debian-like only (Debian, Ubuntu, Pop_os!...)], lists the installed custom kernels through this script, then prompts for which one to uninstall." - install : [RPM and DEB based distros only], does the config step, proceeds to compile, then prompts to install
- uninstall-help : [RPM and DEB based distros only], lists the installed kernels in this system, then gives a hint on how to uninstall them manually."
exit 0 exit 0
fi fi
@ -44,22 +47,52 @@ _misc_adds="false" # We currently don't want this enabled on non-Arch
if [ "$1" = "install" ] || [ "$1" = "config" ]; then if [ "$1" = "install" ] || [ "$1" = "config" ]; then
source linux*-tkg-config/prepare if [ -z $_distro ] && [ "$1" = "install" ]; then
while true; do
echo "Which linux distribution are you running ?"
echo "if it's not on the list, chose the closest one to it: Fedora/Suse for RPM, Ubuntu/Debian for DEB"
echo " 1) Debian"
echo " 2) Fedora"
echo " 3) Suse"
echo " 4) Ubuntu"
read -p "[1-4]: " _distro_index
if [ $1 = "install" ] && [ "$_distro" != "Ubuntu" ]; then if [ "$_distro_index" = "1" ]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Ubuntu\"" _distro="Debian"
msg2 "This script can only install custom kernels for Ubuntu and Debian derivatives. Exiting..." break
elif [ "$_distro_index" = "2" ]; then
_distro="Fedora"
break
elif [ "$_distro_index" = "3" ]; then
_distro="Suse"
break
elif [ "$_distro_index" = "4" ]; then
_distro="Ubuntu"
break
else
echo "Wrong index."
fi
done
fi
if [[ $1 = "install" && "$_distro" != "Ubuntu" && "$_distro" != "Debian" && "$_distro" != "Fedora" && "$_distro" != "Suse" ]]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Ubuntu\", \"Debian\", \"Fedora\" or \"Suse\""
msg2 "This script can only install custom kernels for RPM and DEB based distros, though only those keywords are permitted. Exiting..."
exit 0 exit 0
fi fi
if [ "$_distro" = "Ubuntu" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
msg2 "Installing dependencies" msg2 "Installing dependencies"
sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex qtbase5-dev -y
else elif [ "$_distro" = "Fedora" ]; then
msg2 "Dependencies are unknown for the target linux distribution." msg2 "Installing dependencies"
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign grubby qt5-devel libXi-devel gcc-c++ git ccache flex bison elfutils-libelf-devel openssl-devel dwarves rpm-build -y
elif [ "$_distro" = "Suse" ]; then
msg2 "Installing dependencies"
sudo zypper install -y rpmdevtools ncurses-devel pesign libXi-devel gcc-c++ git ccache flex bison elfutils libelf-devel openssl-devel dwarves make patch bc rpm-build libqt5-qtbase-common-devel libqt5-qtbase-devel lz4
fi fi
# Force prepare script to avoid Arch specific commands if the user didn't change _distro from "Arch" # Force prepare script to avoid Arch specific commands if the user is using `config`
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
_distro="" _distro=""
fi fi
@ -105,6 +138,9 @@ if [ "$1" = "install" ] || [ "$1" = "config" ]; then
msg2 "Copying current kernel's config and running make oldconfig..." msg2 "Copying current kernel's config and running make oldconfig..."
cp /boot/config-`uname -r` .config cp /boot/config-`uname -r` .config
if [ "$_distro" = "Debian" ]; then #Help Debian cert problem.
sed -i -e 's#CONFIG_SYSTEM_TRUSTED_KEYS="debian/certs/test-signing-certs.pem"#CONFIG_SYSTEM_TRUSTED_KEYS=""#g' .config
fi
yes '' | make oldconfig yes '' | make oldconfig
msg2 "Done" msg2 "Done"
@ -132,74 +168,115 @@ if [ "$1" = "install" ]; then
# ccache # ccache
if [ "$_noccache" != "true" ]; then if [ "$_noccache" != "true" ]; then
if [ "$_distro" = "Ubuntu" ] && dpkg -l ccache > /dev/null; then
if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
export PATH="/usr/lib/ccache/bin/:$PATH" export PATH="/usr/lib/ccache/bin/:$PATH"
export CCACHE_SLOPPINESS="file_macro,locale,time_macros" elif [ "$_distro" = "Fedora" ] || [ "$_distro" = "Suse" ]; then
export CCACHE_NOHASHDIR="true" export PATH="/usr/lib64/ccache/:$PATH"
msg2 'ccache was found and will be used'
fi fi
export CCACHE_SLOPPINESS="file_macro,locale,time_macros"
export CCACHE_NOHASHDIR="true"
msg2 'ccache was found and will be used'
fi fi
_kernel_flavor="${_kernel_localversion}"
if [ -z $_kernel_localversion ]; then if [ -z $_kernel_localversion ]; then
_kernel_flavor="tkg-${_cpusched}" _kernel_flavor="tkg-${_cpusched}"
else
_kernel_flavor="tkg-${_kernel_localversion}"
fi fi
if [ "$_distro" = "Ubuntu" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then
msg2 "Building successfully finished!" msg2 "Building successfully finished!"
cd "$_where"
# Create DEBS folder if it doesn't exist
mkdir -p DEBS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv "$_where"/*.deb "$_where"/DEBS/
read -p "Do you want to install the new Kernel ? y/[n]: " _install read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [[ $_install =~ [yY] ]] || [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then if [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then
cd "$_where" cd "$_where"
_kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor _kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor
_headers_deb=linux-headers-${_kernelname}*.deb _headers_deb="linux-headers-${_kernelname}*.deb"
_image_deb=linux-image-${_kernelname}_*.deb _image_deb="linux-image-${_kernelname}_*.deb"
_kernel_devel_deb="linux-libc-dev_${_kernelname}*.rpm"
sudo dpkg -i $_headers_deb $_image_deb cd DEBS
sudo dpkg -i $_headers_deb $_image_deb $_kernel_devel_deb
fi
fi
# Add to the list of installed kernels, used for uninstall elif [[ "$_distro" = "Fedora" || "$_distro" = "Suse" ]]; then
if ! { [ -f installed-kernels ] && grep -Fxq "$_kernelname" installed-kernels; }; then
echo $_kernelname >> installed-kernels # Replace dashes with underscores, it seems that it's being done by binrpm-pkg
# Se we can actually refer properly to the rpm files.
_kernel_flavor=${_kernel_flavor//-/_}
if make -j ${_thread_num} rpm-pkg EXTRAVERSION="_${_kernel_flavor}"; then
msg2 "Building successfully finished!"
cd "$_where"
# Create RPMS folder if it doesn't exist
mkdir -p RPMS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv ~/rpmbuild/RPMS/x86_64/* "$_where"/RPMS/
#Clean up the original folder, unneeded and takes a lot of space
rm -rf ~/rpmbuild/
read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [ "$_install" = "y" ] || [ "$_install" = "Y" ] || [ "$_install" = "yes" ] || [ "$_install" = "Yes" ]; then
_kernelname=$_basekernel.${_kernel_subver}_$_kernel_flavor
_headers_rpm="kernel-headers-${_kernelname}*.rpm"
_kernel_rpm="kernel-${_kernelname}*.rpm"
_kernel_devel_rpm="kernel-devel-${_kernelname}*.rpm"
cd RPMS
if [ "$_distro" = "Fedora" ]; then
sudo dnf install $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
elif [ "$_distro" = "Suse" ]; then
msg2 "Some files from 'linux-glibc-devel' will be replaced by files from the custom kernel-hearders package"
msg2 "To revert back to the original kernel headers do 'sudo zypper install -f linux-glibc-devel'"
sudo zypper install --replacefiles --allow-unsigned-rpm $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
fi fi
msg2 "Install successful"
fi fi
fi fi
fi fi
fi fi
if [ "$1" = "uninstall" ]; then if [ "$1" = "uninstall-help" ]; then
cd "$_where" cd "$_where"
msg2 "List of installed custom tkg kernels: "
if [ ! -f installed-kernels ] || [ ! -s installed-kernels ]; then if [ "$_distro" = "Ubuntu" ]; then
echo "No custom kernel has been installed yet" dpkg -l "*tkg*" | grep "linux.*tkg"
exit 0 dpkg -l "*linux-libc-dev*" | grep "linux.*tkg"
msg2 "To uninstall a version, you should remove the linux-image, linux-headers and linux-libc-dev associated to it (if installed), with: "
msg2 " sudo apt remove linux-image-VERSION linux-headers-VERSION linux-libc-dev-VERSION"
msg2 " where VERSION is displayed in the lists above, uninstall only versions that have \"tkg\" in its name"
elif [ "$_distro" = "Fedora" ]; then
dnf list --installed kernel*
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo dnf remove --noautoremove kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second column"
elif [ "$_distro" = "Suse" ]; then
zypper packages --installed-only | grep "kernel.*tkg"
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo zypper remove --no-clean-deps kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second to last column"
fi fi
i=1
declare -a _custom_kernels
msg2 "Installed custom kernel versions: "
while read p; do
echo " $i) $p"
_custom_kernels+=($p)
i=$((i+1))
done < installed-kernels
i=$((i-1))
_delete_index=0
read -p "Which one would you like to delete ? [1-$i]: " _delete_index
if [ $_delete_index -ge 1 ] && [ $_delete_index -le $i ]; then
_delete_index=$((_delete_index-1))
sudo dpkg -r linux-headers-${_custom_kernels[$_delete_index]} linux-image-${_custom_kernels[$_delete_index]}
fi
rm -f installed-kernels
i=0
for kernel in "${_custom_kernels[@]}"; do
if [ $_delete_index != $i ]; then
echo "$kernel" >> installed-kernels
fi
i=$((i+1))
done
fi fi

View File

@ -36,6 +36,8 @@ fi
_tkg_initscript _tkg_initscript
_distro="Arch"
if [ -n "$_custom_pkgbase" ]; then if [ -n "$_custom_pkgbase" ]; then
pkgbase="${_custom_pkgbase}" pkgbase="${_custom_pkgbase}"
else else

View File

@ -31,31 +31,23 @@ You can enable support for it at the beginning of the PKGBUILD file. Make sure t
## Install procedure ## Install procedure
### Arch & derivatives ### Fedora, Ubuntu and derivatives
``` ```
git clone https://github.com/Frogging-Family/linux-tkg.git git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux58-tkg cd linux-tkg/linux58-tkg
# Edit customization.cfg file # Optional: edit customization.cfg file
makepkg -si
```
### Ubuntu & derivatives
```
git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux58-tkg
# Edit customization.cfg file to at least set _distro to "Ubuntu"
./install.sh install ./install.sh install
``` ```
To uninstall custom kernels installed through the script: Uninstalling custom kernels installed through the script has to be done
manually, the script can can help out with some useful information:
``` ```
cd path/to/linux-tkg/linux58-tkg cd path/to/linux-tkg/linux58-tkg
./install.sh uninstall ./install.sh uninstall-help
``` ```
### Other linux distributions ### Other linux distributions
Other distros are not supported, Debian may work with the `install.sh` script. Otherwise, If your distro is not DEB or RPM based, `install.sh` script can clone the kernel tree, patch and edit a `.config` file from your current distro's
that same `install.sh` script can clone, patch and edit a `.config` file from your current distro's that is expected at ``/boot/config-`uname -r`.config`` (otherwise it won't work as-is)
that is expected at ``/boot/config-`uname -r`.config``. Otherwise it won't work as-is.
The command to do for that is: The command to do for that is:
``` ```

View File

@ -1,7 +1,9 @@
# linux58-TkG config file # linux58-TkG config file
# Linux distribution you are using, options are "Arch" (default), "Debian" or "Ubuntu" # Linux distribution you are using, options are "Arch", "Ubuntu", "Debian", "Fedora" or "Suse".
_distro="Arch" # It is automatically set to "Arch" when using PKGBUILD.
# If left empty, the script will prompt
_distro=""
#### MISC OPTIONS #### #### MISC OPTIONS ####
@ -152,7 +154,7 @@ _custom_commandline="intel_pstate=passive"
# !!! It will also change pkgname - If you don't explicitely need this, don't use it !!! # !!! It will also change pkgname - If you don't explicitely need this, don't use it !!!
_custom_pkgbase="" _custom_pkgbase=""
# [non-Arch specific] Kernel localversion. Putting it to "Mario" will make for example the kernel version be 5.7.0-Mario (given by uname -r) # [non-Arch specific] Kernel localversion. Putting it to "Mario" will make for example the kernel version be 5.7.0-tkg-Mario (given by uname -r)
# If left empty, it will use -tkg-"${_cpusched}" where "${_cpusched}" will be replaced by the user chosen scheduler # If left empty, it will use -tkg-"${_cpusched}" where "${_cpusched}" will be replaced by the user chosen scheduler
_kernel_localversion="" _kernel_localversion=""

View File

@ -16,21 +16,24 @@ plain() {
echo "$1" >&2 echo "$1" >&2
} }
# alias plain=echo # Stop the script at any ecountered error
set -e set -e
_where=`pwd` _where=`pwd`
srcdir="$_where" srcdir="$_where"
_cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.8%2B.patch" source linux*-tkg-config/prepare
_cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v${_basekernel}%2B.patch"
source customization.cfg source customization.cfg
if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall" ]; then if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ]; then
echo "Command not recognised, options are: msg2 "Argument not recognised, options are:
- config : shallow clones the linux 5.8.x git tree into the folder linux-5.8, then applies on it the extra patches and prepares the .config file by copying the one from the current linux system in /boot/config-`uname -r` and updates it. - config : shallow clones the linux ${_basekernel}.x git tree into the folder linux-${_basekernel}, then applies on it the extra patches and prepares the .config file
- install : [Debian-like only (Debian, Ubuntu, Pop_os!...)], does the config step, proceeds to compile, then prompts to install by copying the one from the current linux system in /boot/config-`uname -r` and updates it.
- uninstall : [Debian-like only (Debian, Ubuntu, Pop_os!...)], lists the installed custom kernels through this script, then prompts for which one to uninstall." - install : [RPM and DEB based distros only], does the config step, proceeds to compile, then prompts to install
- uninstall-help : [RPM and DEB based distros only], lists the installed kernels in this system, then gives a hint on how to uninstall them manually."
exit 0 exit 0
fi fi
@ -44,22 +47,52 @@ _misc_adds="false" # We currently don't want this enabled on non-Arch
if [ "$1" = "install" ] || [ "$1" = "config" ]; then if [ "$1" = "install" ] || [ "$1" = "config" ]; then
source linux*-tkg-config/prepare if [ -z $_distro ] && [ "$1" = "install" ]; then
while true; do
echo "Which linux distribution are you running ?"
echo "if it's not on the list, chose the closest one to it: Fedora/Suse for RPM, Ubuntu/Debian for DEB"
echo " 1) Debian"
echo " 2) Fedora"
echo " 3) Suse"
echo " 4) Ubuntu"
read -p "[1-4]: " _distro_index
if [ $1 = "install" ] && [[ "$_distro" != "Ubuntu" && "$_distro" != "Debian" ]]; then if [ "$_distro_index" = "1" ]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Debian\" or \"Ubuntu\"" _distro="Debian"
msg2 "This script can only install custom kernels for Ubuntu and Debian derivatives. Exiting..." break
elif [ "$_distro_index" = "2" ]; then
_distro="Fedora"
break
elif [ "$_distro_index" = "3" ]; then
_distro="Suse"
break
elif [ "$_distro_index" = "4" ]; then
_distro="Ubuntu"
break
else
echo "Wrong index."
fi
done
fi
if [[ $1 = "install" && "$_distro" != "Ubuntu" && "$_distro" != "Debian" && "$_distro" != "Fedora" && "$_distro" != "Suse" ]]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Ubuntu\", \"Debian\", \"Fedora\" or \"Suse\""
msg2 "This script can only install custom kernels for RPM and DEB based distros, though only those keywords are permitted. Exiting..."
exit 0 exit 0
fi fi
if [ "$_distro" = "Debian" ] || [ "$_distro" = "Ubuntu" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
msg2 "Installing dependencies" msg2 "Installing dependencies"
sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex qtbase5-dev -y
else elif [ "$_distro" = "Fedora" ]; then
msg2 "Dependencies are unknown for the target linux distribution." msg2 "Installing dependencies"
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign grubby qt5-devel libXi-devel gcc-c++ git ccache flex bison elfutils-libelf-devel openssl-devel dwarves rpm-build -y
elif [ "$_distro" = "Suse" ]; then
msg2 "Installing dependencies"
sudo zypper install -y rpmdevtools ncurses-devel pesign libXi-devel gcc-c++ git ccache flex bison elfutils libelf-devel openssl-devel dwarves make patch bc rpm-build libqt5-qtbase-common-devel libqt5-qtbase-devel lz4
fi fi
# Force prepare script to avoid Arch specific commands if the user didn't change _distro from "Arch" # Force prepare script to avoid Arch specific commands if the user is using `config`
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
_distro="" _distro=""
fi fi
@ -135,74 +168,115 @@ if [ "$1" = "install" ]; then
# ccache # ccache
if [ "$_noccache" != "true" ]; then if [ "$_noccache" != "true" ]; then
if [[ "$_distro" = "Ubuntu" || "$_distro" = "Debian" ]] && dpkg -l ccache > /dev/null; then
if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
export PATH="/usr/lib/ccache/bin/:$PATH" export PATH="/usr/lib/ccache/bin/:$PATH"
export CCACHE_SLOPPINESS="file_macro,locale,time_macros" elif [ "$_distro" = "Fedora" ] || [ "$_distro" = "Suse" ]; then
export CCACHE_NOHASHDIR="true" export PATH="/usr/lib64/ccache/:$PATH"
msg2 'ccache was found and will be used'
fi fi
export CCACHE_SLOPPINESS="file_macro,locale,time_macros"
export CCACHE_NOHASHDIR="true"
msg2 'ccache was found and will be used'
fi fi
_kernel_flavor="${_kernel_localversion}"
if [ -z $_kernel_localversion ]; then if [ -z $_kernel_localversion ]; then
_kernel_flavor="tkg-${_cpusched}" _kernel_flavor="tkg-${_cpusched}"
else
_kernel_flavor="tkg-${_kernel_localversion}"
fi fi
if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then
msg2 "Building successfully finished!" msg2 "Building successfully finished!"
cd "$_where"
# Create DEBS folder if it doesn't exist
mkdir -p DEBS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv "$_where"/*.deb "$_where"/DEBS/
read -p "Do you want to install the new Kernel ? y/[n]: " _install read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [[ $_install =~ [yY] ]] || [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then if [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then
cd "$_where" cd "$_where"
_kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor _kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor
_headers_deb=linux-headers-${_kernelname}*.deb _headers_deb="linux-headers-${_kernelname}*.deb"
_image_deb=linux-image-${_kernelname}_*.deb _image_deb="linux-image-${_kernelname}_*.deb"
_kernel_devel_deb="linux-libc-dev_${_kernelname}*.rpm"
sudo dpkg -i $_headers_deb $_image_deb cd DEBS
sudo dpkg -i $_headers_deb $_image_deb $_kernel_devel_deb
fi
fi
# Add to the list of installed kernels, used for uninstall elif [[ "$_distro" = "Fedora" || "$_distro" = "Suse" ]]; then
if ! { [ -f installed-kernels ] && grep -Fxq "$_kernelname" installed-kernels; }; then
echo $_kernelname >> installed-kernels # Replace dashes with underscores, it seems that it's being done by binrpm-pkg
# Se we can actually refer properly to the rpm files.
_kernel_flavor=${_kernel_flavor//-/_}
if make -j ${_thread_num} rpm-pkg EXTRAVERSION="_${_kernel_flavor}"; then
msg2 "Building successfully finished!"
cd "$_where"
# Create RPMS folder if it doesn't exist
mkdir -p RPMS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv ~/rpmbuild/RPMS/x86_64/* "$_where"/RPMS/
#Clean up the original folder, unneeded and takes a lot of space
rm -rf ~/rpmbuild/
read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [ "$_install" = "y" ] || [ "$_install" = "Y" ] || [ "$_install" = "yes" ] || [ "$_install" = "Yes" ]; then
_kernelname=$_basekernel.${_kernel_subver}_$_kernel_flavor
_headers_rpm="kernel-headers-${_kernelname}*.rpm"
_kernel_rpm="kernel-${_kernelname}*.rpm"
_kernel_devel_rpm="kernel-devel-${_kernelname}*.rpm"
cd RPMS
if [ "$_distro" = "Fedora" ]; then
sudo dnf install $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
elif [ "$_distro" = "Suse" ]; then
msg2 "Some files from 'linux-glibc-devel' will be replaced by files from the custom kernel-hearders package"
msg2 "To revert back to the original kernel headers do 'sudo zypper install -f linux-glibc-devel'"
sudo zypper install --replacefiles --allow-unsigned-rpm $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
fi fi
msg2 "Install successful"
fi fi
fi fi
fi fi
fi fi
if [ "$1" = "uninstall" ]; then if [ "$1" = "uninstall-help" ]; then
cd "$_where" cd "$_where"
msg2 "List of installed custom tkg kernels: "
if [ ! -f installed-kernels ] || [ ! -s installed-kernels ]; then if [ "$_distro" = "Ubuntu" ]; then
echo "No custom kernel has been installed yet" dpkg -l "*tkg*" | grep "linux.*tkg"
exit 0 dpkg -l "*linux-libc-dev*" | grep "linux.*tkg"
msg2 "To uninstall a version, you should remove the linux-image, linux-headers and linux-libc-dev associated to it (if installed), with: "
msg2 " sudo apt remove linux-image-VERSION linux-headers-VERSION linux-libc-dev-VERSION"
msg2 " where VERSION is displayed in the lists above, uninstall only versions that have \"tkg\" in its name"
elif [ "$_distro" = "Fedora" ]; then
dnf list --installed kernel*
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo dnf remove --noautoremove kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second column"
elif [ "$_distro" = "Suse" ]; then
zypper packages --installed-only | grep "kernel.*tkg"
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo zypper remove --no-clean-deps kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second to last column"
fi fi
i=1
declare -a _custom_kernels
msg2 "Installed custom kernel versions: "
while read p; do
echo " $i) $p"
_custom_kernels+=($p)
i=$((i+1))
done < installed-kernels
i=$((i-1))
_delete_index=0
read -p "Which one would you like to delete ? [1-$i]: " _delete_index
if [ $_delete_index -ge 1 ] && [ $_delete_index -le $i ]; then
_delete_index=$((_delete_index-1))
sudo dpkg -r linux-headers-${_custom_kernels[$_delete_index]} linux-image-${_custom_kernels[$_delete_index]}
fi
rm -f installed-kernels
i=0
for kernel in "${_custom_kernels[@]}"; do
if [ $_delete_index != $i ]; then
echo "$kernel" >> installed-kernels
fi
i=$((i+1))
done
fi fi

View File

@ -36,6 +36,8 @@ fi
_tkg_initscript _tkg_initscript
_distro="Arch"
if [ -n "$_custom_pkgbase" ]; then if [ -n "$_custom_pkgbase" ]; then
pkgbase="${_custom_pkgbase}" pkgbase="${_custom_pkgbase}"
else else

View File

@ -27,33 +27,28 @@ You can enable support for it at the beginning of the PKGBUILD file. Make sure t
## Install procedure ## Install procedure
### Arch & derivatives ## Install procedure
```
git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux59-rc-tkg
# Edit customization.cfg file
makepkg -si
```
### Ubuntu & derivatives ### Fedora, Ubuntu and derivatives
``` ```
git clone https://github.com/Frogging-Family/linux-tkg.git git clone https://github.com/Frogging-Family/linux-tkg.git
cd linux-tkg/linux59-rc-tkg cd linux-tkg/linux59-rc-tkg
# Edit customization.cfg file to at least set _distro to "Ubuntu" # Optional: edit customization.cfg file
./install.sh install ./install.sh install
``` ```
To uninstall custom kernels installed through the script: Uninstalling custom kernels installed through the script has to be done
manually, the script can can help out with some useful information:
``` ```
cd path/to/linux-tkg/linux59-rc-tkg cd path/to/linux-tkg/linux59-rc-tkg
./install.sh uninstall ./install.sh uninstall-help
``` ```
### Other linux distributions ### Other linux distributions
Other distros are not supported, Debian may work with the `install.sh` script. Otherwise, If your distro is not DEB or RPM based, `install.sh` script can clone the kernel tree, patch and edit a `.config` file from your current distro's
that same `install.sh` script can clone, patch and edit a `.config` file from your current distro's that is expected at ``/boot/config-`uname -r`.config`` (otherwise it won't work as-is)
that is expected at ``/boot/config-`uname -r`.config``. Otherwise it won't work as-is.
The command to do for that is: The command to do for that is:
``` ```
./install.sh config ./install.sh config
``` ```

View File

@ -1,7 +1,9 @@
# linux59-TkG config file # linux59-TkG config file
# Linux distribution you are using, options are "Arch" (default), "Ubuntu" # Linux distribution you are using, options are "Arch", "Ubuntu", "Debian", "Fedora" or "Suse".
_distro="Arch" # It is automatically set to "Arch" when using PKGBUILD.
# If left empty, the script will prompt
_distro=""
#### MISC OPTIONS #### #### MISC OPTIONS ####

View File

@ -16,21 +16,24 @@ plain() {
echo "$1" >&2 echo "$1" >&2
} }
# alias plain=echo # Stop the script at any ecountered error
set -e set -e
_where=`pwd` _where=`pwd`
srcdir="$_where" srcdir="$_where"
source linux*-tkg-config/prepare
_cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.8%2B.patch" _cpu_opt_patch_link="https://raw.githubusercontent.com/graysky2/kernel_gcc_patch/master/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.8%2B.patch"
source customization.cfg source customization.cfg
if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall" ]; then if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ]; then
echo "Command not recognised, options are: msg2 "Argument not recognised, options are:
- config : shallow clones the linux 5.9.x git tree into the folder linux-5.9, then applies on it the extra patches and prepares the .config file by copying the one from the current linux system in /boot/config-`uname -r` and updates it. - config : shallow clones the linux ${_basekernel}.x git tree into the folder linux-${_basekernel}, then applies on it the extra patches and prepares the .config file
- install : [Debian-like only (Debian, Ubuntu, Pop_os!...)], does the config step, proceeds to compile, then prompts to install by copying the one from the current linux system in /boot/config-`uname -r` and updates it.
- uninstall : [Debian-like only (Debian, Ubuntu, Pop_os!...)], lists the installed custom kernels through this script, then prompts for which one to uninstall." - install : [RPM and DEB based distros only], does the config step, proceeds to compile, then prompts to install
- uninstall-help : [RPM and DEB based distros only], lists the installed kernels in this system, then gives a hint on how to uninstall them manually."
exit 0 exit 0
fi fi
@ -44,22 +47,52 @@ _misc_adds="false" # We currently don't want this enabled on non-Arch
if [ "$1" = "install" ] || [ "$1" = "config" ]; then if [ "$1" = "install" ] || [ "$1" = "config" ]; then
source linux*-tkg-config/prepare if [ -z $_distro ] && [ "$1" = "install" ]; then
while true; do
echo "Which linux distribution are you running ?"
echo "if it's not on the list, chose the closest one to it: Fedora/Suse for RPM, Ubuntu/Debian for DEB"
echo " 1) Debian"
echo " 2) Fedora"
echo " 3) Suse"
echo " 4) Ubuntu"
read -p "[1-4]: " _distro_index
if [ $1 = "install" ] && [ "$_distro" != "Ubuntu" ]; then if [ "$_distro_index" = "1" ]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Ubuntu\"" _distro="Debian"
msg2 "This script can only install custom kernels for Ubuntu and Debian derivatives. Exiting..." break
elif [ "$_distro_index" = "2" ]; then
_distro="Fedora"
break
elif [ "$_distro_index" = "3" ]; then
_distro="Suse"
break
elif [ "$_distro_index" = "4" ]; then
_distro="Ubuntu"
break
else
echo "Wrong index."
fi
done
fi
if [[ $1 = "install" && "$_distro" != "Ubuntu" && "$_distro" != "Debian" && "$_distro" != "Fedora" && "$_distro" != "Suse" ]]; then
msg2 "Variable \"_distro\" in \"customization.cfg\" hasn't been set to \"Ubuntu\", \"Debian\", \"Fedora\" or \"Suse\""
msg2 "This script can only install custom kernels for RPM and DEB based distros, though only those keywords are permitted. Exiting..."
exit 0 exit 0
fi fi
if [ "$_distro" = "Ubuntu" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
msg2 "Installing dependencies" msg2 "Installing dependencies"
sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex qtbase5-dev -y
else elif [ "$_distro" = "Fedora" ]; then
msg2 "Dependencies are unknown for the target linux distribution." msg2 "Installing dependencies"
sudo dnf install fedpkg fedora-packager rpmdevtools ncurses-devel pesign grubby qt5-devel libXi-devel gcc-c++ git ccache flex bison elfutils-libelf-devel openssl-devel dwarves rpm-build -y
elif [ "$_distro" = "Suse" ]; then
msg2 "Installing dependencies"
sudo zypper install -y rpmdevtools ncurses-devel pesign libXi-devel gcc-c++ git ccache flex bison elfutils libelf-devel openssl-devel dwarves make patch bc rpm-build libqt5-qtbase-common-devel libqt5-qtbase-devel lz4
fi fi
# Force prepare script to avoid Arch specific commands if the user didn't change _distro from "Arch" # Force prepare script to avoid Arch specific commands if the user is using `config`
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
_distro="" _distro=""
fi fi
@ -105,6 +138,9 @@ if [ "$1" = "install" ] || [ "$1" = "config" ]; then
msg2 "Copying current kernel's config and running make oldconfig..." msg2 "Copying current kernel's config and running make oldconfig..."
cp /boot/config-`uname -r` .config cp /boot/config-`uname -r` .config
if [ "$_distro" = "Debian" ]; then #Help Debian cert problem.
sed -i -e 's#CONFIG_SYSTEM_TRUSTED_KEYS="debian/certs/test-signing-certs.pem"#CONFIG_SYSTEM_TRUSTED_KEYS=""#g' .config
fi
yes '' | make oldconfig yes '' | make oldconfig
msg2 "Done" msg2 "Done"
@ -132,74 +168,115 @@ if [ "$1" = "install" ]; then
# ccache # ccache
if [ "$_noccache" != "true" ]; then if [ "$_noccache" != "true" ]; then
if [ "$_distro" = "Ubuntu" ] && dpkg -l ccache > /dev/null; then
if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
export PATH="/usr/lib/ccache/bin/:$PATH" export PATH="/usr/lib/ccache/bin/:$PATH"
export CCACHE_SLOPPINESS="file_macro,locale,time_macros" elif [ "$_distro" = "Fedora" ] || [ "$_distro" = "Suse" ]; then
export CCACHE_NOHASHDIR="true" export PATH="/usr/lib64/ccache/:$PATH"
msg2 'ccache was found and will be used'
fi fi
export CCACHE_SLOPPINESS="file_macro,locale,time_macros"
export CCACHE_NOHASHDIR="true"
msg2 'ccache was found and will be used'
fi fi
_kernel_flavor="${_kernel_localversion}"
if [ -z $_kernel_localversion ]; then if [ -z $_kernel_localversion ]; then
_kernel_flavor="tkg-${_cpusched}" _kernel_flavor="tkg-${_cpusched}"
else
_kernel_flavor="tkg-${_kernel_localversion}"
fi fi
if [ "$_distro" = "Ubuntu" ]; then if [ "$_distro" = "Ubuntu" ] || [ "$_distro" = "Debian" ]; then
if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then if make -j ${_thread_num} deb-pkg LOCALVERSION=-${_kernel_flavor}; then
msg2 "Building successfully finished!" msg2 "Building successfully finished!"
cd "$_where"
# Create DEBS folder if it doesn't exist
mkdir -p DEBS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv "$_where"/*.deb "$_where"/DEBS/
read -p "Do you want to install the new Kernel ? y/[n]: " _install read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [[ $_install =~ [yY] ]] || [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then if [[ $_install =~ [yY] ]] || [ $_install = "yes" ] || [ $_install = "Yes" ]; then
cd "$_where" cd "$_where"
_kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor _kernelname=$_basekernel.$_kernel_subver-$_kernel_flavor
_headers_deb=linux-headers-${_kernelname}*.deb _headers_deb="linux-headers-${_kernelname}*.deb"
_image_deb=linux-image-${_kernelname}_*.deb _image_deb="linux-image-${_kernelname}_*.deb"
_kernel_devel_deb="linux-libc-dev_${_kernelname}*.rpm"
sudo dpkg -i $_headers_deb $_image_deb cd DEBS
sudo dpkg -i $_headers_deb $_image_deb $_kernel_devel_deb
fi
fi
# Add to the list of installed kernels, used for uninstall elif [[ "$_distro" = "Fedora" || "$_distro" = "Suse" ]]; then
if ! { [ -f installed-kernels ] && grep -Fxq "$_kernelname" installed-kernels; }; then
echo $_kernelname >> installed-kernels # Replace dashes with underscores, it seems that it's being done by binrpm-pkg
# Se we can actually refer properly to the rpm files.
_kernel_flavor=${_kernel_flavor//-/_}
if make -j ${_thread_num} rpm-pkg EXTRAVERSION="_${_kernel_flavor}"; then
msg2 "Building successfully finished!"
cd "$_where"
# Create RPMS folder if it doesn't exist
mkdir -p RPMS
# Move rpm files to RPMS folder inside the linux-tkg folder
mv ~/rpmbuild/RPMS/x86_64/* "$_where"/RPMS/
#Clean up the original folder, unneeded and takes a lot of space
rm -rf ~/rpmbuild/
read -p "Do you want to install the new Kernel ? y/[n]: " _install
if [ "$_install" = "y" ] || [ "$_install" = "Y" ] || [ "$_install" = "yes" ] || [ "$_install" = "Yes" ]; then
_kernelname=$_basekernel.${_kernel_subver}_$_kernel_flavor
_headers_rpm="kernel-headers-${_kernelname}*.rpm"
_kernel_rpm="kernel-${_kernelname}*.rpm"
_kernel_devel_rpm="kernel-devel-${_kernelname}*.rpm"
cd RPMS
if [ "$_distro" = "Fedora" ]; then
sudo dnf install $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
elif [ "$_distro" = "Suse" ]; then
msg2 "Some files from 'linux-glibc-devel' will be replaced by files from the custom kernel-hearders package"
msg2 "To revert back to the original kernel headers do 'sudo zypper install -f linux-glibc-devel'"
sudo zypper install --replacefiles --allow-unsigned-rpm $_headers_rpm $_kernel_rpm $_kernel_devel_rpm
fi fi
msg2 "Install successful"
fi fi
fi fi
fi fi
fi fi
if [ "$1" = "uninstall" ]; then if [ "$1" = "uninstall-help" ]; then
cd "$_where" cd "$_where"
msg2 "List of installed custom tkg kernels: "
if [ ! -f installed-kernels ] || [ ! -s installed-kernels ]; then if [ "$_distro" = "Ubuntu" ]; then
echo "No custom kernel has been installed yet" dpkg -l "*tkg*" | grep "linux.*tkg"
exit 0 dpkg -l "*linux-libc-dev*" | grep "linux.*tkg"
msg2 "To uninstall a version, you should remove the linux-image, linux-headers and linux-libc-dev associated to it (if installed), with: "
msg2 " sudo apt remove linux-image-VERSION linux-headers-VERSION linux-libc-dev-VERSION"
msg2 " where VERSION is displayed in the lists above, uninstall only versions that have \"tkg\" in its name"
elif [ "$_distro" = "Fedora" ]; then
dnf list --installed kernel*
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo dnf remove --noautoremove kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second column"
elif [ "$_distro" = "Suse" ]; then
zypper packages --installed-only | grep "kernel.*tkg"
msg2 "To uninstall a version, you should remove the kernel, kernel-headers and kernel-devel associated to it (if installed), with: "
msg2 " sudo zypper remove --no-clean-deps kernel-VERSION kernel-devel-VERSION kernel-headers-VERSION"
msg2 " where VERSION is displayed in the second to last column"
fi fi
i=1
declare -a _custom_kernels
msg2 "Installed custom kernel versions: "
while read p; do
echo " $i) $p"
_custom_kernels+=($p)
i=$((i+1))
done < installed-kernels
i=$((i-1))
_delete_index=0
read -p "Which one would you like to delete ? [1-$i]: " _delete_index
if [ $_delete_index -ge 1 ] && [ $_delete_index -le $i ]; then
_delete_index=$((_delete_index-1))
sudo dpkg -r linux-headers-${_custom_kernels[$_delete_index]} linux-image-${_custom_kernels[$_delete_index]}
fi
rm -f installed-kernels
i=0
for kernel in "${_custom_kernels[@]}"; do
if [ $_delete_index != $i ]; then
echo "$kernel" >> installed-kernels
fi
i=$((i+1))
done
fi fi