diff --git a/README.md b/README.md index 7de5696..5049b3c 100644 --- a/README.md +++ b/README.md @@ -119,3 +119,11 @@ The command to do for that is: ./install.sh config ``` +If one chooses `Generic` as distro. `./install.sh install` will compile the kernel then prompt before doing the following: +```shell +sudo make modules_install +sudo make install +sudo dracut --hostonly --kver $_kernelname +sudo grub-mkconfig -o /boot/grub/grub.cfg +``` + diff --git a/customization.cfg b/customization.cfg index 3c0404d..3445a29 100644 --- a/customization.cfg +++ b/customization.cfg @@ -1,6 +1,6 @@ # linux-TkG config file -# Linux distribution you are using, options are "Arch", "Void", "Ubuntu", "Debian", "Fedora" or "Suse". +# Linux distribution you are using, options are "Arch", "Void", "Ubuntu", "Debian", "Fedora", "Suse", "Generic". # It is automatically set to "Arch" when using PKGBUILD. # If left empty, the script will prompt _distro="" @@ -61,11 +61,11 @@ _diffconfig_name="" # Name of the default config file to use for the kernel # Default (empty): # - Archlinux (PKGBUILD): "config.x86_64" from the linux-tkg-config/5.y folder. -# - install.sh: Picks the .config file from the currently running kernel. +# - install.sh: Picks the .config file from the currently running kernel. # It is recommended to be running an official kernel before running this script, to pick off a correct .config file -# User provided: +# User provided: # - Archlinux : use "config_hardened.x86_64" to get a hardened kernel. To get a complete hardened setup, you have to use "cfs" as _cpusched. -# - Any : custom user provided file, the given path should be relative to the PKGBUILD file. This enables for example to use a user stripped down .config file. +# - Any : custom user provided file, the given path should be relative to the PKGBUILD file. This enables for example to use a user stripped down .config file. # If the .config file isn't up to date with the chosen kernel version, any extra CONFIG_XXXX is set to its default value. # Note: the script copies the resulting .config file as "kernelconfig.new" next to the PKGBUILD as a convenience for an eventual re-use. It gets overwritten at each run. # One can use "kernelconfig.new" here to always use the latest edited .config file. modprobed-db needs to be used only once for its changes to be picked up. diff --git a/install.sh b/install.sh index 39d1d93..479ae9b 100755 --- a/install.sh +++ b/install.sh @@ -25,7 +25,8 @@ _distro_prompt() { echo " 2) Fedora" echo " 3) Suse" echo " 4) Ubuntu" - read -p "[1-4]: " _distro_index + echo " 5) Generic" + read -p "[1-5]: " _distro_index if [ "$_distro_index" = "1" ]; then _distro="Debian" @@ -39,6 +40,9 @@ _distro_prompt() { elif [ "$_distro_index" = "4" ]; then _distro="Ubuntu" break + elif [ "$_distro_index" = "5" ]; then + _distro="Generic" + break else echo "Wrong index." fi @@ -180,9 +184,12 @@ source linux-tkg-config/prepare if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ]; then msg2 "Argument not recognised, options are: - config : interactive script that shallow clones the linux 5.x.y git tree into the folder linux-src-git, then applies extra patches and prepares the .config file - by copying the one from the currently running linux system and updates it. - - install : [for RPM and DEB based distros only], does the config step, proceeds to compile, then prompts to install - - uninstall-help : [for RPM and DEB based distros only], lists the installed kernels in this system, then gives hints on how to uninstall them manually." + by copying the one from the currently running linux system and updates it. + - install : does the config step, proceeds to compile, then prompts to install + - 'DEB' distros: it creates .deb packages that will be installed then stored in the DEBS folder. + - 'RPM' distros: it creates .rpm packages that will be installed then stored in the RPMS folder. + - 'Generic' distro: it uses 'make modules_install' and 'make install', uses 'dracut' to create an initramfs, then updates grub's boot entry. + - uninstall-help : [RPM and DEB based distros only], lists the installed kernels in this system, then gives hints on how to uninstall them manually." exit 0 fi @@ -205,7 +212,7 @@ if [ "$1" = "install" ] || [ "$1" = "config" ]; then # Run init script that is also run in PKGBUILD, it will define some env vars that we will use _tkg_initscript - if [[ $1 = "install" && ! "$_distro" =~ ^(Ubuntu|Debian|Fedora|Suse)$ ]]; then + if [[ $1 = "install" && ! "$_distro" =~ ^(Ubuntu|Debian|Fedora|Suse|Generic)$ ]]; 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 @@ -303,17 +310,11 @@ if [ "$1" = "install" ]; then # ccache if [ "$_noccache" != "true" ]; then - # Todo: deal with generic and paths, maybe just export boths possibilities and not care - if [[ "$_distro" =~ ^(Ubuntu|Debian)$ ]]; then - export PATH="/usr/lib/ccache/bin/:$PATH" - elif [[ "$_distro" =~ ^(Fedora|Suse)$ ]]; then - export PATH="/usr/lib64/ccache/:$PATH" - fi + export PATH="/usr/lib64/ccache/:/usr/lib/ccache/bin/:$PATH" export CCACHE_SLOPPINESS="file_macro,locale,time_macros" export CCACHE_NOHASHDIR="true" msg2 'Enabled ccache' - fi if [ -z $_kernel_localversion ]; then @@ -404,6 +405,36 @@ if [ "$1" = "install" ]; then msg2 "Install successful" fi fi + + elif [ "$_distro" = "Generic" ]; then + + ./scripts/config --set-str LOCALVERSION "-${_kernel_flavor}" + + if make ${llvm_opt} -j ${_thread_num}; then + + if [[ "$_sub" = rc* ]]; then + _kernelname=$_basekernel.${_kernel_subver}-${_sub}-$_kernel_flavor + else + _kernelname=$_basekernel.${_kernel_subver}-$_kernel_flavor + fi + + msg2 "Building successful" + msg2 "The installation process will run the following commands:" + msg2 " sudo make modules_install" + msg2 " sudo make install" + msg2 " sudo dracut --hostonly --kver $_kernelname" + msg2 " sudo grub-mkconfig -o /boot/grub/grub.cfg" + read -p "Continue ? [Y/n]: " _continue + + if ! [[ $_continue =~ ^(Y|y|Yes|yes)$ ]];then + exit 0 + fi + + sudo make modules_install + sudo make install + sudo dracut --hostonly --kver $_kernelname + sudo grub-mkconfig -o /boot/grub/grub.cfg + fi fi fi @@ -414,9 +445,9 @@ if [ "$1" = "uninstall-help" ]; then fi cd "$_where" - msg2 "List of installed custom tkg kernels: " if [ "$_distro" = "Ubuntu" ]; then + msg2 "List of installed custom tkg kernels: " dpkg -l "*tkg*" | grep "linux.*tkg" 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: " @@ -424,17 +455,28 @@ if [ "$1" = "uninstall-help" ]; then msg2 " where VERSION is displayed in the lists above, uninstall only versions that have \"tkg\" in its name" msg2 "Note: linux-libc-dev packages are no longer created and installed, you can safely remove any remnants." elif [ "$_distro" = "Fedora" ]; then + msg2 "List of installed custom tkg kernels: " 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" msg2 "Note: kernel-headers packages are no longer created and installed, you can safely remove any remnants." elif [ "$_distro" = "Suse" ]; then + msg2 "List of installed custom tkg kernels: " 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" msg2 "Note: kernel-headers packages are no longer created and installed, you can safely remove any remnants." + elif [ "$_distro" = "Generic" ]; then + msg2 "Folders in /lib/modules :" + ls /lib/modules + msg2 "Files in /boot :" + ls /boot + msg2 "To uninstall a kernel version installed through install.sh with 'Generic' as a distro:" + msg2 " - Remove manually the corresponding folder in '/lib/modules'" + msg2 " - Remove manually the corresponding 'System.map', 'vmlinuz', 'config' and 'initramfs' in the folder :/boot" + msg2 " - Update the boot menu. e.g. 'sudo grub-mkconfig -o /boot/grub/grub.cfg'" fi fi