- Added menu and avaibility to use custom kernel

This commit is contained in:
dbroqua 2020-05-05 15:22:01 +02:00
parent c1939808c9
commit 7538c4195d

View file

@ -10,14 +10,6 @@ PREFIX='linux-'
EXTENSION='.tar.xz'
SHOW_MENU_CONFIG=0
# Get last kernel version
INFO=`curl -Ls https://www.kernel.org/ | perl -lne 'BEGIN{$/=""} print "$1 $2" if \
/latest_link.*?<a.*?href=\"(.*?)\".*?>(.*?)</s'`
# Extract some values from kernel name
KERNEL=`echo ${INFO} | cut -d' ' -f 2`
URL=`echo ${INFO} | cut -d' ' -f 1`
FILE=`echo ${URL}|rev|cut -d'/' -f 1 | rev`
DIR="/usr/src/${KERNEL}"
# Function to script script if step fail
isPreviousStepOk () {
@ -30,18 +22,54 @@ isPreviousStepOk () {
# Get arguments from command line
while [ $# -gt 0 ]; do
case "$1" in
--help)
printf "****************************************************************************************************\n"
printf "* pkgkernel-auto: Usage\n"
printf "* --menu: show kernel menu\n"
printf "* --archive <path to local kernel archive>: Use local kernel archive\n"
printf "* --extension <archive extention>: if not a archive extension is not tar.xz (tar.xz or tar.gz))\n"
printf "****************************************************************************************************\n"
printf "Example with RC kernel: \n"
printf "pkgkernel-auto.sh --archive /home/dbroqua/Downloads/linux-5.7-rc4.tar.gz --extension tar.gz \n"
printf "****************************************************************************************************\n"
exit 1
;;
--menu)
SHOW_MENU_CONFIG=1
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
printf "***************************\n"
exit 1
esac
shift
;;
--archive)
ARCHIVE=$2
shift
;;
--extension)
EXTENSION=$2
shift
;;
*)
printf "***************************\n"
printf "* Error: Invalid argument.*\n"
printf "***************************\n"
exit 1
esac
shift
done
if [ "${ARCHIVE}" != "" ] ; then
FILE=`basename "$ARCHIVE"`
KERNEL=`echo ${FILE}|sed 's/linux-//'|sed "s/\.${EXTENSION}//"`
else
# Get last kernel version
INFO=`curl -Ls https://www.kernel.org/ | perl -lne 'BEGIN{$/=""} print "$1 $2" if \
/latest_link.*?<a.*?href=\"(.*?)\".*?>(.*?)</s'`
# Extract some values from kernel name
KERNEL=`echo ${INFO} | cut -d' ' -f 2`
URL=`echo ${INFO} | cut -d' ' -f 1`
FILE=`echo ${URL}|rev|cut -d'/' -f 1 | rev`
fi
# Directory to store tmp files
DIR="/usr/src/${KERNEL}"
# Make directory in /usr/src/
mkdir "${DIR}"
@ -66,12 +94,19 @@ apt install \
cd "${DIR}" || exit
# Get kernel archive
wget ${URL}
isPreviousStepOk
if [ "${ARCHIVE}" == "" ] ; then
wget ${URL}
isPreviousStepOk
fi
# Extract kernel archive
tar xavf "${FILE}"
isPreviousStepOk
if [ "${EXTENSION}" == '.tar.xz' ] ; then
tar xavf "${FILE}"
isPreviousStepOk
else
tar xzvf "${ARCHIVE}" -C ${DIR}
isPreviousStepOk
fi
# Enter kernel directory
cd "linux-${KERNEL}"