Added --menu

Display or not menuconfig
This commit is contained in:
dbroqua 2020-04-25 19:02:43 +02:00
parent 36276fcf76
commit c1939808c9

View File

@ -1,19 +1,48 @@
#! /bin/bash #! /bin/bash
# Some colors
GREEN='\033[0;32m' GREEN='\033[0;32m'
RED='\033[0;31m'
DEFAULT='\033[0m' DEFAULT='\033[0m'
# Defaults values
PREFIX='linux-' PREFIX='linux-'
EXTENSION='.tar.xz' EXTENSION='.tar.xz'
SHOW_MENU_CONFIG=0
# Get last kernel version # Get last kernel version
INFO=`curl -Ls https://www.kernel.org/ | perl -lne 'BEGIN{$/=""} print "$1 $2" if \ INFO=`curl -Ls https://www.kernel.org/ | perl -lne 'BEGIN{$/=""} print "$1 $2" if \
/latest_link.*?<a.*?href=\"(.*?)\".*?>(.*?)</s'` /latest_link.*?<a.*?href=\"(.*?)\".*?>(.*?)</s'`
# Extract some values from kernel name
KERNEL=`echo ${INFO} | cut -d' ' -f 2` KERNEL=`echo ${INFO} | cut -d' ' -f 2`
URL=`echo ${INFO} | cut -d' ' -f 1` URL=`echo ${INFO} | cut -d' ' -f 1`
FILE=`echo ${URL}|rev|cut -d'/' -f 1 | rev` FILE=`echo ${URL}|rev|cut -d'/' -f 1 | rev`
DIR="/usr/src/${KERNEL}"
# Function to script script if step fail
isPreviousStepOk () {
if [ $? -ne 0 ]; then
echo "${RED} Error!${DEFAULT}"
exit 1
fi
}
# Get arguments from command line
while [ $# -gt 0 ]; do
case "$1" in
--menu)
SHOW_MENU_CONFIG=1
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
printf "***************************\n"
exit 1
esac
shift
done
# Make directory in /usr/src/ # Make directory in /usr/src/
DIR="/usr/src/${KERNEL}"
mkdir "${DIR}" mkdir "${DIR}"
# Install build dependancies # Install build dependancies
@ -30,49 +59,64 @@ apt install \
flex \ flex \
bison \ bison \
libncurses-dev \ libncurses-dev \
rsync rsync \
git
# Go to build dir # Go to build dir
cd "${DIR}" || exit cd "${DIR}" || exit
# Get kernel archive # Get kernel archive
wget ${URL} wget ${URL}
isPreviousStepOk
# Extract kernel archive # Extract kernel archive
tar xavf "${FILE}" tar xavf "${FILE}"
isPreviousStepOk
# Enter kernel directory # Enter kernel directory
cd "linux-${KERNEL}" || exit cd "linux-${KERNEL}"
isPreviousStepOk
# Get old config # Get old config
make olddefconfig make olddefconfig
isPreviousStepOk
# Show kernel menu # Show kernel menu
make menuconfig if [ ${SHOW_MENU_CONFIG} -eq 1 ]; then
make menuconfig
fi
# Some optimizations # Some optimizations
./scripts/config -d CONFIG_MODULE_SIG_ALL -d CONFIG_MODULE_SIG_KEY -d CONFIG_SYSTEM_TRUSTED_KEYS ./scripts/config -d CONFIG_MODULE_SIG_ALL -d CONFIG_MODULE_SIG_KEY -d CONFIG_SYSTEM_TRUSTED_KEYS
isPreviousStepOk
./scripts/config -d CONFIG_DEBUG_INFO ./scripts/config -d CONFIG_DEBUG_INFO
isPreviousStepOk
# Compile kernel # Compile kernel
make deb-pkg -j"$(nproc)" LOCALVERSION=-"$(dpkg --print-architecture)" \ make deb-pkg -j"$(nproc)" LOCALVERSION=-"$(dpkg --print-architecture)" \
KDEB_PKGVERSION="$(make kernelversion)-1" KDEB_PKGVERSION="$(make kernelversion)-1"
isPreviousStepOk
# Optimization # Optimization
make bindeb-pkg -j"$(nproc)" LOCALVERSION=-"$(dpkg --print-architecture)" \ make bindeb-pkg -j"$(nproc)" LOCALVERSION=-"$(dpkg --print-architecture)" \
KDEB_PKGVERSION="$(make kernelversion)-1" KDEB_PKGVERSION="$(make kernelversion)-1"
isPreviousStepOk
# Go to parent directory # Go to parent directory
cd .. cd ..
# Install new packages # Install new packages
dpkg -i ./*${KERNEL}*.deb dpkg -i ./*${KERNEL}*.deb
isPreviousStepOk
# Update acpi_call # Update acpi_call
git clone git://github.com/teleshoes/acpi_call.git /tmp/acpi_call git clone git://github.com/teleshoes/acpi_call.git /tmp/acpi_call
isPreviousStepOk
cd /tmp/acpi_call cd /tmp/acpi_call
make make
isPreviousStepOk
make install make install
isPreviousStepOk
cd /tmp cd /tmp
# Clean directories # Clean directories