Add Ubuntu install script + general-ish .config&patching script (#26)
* linux57: Add make xconfig option * Linux57: copy PKGBUILD initial commands to _tkg_initscript() * linux57: Update _tkg_initscript() in "tkg-config/prepare" * linux57: Add _define_vars() function in tkg-config/prepare * linux57: Prepend "$_where" to patch paths, in _tkg_srcprep() This is done to be able to change the $_where in the non-Arch install script * linux57: Add distro choice config in customization.cfg, enable "Ubuntu" as option Show options that won't apply when target distro is Ubuntu * linux57: Isolate Arch specific commands in _tkg_srcprep() * linux57: make _tkg_initscript() more verbose * WIP: linux57: Add install.sh script The script downloads linux's source code, applies patches, and handles the .config file after copying the one from the distribution it's running on. TODO: Implement install (and maybe uninstall) * linux57: Add make xconfig option description in customization.cfg * linux57: Fix _EXT_CONFIG_PATH usage and variable sourcing * linux57: Add missing space in condition * linux57: Make _EXT_CONFIG_PATH description as usable by Ubuntu install script * linux57: Add LOCALVERSION kernel choice variable in customization.cfg For now it won't apply for Arch, but can be implemented * linux57: Properly delete linux source folder * linux57: Add progress message when doing make oldconfig * linux57: Add kernel compilation for Ubuntu * linux57: Fix warning in if condition * linux57: Add message when downloading CPU opt patch * linux57: Make script exit at any error * linux57: Move to linux (base version + subversion patch) approach * linux57: Use git to get/reset linux sources and move between subversions This approach has the least impact on the hard-drive given that only the files that need to be changed get changed by git. * linux57: Fix external config loading message * linux57: install.sh: use latest subersion, enable reverting to older ones * linux57: Add extra cleanup steps * Move user_patcher() to tkg-config/prepare * linux57: restore old patch files for old kernel subversions Old kernel subversions are needed for Ubuntu since the latest ones fail to build. * linux57: Define and use script location variable Makes folder navigation more reliable in the script * linux57: Add install step * linux57: install.sh: Uncomment compilation step * linux57: install.sh: Add "config" and "install" commands * linux57: install.sh: Add uninstall command * linux57: Add relative path for misc-patch * Fix leak error for CONFIG_PDS in make deb-pkg * linux57: Define _where in _tkg_srcprep for Arch * Revert "linux57: restore old patch files for old kernel subversions" This reverts commit 65dcbd654c4151283189505c826903c342782d0e. * linux57: Update shasum for pds-undead patch * linux57: Drop support for reverting to older subversions Latest kernel subversions should now work on other distros too * linux57: install.sh load user given customization.cfg first * linux57: install.sh install Ubuntu dependencies * linux57: install.sh: add help message for available commands * linux57: replace _misc_adds with _distro variable * linux57: Update README.md * linux57: README.md: fix typo * linux57: README.md: remove "nano customization.cfg" line * linux57: README.md: fix formatting * Revert "linux57: Update shasum for pds-undead patch" This reverts commit 3c6abef7993a02fc0ae97c23aab379968daa3a31. * Revert "Fix leak error for CONFIG_PDS in make deb-pkg" This reverts commit 40a2a002ae060b309a465d5b6c22a7b91828af0a. * linux57: tkg-config/prepare: remove unused variable defines * linux57: install.sh: use var for folder cleanup * Revert "linux57: replace _misc_adds with _distro variable" This reverts commit 9efdd31b8c0e4c34b2e2878de5bca83ea8e73018.
This commit is contained in:

committed by
GitHub

parent
d039728f97
commit
3c7fd7b2e5
@@ -1,68 +1,226 @@
|
||||
#!/bin/bash
|
||||
|
||||
_tkg_srcprep() {
|
||||
msg2 "Setting version..."
|
||||
scripts/setlocalversion --save-scmversion
|
||||
echo "-$pkgrel-tkg-${_cpusched}" > localversion.10-pkgrel
|
||||
echo "" > localversion.20-pkgname
|
||||
_define_vars() {
|
||||
_basekernel=5.7
|
||||
_where="$_script_loc/linux-${_basekernel}"
|
||||
_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"
|
||||
}
|
||||
|
||||
# add upstream patch
|
||||
patch -p1 -i ../patch-"${pkgver}"
|
||||
_tkg_initscript() {
|
||||
|
||||
# ARCH Patches
|
||||
if [ "${_configfile}" == "config_hardened.x86_64" ] && [ "${_cpusched}" == "cfs" ]; then
|
||||
msg2 "Using linux hardened patchset"
|
||||
patch -Np1 -i ../0012-linux-hardened.patch
|
||||
cp $_script_loc/linux57-tkg-patches/* "$_where" # copy patches inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking
|
||||
cp $_script_loc/linux57-tkg-config/* "$_where" # copy config files and hooks inside the PKGBUILD's dir to preserve makepkg sourcing and md5sum checking
|
||||
|
||||
|
||||
cd $_script_loc/linux-${_basekernel}
|
||||
msg2 "Downloading Graysky2's CPU optimisations patch"
|
||||
wget $_cpu_opt_patch_link
|
||||
msg2 "Done"
|
||||
cd $_script_loc
|
||||
|
||||
if [ -z "$_OPTIPROFILE" ] && [ ! -e "$_where"/cpuschedset ]; then
|
||||
# Prompt about optimized configurations. Available variable values will overwrite customization.cfg/external config ones.
|
||||
plain "Do you want to use a predefined optimized profile?"
|
||||
read -rp "`echo $' > 1.Custom\n 2.Ryzen Desktop (Performance)\n 3.Other Desktop (Performance)\nchoice[1-3?]: '`" _OPTIPROFILE;
|
||||
fi
|
||||
if [ "$_OPTIPROFILE" == "2" ]; then
|
||||
source "$_where"/ryzen-desktop-profile.cfg && msg2 "Ryzen Desktop (Performance) profile will be used." && msg2 ""
|
||||
elif [ "$_OPTIPROFILE" == "3" ]; then
|
||||
source "$_where"/generic-desktop-profile.cfg && msg2 "Generic Desktop (Performance) profile will be used." && msg2 ""
|
||||
fi
|
||||
|
||||
# source cpuschedset early if present
|
||||
if [ -e "$_where"/cpuschedset ]; then
|
||||
source "$_where"/cpuschedset
|
||||
fi
|
||||
|
||||
# CPU SCHED selector
|
||||
if [ -z "$_cpusched" ] && [ ! -e "$_where"/cpuschedset ]; then
|
||||
plain "What CPU sched variant do you want to build/install?"
|
||||
read -rp "`echo $' > 1.PDS\n 2.MuQSS\n 3.BMQ\n 4.CFS\nchoice[1-4?]: '`" CONDITION;
|
||||
if [ "$CONDITION" == "2" ]; then
|
||||
echo "_cpusched=\"MuQSS\"" > "$_where"/cpuschedset
|
||||
elif [ "$CONDITION" == "3" ]; then
|
||||
echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset
|
||||
elif [ "$CONDITION" == "4" ]; then
|
||||
echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset
|
||||
else
|
||||
echo "_cpusched=\"pds\"" > "$_where"/cpuschedset
|
||||
fi
|
||||
if [ -n "$_custom_pkgbase" ]; then
|
||||
echo "_custom_pkgbase=\"${_custom_pkgbase}\"" >> "$_where"/cpuschedset
|
||||
fi
|
||||
elif [ "$_cpusched" == "muqss" ] || [ "$_cpusched" == "MuQSS" ]; then
|
||||
echo "_cpusched=\"MuQSS\"" > "$_where"/cpuschedset
|
||||
elif [ "$_cpusched" == "pds" ]; then
|
||||
echo "_cpusched=\"pds\"" > "$_where"/cpuschedset
|
||||
elif [ "$_cpusched" == "bmq" ]; then
|
||||
echo "_cpusched=\"bmq\"" > "$_where"/cpuschedset
|
||||
else
|
||||
patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
|
||||
echo "_cpusched=\"cfs\"" > "$_where"/cpuschedset
|
||||
fi
|
||||
|
||||
source "$_where"/cpuschedset
|
||||
}
|
||||
|
||||
user_patcher() {
|
||||
# To patch the user because all your base are belong to us
|
||||
local _patches=("$_where"/*."${_userpatch_ext}revert")
|
||||
if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then
|
||||
if [ "$_user_patches_no_confirm" != "true" ]; then
|
||||
msg2 "Found ${#_patches[@]} 'to revert' userpatches for ${_userpatch_target}:"
|
||||
printf '%s\n' "${_patches[@]}"
|
||||
read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION;
|
||||
fi
|
||||
if [ "$_CONDITION" == "y" ] || [ "$_user_patches_no_confirm" == "true" ]; then
|
||||
for _f in "${_patches[@]}"; do
|
||||
if [ -e "${_f}" ]; then
|
||||
msg2 "######################################################"
|
||||
msg2 ""
|
||||
msg2 "Reverting your own ${_userpatch_target} patch ${_f}"
|
||||
msg2 ""
|
||||
msg2 "######################################################"
|
||||
patch -Np1 -R < "${_f}"
|
||||
echo "Reverted your own patch ${_f}" >> "$_where"/last_build_config.log
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
_patches=("$_where"/*."${_userpatch_ext}patch")
|
||||
if [ ${#_patches[@]} -ge 2 ] || [ -e "${_patches}" ]; then
|
||||
if [ "$_user_patches_no_confirm" != "true" ]; then
|
||||
msg2 "Found ${#_patches[@]} userpatches for ${_userpatch_target}:"
|
||||
printf '%s\n' "${_patches[@]}"
|
||||
read -rp "Do you want to install it/them? - Be careful with that ;)"$'\n> N/y : ' _CONDITION;
|
||||
fi
|
||||
if [ "$_CONDITION" == "y" ] || [ "$_user_patches_no_confirm" == "true" ]; then
|
||||
for _f in "${_patches[@]}"; do
|
||||
if [ -e "${_f}" ]; then
|
||||
msg2 "######################################################"
|
||||
msg2 ""
|
||||
msg2 "Applying your own ${_userpatch_target} patch ${_f}"
|
||||
msg2 ""
|
||||
msg2 "######################################################"
|
||||
patch -Np1 < "${_f}"
|
||||
echo "Applied your own patch ${_f}" >> "$_where"/last_build_config.log
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_tkg_srcprep() {
|
||||
|
||||
if [ "${_distro}" == "Arch" ]; then
|
||||
_where=".."
|
||||
|
||||
msg2 "Setting version..."
|
||||
scripts/setlocalversion --save-scmversion
|
||||
echo "-$pkgrel-tkg-${_cpusched}" > localversion.10-pkgrel
|
||||
echo "" > localversion.20-pkgname
|
||||
|
||||
# add upstream patch
|
||||
msg2 "Patching from $_basekernel to $pkgver"
|
||||
patch -p1 -i "$_where"/patch-"${pkgver}"
|
||||
msg2 "Done"
|
||||
|
||||
# ARCH Patches
|
||||
if [ "${_configfile}" == "config_hardened.x86_64" ] && [ "${_cpusched}" == "cfs" ]; then
|
||||
msg2 "Using linux hardened patchset"
|
||||
patch -Np1 -i "$_where"/0012-linux-hardened.patch
|
||||
msg2 "Done"
|
||||
else
|
||||
patch -Np1 -i "$_where"/0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch
|
||||
fi
|
||||
fi
|
||||
|
||||
# graysky's cpu opts - https://github.com/graysky2/kernel_gcc_patch
|
||||
msg2 "Applying graysky's cpu opts patch"
|
||||
patch -Np1 -i ../enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.7%2B.patch
|
||||
if [ "${_distro}" == "Arch" ]; then
|
||||
patch -Np1 -i "$_where"/enable_additional_cpu_optimizations_for_gcc_v10.1%2B_kernel_v5.7%2B.patch
|
||||
else
|
||||
patch -Np1 -i "$_where"/enable_additional_cpu_optimizations_for_gcc_v10.1+_kernel_v5.7+.patch
|
||||
fi
|
||||
msg2 "Done"
|
||||
|
||||
# TkG
|
||||
msg2 "Applying clear linux patches"
|
||||
patch -Np1 -i ../0002-clear-patches.patch
|
||||
patch -Np1 -i "$_where"/0002-clear-patches.patch
|
||||
msg2 "Done"
|
||||
|
||||
msg2 "Applying glitched base patch"
|
||||
patch -Np1 -i ../0003-glitched-base.patch
|
||||
patch -Np1 -i "$_where"/0003-glitched-base.patch
|
||||
msg2 "Done"
|
||||
|
||||
if [ "$_misc_adds" = "true" ]; then
|
||||
msg2 "Applying misc additions patch"
|
||||
patch -Np1 -i ../0012-misc-additions.patch
|
||||
patch -Np1 -i "$_where"/0012-misc-additions.patch
|
||||
fi
|
||||
|
||||
if [ "${_cpusched}" == "MuQSS" ]; then
|
||||
# MuQSS
|
||||
patch -Np1 -i ../0004-5.7-ck1.patch
|
||||
msg2 "Applying MuQSS base patch"
|
||||
patch -Np1 -i "$_where"/0004-5.7-ck1.patch
|
||||
msg2 "Done"
|
||||
|
||||
if [ "${_aggressive_ondemand}" == "true" ]; then
|
||||
patch -Np1 -i ../0004-glitched-ondemand-muqss.patch
|
||||
msg2 "Applying MuQSS agressive ondemand governor patch"
|
||||
patch -Np1 -i "$_where"/0004-glitched-ondemand-muqss.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
patch -Np1 -i ../0004-glitched-muqss.patch
|
||||
|
||||
msg2 "Applying Glitched MuQSS patch"
|
||||
patch -Np1 -i "$_where"/0004-glitched-muqss.patch
|
||||
msg2 "Done"
|
||||
|
||||
elif [ "${_cpusched}" == "pds" ]; then
|
||||
# PDS-mq
|
||||
patch -Np1 -i ../0005-v5.7_undead-pds099o.patch
|
||||
msg2 "Applying PDS base patch"
|
||||
patch -Np1 -i "$_where"/0005-v5.7_undead-pds099o.patch
|
||||
msg2 "Done"
|
||||
|
||||
if [ "${_aggressive_ondemand}" == "true" ]; then
|
||||
patch -Np1 -i ../0005-glitched-ondemand-pds.patch
|
||||
msg2 "Applying PDS agressive ondemand governor patch"
|
||||
patch -Np1 -i "$_where"/0005-glitched-ondemand-pds.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
patch -Np1 -i ../0005-glitched-pds.patch
|
||||
|
||||
msg2 "Applying Glitched PDS patch"
|
||||
patch -Np1 -i "$_where"/0005-glitched-pds.patch
|
||||
msg2 "Done"
|
||||
|
||||
elif [ "${_cpusched}" == "bmq" ]; then
|
||||
|
||||
# Project C / BMQ
|
||||
msg2 "Applying Project C / BMQ base patch"
|
||||
|
||||
patch -Np1 -i ../0009-prjc_v5.7-r3.patch
|
||||
msg2 "Done"
|
||||
|
||||
if [ "${_aggressive_ondemand}" == "true" ]; then
|
||||
patch -Np1 -i ../0009-glitched-ondemand-bmq.patch
|
||||
msg2 "Applying BMQ agressive ondemand governor patch"
|
||||
patch -Np1 -i "$_where"/0009-glitched-ondemand-bmq.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
patch -Np1 -i ../0009-glitched-bmq.patch
|
||||
|
||||
msg2 "Applying Glitched BMQ patch"
|
||||
patch -Np1 -i "$_where"/0009-glitched-bmq.patch
|
||||
msg2 "Done"
|
||||
else
|
||||
patch -Np1 -i ../0003-glitched-cfs.patch
|
||||
msg2 "Applying Glitched CFS patch"
|
||||
patch -Np1 -i "$_where"/0003-glitched-cfs.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
|
||||
if [ -z "${_configfile}" ]; then
|
||||
if [ "${_distro}" == "Arch" ]; then
|
||||
if [ -z "${_configfile}" ]; then
|
||||
_configfile="config.x86_64"
|
||||
fi
|
||||
fi
|
||||
|
||||
cat "${srcdir}/${_configfile}" > ./.config
|
||||
fi
|
||||
|
||||
cat "${srcdir}/${_configfile}" > ./.config
|
||||
|
||||
# Set some -tkg defaults
|
||||
echo "# CONFIG_DYNAMIC_FAULT is not set" >> ./.config
|
||||
@@ -81,8 +239,10 @@ _tkg_srcprep() {
|
||||
sed -i -e 's/# CONFIG_CMDLINE_BOOL is not set/CONFIG_CMDLINE_BOOL=y/' ./.config
|
||||
echo "CONFIG_CMDLINE=\"${_custom_commandline}\"" >> ./.config
|
||||
echo "# CONFIG_CMDLINE_OVERRIDE is not set" >> ./.config
|
||||
if [ "$_noccache" != "true" ] && pacman -Qq ccache &> /dev/null; then
|
||||
sed -i -e 's/CONFIG_GCC_PLUGINS=y/# CONFIG_GCC_PLUGINS is not set/' ./.config
|
||||
if [ "$_noccache" != "true" ]; then
|
||||
if { [ "$_distro" == "Arch" ] && pacman -Qq ccache &> /dev/null; } || { [ "$_distro" == "Ubuntu" ] && dpkg -l ccache > /dev/null; }; then
|
||||
sed -i -e 's/CONFIG_GCC_PLUGINS=y/# CONFIG_GCC_PLUGINS is not set/' ./.config
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$_font_autoselect" != "false" ]; then
|
||||
@@ -557,7 +717,9 @@ _tkg_srcprep() {
|
||||
read -rp "`echo $' > N/y : '`" CONDITION7;
|
||||
fi
|
||||
if [ "$CONDITION7" == "y" ] || [ "$_acs_override" == "true" ]; then
|
||||
patch -Np1 -i ../0006-add-acs-overrides_iommu.patch
|
||||
msg2 "Patching ACS override"
|
||||
patch -Np1 -i "$_where"/0006-add-acs-overrides_iommu.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
|
||||
# bcachefs
|
||||
@@ -568,7 +730,10 @@ _tkg_srcprep() {
|
||||
read -rp "`echo $' > N/y : '`" CONDITION8;
|
||||
fi
|
||||
if [ "$CONDITION8" == "y" ] || [ "$_bcachefs" == "true" ]; then
|
||||
patch -Np1 -i ../0008-5.7-bcachefs.patch
|
||||
msg2 "Patching Bcache filesystem support override"
|
||||
patch -Np1 -i "$_where"/0008-5.7-bcachefs.patch
|
||||
msg2 "Done"
|
||||
|
||||
echo "CONFIG_BCACHEFS_FS=m" >> ./.config
|
||||
echo "CONFIG_BCACHEFS_QUOTA=y" >> ./.config
|
||||
echo "CONFIG_BCACHEFS_POSIX_ACL=y" >> ./.config
|
||||
@@ -585,7 +750,9 @@ _tkg_srcprep() {
|
||||
read -rp "`echo $' > N/y : '`" CONDITION9;
|
||||
fi
|
||||
if [ "$CONDITION9" == "y" ] || [ "$_fsync" == "true" ]; then
|
||||
patch -Np1 -i ../0007-v5.7-fsync.patch
|
||||
msg2 "Patching Fsync support"
|
||||
patch -Np1 -i "$_where"/0007-v5.7-fsync.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
|
||||
# ZFS fix
|
||||
@@ -596,7 +763,9 @@ _tkg_srcprep() {
|
||||
read -rp "`echo $' > N/y : '`" CONDITION11;
|
||||
fi
|
||||
if [ "$CONDITION11" == "y" ] || [ "$_zfsfix" == "true" ]; then
|
||||
patch -Np1 -i ../0011-ZFS-fix.patch
|
||||
msg2 "Patching missing symbol for AES-NI/AVX support on ZFS"
|
||||
patch -Np1 -i "$_where"/0011-ZFS-fix.patch
|
||||
msg2 "Done"
|
||||
fi
|
||||
|
||||
# Community patches
|
||||
@@ -622,12 +791,14 @@ _tkg_srcprep() {
|
||||
rm -f "$_where"/$_p
|
||||
done
|
||||
|
||||
# don't run depmod on 'make install'. We'll do this ourselves in packaging
|
||||
sed -i '2iexit 0' scripts/depmod.sh
|
||||
|
||||
# get kernel version
|
||||
make prepare
|
||||
if [ "$_distro" == "Arch" ]; then
|
||||
# don't run depmod on 'make install'. We'll do this ourselves in packaging
|
||||
sed -i '2iexit 0' scripts/depmod.sh
|
||||
|
||||
# get kernel version
|
||||
make prepare
|
||||
fi
|
||||
|
||||
# modprobed-db
|
||||
if [ -z "$_modprobeddb" ]; then
|
||||
plain ""
|
||||
@@ -678,7 +849,7 @@ _tkg_srcprep() {
|
||||
plain "to configure the kernel before building it?"
|
||||
plain "If you do, make sure your terminal is currently"
|
||||
plain "at least 19 lines by 80 columns large or you'll get an error :D"
|
||||
read -rp "`echo $' > 0. nope\n 1. menuconfig\n 2. nconfig\n choice[0-2?]: '`" CONDITIONMNC;
|
||||
read -rp "`echo $' > 0. nope\n 1. menuconfig\n 2. nconfig\n 3. xconfig\n choice[0-3?]: '`" CONDITIONMNC;
|
||||
_menunconfig="$CONDITIONMNC"
|
||||
fi
|
||||
if [ 1 = "$_menunconfig" ]; then
|
||||
@@ -687,11 +858,14 @@ _tkg_srcprep() {
|
||||
elif [ 2 = "$_menunconfig" ]; then
|
||||
cp .config .config.orig
|
||||
make nconfig
|
||||
elif [ 3 = "$_menunconfig" ]; then
|
||||
cp .config .config.orig
|
||||
make xconfig
|
||||
else
|
||||
# rewrite configuration
|
||||
yes "" | make config >/dev/null
|
||||
fi
|
||||
if [ 1 = "$_menunconfig" ] || [ 2 = "$_menunconfig" ]; then
|
||||
if [ 1 = "$_menunconfig" ] || [ 2 = "$_menunconfig" ] || [ 3 = "$_menunconfig" ]; then
|
||||
if [ -z "${_diffconfig}" ]; then
|
||||
while true; do
|
||||
read -r -p 'Generate a config fragment from your changes? [y/N] ' CONDITIONF
|
||||
@@ -723,6 +897,8 @@ _tkg_srcprep() {
|
||||
rm .config.orig
|
||||
fi
|
||||
|
||||
make -s kernelrelease > version
|
||||
msg2 "Prepared %s version %s" "$pkgbase" "$(<version)"
|
||||
if [ "$_distro" == "Arch" ]; then
|
||||
make -s kernelrelease > version
|
||||
msg2 "Prepared %s version %s" "$pkgbase" "$(<version)"
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user