PDA

View Full Version : [all variants] make, make install, modprobe in post installation script



Anaximander Thales
February 12th, 2013, 01:54 AM
I modified a post installation script for nvidia, found here (http://ubuntuforums.org/showthread.php?t=835573), for installing the Ceton InfiniTV drivers. This -- this has become a learning situation for me as it does not work as expected.

Here is the script:


#!/bin/bash
#

# Set this to the exact path of the ceton infinitv driver you plan to use
# It is recommended to use a symlink here so that this script doesn't
# have to be modified when you change driver versions.
DRIVER=/usr/src/ceton_infinitv_linux_driver


# Build new driver if it doesn't exist
if [ -e /lib/modules/$1/extra/ctn91xx.ko ] ; then
echo "CETON infinitv drivers already exists for this kernel." >&2
else
echo "Building CETON infinitv driver for kernel $1" >&2
cd $DRIVER
/usr/bin/make
/usr/bin/make install
/sbin/modprobe ctn91xx

if [ -e /lib/modules/$1/extra/ctn91xx.ko ] ; then
echo " SUCCESS: Driver installed for kernel $1" >&2
else
echo " FAILURE: See log for issues" >&2
fi
fi

exit 0


I hoped that the script would install the ceton drivers when a new kernel was installed. However, what occurs is it attempts to install the drivers on the current kernel.


Building CETON infinitv driver for kernel 3.2.0-38-generic
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-37-generic'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-37-generic'
Installing ctn91xx driver...
make[1]: Entering directory `/usr/src/linux-headers-3.2.0-37-generic'
INSTALL /home/user/Downloads/ceton_infinitv_linux_driver/ctn91xx.ko
DEPMOD 3.2.0-37-generic
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-37-generic'
cp 98-ctn91xx.rules /etc/udev/rules.d/
/sbin/depmod -a 3.2.0-37-generic
FAILURE: See log for issues

My question is, how do I make this work as a post installation trigger?

Thanks,
AT

Anaximander Thales
February 14th, 2013, 02:22 PM
Bump

schragge
February 14th, 2013, 02:51 PM
Do you have the package linux-headers-3.2.0-38-generic installed?

Anaximander Thales
February 14th, 2013, 03:07 PM
Do you have the package linux-headers-3.2.0-38-generic installed?

In theory, yes -- I can't be 100% certain because at the point the script runs it's still running through the upgrade process.

However, This post install script should run when a kernel update occurs, it should kick off after the kernel is installed. In apt output messages, it checks whether it has been installed for the new kernel or not (the new kernel is checked, and it shows that the driver hasn't installed) and attempts to install for the new kernel, however, when make, make install and modprobe run, they attempt to run against the previous kernel.

schragge
February 14th, 2013, 03:28 PM
I guess then your should use dkms and invoke it from your postinst.

Anaximander Thales
February 14th, 2013, 03:56 PM
I guess then your should use dkms and invoke it from your postinst.

I am invoking it from postinst (script is located in /etc/kernel/postinst.d as stated in the article that I linked to about the original script).

DKMS I am unfamiliar with.

I'll follow this guide (Ubuntu Community - DKMS (https://help.ubuntu.com/community/DKMS)) and report how it goes.

Just a quick read through, it doesn't mention anything about postinst. I am assuming that this part of the DKMS doc:

we install the module into DKMS by copying the module installation files into the kernel source tree /usr/src/<modulename>-<version> and tell DKMS about the new module:
means that after I do that, it'll set up a postinst trigger for when a new kernel is installed. Am I correct in that or
will I need to put the dkms.conf file in the postinst.d directory, or modify my script in some way to make this work?

Thank you,
AT

schragge
February 14th, 2013, 04:13 PM
Also look here (https://wiki.kubuntu.org/Kernel/Dev/DKMSPackaging).

Anaximander Thales
February 14th, 2013, 04:18 PM
Thank you, schragge

When I get home I'll test it out and report back on it.

Thanks,
AT

Anaximander Thales
March 2nd, 2013, 08:01 PM
Okay --
Implemented DKMS --

It worked.

Much thanks to schragge.