- Added menu and avaibility to use custom kernel
This commit is contained in:
parent
c1939808c9
commit
7538c4195d
1 changed files with 55 additions and 20 deletions
|
@ -10,14 +10,6 @@ PREFIX='linux-'
|
||||||
EXTENSION='.tar.xz'
|
EXTENSION='.tar.xz'
|
||||||
SHOW_MENU_CONFIG=0
|
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
|
# Function to script script if step fail
|
||||||
isPreviousStepOk () {
|
isPreviousStepOk () {
|
||||||
|
@ -30,9 +22,29 @@ isPreviousStepOk () {
|
||||||
# Get arguments from command line
|
# Get arguments from command line
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
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)
|
--menu)
|
||||||
SHOW_MENU_CONFIG=1
|
SHOW_MENU_CONFIG=1
|
||||||
;;
|
;;
|
||||||
|
--archive)
|
||||||
|
ARCHIVE=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--extension)
|
||||||
|
EXTENSION=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
printf "***************************\n"
|
printf "***************************\n"
|
||||||
printf "* Error: Invalid argument.*\n"
|
printf "* Error: Invalid argument.*\n"
|
||||||
|
@ -42,6 +54,22 @@ while [ $# -gt 0 ]; do
|
||||||
shift
|
shift
|
||||||
done
|
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/
|
# Make directory in /usr/src/
|
||||||
mkdir "${DIR}"
|
mkdir "${DIR}"
|
||||||
|
|
||||||
|
@ -66,12 +94,19 @@ apt install \
|
||||||
cd "${DIR}" || exit
|
cd "${DIR}" || exit
|
||||||
|
|
||||||
# Get kernel archive
|
# Get kernel archive
|
||||||
wget ${URL}
|
if [ "${ARCHIVE}" == "" ] ; then
|
||||||
isPreviousStepOk
|
wget ${URL}
|
||||||
|
isPreviousStepOk
|
||||||
|
fi
|
||||||
|
|
||||||
# Extract kernel archive
|
# Extract kernel archive
|
||||||
tar xavf "${FILE}"
|
if [ "${EXTENSION}" == '.tar.xz' ] ; then
|
||||||
isPreviousStepOk
|
tar xavf "${FILE}"
|
||||||
|
isPreviousStepOk
|
||||||
|
else
|
||||||
|
tar xzvf "${ARCHIVE}" -C ${DIR}
|
||||||
|
isPreviousStepOk
|
||||||
|
fi
|
||||||
|
|
||||||
# Enter kernel directory
|
# Enter kernel directory
|
||||||
cd "linux-${KERNEL}"
|
cd "linux-${KERNEL}"
|
||||||
|
|
Loading…
Reference in a new issue