dkms: improve consistency of relative paths in kernel hooks

This commit is contained in:
Andrew J. Hesford 2020-08-05 12:13:08 -04:00
parent 8f4c05bf76
commit 22e18e6794
3 changed files with 22 additions and 20 deletions

View file

@ -8,7 +8,7 @@ PKGNAME="$1"
VERSION="$2" VERSION="$2"
ARCH=$(uname -m) ARCH=$(uname -m)
if [ ! -x /usr/sbin/dkms ]; then if [ ! -x /usr/bin/dkms ]; then
exit 0 exit 0
fi fi
@ -59,16 +59,16 @@ while [ $# -gt 1 ]; do
# If adding a module, depmod is necessary unless dkms runs it # If adding a module, depmod is necessary unless dkms runs it
do_depmod="yes" do_depmod="yes"
status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION}) status=$(/usr/bin/dkms status -m ${module} -v ${modulever} -k ${VERSION})
if [ $(echo "$status"|grep -c ": built") -eq 0 ]; then if [ $(echo "$status"|grep -c ": built") -eq 0 ]; then
# Check if the module is still there. # Check if the module is still there.
if [ ! -f usr/src/${module}-${modulever}/dkms.conf ]; then if [ ! -f /usr/src/${module}-${modulever}/dkms.conf ]; then
echo "Skipping nonexistent DKMS module: ${module}-${modulever}." echo "Skipping nonexistent DKMS module: ${module}-${modulever}."
continue continue
fi fi
# Build the module # Build the module
echo -n "Building DKMS module: ${module}-${modulever}... " echo -n "Building DKMS module: ${module}-${modulever}... "
dkms build -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH} /usr/bin/dkms build -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH}
rval=$? rval=$?
# If the module was skipped or failed, go to the next module. # If the module was skipped or failed, go to the next module.
if [ $rval -eq 0 ]; then if [ $rval -eq 0 ]; then
@ -80,14 +80,14 @@ while [ $# -gt 1 ]; do
echo "FAILED!" echo "FAILED!"
continue continue
fi fi
status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION}) status=$(/usr/bin/dkms status -m ${module} -v ${modulever} -k ${VERSION})
fi fi
# If the module is built (either pre-built or just now), install it # If the module is built (either pre-built or just now), install it
if [ $(echo "$status"|grep -c ": built") -eq 1 ] && if [ $(echo "$status"|grep -c ": built") -eq 1 ] &&
[ $(echo "$status"|grep -c ": installed") -eq 0 ]; then [ $(echo "$status"|grep -c ": installed") -eq 0 ]; then
echo -n "Installing DKMS module: ${module}-${modulever}... " echo -n "Installing DKMS module: ${module}-${modulever}... "
dkms install -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH} /usr/bin/dkms install -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH}
rval=$? rval=$?
# If the module failed installation, go to the next module. # If the module failed installation, go to the next module.
if [ $rval -eq 0 ]; then if [ $rval -eq 0 ]; then
@ -101,16 +101,18 @@ while [ $# -gt 1 ]; do
fi fi
done done
if [ -n "$do_depmod" ]; then if [ -z "$do_depmod" ] || [ ! -x /usr/bin/depmod ]; then
echo -n "Generating kernel module dependency lists... " exit 0
depmod -a ${VERSION} fi
rval=$?
if [ $rval -eq 0 ]; then echo -n "Generating kernel module dependency lists... "
/usr/bin/depmod -a ${VERSION}
rval=$?
if [ $rval -eq 0 ]; then
echo "done." echo "done."
else else
echo "FAILED!" echo "FAILED!"
exit $rval exit $rval
fi
fi fi
exit 0 exit 0

View file

@ -4,14 +4,14 @@
PKGNAME="$1" PKGNAME="$1"
VERSION="$2" VERSION="$2"
if [ -x /usr/sbin/dkms ]; then if [ -x /usr/bin/dkms ]; then
while read line; do while read line; do
name=`echo "$line" | awk '{print $1}' | sed 's/,$//'` name=`echo "$line" | awk '{print $1}' | sed 's/,$//'`
vers=`echo "$line" | awk '{print $2}' | sed 's/,$//'` vers=`echo "$line" | awk '{print $2}' | sed 's/,$//'`
arch=`echo "$line" | awk '{print $4}' | sed 's/:$//'` arch=`echo "$line" | awk '{print $4}' | sed 's/:$//'`
echo "dkms: removing: $name $vers (${PKGNAME}-${VERSION}) ($arch)" >&2 echo "dkms: removing: $name $vers (${PKGNAME}-${VERSION}) ($arch)" >&2
dkms remove -q -m $name -v $vers -k ${VERSION} -a $arch /usr/bin/dkms remove -q -m $name -v $vers -k ${VERSION} -a $arch
done < <(dkms status -k ${VERSION} 2>/dev/null | grep ": installed") done < <(/usr/bin/dkms status -k ${VERSION} 2>/dev/null | grep ": installed")
fi fi
rmdir \ rmdir \

View file

@ -1,7 +1,7 @@
# Template file for 'dkms' # Template file for 'dkms'
pkgname=dkms pkgname=dkms
version=2.8.3 version=2.8.3
revision=1 revision=2
conf_files="/etc/dkms/framework.conf" conf_files="/etc/dkms/framework.conf"
depends="bash kmod gcc make coreutils linux-headers" depends="bash kmod gcc make coreutils linux-headers"
short_desc="Dynamic Kernel Modules System" short_desc="Dynamic Kernel Modules System"