From b5def1af8ed71783f5dd067afb8d3c9d260a9899 Mon Sep 17 00:00:00 2001 From: turmary Date: Sun, 27 Sep 2020 11:01:51 +0100 Subject: [PATCH] Add: script option --keep-kernel to not change current kernel --- install.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index ad0ca61..3be9d4d 100755 --- a/install.sh +++ b/install.sh @@ -132,13 +132,48 @@ function download_install_debpkg() { return $r } -option_pattern="compat-kernel" -if [[ $1 =~ ${option_pattern} ]]; then +function usage() { + cat <<-__EOF__ + usage: sudo ./install [ --compat-kernel | --keep-kernel ] [ -h | --help ] + default action is update kernel & headers to latest version. + --compat-kernel uses an older kernel but ensures that the driver can work. + --keep-kernel don't change/update the system kernel, maybe install + coressponding kernel headers. + --help show this help message +__EOF__ + exit 1 +} + +compat_kernel= +keep_kernel= +# parse commandline options +while [ ! -z "$1" ] ; do + case $1 in + -h|--help) + usage + ;; + --compat-kernel) + compat_kernel=Y + ;; + --keep-kernel) + keep_kernel=Y + ;; + esac + shift +done + +if [ "X$keep_kernel" != "X" ]; then + FORCE_KERNEL=$(dpkg -s raspberrypi-kernel | awk '/^Version:/{printf "%s\n",$2;}') + echo "Keep current system kernel not to change" +elif [ "X$compat_kernel" != "X" ]; then echo "will compile with a compatible kernel..." else FORCE_KERNEL="" echo "will compile with the latest kernel..." fi +[ "X$FORCE_KERNEL" != "X" ] && { + echo -e "The kernel & headers use package version: $FORCE_KERNEL\r\n\r\n" +} function install_kernel() { local _url _prefix