You are not logged in.

#1 2015-06-01 19:30:39

kox
Member
Registered: 2015-05-01
Posts: 146

Automatically build kernel module after kernel update

Hello. Everytime kernel is updated, my wifi drivers don't work. I need to use this to get my adapter working: https://aur.archlinux.org/packages/8192cu-dkms/ .
After kernel update, I have to manually reinstall the package, so the kernel module gets rebuilt. Is there any way to make it automatic?

Offline

#2 2015-06-01 19:53:53

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,764
Website

Re: Automatically build kernel module after kernel update

You could use a custom mkinitcpio hook -- create a file at /usr/lib/initcpio/install/wifi-update with this content:

#!/usr/bin/env bash
build() {
	/root/watch.sh &
}

help() {
	cat <<HELPEOF
This hook waits for mkinitcpio to finish and re-installs the wi-fi drivers from the AUR
HELPEOF
}

Then write a script (/root/watch.sh) to re-install the package with this format:

#!/usr/bin/env bash

while [[ -d "/proc/$PPID" ]]; do
	sleep 1
done

/usr/bin/wget https://aur.archlinux.org/packages/81/8192cu-dkms/8192cu-dkms.tar.gz
/usr/bin/tar xf 8192cu-dkms.tar.gz
cd 8192cu-dkms
/usr/bin/su <user name> -c 'makepkg -fics'

echo "Re-installed drivers :)"

Then add "wifi-update" to the list of HOOKS in /etc/mkinitcpio.conf

I have no idea if this will actually work, I've just cobbled it together -- you might want to improve it wink

EDIT: Added `cd`

Last edited by Head_on_a_Stick (2015-06-02 06:49:55)

Online

#3 2015-06-02 06:30:44

pypi
Wiki Maintainer
Registered: 2014-04-22
Posts: 250

Re: Automatically build kernel module after kernel update

As another idea, perhaps you could use incrond to run a script when the kernel is upgraded?
Or you could wait for pacman hooks...

Offline

#4 2015-06-02 07:01:43

kox
Member
Registered: 2015-05-01
Posts: 146

Re: Automatically build kernel module after kernel update

Thank you very much for this script. I'm not sure if it works, how do I test it without waiting for kernel update? I tried mkinitcpio -p linux , but this is something different than updating kernel via pacman, isn't it? Your script didn't run and wifi drivers still work, same for graphics drivers.

Offline

#5 2015-06-02 07:05:16

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,764
Website

Re: Automatically build kernel module after kernel update

kox wrote:

Thank you very much for this script. I'm not sure if it works, how do I test it without waiting for kernel update? I tried mkinitcpio -p linux , but this is something different than updating kernel via pacman, isn't it? Your script didn't run and wifi drivers still work, same for graphics drivers.

I added a `cd` command to the "script" a few minutes ago -- the AUR package will not build without this.

I really don't know if it will work and I have no way of testing it on my hardware.

I would suggest manually removing the wireless driver then running `mkinitcpio -p linux` and see if they are installed by the script.

Online

#6 2015-06-02 07:16:51

kox
Member
Registered: 2015-05-01
Posts: 146

Re: Automatically build kernel module after kernel update

I noticed it, but your script doesn't run at all when I type `mkinitcpio -p linux`. And wifi still works after reboot. Same for graphics driver, it has a hook at shutdown, that rebuilds its module after kernel update, it haven't run too and graphics driver works. It's like 'mkinitcpio -p linux' does nothing to the system.

==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'default'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img
==> Starting build: 4.0.4-2-ARCH
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux.preset: 'fallback'
  -> -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback.img -S autodetect
==> Starting build: 4.0.4-2-ARCH
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: aic94xx
  -> Running build hook: [filesystems]
  -> Running build hook: [keyboard]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback.img
==> Image generation successful

Last edited by kox (2015-06-02 07:18:24)

Offline

#7 2015-06-02 07:20:43

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,764
Website

Re: Automatically build kernel module after kernel update

Did you add the "wifi-update" hook to mkinitcpio.conf?

Perhaps you should try the incron method suggested by @pypi

Online

#8 2015-06-03 08:14:35

kox
Member
Registered: 2015-05-01
Posts: 146

Re: Automatically build kernel module after kernel update

I forgot about it. It seems to work now, thanks!

Offline

#9 2015-06-03 08:41:41

progandy
Member
Registered: 2012-05-17
Posts: 5,205

Re: Automatically build kernel module after kernel update

Why do you have to reinstall the package? A simple "dkms autoinstall" should do wonders, there is even an aur package available:  mkinitcpio-dkms.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#10 2015-06-03 18:21:18

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,764
Website

Re: Automatically build kernel module after kernel update

@OP: Excellent news!

@progandy: D'oh! hmm

Online

Board footer

Powered by FluxBB