@@ -119,40 +119,20 @@ verify_igpu_driver(){
119119}
120120
121121verify_kernel_package () {
122- echo -e " Checking kernel version"
123- LATEST_KERNEL_VERSION=$( apt-cache madison $KERNEL_PACKAGE_NAME | awk ' {print $3}' | sort -V | tail -n 1 | tr ' -' ' .' )
124- CURRENT_KERNEL_VERSION_INSTALLED=$( dpkg -l | grep " ^ii.*$KERNEL_PACKAGE_NAME " | awk ' {print $3}' | sort -V | tail -n 1 | tr ' -' ' .' )
125- LATEST_KERNEL_INSTALLED=$( dpkg -l | grep " ^ii.*$KERNEL_PACKAGE_NAME " | grep -E " ${LATEST_KERNEL_VERSION} [^ ]*" | awk ' {print $3}' | tr ' -' ' .' )
122+ CURRENT_KERNEL_VERSION=$( uname -r)
123+ KERNEL_VERSION=${KERNEL_PACKAGE_NAME# linux-image-}
126124
127- # extract flavour name
128- KERNEL_FLAVOUR=" "
129- if [[ $KERNEL_PACKAGE_NAME == * " generic" * ]]; then
130- KERNEL_FLAVOUR=" generic"
131- elif [[ $KERNEL_PACKAGE_NAME == * " oem" * ]]; then
132- KERNEL_FLAVOUR=" oem"
133- elif [[ $KERNEL_PACKAGE_NAME == * " intel-iotg" * ]]; then
134- KERNEL_FLAVOUR=" intel-iotg"
135- fi
136-
137- if [ -z " $LATEST_KERNEL_INSTALLED " ]; then
138- echo " Installing latest '${KERNEL_PACKAGE_NAME} ' kernel"
125+ if [ " $CURRENT_KERNEL_VERSION " != " $KERNEL_VERSION " ]; then
126+ echo -e " Current Kernel: $CURRENT_KERNEL_VERSION "
127+ echo -e " To be install: $KERNEL_VERSION "
139128 build_kernel
140- fi
141- if [[ ! " $LATEST_KERNEL_VERSION " == * " $CURRENT_KERNEL_VERSION_REVISION " * ]]; then
142- if dpkg -l | grep -q ' linux-image.*generic$' && [ " $KERNEL_FLAVOUR " != " generic" ]; then
143- echo " Removing generic kernel"
144- sudo apt remove -y --auto-remove linux-image-generic-hwe-$OS_VERSION
145- sudo DEBIAN_FRONTEND=noninteractive apt purge -y ' linux-image-*-generic'
146- elif dpkg -l | grep -q ' linux-image.*iotg$' && [ " $KERNEL_FLAVOUR " != " intel-iotg" ]; then
147- echo " Removing Intel IoT kernel"
148- sudo apt remove -y --auto-remove linux-image-intel-iotg
149- sudo DEBIAN_FRONTEND=noninteractive apt purge -y ' linux-image-*-iotg'
150- elif dpkg -l | grep -q ' linux-image.*oem$' && [ " $KERNEL_FLAVOUR " != " oem" ]; then
151- echo " Removing OEM kernel"
152- sudo DEBIAN_FRONTEND=noninteractive apt purge -y ' linux-image-*-oem'
153- fi
154- echo " Running kernel version: $CURRENT_KERNEL_VERSION_REVISION "
155- echo " Installed kernel version: $CURRENT_KERNEL_VERSION_INSTALLED "
129+ elif [ " $CURRENT_KERNEL_VERSION " == " $KERNEL_VERSION " ]; then
130+ echo -e " Current Kernel: $CURRENT_KERNEL_VERSION "
131+ echo -e " Kernel Updated"
132+ else
133+ # TODO: option to install kernel via verify_custom_build_kernel
134+ echo " Error: Custom build kernel not yet supported."
135+ exit 1
156136 fi
157137}
158138
@@ -189,6 +169,10 @@ replace_kernel(){
189169 sudo dpkg -i linux-headers-6.1.80--000_6.1.80-0_amd64.deb
190170 sudo dpkg -i linux-image-6.1.80--000_6.1.80-0_amd64.deb
191171 sudo dpkg -i linux-libc-dev_6.1.80-0_amd64.deb
172+
173+ echo -e " ## Update grub"
174+ sudo sed -i ' s/^GRUB_DEFAULT=.*$/GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 6.1.80--000"/' /etc/default/grub
175+
192176 sudo update-grub
193177 echo " System reboot is required. Re-run the script after reboot"
194178 exit 0
@@ -245,11 +229,7 @@ verify_os() {
245229}
246230
247231verify_kernel () {
248- echo -e " \n# Verifying kernel version"
249- CURRENT_KERNEL_VERSION=$( uname -r | cut -d' -' -f1)
250- CURRENT_KERNEL_REVISION=$( uname -r | rev | cut -d' -' -f1 | rev)
251- CURRENT_KERNEL_VERSION_REVISION=" $CURRENT_KERNEL_VERSION .$CURRENT_KERNEL_REVISION "
252-
232+ echo -e " \n# Verifying kernel version"
253233 if [[ -n " $KERNEL_PACKAGE_NAME " ]]; then
254234 verify_kernel_package
255235 else
0 commit comments