From ac2bf5f638e470c60b812b20af54b296aab8ab27 Mon Sep 17 00:00:00 2001 From: turmary Date: Wed, 30 Sep 2020 10:39:23 +0800 Subject: [PATCH] Move: dkms module removing to the position before kernel update --- install.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 4e76a45..ac6ebc7 100755 --- a/install.sh +++ b/install.sh @@ -201,11 +201,34 @@ function install_kernel() { } } +function uninstall_module { + src=$1 + mod=$2 + + if [[ -d /var/lib/dkms/$mod/$ver/$marker ]]; then + rmdir /var/lib/dkms/$mod/$ver/$marker + fi + + if [[ -e /usr/src/$mod-$ver || -e /var/lib/dkms/$mod/$ver ]]; then + dkms remove --force -m $mod -v $ver --all + rm -rf /usr/src/$mod-$ver + fi + + return 0 +} + # update and install required packages -which apt &>/dev/null -if [[ $? -eq 0 ]]; then +which apt &>/dev/null; r=$? +if [[ $r -eq 0 ]]; then + echo -e "\n### Install required tool packages" apt update -y apt-get -y install dkms git i2c-tools libasound2-plugins +fi + +echo -e "\n### Uninstall previous dkms module" +uninstall_module "./" "seeed-voicecard" + +if [[ $r -eq 0 ]]; then echo -e "\n### Install required kernel package" install_kernel # rpi-update checker @@ -232,15 +255,6 @@ function install_module { src=$1 mod=$2 - if [[ -d /var/lib/dkms/$mod/$ver/$marker ]]; then - rmdir /var/lib/dkms/$mod/$ver/$marker - fi - - if [[ -e /usr/src/$mod-$ver || -e /var/lib/dkms/$mod/$ver ]]; then - dkms remove --force -m $mod -v $ver --all - rm -rf /usr/src/$mod-$ver - fi - mkdir -p /usr/src/$mod-$ver cp -a $src/* /usr/src/$mod-$ver/ @@ -261,7 +275,6 @@ function install_module { echo -e "\n### Install sound card driver" install_module "./" "seeed-voicecard" - # install dtbos echo -e "\n### Install device tree overlays" cp -v seeed-2mic-voicecard.dtbo $OVERLAYS